check_vtk.m4 \
check_VTKViewer.m4 \
check_corba_in_GUI.m4 \
+check_QxGraphViewer.m4 \
README
--- /dev/null
+#
+# Check configure option --disable-qxGraphViewer=[yes|no|DIR] taking into account that
+# DISABLE_QXGRAPHVIEWER may be already set during build_configure,
+# Set DISABLE_QXGRAPHVIEWER to yes|no
+#
+# Author : Edawrd AGAPOV (OCC, 2005)
+#
+
+AC_DEFUN([CHECK_QXGRAPHVIEWER],[
+
+AC_ARG_WITH(qxGraphViewer,
+ [ --disable-qxGraphViewer default=no ],
+ disable_qxGraphViewer="$withval",disable_qxGraphViewer="${DISABLE_QXGRAPHVIEWER}")
+
+case $disable_qxGraphViewer in
+ yes)
+# AC_MSG_RESULT(************************************************)
+# AC_MSG_RESULT(******* DISABLE QxGraphViewer configuration ********)
+# AC_MSG_RESULT(************************************************)
+ DISABLE_QXGRAPHVIEWER="yes"
+ AC_SUBST(DISABLE_QXGRAPHVIEWER)
+esac
+
+
+])dnl
DISABLE_SALOMEOBJECT="yes"
fi
+if test "x${enable_qxGraphViewer}" != "xno" ; then
+ DISABLE_QXGRAPHVIEWER="no"
+else
+ DISABLE_QXGRAPHVIEWER="yes"
+fi
+
dnl
dnl Initialize source and build root directories
CHECK_SALOMEOBJECT
echo "DISABLE_SALOMEOBJECT = "$DISABLE_SALOMEOBJECT
+echo
+echo ---------------------------------------------
+echo Testing QxGraphViewer
+echo ---------------------------------------------
+echo
+
+CHECK_QXGRAPHVIEWER
+echo "DISABLE_QXGRAPHVIEWER = "$DISABLE_QXGRAPHVIEWER
+
if test "x${GUI_DISABLE_CORBA}" != "xyes" ; then
if test "x${DISABLE_PYCONSOLE}" == "xyes" ; then
echo "failed : for full configuration of GUI module necessary enable PyConsole !"
echo "failed : for full configuration of GUI module necessary enable SalomeObject !"
exit
fi
+ if test "x${DISABLE_QXGRAPHVIEWER}" == "xyes" ; then
+ echo "failed : for full configuration of GUI module necessary enable QxGraphViewer !"
+ exit
+ fi
fi
echo
AM_CONDITIONAL(ENABLE_OCCVIEWER, [test "$DISABLE_OCCVIEWER" = no])
AM_CONDITIONAL(ENABLE_VTKVIEWER, [test "$DISABLE_VTKVIEWER" = no])
AM_CONDITIONAL(ENABLE_SALOMEOBJECT, [test "$DISABLE_SALOMEOBJECT" = no])
+AM_CONDITIONAL(ENABLE_QXGRAPHVIEWER, [test "$DISABLE_QXGRAPHVIEWER" = no])
echo
echo ---------------------------------------------
./src/Plot2d/Makefile \
./src/SPlot2d/Makefile \
./src/SUPERVGraph/Makefile \
+ ./src/QxGraph/Makefile \
./src/LightApp/Makefile \
./src/ResExporter/Makefile \
./src/RegistryDisplay/Makefile \
// #include <SUPERVGraph_ViewManager.h>
//#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ #include <QxGraph_ViewModel.h>
+ #include <QxGraph_ViewWindow.h>
+ #include <QxGraph_ViewManager.h>
+#endif
+
#include <QtxWorkstack.h>
#include <qdir.h>
#ifndef DISABLE_VTKVIEWER
createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), ALT+Key_K );
#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), ALT+Key_C );
+#endif
createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
case NewVTKViewId:
type = VTKViewer_Viewer::Type();
break;
+#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ case NewQxGraphViewId:
+ type = QxGraph_Viewer::Type();
+ break;
#endif
}
if( a )
a->setEnabled( activeStudy() );
#endif
+
+#ifndef DISABLE_QXGRAPHVIEWER
+ a = action( NewQxGraphViewId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
}
/*!
// viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
// }
//#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ if( vmType == QxGraph_Viewer::Type() )
+ {
+ viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
+ }
+#endif
#ifndef DISABLE_OCCVIEWER
if( vmType == OCCViewer_Viewer::Type() )
{
NewVTKViewId,
#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ NewQxGraphViewId,
+#endif
+
PreferencesId, MRUId, UserID };
public:
LightApp_Application();
else !ENABLE_SUPERVGRAPHVIEWER
libLightApp_la_CPPFLAGS+= -DDISABLE_SUPERVGRAPHVIEWER
endif
+if ENABLE_QXGRAPHVIEWER
+ libLightApp_la_CPPFLAGS+= -I$(srcdir)/../QxGraph
+else !ENABLE_QXGRAPHVIEWER
+ libLightApp_la_CPPFLAGS+= -DDISABLE_QXGRAPHVIEWER
+endif
if ENABLE_SALOMEOBJECT
msgid "LightApp_Application::NEW_WINDOW_3"
msgstr "VT&K view"
+msgid "LightApp_Application::NEW_WINDOW_4"
+msgstr "&QxGraph view"
+
msgid "LightApp_Application::INF_CANCELLED"
msgstr "Module activation cancelled"
if ENABLE_SUPERVGRAPHVIEWER
SUBDIRS += SUPERVGraph
endif
+if ENABLE_QXGRAPHVIEWER
+ SUBDIRS += QxGraph
+endif
SUBDIRS += LightApp ResExporter
if GUI_ENABLE_CORBA
--- /dev/null
+# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+lib_LTLIBRARIES = libQxGraph.la
+
+salomeinclude_HEADERS= \
+ QxGraph_ActiveItem.h \
+ QxGraph_Prs.h \
+ QxGraph_Canvas.h \
+ QxGraph_CanvasView.h \
+ QxGraph_ViewWindow.h \
+ QxGraph_ViewManager.h \
+ QxGraph_ViewModel.h \
+ QxGraph_Def.h \
+ QxGraph.h
+
+dist_libQxGraph_la_SOURCES= \
+ QxGraph_Prs.cxx \
+ QxGraph_Canvas.cxx \
+ QxGraph_CanvasView.cxx \
+ QxGraph_ViewWindow.cxx \
+ QxGraph_ViewManager.cxx \
+ QxGraph_ViewModel.cxx
+
+MOC_FILES= \
+ QxGraph_Canvas_moc.cxx \
+ QxGraph_CanvasView_moc.cxx \
+ QxGraph_ViewWindow_moc.cxx \
+ QxGraph_ViewManager_moc.cxx \
+ QxGraph_ViewModel_moc.cxx
+
+nodist_libQxGraph_la_SOURCES= $(MOC_FILES)
+
+dist_salomeres_DATA= \
+ resources/view_fitall.png \
+ resources/view_fitarea.png \
+ resources/view_glpan.png \
+ resources/view_pan.png \
+ resources/view_reset.png \
+ resources/view_zoom.png
+
+nodist_salomeres_DATA= \
+ QxGraph_images.qm \
+ QxGraph_msg_en.qm
+
+libQxGraph_la_CPPFLAGS=$(QT_INCLUDES) $(CAS_CPPFLAGS) $(PYTHON_INCLUDES) $(BOOST_CPPFLAGS) \
+ -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT
+libQxGraph_la_LDFLAGS=$(QT_MT_LIBS) ../SUIT/libsuit.la
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifdef WNT
+#ifdef QXGRAPH_EXPORTS
+#define QXGRAPH_EXPORT __declspec(dllexport)
+#else
+#define QXGRAPH_EXPORT __declspec(dllimport)
+#endif
+#else
+#define QXGRAPH_EXPORT
+#endif
+
+#ifdef WNT
+#pragma warning ( disable:4251 )
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef QXGRAPH_ACTIVEITEM_H
+#define QXGRAPH_ACTIVEITEM_H
+
+#include "QxGraph.h"
+
+#include <qpoint.h>
+#include <qwmatrix.h>
+#include <qevent.h>
+
+class QXGRAPH_EXPORT QxGraph_ActiveItem
+{
+ public:
+ QxGraph_ActiveItem() {}
+ ~QxGraph_ActiveItem() {}
+
+ virtual bool isMoveable() = 0;
+ virtual void beforeMoving() = 0;
+ virtual void afterMoving() = 0;
+
+ virtual bool isResizable(QPoint thePoint, int& theCursorType) { return false; }
+ virtual bool isResizing() { return false; }
+ virtual void beforeResizing(int theCursorType) {}
+ virtual void resize(QPoint thePoint) {}
+ virtual void afterResizing() {}
+
+ virtual void hilight(const QPoint& theMousePos, const bool toHilight = true) = 0;
+ virtual void select(const QPoint& theMousePos, const bool toSelect = true) = 0;
+ virtual void showPopup(QWidget* theParent, QMouseEvent* theEvent, const QPoint& theMousePos = QPoint()) = 0;
+
+ virtual QString getToolTipText(const QPoint& theMousePos, QRect& theRect) const = 0;
+
+ virtual bool arePartsOfOtherItem(QxGraph_ActiveItem* theSecondItem) { return false; }
+
+ void setTMatrix(QWMatrix theMatrix) { myTMatrix = theMatrix; }
+ QWMatrix getTMatrix() const { return myTMatrix; }
+
+ private:
+ QWMatrix myTMatrix; // canvas view's current transformation matrix
+};
+
+#endif
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "QxGraph_Canvas.h"
+#include "QxGraph_Def.h"
+#include "QxGraph_Prs.h"
+
+#include <SUIT_ResourceMgr.h>
+
+#include <qobjectlist.h>
+
+/*!
+ Constructor
+*/
+QxGraph_Canvas::QxGraph_Canvas(SUIT_ResourceMgr* theMgr) :
+ QCanvas()
+{
+ printf("Construct QxGraph_Canvas\n");
+
+ resize(GRAPH_WIDTH, GRAPH_HEIGHT);
+ setDoubleBuffering(true);
+
+ QColor aColor = theMgr->colorValue( "QxGraph", "Background", DEF_BACK_COLOR );
+ setBackgroundColor(aColor);
+}
+
+/*!
+ Destructor
+*/
+QxGraph_Canvas::~QxGraph_Canvas()
+{
+ /*QObjectList* aNodeList = queryList("QObject");
+ QObjectListIt aIt(*aNodeList);
+ QObject* anObj;
+ while ( (anObj = aIt.current()) != 0 ) {
+ ++aIt;
+ aNodeList->removeRef(anObj);
+ delete anObj;
+ }
+ delete aNodeList;*/
+
+ myPrsList.setAutoDelete(true);
+ myPrsList.clear();
+}
+
+/*!
+ Add view
+*/
+void QxGraph_Canvas::addView(QCanvasView* theView)
+{
+ QCanvas::addView(theView);
+ theView->setPaletteBackgroundColor(backgroundColor().light(120));
+}
+
+/*!
+ Get Prs object with index theIndex
+*/
+QxGraph_Prs* QxGraph_Canvas::getPrs(int theIndex)
+{
+ QxGraph_Prs* aRetPrs = 0;
+ if ( theIndex >= 0 && theIndex < myPrsList.count() )
+ aRetPrs = myPrsList.at(theIndex);
+ return aRetPrs;
+}
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef QXGRAPH_CANVAS_H
+#define QXGRAPH_CANVAS_H
+
+#include "QxGraph.h"
+
+#include <qcanvas.h>
+#include <qptrlist.h>
+
+class SUIT_ResourceMgr;
+class QxGraph_Prs;
+
+class QXGRAPH_EXPORT QxGraph_Canvas : public QCanvas {
+ Q_OBJECT
+
+ public:
+ QxGraph_Canvas(SUIT_ResourceMgr*);
+ virtual ~QxGraph_Canvas();
+
+ void addView(QCanvasView* theView);
+
+ QPtrList<QxGraph_Prs> getPrsList() const { return myPrsList; }
+ QxGraph_Prs* getPrs(int theIndex = 0);
+ void addPrs(QxGraph_Prs* thePrs) { myPrsList.append(thePrs); }
+
+ private:
+ QPtrList<QxGraph_Prs> myPrsList;
+
+};
+
+#endif
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "QxGraph_CanvasView.h"
+#include "QxGraph_Canvas.h"
+#include "QxGraph_ViewWindow.h"
+#include "QxGraph_ActiveItem.h"
+#include "QxGraph_Def.h"
+
+#include <qwmatrix.h>
+#include <math.h>
+
+const char* imageZoomCursor[] = {
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+".#######........................",
+"..aaaaaaa.......................",
+"................................",
+".............#####..............",
+"...........##.aaaa##............",
+"..........#.aa.....a#...........",
+".........#.a.........#..........",
+".........#a..........#a.........",
+"........#.a...........#.........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+".........#...........#.a........",
+".........#a..........#a.........",
+".........##.........#.a.........",
+"........#####.....##.a..........",
+".......###aaa#####.aa...........",
+"......###aa...aaaaa.......#.....",
+".....###aa................#a....",
+"....###aa.................#a....",
+"...###aa...............#######..",
+"....#aa.................aa#aaaa.",
+".....a....................#a....",
+"..........................#a....",
+"...........................a....",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageCrossCursor[] = {
+ "32 32 3 1",
+ ". c None",
+ "a c #000000",
+ "# c #ffffff",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "...............#................",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ ".......#################........",
+ "........aaaaaaa#aaaaaaaaa.......",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "...............#a...............",
+ "................a...............",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................",
+ "................................"};
+
+/*!
+ Constructor
+*/
+QxGraph_CanvasView::QxGraph_CanvasView(QxGraph_Canvas* theCanvas, QxGraph_ViewWindow* theViewWindow) :
+ QCanvasView(theCanvas, theViewWindow, 0, Qt::WRepaintNoErase),
+ myCurrentItem(0),
+ myHilightedItem(0),
+ mySelectedItem(0)
+{
+ printf("Construct QxGraph_CanvasView\n");
+ setName("QxGraph_CanvasView");
+
+ myOperation = NOTHING;
+ myCursor = cursor();
+ mySelectedRect = 0;
+
+ myTimer = new QTimer(this);
+ connect(myTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
+
+ viewport()->setMouseTracking(true);
+}
+
+/*!
+ Destructor
+*/
+QxGraph_CanvasView::~QxGraph_CanvasView()
+{
+}
+
+void QxGraph_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent)
+{
+ myPoint = inverseWorldMatrix().map(theEvent->pos());
+ myGlobalPoint = theEvent->globalPos();
+ myCurrentItem = 0;
+
+ if ( theEvent->button() == Qt::MidButton && theEvent->state() == Qt::ControlButton
+ ||
+ myOperation == PANVIEW )
+ { // Panning
+ if ( myOperation != PANVIEW ) {
+ myOperation = PANVIEW;
+ myCursor = cursor(); // save old cursor
+ QCursor panCursor (Qt::SizeAllCursor);
+ setCursor(panCursor);
+ }
+ return;
+ }
+
+ if ( myOperation == PANGLOBAL )
+ { // Global panning
+ return;
+ }
+
+ if ( theEvent->button() == Qt::LeftButton && theEvent->state() == Qt::ControlButton
+ ||
+ myOperation == ZOOMVIEW )
+ { // Zoom
+ if ( myOperation != ZOOMVIEW ) {
+ myOperation = ZOOMVIEW;
+ myCursor = cursor(); // save old cursor
+ QPixmap zoomPixmap (imageZoomCursor);
+ QCursor zoomCursor (zoomPixmap);
+ setCursor(zoomCursor);
+ }
+ return;
+ }
+
+ if ( theEvent->button() == Qt::LeftButton )
+ {
+ QCanvasItemList aList = canvas()->collisions(myPoint);
+ // to move items on canvas view
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ int aCursorType;
+ if ( anActItem && anActItem->isResizable(myPoint,aCursorType) )
+ { // resize itself only active items if it is resizable
+ anActItem->beforeResizing(aCursorType);
+ myCurrentItem = *it;
+ return;
+ }
+ else if ( anActItem && anActItem->isMoveable() )
+ { // move itself only active items if it is moveable
+ anActItem->beforeMoving();
+ myCurrentItem = *it;
+ return;
+ }
+ }
+ }
+}
+
+void QxGraph_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent)
+{
+ QPoint aPoint = inverseWorldMatrix().map(theEvent->pos());
+ QPoint aGlobalPoint = theEvent->globalPos();
+
+ if (myTimer->isActive()) myTimer->stop();
+
+ if ( myOperation == PANVIEW )
+ { // Panning
+ scrollBy(myGlobalPoint.x() - aGlobalPoint.x(),
+ myGlobalPoint.y() - aGlobalPoint.y());
+ myGlobalPoint = aGlobalPoint;
+ return;
+ }
+
+ if ( myOperation == WINDOWFIT )
+ { // Fit within rectangle
+ int aLX, aTY; //left x and top y
+ if (myPoint.x() < aPoint.x()) aLX = myPoint.x();
+ else aLX = aPoint.x();
+ if (myPoint.y() < aPoint.y()) aTY = myPoint.y();
+ else aTY = aPoint.y();
+ QRect aRect(aLX, aTY, abs(myPoint.x()-aPoint.x()), abs(myPoint.y()-aPoint.y()));
+ QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas());
+
+ //hide old selected rectangle
+ if (mySelectedRect)
+ mySelectedRect->hide();
+ //draw new selected rectangle
+ QPen pen(Qt::black,1,Qt::SolidLine);
+ aRect1->setPen(pen);
+ aRect1->setZ(3);
+ aRect1->show();
+
+ mySelectedRect = aRect1;
+ canvas()->update();
+ }
+
+ if ( myOperation == ZOOMVIEW )
+ { // Zoom
+ QWMatrix m = worldMatrix();
+
+ double dx = aGlobalPoint.x() - myGlobalPoint.x();
+ double s = 1. + fabs(dx)*( (m.m11() < 1) ? m.m11() : 1. )/70.;
+ if (dx < 0) s = 1./s;
+
+ m.scale(s, s);
+ setWorldMatrix(m);
+
+ // remember the canvas view's current transformation matrix in all canvas items
+ QCanvasItemList aList = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if ( anActItem ) anActItem->setTMatrix(m);
+ }
+
+ myGlobalPoint = aGlobalPoint;
+ return;
+ }
+
+ if ( myCurrentItem )
+ {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( myCurrentItem );
+ if ( anActItem && anActItem->isResizing() )
+ { // to resize items on canvas view
+ anActItem->resize(aPoint);
+ return;
+ }
+
+ // to move items on canvas view
+ if ( myCurrentItem->x() && myCurrentItem->y() ) {
+ double cx = myCurrentItem->x() - myPoint.x();
+ double cy = myCurrentItem->y() - myPoint.y();
+
+ if (aPoint.x()+cx < 0) aPoint.setX(-(int)cx);
+ if (aPoint.y()+cy < 0) aPoint.setY(-(int)cy);
+ }
+ myCurrentItem->moveBy(aPoint.x() - myPoint.x(),
+ aPoint.y() - myPoint.y());
+ myPoint = aPoint;
+ canvas()->update();
+
+ // scroll contents if mouse is outside
+ QRect r(contentsX(), contentsY(), visibleWidth(), visibleHeight());
+ if (!r.contains(theEvent->pos())) {
+ int dx = 0, dy = 0;
+ if (theEvent->pos().x() < r.left()) dx = theEvent->pos().x() - r.left();
+ if (theEvent->pos().x() > r.right()) dx = theEvent->pos().x() - r.right();
+ if (theEvent->pos().y() < r.top()) dy = theEvent->pos().y() - r.top();
+ if (theEvent->pos().y() > r.bottom()) dy = theEvent->pos().y() - r.bottom();
+ scrollBy(dx, dy);
+ // start timer to scroll in silent mode
+ myDX = dx; myDY = dy;
+ myTimer->start(100);
+ }
+
+ return;
+ }
+ else
+ {
+ QCanvasItemList aList = canvas()->collisions(aPoint);
+ // perform actions for active items
+ bool isHilightPerformed = false;
+
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+
+ if (!isHilightPerformed && anActItem) {
+ // hilight
+ anActItem->hilight(aPoint);
+ if (anActItem != myHilightedItem) {
+ if (myHilightedItem)
+ myHilightedItem->hilight(aPoint, false);
+ myHilightedItem = anActItem;
+ }
+ isHilightPerformed = true;
+
+ // show tooltip
+ QxGraph_ToolTip* aToolTip = new QxGraph_ToolTip(this);
+ aToolTip->maybeTip(aPoint);
+ }
+
+ int aCursorType;
+ if ( anActItem && anActItem->isResizable(aPoint,aCursorType) ) {
+ // set resize cursor
+ QCursor resizeCursor;
+ switch (aCursorType)
+ {
+ case 1: //left
+ case 3: //right
+ resizeCursor = QCursor(Qt::SizeHorCursor);
+ break;
+ case 2: //top
+ case 4: //bottom
+ resizeCursor = QCursor(Qt::SizeVerCursor);
+ break;
+ case 5: //left-top
+ case 7: //right-bottom
+ resizeCursor = QCursor(Qt::SizeFDiagCursor);
+ break;
+ case 6: //right-top
+ case 8: //left-bottom
+ resizeCursor = QCursor(Qt::SizeBDiagCursor);
+ break;
+ default :
+ resizeCursor = QCursor(Qt::ArrowCursor);
+ break;
+ }
+ setCursor(resizeCursor);
+ return;
+ }
+ else {
+ // reset old cursor
+ setCursor(QCursor(Qt::ArrowCursor));
+ return;
+ }
+ }
+
+ if (!isHilightPerformed && myHilightedItem) {
+ myHilightedItem->hilight(aPoint, false);
+ myHilightedItem = 0;
+ QToolTip::hide(); //@ temporary solution
+ }
+
+ if ( cursor().shape() == Qt::SizeVerCursor || cursor().shape() == Qt::SizeHorCursor
+ || cursor().shape() == Qt::SizeBDiagCursor || cursor().shape() == Qt::SizeFDiagCursor)
+ setCursor(QCursor(Qt::ArrowCursor));
+ }
+}
+
+void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
+{
+ QPoint aPoint = inverseWorldMatrix().map(theEvent->pos());
+
+ if (myTimer->isActive()) myTimer->stop();
+
+ if (myCurrentItem)
+ { // to move items on canvas view
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( myCurrentItem );
+ if ( anActItem && anActItem->isResizing() )
+ {
+ anActItem->afterResizing();
+ // reset old cursor
+ setCursor(QCursor(Qt::ArrowCursor));
+ }
+ else if ( anActItem && anActItem->isMoveable() )
+ anActItem->afterMoving();
+ }
+ myCurrentItem = 0;
+
+ if ( myOperation == PANVIEW )
+ { // Panning
+ myOperation = NOTHING;
+ viewport()->setMouseTracking(true);
+ setCursor(myCursor);
+ }
+
+ if ( myOperation == PANGLOBAL )
+ { // Global panning
+ myOperation = NOTHING;
+ center( theEvent->x(), theEvent->y() );
+ setCursor(myCursor);
+ }
+
+ if ( myOperation == WINDOWFIT )
+ { // Fit within rectangle
+ myOperation = NOTHING;
+
+ if (mySelectedRect) {
+ mySelectedRect->hide();
+ mySelectedRect = 0;
+ //canvas()->update();
+ }
+
+ //myPoint is the start point for selecting rectangle now
+ int aLX, aTY; //left x and top y
+ if (myPoint.x() < aPoint.x()) aLX = myPoint.x();
+ else aLX = aPoint.x();
+ if (myPoint.y() < aPoint.y()) aTY = myPoint.y();
+ else aTY = aPoint.y();
+
+ //calculate width and height for new view and new zoom factor
+ double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-aPoint.x())));
+ double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-aPoint.y())));
+ if (aXzoom > aYzoom) aXzoom = aYzoom;
+
+ QWMatrix m;
+ m.scale(aXzoom, aXzoom);
+ setWorldMatrix(m);
+
+ // remember the canvas view's current transformation matrix in all canvas items
+ QCanvasItemList aList = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if ( anActItem ) anActItem->setTMatrix(m);
+ }
+
+ setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom));
+
+ canvas()->update();
+
+ viewport()->setMouseTracking(true);
+ setCursor(myCursor);
+ }
+
+ if ( myOperation == ZOOMVIEW )
+ { // Zoom
+ myOperation = NOTHING;
+ viewport()->setMouseTracking(true);
+ setCursor(myCursor);
+ }
+
+ if ( theEvent->button() == RightButton )
+ {
+ // Selection mechanism
+ QCanvasItemList aList = canvas()->collisions(aPoint);
+ bool isSelectionPerformed = false;
+
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if (!isSelectionPerformed && anActItem)
+ {
+ anActItem->select(aPoint);
+ if (anActItem != mySelectedItem)
+ {
+ if (mySelectedItem && isSelectedItemInCanvas() &&
+ !mySelectedItem->arePartsOfOtherItem(anActItem)) mySelectedItem->select(aPoint, false);
+ mySelectedItem = anActItem;
+
+ // unhilight hilighted item if selection was performed
+ if (myHilightedItem) {
+ myHilightedItem->hilight(aPoint, false);
+ myHilightedItem = 0;
+ }
+ }
+ isSelectionPerformed = true;
+ }
+ }
+
+ if (!isSelectionPerformed)
+ {
+ if ( mySelectedItem )
+ {
+ if ( isSelectedItemInCanvas() ) mySelectedItem->select(aPoint, false);
+ mySelectedItem = 0;
+ }
+
+ // Background popup
+ printf("Background popup\n");
+ QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+ theEvent->pos(), theEvent->globalPos(),
+ theEvent->state() );
+ if ( getViewWindow() )
+ getViewWindow()->contextPopupEvent(&aEvent); // => emit contextMenuRequested( &aEvent );
+ }
+ else
+ { // show context popup for the selected item
+ mySelectedItem->showPopup(viewport(), theEvent, aPoint);
+ }
+ }
+
+ if ( theEvent->button() == LeftButton )
+ {
+ // Selection mechanism
+ QCanvasItemList aList = canvas()->collisions(aPoint);
+
+ if ( aList.empty() && mySelectedItem )
+ {
+ if ( isSelectedItemInCanvas() ) mySelectedItem->select(aPoint, false);
+ mySelectedItem = 0;
+ }
+ else
+ {
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if (anActItem)
+ {
+ anActItem->select(aPoint);
+ if (anActItem != mySelectedItem)
+ {
+ if (mySelectedItem && isSelectedItemInCanvas() &&
+ !mySelectedItem->arePartsOfOtherItem(anActItem)) mySelectedItem->select(aPoint, false);
+ mySelectedItem = anActItem;
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+void QxGraph_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
+{
+
+}
+
+bool QxGraph_CanvasView::isSelectedItemInCanvas()
+{
+ // check if mySelectedItem is included into the canvas:
+ // if yes => unselect it
+ // if no => do nothing
+ bool anIsInCanvas = false;
+ QCanvasItemList aListC = canvas()->allItems();
+ for (QCanvasItemList::Iterator itC = aListC.begin(); itC != aListC.end(); ++itC) {
+ QxGraph_ActiveItem* anActItemC = dynamic_cast<QxGraph_ActiveItem*>( *itC );
+ if ( anActItemC && anActItemC == mySelectedItem ) {
+ anIsInCanvas = true;
+ break;
+ }
+ }
+ return anIsInCanvas;
+}
+
+void QxGraph_CanvasView::activateFitAll()
+{
+ //myOperation = FITALL;
+ int w = 0, h = 0;
+ QCanvasItemList l = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
+ QRect r = (*it)->boundingRect();
+ if (w < r.right()) w = r.right();
+ if (h < r.bottom()) h = r.bottom();
+ }
+ w += GRAPH_MARGIN; h += GRAPH_MARGIN;
+ double s = ((double)visibleWidth())/((double)w);
+ double s1 = ((double)visibleHeight())/((double)h);
+ if (s > s1) s = s1;
+
+ setContentsPos(0,0);
+ QWMatrix m;
+ m.scale(s, s);
+ setWorldMatrix(m);
+
+ // remember the canvas view's current transformation matrix in all canvas items
+ QCanvasItemList aList = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if ( anActItem ) anActItem->setTMatrix(m);
+ }
+
+ canvas()->update();
+ //myOperation = NOTHING;
+}
+
+void QxGraph_CanvasView::activateFitRect()
+{
+ myOperation = WINDOWFIT;
+ viewport()->setMouseTracking(false);
+ myCursor = cursor(); // save old cursor
+ QCursor handCursor (Qt::PointingHandCursor);
+ setCursor(handCursor);
+}
+
+void QxGraph_CanvasView::activateZoom()
+{
+ myOperation = ZOOMVIEW;
+ viewport()->setMouseTracking(false);
+ myCursor = cursor(); // save old cursor
+ QPixmap zoomPixmap (imageZoomCursor);
+ QCursor zoomCursor (zoomPixmap);
+ setCursor(zoomCursor);
+}
+
+void QxGraph_CanvasView::activatePanning()
+{
+ myOperation = PANVIEW;
+ viewport()->setMouseTracking(false);
+ myCursor = cursor(); // save old cursor
+ QCursor panCursor (Qt::SizeAllCursor);
+ setCursor(panCursor);
+}
+
+void QxGraph_CanvasView::activateGlobalPanning()
+{
+ myOperation = PANGLOBAL;
+ myCursor = cursor(); // save old cursor
+ QPixmap globalPanPixmap (imageCrossCursor);
+ QCursor glPanCursor (globalPanPixmap);
+ setCursor(glPanCursor);
+}
+
+void QxGraph_CanvasView::activateReset()
+{
+ //myOperation = RESETVIEW;
+ setContentsPos(0,0);
+ QWMatrix m;
+ setWorldMatrix(m);
+
+ // remember the canvas view's current transformation matrix in all canvas items
+ QCanvasItemList aList = canvas()->allItems();
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if ( anActItem ) anActItem->setTMatrix(m);
+ }
+
+ //myOperation = NOTHING;
+}
+
+void QxGraph_CanvasView::onTimeout()
+{
+ if (myCurrentItem) {
+ scrollBy(myDX, myDY);
+
+ double cx, cy;
+ inverseWorldMatrix().map((double)myDX, (double)myDY, &cx, &cy);
+ if (myCurrentItem->x()+cx < 0) cx = -myCurrentItem->x();
+ if (myCurrentItem->y()+cy < 0) cy = -myCurrentItem->y();
+ myCurrentItem->moveBy(cx, cy);
+ myPoint.setX(myPoint.x()+(int)cx);
+ myPoint.setY(myPoint.y()+(int)cy);
+ canvas()->update();
+ }
+}
+
+QxGraph_ViewWindow* QxGraph_CanvasView::getViewWindow() const
+{
+ return dynamic_cast<QxGraph_ViewWindow*>( parent() );
+}
+
+/*!
+ Shows tooltip if necessary
+*/
+void QxGraph_ToolTip::maybeTip(const QPoint& theMousePos) {
+ QCanvasItemList aList = ((QCanvasView*)parentWidget())->canvas()->collisions(theMousePos);
+
+ for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) {
+ QxGraph_ActiveItem* anActItem = dynamic_cast<QxGraph_ActiveItem*>( *it );
+ if (anActItem)
+ {
+ QRect aRect;
+ QString aText = anActItem->getToolTipText(theMousePos, aRect);
+ int avX, avY;
+ QWMatrix aWM = ((QCanvasView*)parentWidget())->worldMatrix();
+ ((QCanvasView*)parentWidget())->contentsToViewport((int)(aRect.left()*aWM.m11()),
+ (int)(aRect.top()*aWM.m22()),
+ avX, avY);
+ QRect aTipRect(avX, avY, (int)(aRect.width()*aWM.m11()), (int)(aRect.height()*aWM.m22()));
+ if (!aText.isEmpty())
+ tip(aTipRect, aText);
+ return;
+ }
+ }
+}
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef QXGRAPH_CANVASVIEW_H
+#define QXGRAPH_CANVASVIEW_H
+
+#include "QxGraph.h"
+
+#include <qcanvas.h>
+#include <qcursor.h>
+#include <qtimer.h>
+#include <qtooltip.h>
+
+class QxGraph_Canvas;
+class QxGraph_ViewWindow;
+class QxGraph_ActiveItem;
+
+class QXGRAPH_EXPORT QxGraph_CanvasView : public QCanvasView {
+ Q_OBJECT
+
+ public:
+ enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, PANGLOBAL,
+ WINDOWFIT, FITALLVIEW, RESETVIEW };
+
+ QxGraph_CanvasView(QxGraph_Canvas* theCanvas, QxGraph_ViewWindow* theViewWindow);
+ virtual ~QxGraph_CanvasView();
+
+ QxGraph_ViewWindow* getViewWindow() const;
+
+ void activateFitAll();
+ void activateFitRect();
+ void activateZoom();
+ void activatePanning();
+ void activateGlobalPanning();
+ void activateReset();
+
+ public slots:
+ void onTimeout();
+ //void changeBackground();
+
+ protected:
+ void contentsMousePressEvent(QMouseEvent* theEvent);
+ void contentsMouseMoveEvent(QMouseEvent* theEvent);
+ void contentsMouseReleaseEvent(QMouseEvent* theEvent);
+ void contentsMouseDoubleClickEvent(QMouseEvent* theEvent);
+
+ bool isSelectedItemInCanvas();
+
+ private:
+ // for moving items
+ QCanvasItem* myCurrentItem;
+ QPoint myPoint;
+ QPoint myGlobalPoint;
+
+ // for control toolbar actions
+ OperationType myOperation;
+ QCursor myCursor;
+ QCanvasRectangle* mySelectedRect;
+
+ // for automatic content scrolling if mouse is outside
+ QTimer* myTimer;
+ int myDX;
+ int myDY;
+
+ // for hilight
+ QxGraph_ActiveItem* myHilightedItem;
+
+ // for selection
+ QxGraph_ActiveItem* mySelectedItem;
+};
+
+
+class QxGraph_ToolTip: public QToolTip {
+
+ public:
+ QxGraph_ToolTip(QWidget* theWidget, QToolTipGroup* theGroup = 0):
+ QToolTip(theWidget, theGroup) {}
+ ~QxGraph_ToolTip() { remove(parentWidget()); }
+
+ virtual void maybeTip(const QPoint& theMousePos);
+};
+
+#endif
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef QXGRAPH_DEF_H
+#define QXGRAPH_DEF_H
+
+#define DEF_BACK_COLOR QColor(144, 208, 211)
+#define RECTANGLE_BODY QColor(255,249,147)
+
+#define GRAPH_WIDTH 1250
+#define GRAPH_HEIGHT 950
+
+#define GRAPH_MARGIN 50
+
+#endif
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "QxGraph_Prs.h"
+
+#include "QxGraph_Canvas.h"
+#include "QxGraph_Def.h" // for debug only
+
+#include "SUIT_Session.h" // for debug only
+
+/*!
+ Constructor
+*/
+QxGraph_Prs::QxGraph_Prs(QxGraph_Canvas* theCanvas):
+ myCanvas(theCanvas),
+ myDMode(0),
+ needUpdate(true)
+{
+ myCanvas->addPrs(this);
+}
+
+/*!
+ Destructor
+*/
+QxGraph_Prs::~QxGraph_Prs()
+{
+ for ( DMode2ItemList::iterator it1 = myDisplayMap.begin();
+ it1 != myDisplayMap.end();
+ it1++ )
+ {
+ for ( std::list<QCanvasItem*>::iterator it2 = (*it1).second.begin();
+ it2 != (*it1).second.end();
+ it2++ )
+ {
+ QCanvasItem* anItem = *it2;
+ if ( anItem ) delete anItem;
+ }
+ }
+
+ myDisplayMap.clear();
+}
+
+/*!
+ Add item to display in the view with index theDMode
+*/
+void QxGraph_Prs::addItem(QCanvasItem* theItem, int theDMode)
+{
+ if ( theDMode == -1 ) // add item for the current display mode
+ myDisplayMap[myDMode].push_back(theItem);
+ else
+ myDisplayMap[theDMode].push_back(theItem);
+}
+
+/*!
+ Remove item from the view with index theDMode
+*/
+void QxGraph_Prs::removeItem(QCanvasItem* theItem, int theDMode)
+{
+ if ( theDMode == -1 ) // remove item from the current display mode
+ myDisplayMap[myDMode].remove(theItem);
+ else
+ myDisplayMap[theDMode].remove(theItem);
+}
+
+/*! Adds all the items of this presentation for the current display mode
+ * to the canvas.
+ */
+void QxGraph_Prs::show()
+{
+ if ( isToUpdate() )
+ update();
+
+ for ( std::list<QCanvasItem*>::iterator it = myDisplayMap[myDMode].begin();
+ it != myDisplayMap[myDMode].end();
+ it++ )
+ {
+ QCanvasItem* anItem = *it;
+ if ( anItem )
+ {
+ anItem->setCanvas( myCanvas );
+ anItem->show();
+ }
+ }
+}
+
+/*! Removes all the items belonging to this presentation from the canvas.
+ */
+void QxGraph_Prs::hide()
+{
+ for ( DMode2ItemList::iterator it1 = myDisplayMap.begin();
+ it1 != myDisplayMap.end();
+ it1++ )
+ {
+ for ( std::list<QCanvasItem*>::iterator it2 = (*it1).second.begin();
+ it2 != (*it1).second.end();
+ it2++ )
+ {
+ QCanvasItem* anItem = *it2;
+ if ( anItem )
+ {
+ anItem->setCanvas( 0 );
+ }
+ }
+ }
+}
+
+/*! Prepare for full recomputation of the presentation
+ */
+void QxGraph_Prs::setToUpdate( const bool theFlag )
+{
+ needUpdate = theFlag;
+}
+
+/*! Re-fills the presentation with items.
+ * Base implementation just resets <needUpdate> flag.
+ * It should be called at the end by re-implementations.
+ */
+void QxGraph_Prs::update()
+{
+ setToUpdate( false );
+}
+
+/*!
+ Add a QCanvasRectangle item for display mode DMode
+*/
+QCanvasItem* QxGraph_Prs::addRectangleItem(QRect theRect, int theDMode)
+{
+ QCanvasRectangle* aRectItem;
+ if ( myCanvas )
+ {
+ QCanvasRectangle* aRectItem = new QCanvasRectangle(theRect, myCanvas);
+ aRectItem->setZ(0);
+ aRectItem->show();
+ myCanvas->update();
+
+ // test drawing features: brush, pen ...
+ QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "QxGraph", "NodeBody", RECTANGLE_BODY ));
+ aRectItem->setBrush(aBr);
+ }
+ addItem(aRectItem);
+ return aRectItem;
+}
+
+/*!
+ Add a QCanvasPolygon item for display mode DMode
+*/
+QCanvasItem* QxGraph_Prs::addPolygonItem(QPointArray thePA, int theDMode)
+{
+ QCanvasPolygon* aPolyItem;
+ if ( myCanvas )
+ {
+ aPolyItem = new QCanvasPolygon(myCanvas);
+ aPolyItem->setZ(0);
+ aPolyItem->setPoints(thePA);
+ aPolyItem->show();
+ myCanvas->update();
+
+ // test drawing features: brush, pen ...
+ QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "QxGraph", "NodeBody", RECTANGLE_BODY ));
+ aPolyItem->setBrush(aBr);
+ QPen aPen(Qt::black,2);
+ aPolyItem->setPen(aPen);
+ }
+ addItem(aPolyItem);
+ return aPolyItem;
+}
+
+/*!
+ Add a QCanvasLine item for display mode DMode
+*/
+QCanvasItem* QxGraph_Prs::addLineItem(QPoint theStart, QPoint theEnd, int theDMode)
+{
+ QCanvasLine* aLineItem;
+ if ( myCanvas )
+ {
+ aLineItem = new QCanvasLine(myCanvas);
+ aLineItem->setZ(0);
+ aLineItem->setPoints(theStart.x(), theStart.y(), theEnd.x(), theEnd.y());
+ aLineItem->show();
+ myCanvas->update();
+
+ // test drawing features: brush, pen ...
+ QPen aPen(Qt::black,2);
+ aLineItem->setPen(aPen);
+ }
+ addItem(aLineItem);
+ return aLineItem;
+}
+
+/*!
+ Add a QCanvasEllipse item for display mode DMode
+*/
+QCanvasItem* QxGraph_Prs::addEllipseItem(int theW, int theH, int theStartAngle, int theAngle, int theDMode)
+{
+ QCanvasEllipse* aEllipseItem;
+ if ( myCanvas )
+ {
+ aEllipseItem = new QCanvasEllipse(theW, theH, theStartAngle, theAngle, myCanvas);
+ aEllipseItem->setZ(0);
+ aEllipseItem->show();
+ myCanvas->update();
+
+ // test drawing features: brush, pen ...
+ QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "QxGraph", "NodeBody", RECTANGLE_BODY ));
+ aEllipseItem->setBrush(aBr);
+ QPen aPen(Qt::black,2);
+ aEllipseItem->setPen(aPen);
+ }
+ addItem(aEllipseItem);
+ return aEllipseItem;
+}
+
+/*!
+ Add a QCanvasText item for display mode DMode
+*/
+QCanvasItem* QxGraph_Prs::addTextItem(QString theText, int theDMode)
+{
+ QCanvasText* aTextItem;
+ if ( myCanvas )
+ {
+ aTextItem = new QCanvasText(theText, myCanvas);
+ aTextItem->setZ(0);
+ aTextItem->show();
+ myCanvas->update();
+
+ // test drawing features: font, color, text flags ...
+ aTextItem->setColor(Qt::darkBlue);
+ //aTextItem->setFont(QFont("Times"/*"Helvetica"*/, 14, QFont::Normal, true));
+ }
+ addItem(aTextItem);
+ return aTextItem;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef QXGRAPH_PRS_H
+#define QXGRAPH_PRS_H
+
+#include <QxGraph.h>
+
+#include <qcanvas.h>
+#include <map>
+#include <list>
+
+class QxGraph_Canvas;
+
+class QXGRAPH_EXPORT QxGraph_Prs
+{
+ public:
+ QxGraph_Prs(QxGraph_Canvas*);
+ virtual ~QxGraph_Prs();
+
+ QxGraph_Canvas* getCanvas() const { return myCanvas; }
+
+ void addItem(QCanvasItem* theItem, int theDMode = -1);
+ void removeItem(QCanvasItem* theItem, int theDMode = -1);
+
+ /* add items for display mode theDMode
+ if theDMode is equal to -1 add item for the current (active) display mode */
+ QCanvasItem* addRectangleItem(QRect theRect, int theDMode = -1);
+ QCanvasItem* addPolygonItem(QPointArray thePA, int theDMode = -1);
+ QCanvasItem* addLineItem(QPoint theStart, QPoint theEnd, int theDMode = -1);
+ QCanvasItem* addEllipseItem(int theW, int theH, int theStartAngle, int theAngle, int theDMode = -1);
+ QCanvasItem* addTextItem(QString theText, int theDMode = -1);
+
+ typedef std::map< int, std::list<QCanvasItem*> > DMode2ItemList;
+
+ const DMode2ItemList& getDisplayMap() const { return myDisplayMap; }
+ const std::list<QCanvasItem*>& getItems(int theDMode) { return myDisplayMap[theDMode]; }
+
+ void setDMode(int theDMode) { myDMode = theDMode; }
+ int getDMode() const { return myDMode; }
+
+ virtual void show();
+ virtual void hide();
+ virtual void setToUpdate( const bool );
+ bool isToUpdate() { return needUpdate; }
+
+protected:
+ virtual void update();
+
+private:
+ QxGraph_Canvas* myCanvas;
+ DMode2ItemList myDisplayMap;
+
+ int myDMode;
+ bool needUpdate;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "QxGraph_ViewManager.h"
+
+int QxGraph_ViewManager::myMaxId = 0;
+
+/*!
+ Constructor
+*/
+QxGraph_ViewManager::QxGraph_ViewManager( SUIT_Study* theStudy,
+ SUIT_Desktop* theDesktop,
+ SUIT_ViewModel* theViewModel )
+ : SUIT_ViewManager( theStudy, theDesktop, theViewModel )
+{
+ myId = ++myMaxId;
+}
+
+/*!
+ Destructor
+*/
+QxGraph_ViewManager::~QxGraph_ViewManager()
+{
+}
+
+/*!
+ Sets view name
+ \param theView - view to assign name
+*/
+void QxGraph_ViewManager::setViewName(SUIT_ViewWindow* theView)
+{
+ int aPos = myViews.find(theView);
+ theView->setCaption( QString( "QxGraph scene:%1 - viewer:%2" ).arg( myId ).arg(aPos+1));
+}
+
+/*!
+ Fills popup menu with custom actions
+ \param popup - popup menu to be filled with
+*/
+void QxGraph_ViewManager::contextMenuPopup( QPopupMenu* thePopup)
+{
+ SUIT_ViewManager::contextMenuPopup( thePopup );
+ // to be implemented
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef QXGRAPH_VIEWMANAGER_H
+#define QXGRAPH_VIEWMANAGER_H
+
+#include "QxGraph.h"
+
+#include "QxGraph_ViewModel.h"
+#include "SUIT_ViewManager.h"
+
+class SUIT_Desktop;
+
+class QXGRAPH_EXPORT QxGraph_ViewManager : public SUIT_ViewManager
+{
+ Q_OBJECT
+
+public:
+ QxGraph_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop, SUIT_ViewModel* theViewModel = 0 );
+ ~QxGraph_ViewManager();
+
+ virtual void contextMenuPopup( QPopupMenu* thePopup );
+
+protected:
+ void setViewName(SUIT_ViewWindow* theView);
+
+private:
+ static int myMaxId;
+ int myId;
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "QxGraph_ViewModel.h"
+#include "QxGraph_ViewWindow.h"
+#include "QxGraph_Canvas.h"
+#include "QxGraph_CanvasView.h"
+#include "QxGraph_Def.h"
+#include "QxGraph_Prs.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_Session.h"
+
+#include <qcolordialog.h>
+#include <qpopupmenu.h>
+#include <qcanvas.h> // for addRectangleItem(...) method (can be removed in the future)
+
+/*!
+ Constructor
+*/
+QxGraph_Viewer::QxGraph_Viewer()
+ :SUIT_ViewModel(),
+ myCanvas(0),
+ myCurrentView(0)
+{
+ printf("Construct QxGraph_Viewer\n");
+ //myCanvases.setAutoDelete(true);
+ //myCanvasViews.setAutoDelete(true);
+}
+
+/*!
+ Destructor
+*/
+QxGraph_Viewer::~QxGraph_Viewer()
+{
+ if ( myCanvas ) delete myCanvas;
+ //if ( !myCanvases.isEmpty() ) myCanvases.clear();
+ if ( !myCanvasViews.isEmpty() ) myCanvasViews.clear();
+ myCurrentView = 0;
+}
+
+/*!
+ Start initialization of view window
+ \param view - view window to be initialized
+*/
+void QxGraph_Viewer::initView( QxGraph_ViewWindow* view )
+{
+ if ( view )
+ {
+ view->initLayout();
+
+ /*
+ // test add items into the current canvas view
+ QRect aRect(100,200,200,100);
+ QCanvasItem* aRectItem = aPrs->addRectangleItem(aRect);
+ //delete aRectItem;
+
+ QPointArray aPA(6);
+ aPA.putPoints(0, 6, 400,100, 500,70, 600,100, 600,200, 500,230, 400,200);
+ QCanvasItem* aPolyItem = aPrs->addPolygonItem(aPA);
+ //delete aPolyItem;
+
+ QPoint aStart(500,300), aEnd(700,250);
+ QCanvasItem* aLineItem = aPrs->addLineItem(aStart, aEnd);
+ //delete aLineItem;
+
+ QCanvasItem* aEllipseItem = aPrs->addEllipseItem(200, 100, 30*16, 120*16);
+ aEllipseItem->setX(400);
+ aEllipseItem->setY(400);
+ //delete aEllipseItem;
+
+ QCanvasItem* aTextItem = aPrs->addTextItem("This is a QCanvasText item");
+ aTextItem->setX(100);
+ aTextItem->setY(500);
+ //delete aTextItem;
+ */
+ }
+}
+
+/*!
+ Creates new view window
+ \param theDesktop - main window of application
+*/
+SUIT_ViewWindow* QxGraph_Viewer::createView(SUIT_Desktop* theDesktop)
+{
+ QxGraph_ViewWindow* aRes = new QxGraph_ViewWindow( theDesktop, this );
+ initView( aRes );
+ return aRes;
+}
+
+/*!
+ Set view with index theIndex from myCanvasViews as current view
+ \param theIndex - the index of the view in the list
+*/
+void QxGraph_Viewer::setCurrentView(int theIndex)
+{
+ if ( theIndex >= 0 && theIndex < myCanvasViews.count() )
+ {
+ myCurrentView = myCanvasViews.at(theIndex);
+ myViewManager->getActiveView()->setCentralWidget(myCurrentView);
+ }
+}
+
+/*!
+ Builds popup for QxGraph viewer
+*/
+void QxGraph_Viewer::contextMenuPopup(QPopupMenu* thePopup)
+{
+ printf("QxGraph_Viewer::contextMenuPopup\n");
+ thePopup->insertItem( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBgColor() ) );
+
+ thePopup->insertSeparator();
+
+ QxGraph_ViewWindow* aView = (QxGraph_ViewWindow*)(myViewManager->getActiveView());
+ if ( aView && !aView->getToolBar()->isVisible() )
+ thePopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
+}
+
+/*!
+ SLOT: called if background color is to be changed changed, passes new color to current canvas view
+*/
+void QxGraph_Viewer::onChangeBgColor()
+{
+ QxGraph_ViewWindow* aView = (QxGraph_ViewWindow*)(myViewManager->getActiveView());
+ if( !aView )
+ return;
+ QColor aColorActive = aView->backgroundColor();
+
+ QColor selColor = QColorDialog::getColor( aColorActive, aView);
+ if ( selColor.isValid() )
+ aView->setBackgroundColor(selColor);
+}
+
+/*!
+ SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window
+*/
+void QxGraph_Viewer::onShowToolbar() {
+ QxGraph_ViewWindow* aView = (QxGraph_ViewWindow*)(myViewManager->getActiveView());
+ if ( aView )
+ aView->getToolBar()->show();
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef QXGRAPH_VIEWMODEL_H
+#define QXGRAPH_VIEWMODEL_H
+
+#include "QxGraph.h"
+
+#include "SUIT_ViewModel.h"
+
+class QCanvasItem; // for addRectangleItem(...) method (can be removed in the future)
+
+class QxGraph_Canvas;
+class QxGraph_CanvasView;
+class QxGraph_ViewWindow;
+class QxGraph_Prs;
+
+class QXGRAPH_EXPORT QxGraph_Viewer: public SUIT_ViewModel
+{
+ Q_OBJECT
+
+ public:
+ static QString Type() { return "QxGraphViewer"; }
+
+ QxGraph_Viewer();
+ virtual ~QxGraph_Viewer();
+
+ virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+ virtual QString getType() const { return Type(); }
+
+ virtual void contextMenuPopup(QPopupMenu*);
+
+ QxGraph_Canvas* getCanvas() const { return myCanvas; }
+ void setCanvas(QxGraph_Canvas* theCanvas) { myCanvas = theCanvas; }
+ //QPtrList<QxGraph_Canvas> getCanvases() { return myCanvases; }
+ //void setCanvases(QPtrList<QxGraph_Canvas> theCanvases) { myCanvases = theCanvases; }
+
+ //void addCanvas(QxGraph_Canvas* theCanvas) { myCanvases.append(theCanvas); }
+ //void removeCanvas(QxGraph_Canvas* theCanvas) { myCanvases.remove(theCanvas); }
+
+ QPtrList<QxGraph_CanvasView> getCanvasViews() { return myCanvasViews; }
+ void setCanvasViews(QPtrList<QxGraph_CanvasView> theViews) { myCanvasViews = theViews; }
+
+ void addView(QxGraph_CanvasView* theView) { myCanvasViews.append(theView); }
+ void removeView(QxGraph_CanvasView* theView) { myCanvasViews.remove(theView); }
+
+ QxGraph_CanvasView* getCurrentView() const { return myCurrentView; }
+ void setCurrentView(QxGraph_CanvasView* theView) { myCurrentView = theView; }
+ void setCurrentView(int theIndex);
+
+ protected:
+ void initView(QxGraph_ViewWindow* view);
+
+ protected slots:
+ void onShowToolbar();
+ void onChangeBgColor();
+
+ private:
+ QxGraph_Canvas* myCanvas;
+ //QPtrList<QxGraph_Canvas> myCanvases;
+ QPtrList<QxGraph_CanvasView> myCanvasViews;
+
+ QxGraph_CanvasView* myCurrentView;
+
+};
+
+#endif
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "QxGraph_ViewWindow.h"
+#include "QxGraph_Def.h"
+#include "QxGraph_Canvas.h"
+#include "QxGraph_CanvasView.h"
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_ToolButton.h>
+
+//QT Include
+#include <qlayout.h>
+#include <qcolor.h>
+//#include <qcolordialog.h>
+
+using namespace std;
+
+/*!
+ Constructor
+*/
+QxGraph_ViewWindow::QxGraph_ViewWindow( SUIT_Desktop* theDesktop, QxGraph_Viewer* theModel)
+ : SUIT_ViewWindow( theDesktop )
+{
+ printf("Construct QxGraph_ViewWindow\n");
+ myViewModel = theModel;
+}
+
+/*!
+ Initialization
+*/
+void QxGraph_ViewWindow::initLayout()
+{
+ initCanvas();
+ initCanvasViews();
+
+ myToolBar = new QToolBar(this);
+ myToolBar->setCloseMode(QDockWindow::Undocked);
+ myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+ createActions();
+ createToolBar();
+}
+
+/*!
+ Canvas initialization
+*/
+void QxGraph_ViewWindow::initCanvas()
+{
+ if ( myViewModel )
+ myViewModel->setCanvas( new QxGraph_Canvas(resMgr()) );
+ //myViewModel->addCanvas( new QxGraph_Canvas(resMgr()) );
+}
+
+/*!
+ Canvas views initialization
+*/
+void QxGraph_ViewWindow::initCanvasViews()
+{
+ if ( myViewModel )
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ //QxGraph_Canvas* aCanvas = new QxGraph_Canvas(resMgr());
+ //myViewModel->addCanvas( aCanvas );
+
+ QxGraph_CanvasView* aCanvasView = new QxGraph_CanvasView( myViewModel->getCanvas(), this );
+ //QxGraph_CanvasView* aCanvasView = new QxGraph_CanvasView( aCanvas, this );
+ myViewModel->addView(aCanvasView);
+
+ aCanvasView->hide();
+ }
+
+ // the first view is shown and is the current
+ myViewModel->getCanvasViews().first()->show();
+ myViewModel->setCurrentView( myViewModel->getCanvasViews().first() );
+
+ /* test for 1 view -->
+ QxGraph_CanvasView* aCanvasView = new QxGraph_CanvasView( myViewModel->getCanvas(), this );
+ myViewModel->addView(aCanvasView);
+ myViewModel->setCurrentView(aCanvasView);
+ test for 1 view <-- */
+
+ setCentralWidget( myViewModel->getCurrentView() );
+
+ /*if ( inherits( "QMainWindow" ) ) {
+ printf("== > 1\n");
+ ( ( QMainWindow* )this )->setCentralWidget( myViewModel->getCurrentView() );
+ }
+ else {
+ printf("== > 2\n");
+ QBoxLayout* layout = new QVBoxLayout( this );
+ layout->addWidget( myViewModel->getCurrentView() );
+ }*/
+ }
+}
+
+/*!
+ Creates actions of QxGraph view window
+*/
+void QxGraph_ViewWindow::createActions()
+{
+ if (!myActionsMap.isEmpty()) return;
+ SUIT_ResourceMgr* aResMgr = resMgr();
+ QtxAction* aAction;
+
+ // FitAll
+ aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_FITALL" ) ),
+ tr( "MNU_FITALL" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITALL"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll()));
+ myActionsMap[ FitAllId ] = aAction;
+
+ // FitRect
+ aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_FITAREA" ) ),
+ tr( "MNU_FITRECT" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITRECT"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea()));
+ myActionsMap[ FitRectId ] = aAction;
+
+ // Zoom
+ aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_ZOOM" ) ),
+ tr( "MNU_ZOOM_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom()));
+ myActionsMap[ ZoomId ] = aAction;
+
+ // Panning
+ aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_PAN" ) ),
+ tr( "MNU_PAN_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_PAN_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
+ myActionsMap[ PanId ] = aAction;
+
+ // Global Panning
+ aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_GLOBALPAN" ) ),
+ tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan()));
+ myActionsMap[ GlobalPanId ] = aAction;
+
+ // Reset
+ aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "QxGraph", tr( "ICON_QXGRAPH_RESET" ) ),
+ tr( "MNU_RESET_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_RESET_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
+ myActionsMap[ ResetId ] = aAction;
+}
+
+/*!
+ Creates toolbar of QxGraph view window
+*/
+void QxGraph_ViewWindow::createToolBar()
+{
+ SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar, "scale");
+ aScaleBtn->AddAction(myActionsMap[FitAllId]);
+ aScaleBtn->AddAction(myActionsMap[FitRectId]);
+ aScaleBtn->AddAction(myActionsMap[ZoomId]);
+
+ SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar, "pan");
+ aPanningBtn->AddAction(myActionsMap[PanId]);
+ aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+
+ myActionsMap[ResetId]->addTo(myToolBar);
+}
+
+/*!
+ Destructor
+*/
+QxGraph_ViewWindow::~QxGraph_ViewWindow() {}
+
+/*!
+ Reset the active view
+*/
+void QxGraph_ViewWindow::onViewReset()
+{
+ printf( "QxGraph_ViewWindow::onViewReset\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activateReset();
+}
+
+/*!
+ Sets a new center of the active view
+*/
+void QxGraph_ViewWindow::onViewGlobalPan()
+{
+ printf( "QxGraph_ViewWindow::onViewGlobalPan\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activateGlobalPanning();
+}
+
+/*!
+ Zooms the active view
+*/
+void QxGraph_ViewWindow::onViewZoom()
+{
+ printf( "QxGraph_ViewWindow::onViewZoom\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activateZoom();
+}
+
+/*!
+ Moves the active view
+*/
+void QxGraph_ViewWindow::onViewPan()
+{
+ printf( "QxGraph_ViewWindow::onViewPan\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activatePanning();
+}
+
+/*!
+ Fits all obejcts within a rectangular area of the active view
+*/
+void QxGraph_ViewWindow::onViewFitArea()
+{
+ printf( "QxGraph_ViewWindow::onViewFitArea\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activateFitRect();
+}
+
+/*!
+ Fits all objects in the active view
+*/
+void QxGraph_ViewWindow::onViewFitAll()
+{
+ printf( "QxGraph_ViewWindow::onViewFitAll\n" );
+ if ( myViewModel && myViewModel->getCurrentView() )
+ myViewModel->getCurrentView()->activateFitAll();
+}
+
+/*!
+ Set background of the viewport
+*/
+void QxGraph_ViewWindow::setBackgroundColor( const QColor& color )
+{
+ if ( myViewModel && myViewModel->getCurrentView()) {
+ myViewModel->getCurrentView()->canvas()->setBackgroundColor(color);
+ myViewModel->getCurrentView()->setPaletteBackgroundColor(color.light(120));
+ }
+}
+
+/*!
+ Returns background of the viewport
+*/
+QColor QxGraph_ViewWindow::backgroundColor() const
+{
+ if ( myViewModel && myViewModel->getCurrentView())
+ return myViewModel->getCurrentView()->canvas()->backgroundColor();
+ return QColor();
+}
+
+/*!
+ Custom resize event handler
+*/
+void QxGraph_ViewWindow::resizeEvent( QResizeEvent* theEvent )
+{
+ // QMainWindow::resizeEvent( theEvent );
+ //if ( myView ) myView->resizeView( theEvent );
+}
+
+/*!
+ Get resource manager
+*/
+SUIT_ResourceMgr* QxGraph_ViewWindow::resMgr() const
+{
+ return SUIT_Session::session()->resourceMgr();
+}
+
--- /dev/null
+// SALOME QxGraph : build Supervisor viewer into desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef QXGRAPH_VIEWWINDOW_H
+#define QXGRAPH_VIEWWINDOW_H
+
+#include "QxGraph.h"
+#include "QxGraph_ViewModel.h"
+
+#include "SUIT_ViewWindow.h"
+
+#include "QtxAction.h"
+
+#include <qaction.h>
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+class SUIT_ResourceMgr;
+
+class QXGRAPH_EXPORT QxGraph_ViewWindow : public SUIT_ViewWindow {
+ Q_OBJECT
+
+ public:
+ QxGraph_ViewWindow(SUIT_Desktop* theDesktop, QxGraph_Viewer* theModel);
+ virtual ~QxGraph_ViewWindow();
+
+ void setBackgroundColor( const QColor& );
+ QColor backgroundColor() const;
+
+ QToolBar* getToolBar() { return myToolBar; }
+
+ SUIT_ResourceMgr* resMgr() const;
+
+ QxGraph_Viewer* getViewModel() const { return myViewModel; }
+ void setViewModel(QxGraph_Viewer* theViewModel) { myViewModel = theViewModel; }
+
+ virtual void initLayout();
+
+ void contextPopupEvent(QContextMenuEvent* theEvent) { emit contextMenuRequested( theEvent); }
+
+ public slots:
+ void onViewFitAll();
+ void onViewFitArea();
+ void onViewZoom();
+ void onViewPan();
+ void onViewGlobalPan();
+ void onViewReset();
+
+ protected:
+ void resizeEvent( QResizeEvent* theEvent );
+
+ virtual void initCanvas();
+ virtual void initCanvasViews();
+
+ private:
+ void createActions();
+ void createToolBar();
+
+ //! Actions ID
+ enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ResetId };
+ typedef QMap<int, QtxAction*> ActionsMap;
+
+ ActionsMap myActionsMap;
+ QToolBar* myToolBar;
+
+ QxGraph_Viewer* myViewModel;
+
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QxGraph_images.po
+// Created: 03/02/2007
+// Author: Margarita Karpunina
+// Copyright (C) CEA 2007
+
+
+msgid "ICON_QXGRAPH_FITALL"
+msgstr "view_fitall.png"
+
+msgid "ICON_QXGRAPH_FITAREA"
+msgstr "view_fitarea.png"
+
+msgid "ICON_QXGRAPH_ZOOM"
+msgstr "view_zoom.png"
+
+msgid "ICON_QXGRAPH_PAN"
+msgstr "view_pan.png"
+
+msgid "ICON_QXGRAPH_GLOBALPAN"
+msgstr "view_glpan.png"
+
+msgid "ICON_QXGRAPH_RESET"
+msgstr "view_reset.png"
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QxGraph_msg_en.po
+// Created: 03/02/2007
+// Author: Margarita Karpunina
+// Copyright (C) CEA 2007
+
+msgid "LBL_TOOLBAR_LABEL"
+msgstr "View Operations"
+
+msgid "DSC_RESET_VIEW"
+msgstr "Reset View Point"
+
+msgid "MNU_RESET_VIEW"
+msgstr "Reset"
+
+msgid "DSC_PAN_VIEW"
+msgstr "Panning the view"
+
+msgid "MNU_PAN_VIEW"
+msgstr "Panning"
+
+msgid "MEN_CHANGE_BACKGROUND"
+msgstr "Change background..."
<parameter name="OB" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<parameter name="CAM" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<parameter name="SUPERVGraph" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
+ <parameter name="QxGraph" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<parameter name="ToolsGUI" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<!-- NETGENPlugin and GHS3DPlugin -->
<!-- Here the environment variables are used in upper case, -->
<parameter name="Title" value="63, 213, 255" />
<parameter name="NodeBody" value="255, 249, 147" />
</section>
+ <section name="QxGraph" >
+ <!-- QxGraph viewer preferences -->
+ <parameter name="Background" value="144, 208, 211" />
+ <parameter name="Title" value="63, 213, 255" />
+ <parameter name="NodeBody" value="255, 249, 147" />
+ </section>
<section name="FileDlg" >
<!-- "Open/Save File" dialog box preferences-->
<parameter name="QuickDirList" value="${DATA_DIR}" />