Salome HOME
Merge branch 'master' of newgeom:newgeom
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 10 Apr 2014 13:37:46 +0000 (17:37 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 10 Apr 2014 13:37:46 +0000 (17:37 +0400)
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MenuGroupPanel.h
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_ViewWindow.cpp
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_Workbench.cpp
src/XGUI/XGUI_Workbench.h
src/XGUI/XGUI_Workshop.cpp

index 99d2422e9c32dced0a0ce88ac985f384998ed7f5..25ea218c9519b3771d8e7507805341737061f50f 100644 (file)
@@ -121,7 +121,7 @@ void XGUI_MainWindow::createDockWidgets()
   myPropertyPanelDock = createPropertyPanel();
   addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
   hidePropertyPanel(); //<! Invisible by default
-
+  hideObjectBrowser();
   tabifyDockWidget(aObjDock, myPropertyPanelDock);
 }
 
@@ -171,9 +171,6 @@ QDockWidget* XGUI_MainWindow::createObjectBrowser()
   aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
   aObjDock->setWindowTitle(tr("Object browser"));
   myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
-  //myObjectBrowser->setColumnCount(1);
-  //myObjectBrowser->setHeaderHidden(true);
   aObjDock->setWidget(myObjectBrowser);
-//  fillObjectBrowser();
   return aObjDock;
 }
index 7f9f575957ec787affe1179db817d64ef0c84770..58fd7a7975550847c69a2e14110e38ca98a49c73 100644 (file)
@@ -7,12 +7,17 @@
 class XGUI_Command;
 class QGridLayout;
 
+/**\class XGUI_MenuGroupPanel
+ * \ingroup GUI
+ * \brief Represents a one group in a page of main menu (workbench)
+ */
 class XGUI_MenuGroupPanel: public QWidget
 {
 Q_OBJECT
 public:
   explicit XGUI_MenuGroupPanel(QWidget *parent = 0);
 
+  //! Adding a new feature (Command) in the group
   XGUI_Command* addFeature(const QString& theId, const QString& theTitle, const QString& theTip,
                            const QIcon& theIcon, const QKeySequence& theKeys = QKeySequence());
 
index dff46d5aeb5ae6a7948adcf2842321041b8bb6b5..0d1043c0f3f3734b3cee40abb3165529f24fdf61 100644 (file)
@@ -8,27 +8,37 @@
 
 class XGUI_DocumentDataModel;
 
-class XGUI_ObjectsBrowser : public QTreeView
+/**\class XGUI_ObjectsBrowser
+ * \ingroup GUI
+ * \brief Object browser window object. Represents data tree of current data structure
+ */
+ class XGUI_ObjectsBrowser : public QTreeView
 {
   Q_OBJECT
 public:
   XGUI_ObjectsBrowser(QWidget* theParent);
   virtual ~XGUI_ObjectsBrowser();
 
+  //! Returns Model which provides access to data objects
   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
 
+  //! Returns list of currently selected features
   QFeatureList selectedData() const { return mySelectedData; }
 
 signals:
+  //! Emited when selection is changed
   void selectionChanged();
 
 
 private slots:
+  //! Called when selection in Data Tree is changed
   void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
 
 private:
+  //! Internal model
   XGUI_DocumentDataModel* myDocModel;
 
+  //! List of currently selected data
   QFeatureList mySelectedData;
 };
 
index 9d1d1e72490207b1b9a426b368d3ce2dc5532704..c4c09491de67d2fe34635116cb1ee8888ef4fc70 100644 (file)
@@ -33,7 +33,9 @@ void XGUI_SelectionMgr::onSelectionChanged()
     FeaturePtr aFeature = mySelectedData.first();
 
     std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
-    aMgr->setCurrentDocument(aFeature->data()->docRef("PartDocument")->value());
+    std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+    if (aDocRef)
+      aMgr->setCurrentDocument(aDocRef->value());
   }
 
   emit selectionChanged();
index 5f50ca3d81d6b344652d236061b903a54aa73ffa..58af58ea0515878ba974481329f58e539ec0a8f4 100644 (file)
@@ -6,6 +6,11 @@
 
 class XGUI_Workshop;
 
