mirror of https://github.com/CGAL/cgal
added the standard tool
added standard tool functionality in Qt_widget
This commit is contained in:
parent
642c77a468
commit
f2f4a37738
|
|
@ -107,6 +107,10 @@ SOURCE=.\Qt_widget_move_list_point.C
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget_standard_tool.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget_standard_toolbar.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -169,6 +173,25 @@ InputPath=.\Qt_widget_move_list_point.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_widget_standard_tool.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=..\..\..\include\CGAL\IO\Qt_widget_standard_tool.h
|
||||
|
||||
"../../../src/CGALQt/Qt_Widget_standard_tool.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "../../../src/CGALQt/Qt_Widget_standard_tool.moc" "../../../Include/CGAL/IO/Qt_Widget_standard_tool.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_Widget_standard_toolbar.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@
|
|||
namespace CGAL {
|
||||
|
||||
class Qt_widget_tool;
|
||||
class Qt_widget_standard_tool;
|
||||
class Qt_widget_layer;
|
||||
|
||||
typedef
|
||||
struct togglelayer{
|
||||
CGAL::Qt_widget_layer *layer;
|
||||
|
|
@ -153,9 +155,12 @@ public:
|
|||
|
||||
// tool system
|
||||
// ~~~~~~~~~~~
|
||||
void attach_standard(Qt_widget_standard_tool* tool);
|
||||
void attach(Qt_widget_tool* tool);
|
||||
inline bool has_tool() const { return _has_tool; };
|
||||
void detach_current_tool();
|
||||
inline bool has_standard_tool() const { return _has_standard_tool; };
|
||||
void detach_current_tool();
|
||||
void detach_current_standard_tool();
|
||||
|
||||
void new_object(CGAL::Object obj) { emit(new_cgal_object(obj)); };
|
||||
|
||||
|
|
@ -221,11 +226,13 @@ private:
|
|||
|
||||
// current tool
|
||||
bool _has_tool;
|
||||
Qt_widget_tool *current_tool;
|
||||
bool _has_standard_tool;
|
||||
Qt_widget_tool *current_tool;
|
||||
Qt_widget_standard_tool *current_standard_tool;
|
||||
|
||||
//for layers
|
||||
std::list<Qt_widget_layer*> qt_layers;
|
||||
std::list<togglelayer> qt_toggle_layers;
|
||||
std::list<togglelayer> qt_toggle_layers;
|
||||
};//end Qt_widget class
|
||||
|
||||
// manipulators
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include <CGAL/IO/pixmaps/hand.xpm>
|
||||
#include <CGAL/IO/pixmaps/holddown.xpm>
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_tool.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_tool.h>
|
||||
#include <qrect.h>
|
||||
|
||||
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
class Qt_widget_handtool : public Qt_widget_tool
|
||||
class Qt_widget_handtool : public Qt_widget_standard_tool
|
||||
{
|
||||
public:
|
||||
Qt_widget_handtool() : wasrepainted(TRUE), on_first(FALSE){};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : include/CGAL/IO/Qt_widget_standard_tool.h
|
||||
// package : Qt_widget
|
||||
// author(s) : Laurent Rineau & Radu Ursu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifndef CGAL_QT_WIDGET_STANDARD_TOOL_H
|
||||
#define CGAL_QT_WIDGET_STANDARD_TOOL_H
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/Object.h>
|
||||
#include <qobject.h>
|
||||
#include <qcursor.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
class Qt_widget_standard_tool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Qt_widget_standard_tool();
|
||||
inline bool is_attached() const
|
||||
{ return (widget==0); };
|
||||
|
||||
// Event handlers
|
||||
virtual void mousePressEvent(QMouseEvent *) {} ;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *) {};
|
||||
virtual void wheelEvent(QMouseEvent *) {};
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *) {};
|
||||
virtual void mouseMoveEvent(QMouseEvent *) {};
|
||||
virtual void keyPressEvent(QKeyEvent *) {};
|
||||
virtual void keyReleaseEvent(QKeyEvent *) {};
|
||||
virtual void enterEvent(QEvent *) {};
|
||||
virtual void leaveEvent(QEvent *) {};
|
||||
|
||||
|
||||
signals:
|
||||
void redraw(); //this signal is emited when the tool
|
||||
//needs to repaint the widget
|
||||
|
||||
public slots:
|
||||
virtual void widget_repainted() {}; //called every time widget been repainted
|
||||
|
||||
protected:
|
||||
virtual void attaching() {};
|
||||
virtual void detaching() {};
|
||||
|
||||
Qt_widget *widget;
|
||||
QCursor oldcursor;
|
||||
private:
|
||||
// attach a Qt_widget to the tool
|
||||
void attach(Qt_widget *w);
|
||||
// detach it
|
||||
void detach();
|
||||
friend class Qt_widget;
|
||||
};
|
||||
} // namespace CGAL
|
||||
#endif // CGAL_QT_WIDGET_TOOL_H
|
||||
|
||||
|
|
@ -49,9 +49,6 @@ public:
|
|||
|
||||
|
||||
private slots:
|
||||
|
||||
void toggle_button();
|
||||
|
||||
void toolregion();
|
||||
void zoomin();
|
||||
void zoomout();
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@
|
|||
#define CGAL_QT_WIDGET_ZOOM_H
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_tool.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_tool.h>
|
||||
#include <qcolor.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
class Qt_widget_zoom : public Qt_widget_tool
|
||||
class Qt_widget_zoom : public Qt_widget_standard_tool
|
||||
{
|
||||
private:
|
||||
int x2, y2;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#define CGAL_QT_WIDGET_ZOOMRECT_H
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_tool.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_tool.h>
|
||||
#include <qrect.h>
|
||||
|
||||
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
class Qt_widget_zoomrect : public Qt_widget_tool
|
||||
class Qt_widget_zoomrect : public Qt_widget_standard_tool
|
||||
{
|
||||
public:
|
||||
int first_x, first_y, x2, y2;
|
||||
|
|
|
|||
|
|
@ -20,16 +20,19 @@
|
|||
|
||||
#ifdef CGAL_USE_QT
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/Bbox_2.h>
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_tool.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_tool.h>
|
||||
#include <CGAL/IO/Qt_widget_layer.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
Qt_widget::Qt_widget(QWidget *parent, const char *name) :
|
||||
QWidget(parent, name), Locked(0), _pointSize(4),
|
||||
_pointStyle(DISC), _has_tool(false), current_tool(0)
|
||||
_pointStyle(DISC), _has_tool(false), current_tool(0),
|
||||
_has_standard_tool(false), current_standard_tool(0)
|
||||
{
|
||||
setCaption("CGAL::Qt_widget");
|
||||
|
||||
|
|
@ -134,7 +137,9 @@ void Qt_widget::paintEvent(QPaintEvent *e)
|
|||
void Qt_widget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
emit(mousePressed(e));
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->mousePressEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->mousePressEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -145,7 +150,9 @@ void Qt_widget::mousePressEvent(QMouseEvent *e)
|
|||
void Qt_widget::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
emit(mouseReleased(e));
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->mouseReleaseEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->mouseReleaseEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -156,7 +163,9 @@ void Qt_widget::mouseReleaseEvent(QMouseEvent *e)
|
|||
void Qt_widget::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
emit(mouseMoved(e));
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->mouseMoveEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->mouseMoveEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -166,7 +175,9 @@ void Qt_widget::mouseMoveEvent(QMouseEvent *e)
|
|||
|
||||
void Qt_widget::wheelEvent(QMouseEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->wheelEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->wheelEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -176,7 +187,9 @@ void Qt_widget::wheelEvent(QMouseEvent *e)
|
|||
|
||||
void Qt_widget::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->mouseDoubleClickEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->mouseDoubleClickEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -186,7 +199,9 @@ void Qt_widget::mouseDoubleClickEvent(QMouseEvent *e)
|
|||
|
||||
void Qt_widget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->keyPressEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->keyPressEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -196,7 +211,9 @@ void Qt_widget::keyPressEvent(QKeyEvent *e)
|
|||
|
||||
void Qt_widget::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->keyReleaseEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->keyReleaseEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -206,7 +223,9 @@ void Qt_widget::keyReleaseEvent(QKeyEvent *e)
|
|||
|
||||
void Qt_widget::enterEvent(QEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->enterEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->enterEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -216,7 +235,9 @@ void Qt_widget::enterEvent(QEvent *e)
|
|||
|
||||
void Qt_widget::leaveEvent(QEvent *e)
|
||||
{
|
||||
if (has_tool())
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->leaveEvent(e);
|
||||
if (has_tool() && !has_standard_tool())
|
||||
current_tool->leaveEvent(e);
|
||||
std::list<togglelayer>::iterator it;
|
||||
for(it = qt_toggle_layers.begin(); it!= qt_toggle_layers.end(); it++)
|
||||
|
|
@ -341,6 +362,16 @@ Qt_widget& operator<<(Qt_widget& w, const Bbox_2& r)
|
|||
*Ursu Radu coding ....
|
||||
*
|
||||
*********************************************/
|
||||
void Qt_widget::attach_standard(Qt_widget_standard_tool* tool) {
|
||||
if (has_standard_tool()) {
|
||||
current_standard_tool->detach();
|
||||
emit(detached_tool());
|
||||
}
|
||||
current_standard_tool=tool;
|
||||
_has_standard_tool=true;
|
||||
current_standard_tool->attach(this);
|
||||
}
|
||||
|
||||
void Qt_widget::attach(Qt_widget_tool* tool) {
|
||||
if (has_tool()) {
|
||||
current_tool->detach();
|
||||
|
|
@ -350,6 +381,12 @@ void Qt_widget::attach(Qt_widget_tool* tool) {
|
|||
_has_tool=true;
|
||||
current_tool->attach(this);
|
||||
}
|
||||
void Qt_widget::detach_current_standard_tool()
|
||||
{
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->detach();
|
||||
_has_standard_tool = FALSE;
|
||||
};
|
||||
void Qt_widget::detach_current_tool()
|
||||
{
|
||||
if (has_tool()) {
|
||||
|
|
@ -376,6 +413,8 @@ void Qt_widget::redraw()
|
|||
(*it).layer->draw(*this);
|
||||
|
||||
unlock();
|
||||
if (has_standard_tool())
|
||||
current_standard_tool->widget_repainted();
|
||||
if (has_tool())
|
||||
current_tool->widget_repainted();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : src/Qt_widget_standard_tool.C
|
||||
// package : Qt_widget
|
||||
// author(s) : Laurent Rineau & Radu Ursu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifdef CGAL_USE_QT
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_tool.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
Qt_widget_standard_tool::Qt_widget_standard_tool() :
|
||||
widget(0) {};
|
||||
|
||||
void Qt_widget_standard_tool::attach(Qt_widget *w)
|
||||
{
|
||||
widget=w;
|
||||
attaching();
|
||||
}
|
||||
|
||||
void Qt_widget_standard_tool::detach()
|
||||
{
|
||||
detaching();
|
||||
widget=0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#include "Qt_widget_standard_tool.moc"
|
||||
|
||||
#endif
|
||||
|
|
@ -102,45 +102,40 @@ namespace CGAL {
|
|||
but[4]->setToggleButton(TRUE);
|
||||
but[5]->setToggleButton(TRUE);
|
||||
|
||||
connect(w, SIGNAL(detached_tool()), this, SLOT(toggle_button()));
|
||||
nr_of_buttons = 6;
|
||||
};
|
||||
|
||||
void Standard_toolbar::toggle_button ()
|
||||
{
|
||||
if(is_active) {
|
||||
but[activebutton]->toggle();
|
||||
is_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Standard_toolbar::toolregion()
|
||||
{
|
||||
if (but[3]->isOn())
|
||||
{
|
||||
widget->attach(&zoombut);
|
||||
activebutton = 3;
|
||||
is_active = true;
|
||||
if(is_active)
|
||||
but[activebutton]->toggle();
|
||||
widget->attach_standard(&zoombut);
|
||||
activebutton = 3;
|
||||
is_active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_active = false;
|
||||
widget->detach_current_tool();
|
||||
widget->detach_current_standard_tool();
|
||||
}
|
||||
}
|
||||
|
||||
void Standard_toolbar::zoominrect()
|
||||
{
|
||||
if (but[4]->isOn())
|
||||
{
|
||||
widget->attach(&zoomrectbut);
|
||||
{
|
||||
if(is_active)
|
||||
but[activebutton]->toggle();
|
||||
widget->attach_standard(&zoomrectbut);
|
||||
activebutton = 4;
|
||||
is_active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_active = false;
|
||||
widget->detach_current_tool();
|
||||
widget->detach_current_standard_tool();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +152,8 @@ namespace CGAL {
|
|||
void Standard_toolbar::notool()
|
||||
{
|
||||
if(is_active) {
|
||||
widget->detach_current_tool();
|
||||
but[activebutton]->toggle();
|
||||
widget->detach_current_standard_tool();
|
||||
is_active = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -166,14 +162,15 @@ namespace CGAL {
|
|||
void Standard_toolbar::handtool()
|
||||
{
|
||||
if (but[5]->isOn())
|
||||
{
|
||||
widget->detach_current_tool();
|
||||
widget->attach(&handtoolbut);
|
||||
{
|
||||
if(is_active)
|
||||
but[activebutton]->toggle();
|
||||
widget->attach_standard(&handtoolbut);
|
||||
activebutton = 5;
|
||||
is_active = true;
|
||||
} else {
|
||||
is_active = false;
|
||||
widget->detach_current_tool();
|
||||
widget->detach_current_standard_tool();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue