From bfc592b7af1751c4a64d5e545f5ac1dc513ecd01 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 10 Apr 2014 15:18:19 +0400 Subject: [PATCH] Command New Document provided --- src/XGUI/XGUI_MainWindow.cpp | 5 +-- src/XGUI/XGUI_MenuGroupPanel.h | 5 +++ src/XGUI/XGUI_ObjectsBrowser.h | 12 ++++++- src/XGUI/XGUI_SelectionMgr.cpp | 4 ++- src/XGUI/XGUI_SelectionMgr.h | 9 +++++- src/XGUI/XGUI_Viewer.cpp | 2 +- src/XGUI/XGUI_Viewer.h | 59 +++++++++++++++++++++++----------- src/XGUI/XGUI_Workshop.cpp | 28 ++++++++-------- 8 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index 99d2422e9..25ea218c9 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -121,7 +121,7 @@ void XGUI_MainWindow::createDockWidgets() myPropertyPanelDock = createPropertyPanel(); addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock); hidePropertyPanel(); //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; } diff --git a/src/XGUI/XGUI_MenuGroupPanel.h b/src/XGUI/XGUI_MenuGroupPanel.h index 7f9f57595..58fd7a797 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.h +++ b/src/XGUI/XGUI_MenuGroupPanel.h @@ -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()); diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index dff46d5ae..0d1043c0f 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -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; }; diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 9d1d1e724..c4c09491d 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -33,7 +33,9 @@ void XGUI_SelectionMgr::onSelectionChanged() FeaturePtr aFeature = mySelectedData.first(); std::shared_ptr aMgr = ModelAPI_PluginManager::get(); - aMgr->setCurrentDocument(aFeature->data()->docRef("PartDocument")->value()); + std::shared_ptr aDocRef = aFeature->data()->docRef("PartDocument"); + if (aDocRef) + aMgr->setCurrentDocument(aDocRef->value()); } emit selectionChanged(); diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 5f50ca3d8..58af58ea0 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -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; }; diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 6bec77168..6added867 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -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; diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 654221a59..6afdf36ec 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e5552b506..682a4eea7 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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 aMgr = ModelAPI_PluginManager::get(); - std::shared_ptr aPoint1 = aMgr->rootDocument()->addFeature("Point"); - std::shared_ptr aPart = aMgr->rootDocument()->addFeature("Part"); - aPart->execute(); - aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value()); - std::shared_ptr aPoint2 = aMgr->rootDocument()->addFeature("Point"); - aPoint2 = aMgr->rootDocument()->addFeature("Point"); - - aPart = aMgr->rootDocument()->addFeature("Part"); - aPart->execute(); + //std::shared_ptr aMgr = ModelAPI_PluginManager::get(); + //std::shared_ptr aPoint1 = aMgr->rootDocument()->addFeature("Point"); + //std::shared_ptr aPart = aMgr->rootDocument()->addFeature("Part"); + //aPart->execute(); + //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value()); + //std::shared_ptr 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(); } //****************************************************** -- 2.39.2