+/**\class XGUI_SelectionMgr
+ * \ingroup GUI
+ * \brief Selection manager. Provides selection event on selection in 
+ * Object Browser and Viewer
+ */
 class XGUI_SelectionMgr : public QObject
 {
   Q_OBJECT
@@ -13,10 +18,11 @@ public:
   XGUI_SelectionMgr(XGUI_Workshop* theParent);
   virtual ~XGUI_SelectionMgr();
 
+  //! Returns list of currently selected objects
   QFeatureList selectedData() const { return mySelectedData; }
 
-
 signals:
+  //! Emited when selection in a one of viewers was changed
   void selectionChanged();
 
 public slots:
@@ -25,6 +31,7 @@ public slots:
 private:
   XGUI_Workshop* myWorkshop;
 
+  //! List of selected features
   QFeatureList mySelectedData;
 };
 
index 9f8edf365ccedd48e89d31f8c2de66715d3e0e57..f68ca95c32e9043844a9c71992cc57b15e4859bc 100644 (file)
@@ -93,7 +93,7 @@ void ViewerToolbar::repaintBackground()
 void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
 {
   repaintBackground();
-  QToolBar::paintEvent(theEvent);
+  //QToolBar::paintEvent(theEvent);
 }
 
 //**************************************************************************
index ed02e33b1ff2161568636af0b9008d353c3d23d3..0f6e40282c133495240260c2f86dae78ac075b07 100644 (file)
@@ -227,7 +227,7 @@ bool XGUI_Viewer::isTrihedronVisible() const
  \param on - new state
  */
 
