]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
QxGraph viewer based on QCanvas (first integration).
authormkr <mkr@opencascade.com>
Wed, 7 Mar 2007 14:14:45 +0000 (14:14 +0000)
committermkr <mkr@opencascade.com>
Wed, 7 Mar 2007 14:14:45 +0000 (14:14 +0000)
30 files changed:
adm_local/unix/config_files/check_QxGraphViewer.m4 [new file with mode: 0644]
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/Makefile.in
src/LightApp/resources/LightApp_msg_en.po
src/Makefile.in
src/QxGraph/Makefile.in [new file with mode: 0755]
src/QxGraph/QxGraph.h [new file with mode: 0644]
src/QxGraph/QxGraph_Canvas.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_Canvas.h [new file with mode: 0644]
src/QxGraph/QxGraph_CanvasView.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_CanvasView.h [new file with mode: 0644]
src/QxGraph/QxGraph_Def.h [new file with mode: 0644]
src/QxGraph/QxGraph_View.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_View.h [new file with mode: 0644]
src/QxGraph/QxGraph_ViewManager.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_ViewManager.h [new file with mode: 0644]
src/QxGraph/QxGraph_ViewModel.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_ViewModel.h [new file with mode: 0644]
src/QxGraph/QxGraph_ViewWindow.cxx [new file with mode: 0644]
src/QxGraph/QxGraph_ViewWindow.h [new file with mode: 0644]
src/QxGraph/resources/QxGraph_images.po [new file with mode: 0644]
src/QxGraph/resources/QxGraph_msg_en.po [new file with mode: 0644]
src/QxGraph/resources/view_fitall.png [new file with mode: 0755]
src/QxGraph/resources/view_fitarea.png [new file with mode: 0755]
src/QxGraph/resources/view_glpan.png [new file with mode: 0755]
src/QxGraph/resources/view_pan.png [new file with mode: 0644]
src/QxGraph/resources/view_reset.png [new file with mode: 0644]
src/QxGraph/resources/view_zoom.png [new file with mode: 0755]
src/SalomeApp/resources/SalomeApp.xml

diff --git a/adm_local/unix/config_files/check_QxGraphViewer.m4 b/adm_local/unix/config_files/check_QxGraphViewer.m4
new file mode 100644 (file)
index 0000000..1ef9f73
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# 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
index f77fbe38ed878b5986dcba13576961361d6856d1..e749fd29e443d3422a01a0b6ba2e4f679292d719 100644 (file)
 //  #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>
@@ -609,6 +615,9 @@ void LightApp_Application::createActions()
 #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" ),
@@ -710,6 +719,11 @@ void LightApp_Application::onNewWindow()
   case NewVTKViewId:
     type = VTKViewer_Viewer::Type();
     break;
+#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+  case NewQxGraphViewId:
+    type = QxGraph_Viewer::Type();
+    break;
 #endif
   }
 
@@ -908,6 +922,12 @@ void LightApp_Application::updateCommandsStatus()
   if( a )
     a->setEnabled( activeStudy() );
 #endif
+
+#ifndef DISABLE_QXGRAPHVIEWER
+  a = action( NewQxGraphViewId );
+  if( a )
+    a->setEnabled( activeStudy() );
+#endif
 }
 
 /*!
@@ -1362,6 +1382,12 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
   //    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() )
   {
index b061966babc3ac3ce269dcc2fd442eed42d0fc49..9bbecfed717cd8424bdb5498df32902cad27e908 100644 (file)
@@ -91,6 +91,10 @@ public:
          NewVTKViewId,
 #endif
 
+#ifndef DISABLE_QXGRAPHVIEWER
+         NewQxGraphViewId,
+#endif
+
          PreferencesId, MRUId, UserID };
 public:
   LightApp_Application();
index eb1cef66f767eda6eb41ce570f143ee06809598b..3338a2b06588c7dbdb8c7f90b40daf11f5724be6 100755 (executable)
@@ -181,6 +181,9 @@ endif
 ifeq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
   CPPFLAGS+= -DDISABLE_SUPERVGRAPHVIEWER
 endif
+ifeq ($(DISABLE_QXGRAPHVIEWER),yes)
+  CPPFLAGS+= -DDISABLE_QXGRAPHVIEWER
+endif
 ifeq ($(DISABLE_SALOMEOBJECT),yes)
   CPPFLAGS+= -DDISABLE_SALOMEOBJECT
 endif
@@ -223,5 +226,8 @@ endif
 ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
   LIBS+= -lSUPERVGraph
 endif
+ifneq ($(DISABLE_QXGRAPHVIEWER),yes)
+  LIBS+= -lQxGraph
+endif
 
 @CONCLUDE@
index f06c47efc749934da7aa8bec67148f410b8358f2..cd3cd7df37b5577fcc660a23339ef73379afb061 100644 (file)
@@ -95,6 +95,9 @@ msgstr "&OCC view"
 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"
 
index f55c420e760cf224574ad9bcb3b92157a91b103c..25df347d21302bf7651eabfa854c7b29c7cc0edb 100755 (executable)
@@ -66,6 +66,9 @@ endif
 ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
   SUBDIRS += SUPERVGraph
 endif
+ifneq ($(DISABLE_QXGRAPHVIEWER),yes)
+SUBDIRS += QxGraph
+endif
 SUBDIRS += LightApp ResExporter
 
 ifneq ($(GUI_DISABLE_CORBA),yes)
diff --git a/src/QxGraph/Makefile.in b/src/QxGraph/Makefile.in
new file mode 100755 (executable)
index 0000000..e8aca9a
--- /dev/null
@@ -0,0 +1,64 @@
+#  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
+#
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl:@srcdir@/resources
+
+
+@COMMENCE@
+
+EXPORT_HEADERS = QxGraph_Canvas.h \
+                QxGraph_CanvasView.h \
+                QxGraph_ViewWindow.h \
+                QxGraph_ViewManager.h \
+                QxGraph_ViewModel.h \
+                QxGraph_Def.h \
+                QxGraph.h
+
+# .po files to transmit in .qm
+PO_FILES = QxGraph_images.po \
+          QxGraph_msg_en.po  
+
+# Libraries targets
+
+LIB = libQxGraph.la
+LIB_SRC =        QxGraph_Canvas.cxx \
+                 QxGraph_CanvasView.cxx \
+                 QxGraph_ViewWindow.cxx \
+                 QxGraph_ViewManager.cxx \
+                 QxGraph_ViewModel.cxx 
+
+LIB_MOC =        QxGraph_Canvas_moc.cxx \
+                 QxGraph_CanvasView_moc.cxx \
+                 QxGraph_ViewWindow_moc.cxx \
+                 QxGraph_ViewManager_moc.cxx \
+                 QxGraph_ViewModel_moc.cxx 
+
+RESOURCES_FILES = view_pan.png \
+                 view_reset.png
+
+LIB_CLIENT_IDL = 
+
+CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(BOOST_CPPFLAGS)
+LDFLAGS+=$(QT_MT_LIBS) -lsuit
+
+
+@CONCLUDE@
diff --git a/src/QxGraph/QxGraph.h b/src/QxGraph/QxGraph.h
new file mode 100644 (file)
index 0000000..e11d0f0
--- /dev/null
@@ -0,0 +1,35 @@
+//  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
diff --git a/src/QxGraph/QxGraph_Canvas.cxx b/src/QxGraph/QxGraph_Canvas.cxx
new file mode 100644 (file)
index 0000000..76f7b41
--- /dev/null
@@ -0,0 +1,57 @@
+//  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 <SUIT_ResourceMgr.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()
+{
+}
+
+/*!
+  Add view
+*/
+void QxGraph_Canvas::addView(QCanvasView* theView)
+{
+  QCanvas::addView(theView);
+  theView->setPaletteBackgroundColor(backgroundColor().light(120));
+}
diff --git a/src/QxGraph/QxGraph_Canvas.h b/src/QxGraph/QxGraph_Canvas.h
new file mode 100644 (file)
index 0000000..9bbf80c
--- /dev/null
@@ -0,0 +1,45 @@
+//  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>
+
+class SUIT_ResourceMgr;
+
+class QXGRAPH_EXPORT QxGraph_Canvas : public QCanvas {
+  Q_OBJECT
+
+ public:
+  QxGraph_Canvas(SUIT_ResourceMgr*);
+  virtual ~QxGraph_Canvas();
+
+  void addView(QCanvasView* theView);
+
+ private:
+
+};
+
+#endif
diff --git a/src/QxGraph/QxGraph_CanvasView.cxx b/src/QxGraph/QxGraph_CanvasView.cxx
new file mode 100644 (file)
index 0000000..b6a3833
--- /dev/null
@@ -0,0 +1,439 @@
+//  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_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),
+  myCurrentItem(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) {
+      myCurrentItem = *it;
+      myCurrentItem->setZ(2);
+      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
+    double dx = aGlobalPoint.x() - myGlobalPoint.x();
+    double s = 1. + fabs(dx)/10.;
+    if (dx < 0) s = 1./s;
+    
+    QWMatrix m = worldMatrix();
+    m.scale(s, s);
+    setWorldMatrix(m);
+       
+    myGlobalPoint = aGlobalPoint;
+    return;
+  }
+
+  if ( myCurrentItem )
+  { // 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;
+  }
+}
+
+void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent)
+{
+  if (myTimer->isActive()) myTimer->stop();
+
+  if (myCurrentItem)
+  { // to move items on canvas view    
+    myCurrentItem->setZ(0);
+    canvas()->update();
+  }
+  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
+    QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos());
+    int aLX, aTY; //left x and top y
+    if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x();
+    else aLX = anEndPoint.x();
+    if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y();
+    else aTY = anEndPoint.y();
+
+    //calculate width and height for new view and new zoom factor
+    double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x())));
+    double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y())));
+    if (aXzoom > aYzoom) aXzoom = aYzoom;
+    
+    QWMatrix m;
+    m.scale(aXzoom, aXzoom);
+    setWorldMatrix(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 )
+  { // Background popup
+    printf("Background popup\n");
+    QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+                             theEvent->pos(), theEvent->globalPos(),
+                             theEvent->state() );
+    if ( getViewWindow() )
+      getViewWindow()->contextPopupEvent(&aEvent); // => emit contextMenuRequested( &aEvent );
+  }
+}
+
+void QxGraph_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent)
+{
+
+}
+
+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);
+  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);
+  //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() );
+}
diff --git a/src/QxGraph/QxGraph_CanvasView.h b/src/QxGraph/QxGraph_CanvasView.h
new file mode 100644 (file)
index 0000000..2acf19f
--- /dev/null
@@ -0,0 +1,81 @@
+//  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>
+
+class QxGraph_Canvas;
+class QxGraph_ViewWindow;
+
+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);
+
+ 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;
+};
+
+#endif
diff --git a/src/QxGraph/QxGraph_Def.h b/src/QxGraph/QxGraph_Def.h
new file mode 100644 (file)
index 0000000..e8dc248
--- /dev/null
@@ -0,0 +1,34 @@
+//  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  1050
+#define GRAPH_HEIGHT 750
+
+#define GRAPH_MARGIN 50
+
+#endif
diff --git a/src/QxGraph/QxGraph_View.cxx b/src/QxGraph/QxGraph_View.cxx
new file mode 100644 (file)
index 0000000..738865b
--- /dev/null
@@ -0,0 +1,105 @@
+//  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_View.h"
+#include "QxGraph_Canvas.h"
+#include "QxGraph_CanvasView.h"
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+//QT Include
+#include <qmainwindow.h>
+#include <qlayout.h>
+
+/*!
+  Constructor
+*/
+QxGraph_View::QxGraph_View( QWidget* theParent ): QWidget( theParent )
+{
+  printf("Constructor 1 of QxGraph_View\n");
+  init(theParent);
+}
+
+/*!
+  Constructor
+*/
+QxGraph_View::QxGraph_View( QxGraph_View* theParent ): QWidget( theParent )
+{
+  printf("Constructor 2 of QxGraph_View\n");
+  init(theParent);
+}
+
+/*!
+  Initialization
+*/
+void QxGraph_View::init( QWidget* theParent )
+{
+  if ( theParent->inherits( "QMainWindow" ) ) {
+    ( ( QMainWindow* )theParent )->setCentralWidget( this );
+  }
+  else {
+    QBoxLayout* layout = new QVBoxLayout( theParent );
+    layout->addWidget( this );
+  }
+
+  initCanvas();
+  initCanvasViews();
+}
+
+/*!
+  Canvas initialization
+*/
+void QxGraph_View::initCanvas()
+{
+  myCanvas = new QxGraph_Canvas(resMgr());
+}
+
+/*!
+  Canvas views initialization
+*/
+void QxGraph_View::initCanvasViews()
+{
+  QBoxLayout * layout = new QVBoxLayout(this);
+  layout->setMargin(0);
+  layout->setSpacing(0);
+
+  for (int i = 0; i < 2; i++)
+  {
+    QxGraph_CanvasView* aCanvasView = new QxGraph_CanvasView( myCanvas, this );
+    myCanvasViews.append(aCanvasView);
+    layout->addWidget(aCanvasView);
+    aCanvasView->hide();
+  }
+
+  // the first view is shown and is the current
+  myCanvasViews.first()->show();
+  myCurrentView = myCanvasViews.first();
+}
+
+/*!
+  Get resource manager
+*/
+SUIT_ResourceMgr* QxGraph_View::resMgr() const
+{
+  return SUIT_Session::session()->resourceMgr();
+}
diff --git a/src/QxGraph/QxGraph_View.h b/src/QxGraph/QxGraph_View.h
new file mode 100644 (file)
index 0000000..bdc50e6
--- /dev/null
@@ -0,0 +1,67 @@
+//  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_VIEW_H
+#define QXGRAPH_VIEW_H
+
+#include "QxGraph.h"
+
+//#include <qaction.h>
+#include <qwidget.h>
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+class SUIT_ResourceMgr;
+class QxGraph_Canvas;
+class QxGraph_CanvasView;
+
+class QXGRAPH_EXPORT QxGraph_View : public QWidget {
+  Q_OBJECT
+
+ public:
+  QxGraph_View(QWidget* theParent);
+  QxGraph_View(QxGraph_View* theParent);
+
+  ~QxGraph_View() {};
+
+  SUIT_ResourceMgr* resMgr() const;
+
+ protected:
+  void init(QWidget* theParent);
+  virtual void initCanvas();
+  virtual void initCanvasViews();
+
+ private:
+  QxGraph_Canvas*               myCanvas;
+  QPtrList<QxGraph_CanvasView> myCanvasViews;
+
+  QxGraph_CanvasView*           myCurrentView;
+
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
diff --git a/src/QxGraph/QxGraph_ViewManager.cxx b/src/QxGraph/QxGraph_ViewManager.cxx
new file mode 100644 (file)
index 0000000..1480b20
--- /dev/null
@@ -0,0 +1,59 @@
+// 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
+}
diff --git a/src/QxGraph/QxGraph_ViewManager.h b/src/QxGraph/QxGraph_ViewManager.h
new file mode 100644 (file)
index 0000000..db3ed53
--- /dev/null
@@ -0,0 +1,48 @@
+// 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
diff --git a/src/QxGraph/QxGraph_ViewModel.cxx b/src/QxGraph/QxGraph_ViewModel.cxx
new file mode 100644 (file)
index 0000000..2dd37cb
--- /dev/null
@@ -0,0 +1,300 @@
+// 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 "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 = 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 = addPolygonItem(aPA);
+    //delete aPolyItem;
+
+    QPoint aStart(500,300), aEnd(700,250);
+    QCanvasItem* aLineItem = addLineItem(aStart, aEnd);
+    //delete aLineItem;
+
+    QCanvasItem* aEllipseItem = addEllipseItem(200, 100, 30*16, 120*16);
+    aEllipseItem->setX(400);
+    aEllipseItem->setY(400);
+    //delete aEllipseItem;
+
+    QCanvasItem* aTextItem = addTextItem("This is a QCanvasText item");
+    aTextItem->setX(100);
+    aTextItem->setY(100);
+    //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();    
+}
+
+/*!
+  Add a QCanvasRectangle item into canvas (canvas view) with index theIndex
+*/
+QCanvasItem* QxGraph_Viewer::addRectangleItem(QRect theRect, int theIndex)
+{
+  QCanvasRectangle* aRectItem;
+
+  QCanvas* aCanvas = 0;
+  if ( theIndex == -1 ) // add item into the current canvas (canvas view)
+    aCanvas = myCurrentView->canvas();
+  else if ( theIndex >= 0 & theIndex < myCanvasViews.count() )
+    aCanvas = myCanvases.at(theIndex);
+
+  if ( aCanvas )
+  {
+    QCanvasRectangle* aRectItem = new QCanvasRectangle(theRect, aCanvas);
+    aRectItem->setZ(0);
+    aRectItem->show();
+    aCanvas->update();
+    
+    // test drawing features: brush, pen ...
+    QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "SUPERVGraph", "NodeBody", RECTANGLE_BODY ));
+    aRectItem->setBrush(aBr);
+  }
+
+  return aRectItem;
+}
+
+/*!
+  Add a QCanvasPolygon item into canvas (canvas view) with index theIndex
+*/
+QCanvasItem* QxGraph_Viewer::addPolygonItem(QPointArray thePA, int theIndex)
+{
+  QCanvasPolygon* aPolyItem;
+  
+  QCanvas* aCanvas = 0;
+  if ( theIndex == -1 ) // add item into the current canvas (canvas view)
+    aCanvas = myCurrentView->canvas();
+  else if ( theIndex >= 0 & theIndex < myCanvasViews.count() )
+    aCanvas = myCanvases.at(theIndex);
+
+  if ( aCanvas )
+  {
+    aPolyItem = new QCanvasPolygon(aCanvas);
+    aPolyItem->setZ(0);
+    aPolyItem->setPoints(thePA);
+    aPolyItem->show();
+    aCanvas->update();
+    
+    // test drawing features: brush, pen ...
+    QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "SUPERVGraph", "NodeBody", RECTANGLE_BODY ));
+    aPolyItem->setBrush(aBr);
+    QPen aPen(Qt::black,2);
+    aPolyItem->setPen(aPen);
+  }
+
+  return aPolyItem;
+}
+
+/*!
+  Add a QCanvasLine item into canvas (canvas view) with index theIndex
+*/
+QCanvasItem* QxGraph_Viewer::addLineItem(QPoint theStart, QPoint theEnd, int theIndex)
+{
+  QCanvasLine* aLineItem;
+
+  QCanvas* aCanvas = 0;
+  if ( theIndex == -1 ) // add item into the current canvas (canvas view)
+    aCanvas = myCurrentView->canvas();
+  else if ( theIndex >= 0 & theIndex < myCanvasViews.count() )
+    aCanvas = myCanvases.at(theIndex);
+
+  if ( aCanvas )
+  {
+    aLineItem = new QCanvasLine(aCanvas);
+    aLineItem->setZ(0);
+    aLineItem->setPoints(theStart.x(), theStart.y(), theEnd.x(), theEnd.y());
+    aLineItem->show();
+    aCanvas->update();
+  
+    // test drawing features: brush, pen ...
+    QPen aPen(Qt::black,2);
+    aLineItem->setPen(aPen);
+  }
+  
+  return aLineItem;
+}
+
+/*!
+  Add a QCanvasEllipse item into canvas (canvas view) with index theIndex
+*/
+QCanvasItem* QxGraph_Viewer::addEllipseItem(int theW, int theH, int theStartAngle, int theAngle, int theIndex)
+{
+  QCanvasEllipse* aEllipseItem;
+  
+  QCanvas* aCanvas = 0;
+  if ( theIndex == -1 ) // add item into the current canvas (canvas view)
+    aCanvas = myCurrentView->canvas();
+  else if ( theIndex >= 0 & theIndex < myCanvasViews.count() )
+    aCanvas = myCanvases.at(theIndex);
+
+  if ( aCanvas )
+  {
+    aEllipseItem = new QCanvasEllipse(theW, theH, theStartAngle, theAngle, aCanvas);
+    aEllipseItem->setZ(0);
+    aEllipseItem->show();
+    aCanvas->update();
+    
+    // test drawing features: brush, pen ...
+    QBrush aBr(SUIT_Session::session()->resourceMgr()->colorValue( "SUPERVGraph", "NodeBody", RECTANGLE_BODY ));
+    aEllipseItem->setBrush(aBr);
+    QPen aPen(Qt::black,2);
+    aEllipseItem->setPen(aPen);
+  }
+
+  return aEllipseItem;
+}
+
+/*!
+  Add a QCanvasText item into canvas (canvas view) with index theIndex
+*/
+QCanvasItem* QxGraph_Viewer::addTextItem(QString theText, int theIndex)
+{
+  QCanvasText* aTextItem;
+  
+  QCanvas* aCanvas = 0;
+  if ( theIndex == -1 ) // add item into the current canvas (canvas view)
+    aCanvas = myCurrentView->canvas();
+  else if ( theIndex >= 0 & theIndex < myCanvasViews.count() )
+    aCanvas = myCanvases.at(theIndex);
+
+  if ( aCanvas )
+  {
+    aTextItem = new QCanvasText(theText, aCanvas);
+    aTextItem->setZ(0);
+    aTextItem->show();
+    aCanvas->update();
+    
+    // test drawing features: font, color, text flags ...
+    aTextItem->setColor(Qt::darkBlue);
+    aTextItem->setFont(QFont("Times"/*"Helvetica"*/, 14, QFont::Normal, true));
+  }
+
+  return aTextItem;
+}
diff --git a/src/QxGraph/QxGraph_ViewModel.h b/src/QxGraph/QxGraph_ViewModel.h
new file mode 100644 (file)
index 0000000..d3c893f
--- /dev/null
@@ -0,0 +1,88 @@
+// 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_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() { 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() { return myCurrentView; }
+  void                setCurrentView(QxGraph_CanvasView* theView) { myCurrentView = theView; }
+  void                setCurrentView(int theIndex);
+
+  /* add items into canvas (canvas view) with index theIndex
+     if theIndex is equal to -1 add item into current (active) canvas (canvas view) */
+  QCanvasItem*   addRectangleItem(QRect theRect, int theIndex = -1);
+  QCanvasItem*   addPolygonItem(QPointArray thePA, int theIndex = -1);
+  QCanvasItem*   addLineItem(QPoint theStart, QPoint theEnd, int theIndex = -1);
+  QCanvasItem*   addEllipseItem(int theW, int theH, int theStartAngle, int theAngle, int theIndex = -1);
+  QCanvasItem*   addTextItem(QString theText, int theIndex = -1);
+
+ 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
diff --git a/src/QxGraph/QxGraph_ViewWindow.cxx b/src/QxGraph/QxGraph_ViewWindow.cxx
new file mode 100644 (file)
index 0000000..e94f402
--- /dev/null
@@ -0,0 +1,288 @@
+//  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(); 
+}
+
diff --git a/src/QxGraph/QxGraph_ViewWindow.h b/src/QxGraph/QxGraph_ViewWindow.h
new file mode 100644 (file)
index 0000000..88fe11b
--- /dev/null
@@ -0,0 +1,95 @@
+//  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
diff --git a/src/QxGraph/resources/QxGraph_images.po b/src/QxGraph/resources/QxGraph_images.po
new file mode 100644 (file)
index 0000000..3b59f61
--- /dev/null
@@ -0,0 +1,42 @@
+// 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"
+
diff --git a/src/QxGraph/resources/QxGraph_msg_en.po b/src/QxGraph/resources/QxGraph_msg_en.po
new file mode 100644 (file)
index 0000000..670735b
--- /dev/null
@@ -0,0 +1,40 @@
+// 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..."
diff --git a/src/QxGraph/resources/view_fitall.png b/src/QxGraph/resources/view_fitall.png
new file mode 100755 (executable)
index 0000000..c09ff94
Binary files /dev/null and b/src/QxGraph/resources/view_fitall.png differ
diff --git a/src/QxGraph/resources/view_fitarea.png b/src/QxGraph/resources/view_fitarea.png
new file mode 100755 (executable)
index 0000000..5b79594
Binary files /dev/null and b/src/QxGraph/resources/view_fitarea.png differ
diff --git a/src/QxGraph/resources/view_glpan.png b/src/QxGraph/resources/view_glpan.png
new file mode 100755 (executable)
index 0000000..c23322a
Binary files /dev/null and b/src/QxGraph/resources/view_glpan.png differ
diff --git a/src/QxGraph/resources/view_pan.png b/src/QxGraph/resources/view_pan.png
new file mode 100644 (file)
index 0000000..50db458
Binary files /dev/null and b/src/QxGraph/resources/view_pan.png differ
diff --git a/src/QxGraph/resources/view_reset.png b/src/QxGraph/resources/view_reset.png
new file mode 100644 (file)
index 0000000..7ba93b9
Binary files /dev/null and b/src/QxGraph/resources/view_reset.png differ
diff --git a/src/QxGraph/resources/view_zoom.png b/src/QxGraph/resources/view_zoom.png
new file mode 100755 (executable)
index 0000000..b465739
Binary files /dev/null and b/src/QxGraph/resources/view_zoom.png differ
index 90327232610cea489be5ccdd311c2fe2cd4ea900..db53d8e3ccbd28697a7cf275e86da60683dd7920 100644 (file)
@@ -43,6 +43,7 @@
     <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}" />