-void XGUI_Viewer::setTrihedronShown(const bool on)
+void XGUI_Viewer::setTrihedronShown(bool on)
 {
   if (myTrihedron.IsNull())
     return;
index 654221a595bd99b13f7b0c5c8bff3e3f1ee13e9d..6afdf36ec93065c94aee4c2434cc7ce554c86aff 100644 (file)
@@ -17,6 +17,11 @@ class XGUI_ViewWindow;
 class QMouseEvent;
 class QKeyEvent;
 
+/**\class XGUI_Viewer
+ * \ingroup GUI
+ * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
+ * when each of view window is a one point of view on this scene.
+ */
 class XGUI_Viewer: public QObject
 {
 Q_OBJECT
@@ -26,38 +31,56 @@ public:
   XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
   ~XGUI_Viewer();
 
+  //! Creates a new view window
   QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
 
+  //! Return pointer on a main window - parent of the Viewer
   XGUI_MainWindow* mainWindow() const
   {
     return myMainWindow;
   }
 
+  //! Returns OCCT object which manages 3d scene
   Handle(V3d_Viewer) v3dViewer() const
   {
     return myV3dViewer;
   }
 
+  //! Returns OCCT object which manages displaying and selection in 3d scene
   Handle(AIS_InteractiveContext) AISContext() const
   {
     return myAISContext;
   }
 
+  //! Trihedron 3d object shown in the viewer
   Handle(AIS_Trihedron) trihedron() const
   {
     return myTrihedron;
   }
 
+  //! On/Off visibility of the trihedron object
   void toggleTrihedron();
+
+  //! Returns true if trihedron is visible
   bool isTrihedronVisible() const;
-  void setTrihedronShown(const bool on);
+
+  //! Returns true if trihedron is visible
+  void setTrihedronShown(bool on);
+
+  //! Returns trihedron size
   double trihedronSize() const;
+
+  //! Sets trihedron size
   void setTrihedronSize(const double sz, bool isRelative);
+
   bool trihedronRelative() const
   {
     return myIsRelative;
   }
+  //! Update trihedron
   void updateTrihedron();
+
+  //! Compute trihedron size dependent on 3d scene size
   bool computeTrihedronSize(double& theNewSize, double& theSize);
 
   static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
@@ -75,28 +98,28 @@ public:
   static InteractionStyle2ButtonsMap myButtonMap;
 
 signals:
-    void lastViewClosed();
-    void tryCloseView(XGUI_ViewWindow* theWindow);
-    void deleteView(XGUI_ViewWindow* theWindow);
-    void viewCreated(XGUI_ViewWindow* theWindow);
-    void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-    void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-    void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-    void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-    void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
-    void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
-    void activated(XGUI_ViewWindow* theWindow);
+  void lastViewClosed();
+  void tryCloseView(XGUI_ViewWindow* theWindow);
+  void deleteView(XGUI_ViewWindow* theWindow);
+  void viewCreated(XGUI_ViewWindow* theWindow);
+  void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
+  void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
+  void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
+  void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
+  void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
+  void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
+  void activated(XGUI_ViewWindow* theWindow);
 
 private slots:
-    void onViewClosed(QMdiSubWindow*);
-    //void onViewMapped();
-    void onWindowActivated(QMdiSubWindow*);
+  void onViewClosed(QMdiSubWindow*);
+  //void onViewMapped();
+  void onWindowActivated(QMdiSubWindow*);
 
 private:
-    void addView(QMdiSubWindow* theView);
+  void addView(QMdiSubWindow* theView);
 
-    /*! Removes the View from internal Views list.*/
-    void removeView(QMdiSubWindow* theView);
+  /*! Removes the View from internal Views list.*/
+  void removeView(QMdiSubWindow* theView);
 
 private:
   XGUI_MainWindow* myMainWindow;
index b3a1aee2b98d5db5c01e5ada92be46433ad7ec30..996d5a7aeffe9df3245cb776321c6d244a430dd2 100644 (file)
@@ -50,6 +50,7 @@ XGUI_Workbench::XGUI_Workbench(QWidget *theParent)
 
   myCommandsArea = new CommandsArea(this);
   aMainLayout->addWidget(myCommandsArea);
+  myCommandsArea->viewport()->installEventFilter(this);
 
   myChildWidget = new QWidget(myCommandsArea);
   myCommandsArea->setWidget(myChildWidget);
@@ -159,3 +160,14 @@ bool XGUI_Workbench::isExceedsRight()
   int aWgtWidth = myChildWidget->childrenRect().width();
   return ((aVPWidth - aPos.x()) < aWgtWidth);
 }
+
+bool XGUI_Workbench::eventFilter(QObject *theObj, QEvent *theEvent)
+{
+  if (theObj == myCommandsArea->viewport()) {
+    if (theEvent->type() == QEvent::Resize) {
+      myLeftButton->setVisible(isExceedsLeft());
+      myRightButton->setVisible(isExceedsRight());
+    }
+  }
+  return QWidget::eventFilter(theObj, theEvent);
+}
\ No newline at end of file
index cc362db2b10f9e6cc0e08240bc157079cf5c794f..57b17d3bea7a58a963685c8737058d4508b7078a 100644 (file)
@@ -27,6 +27,7 @@ private slots:
 
 protected:
   virtual void resizeEvent(QResizeEvent * theEvent);
+  virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
 
 private:
   void addSeparator();
index e5552b506793d76400f266c4de951d2269b37119..682a4eea7e39f8d89545a22924117ccfc07d51c8 100644 (file)
@@ -65,21 +65,18 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, aPartSetId);
   activateModule();
   myMainWindow->show();
-  QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
-  aWnd->showMaximized();
-  myMainWindow->showPythonConsole();
 
   // Testing of document creation
-  std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
-  std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
-  std::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
-  aPart->execute();
-  aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
-  std::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
-  aPoint2 = aMgr->rootDocument()->addFeature("Point");
-
-  aPart = aMgr->rootDocument()->addFeature("Part");
-  aPart->execute();
+  //std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+  //std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
+  //std::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
+  //aPart->execute();
+  //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
+  //std::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
+  //aPoint2 = aMgr->rootDocument()->addFeature("Point");
+
+  //aPart = aMgr->rootDocument()->addFeature("Part");
+  //aPart->execute();
 }
 
 //******************************************************
@@ -249,7 +246,12 @@ void XGUI_Workshop::onExit()
 //******************************************************
 void XGUI_Workshop::onNew()
 {
+  QApplication::setOverrideCursor(Qt::WaitCursor);
   myMainWindow->showObjectBrowser();
+  myMainWindow->showPythonConsole();
+  QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
+  aWnd->showMaximized();
+  QApplication::restoreOverrideCursor();
 }
 
 //******************************************************