From d264560231205a57380b51201bd947056838c3a7 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 9 Apr 2014 19:37:40 +0400 Subject: [PATCH] Documenting of classes --- src/XGUI/XGUI_Command.h | 13 ++++ src/XGUI/XGUI_Constants.h | 11 +++ src/XGUI/XGUI_DocumentDataModel.cpp | 3 + src/XGUI/XGUI_DocumentDataModel.h | 20 ++++- src/XGUI/XGUI_MainMenu.h | 9 +++ src/XGUI/XGUI_MainWindow.h | 14 +++- src/XGUI/XGUI_ObjectsBrowser.cpp | 11 --- src/XGUI/XGUI_PartDataModel.h | 20 ++++- src/XGUI/XGUI_RubberBand.h | 14 ++++ src/XGUI/XGUI_ViewWindow.h | 115 +++++++++++++++++++++++----- src/XGUI/XGUI_Workshop.h | 8 ++ 11 files changed, 201 insertions(+), 37 deletions(-) diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h index 855dbb91f..1bef9e0db 100644 --- a/src/XGUI/XGUI_Command.h +++ b/src/XGUI/XGUI_Command.h @@ -6,6 +6,10 @@ #define MIN_BUTTON_HEIGHT 18 #define MIN_BUTTON_WIDTH 40 +/**\class XGUI_Command + * \ingroup GUI + * \brief Represents a command item in the application menu (Workbench) + */ class XGUI_Command: public QWidgetAction { Q_OBJECT @@ -14,17 +18,26 @@ public: XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent); ~XGUI_Command(); + //! Returns true if the command is enabled virtual bool enabled() const; + + //! Set the command enabled virtual void enable(); + + //! Set the command disabled virtual void disable(); + + //! Returns Id of the command virtual QString getId() const { return myId; } + //! Connect the command to a slot virtual void connectTo(const QObject* theResiver, const char* theSlot); protected: + //! Creates a command representation widget dependently on parent widget type virtual QWidget* createWidget(QWidget* theParent); private: diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h index 17f0e2dd1..643dbbae8 100644 --- a/src/XGUI/XGUI_Constants.h +++ b/src/XGUI/XGUI_Constants.h @@ -3,6 +3,9 @@ #include +//! This file contains varioous constants used in the application + + typedef QList QIntList; //!< list of int values typedef QList QShortList; //!< list of short int values typedef QList QDoubleList; //!< list of double values @@ -10,6 +13,7 @@ typedef QList QDoubleList; //!< list of double values namespace XGUI { +//! Types of gradient type used in background of Viewer 3d enum GradientType { NoGradient = -1, @@ -24,31 +28,38 @@ enum GradientType LastGradient = Corner4Gradient }; +//! Type of rotation point in viewer 3d enum RotationPointType { GRAVITY, SELECTED }; +//! Type of ribbon rect in Viewer 3d enum SketchingType { NoSketching, Rect, Polygon }; + +//! View window operations accessible by hot keys enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA }; +//! Types of view window interactions enum InteractionStyle { STANDARD, KEY_FREE }; +//! Types of 2d mode in viewer 3d enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane }; +//! Types of background in view window enum BackgroundMode { NoBackground, // no (invalid) background data diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 882d5f724..ba23d472d 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -17,11 +17,14 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) : QAbstractItemModel(theParent) { + // Find Document object std::shared_ptr aMgr = ModelAPI_PluginManager::get(); myDocument = aMgr->currentDocument(); + // Register in event loop Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_UPDATED)); + // Create a top part of data tree model myModel = new XGUI_TopDataModel(this); myModel->setDocument(myDocument); } diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index 1181b0805..6e4a8969e 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -11,11 +11,17 @@ class ModelAPI_Document; class XGUI_PartDataModel; class XGUI_TopDataModel; - +/**\class XGUI_DocumentDataModel + * \ingroup GUI + * \brief This is a proxy data model for Object Browser (QTreeView). + * It contains several sub-models for generation of each sub-part of data tree. + */ class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener { Q_OBJECT public: + + XGUI_DocumentDataModel(QObject* theParent); virtual ~XGUI_DocumentDataModel(); @@ -39,16 +45,28 @@ public: private: + //! Converts QModelIndex of this model to QModelIndex of a one of sub-models. QModelIndex toSourceModel(const QModelIndex& theProxy) const; + + //! Finds a pointer on QModelIndex which is equal to the given one QModelIndex* findModelIndex(const QModelIndex& theIndex) const; + + //! Returns pointer on QModelIndex which is equal to the given one. QModelIndex* getModelIndex(const QModelIndex& theIndex) const; + + //! Deletes all saved pointers on QModelIndex objects. void clearModelIndexes(); + //! Document std::shared_ptr myDocument; + //! Data model of top part of data tree (not parts object) XGUI_TopDataModel* myModel; + + //! Data models for Parts data tree representation (one data model per a one part) QList myPartModels; + //! List of saved QModelIndexes created by sub-models QList myIndexes; }; diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index c5837e757..028f73b12 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -14,6 +14,10 @@ class QLabel; class QAction; class QDockWidget; +/**\class XGUI_MainMenu + * \ingroup GUI + * \brief Class for creation of main menu (set of workbenches) + */ class XGUI_MainMenu: public QObject { Q_OBJECT @@ -21,11 +25,16 @@ public: XGUI_MainMenu(XGUI_MainWindow *parent); virtual ~XGUI_MainMenu(); + //! Creates and adds a new workbench (menu group) with the given name and returns it. XGUI_Workbench* addWorkbench(const QString& theId, const QString& theText = ""); + + //! Returns workbench (menu group) by the given name. XGUI_Workbench* findWorkbench(const QString& theId); + //! Returns General page (predefined workbench) XGUI_Workbench* generalPage() const { return myGeneralPage; } + //! Rerturns last created workbench in dock widget container QDockWidget* getLastDockWindow() const { return myMenuTabs.last(); } private: diff --git a/src/XGUI/XGUI_MainWindow.h b/src/XGUI/XGUI_MainWindow.h index 5ac18d547..4cdbba52c 100644 --- a/src/XGUI/XGUI_MainWindow.h +++ b/src/XGUI/XGUI_MainWindow.h @@ -9,6 +9,11 @@ class XGUI_ObjectsBrowser; class QMdiArea; class PyConsole_EnhConsole; +/**\class XGUI_MainWindow + * \ingroup GUI + * \brief Main window of the application (Desktop). + * It contains: Object Browser, 3d Viewer, Python console, property panel, main menu + */ class XGUI_MainWindow: public QMainWindow { Q_OBJECT @@ -17,21 +22,22 @@ public: XGUI_MainWindow(QWidget* parent = 0); virtual ~XGUI_MainWindow(); + //! Returns main menu object XGUI_MainMenu* menuObject() const { return myMenuBar; } + //! Returns Object browser XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; } - void showObjectBrowser(); - void hideObjectBrowser(); - + //! Returns MDI area QMdiArea* mdiArea() const; + //! Returns 3d viewer XGUI_Viewer* viewer() const { return myViewer; @@ -42,6 +48,8 @@ public slots: void hidePythonConsole(); void showPropertyPanel(); void hidePropertyPanel(); + void showObjectBrowser(); + void hideObjectBrowser(); private: void createDockWidgets(); diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 5b6547c63..53e804401 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -1,22 +1,11 @@ #include "XGUI_ObjectsBrowser.h" #include "XGUI_DocumentDataModel.h" -//#include "XGUI_PartDataModel.h" - -//#include -//#include -//#include -//#include -//#include -//#include XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) : QTreeView(theParent) { setHeaderHidden(true); XGUI_DocumentDataModel* aDocModel = new XGUI_DocumentDataModel(this); - //std::shared_ptr aMgr = ModelAPI_PluginManager::get(); - //std::shared_ptr aDocument = aMgr->currentDocument(); - //aDocModel->setDocument(aDocument, 0); setModel(aDocModel); } diff --git a/src/XGUI/XGUI_PartDataModel.h b/src/XGUI/XGUI_PartDataModel.h index 3d2c0cccd..c8fb16629 100644 --- a/src/XGUI/XGUI_PartDataModel.h +++ b/src/XGUI/XGUI_PartDataModel.h @@ -7,6 +7,11 @@ class ModelAPI_Feature; class ModelAPI_Document; +/**\class XGUI_TopDataModel + * \ingroup GUI + * \brief This is a data model for Object Browser (QTreeView). + * It represents only upper part of data tree (non-parts tree items) + */ class XGUI_TopDataModel : public QAbstractItemModel { Q_OBJECT @@ -14,6 +19,7 @@ public: XGUI_TopDataModel(QObject* theParent); virtual ~XGUI_TopDataModel(); + //! Set a document object virtual void setDocument(const std::shared_ptr& theDoc) { myDocument = theDoc; @@ -35,6 +41,7 @@ public: virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const; private: + //! Types of QModelIndexes enum DataIds { ParamsFolder, ParamObject, @@ -42,11 +49,16 @@ private: ConstructObject }; + //! Document object std::shared_ptr myDocument; }; - +/**\class XGUI_PartDataModel + * \ingroup GUI + * \brief This is a data model for Object Browser (QTreeView). + * It represents data tree only of a one part + */ class XGUI_PartDataModel : public QAbstractItemModel { Q_OBJECT @@ -54,6 +66,7 @@ public: XGUI_PartDataModel(QObject* theParent); virtual ~XGUI_PartDataModel(); + //! Set a document object and Id of a part in the document virtual void setDocument(const std::shared_ptr& theDoc, int theId) { myDocument = theDoc; @@ -78,7 +91,7 @@ public: private: std::shared_ptr featureDocument() const; - + //! Types of QModelIndexes enum DataIds { MyRoot, ParamsFolder, @@ -87,7 +100,10 @@ private: ConstructObject }; + //! Document object std::shared_ptr myDocument; + + //! Id of the current part object in the document int myId; }; diff --git a/src/XGUI/XGUI_RubberBand.h b/src/XGUI/XGUI_RubberBand.h index 7d9fc43b4..76b3a6bc9 100644 --- a/src/XGUI/XGUI_RubberBand.h +++ b/src/XGUI/XGUI_RubberBand.h @@ -3,6 +3,13 @@ #include +/*! + \class XGUI_AbstractRubberBand + \ingroup GUI + \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. + + Currently this class does not support Style functionality in full. +*/ class XGUI_AbstractRubberBand: public QWidget { Q_OBJECT @@ -32,6 +39,13 @@ protected: bool myIsClosed; }; +/*! + \class XGUI_RectRubberBand + \ingroup GUI + \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. + + Redefinition for rectangular rubber band +*/ class XGUI_RectRubberBand: public XGUI_AbstractRubberBand { Q_OBJECT diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 3efd7bb87..be28c95a0 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -20,10 +20,18 @@ class ViewerLabel; class XGUI_RectRubberBand; class QMdiSubWindow; +/*! + \class XGUI_ViewWindow + \ingroup GUI + \brief Implements a one view window of 3d viewer object. + It contains a view port object (drawing area) and toolbars for view camera and window management. + Also it managements events in view port +*/ class XGUI_ViewWindow: public QFrame { Q_OBJECT public: + //! Types of viewer operations enum OperationType { NOTHING, @@ -48,65 +56,122 @@ public: virtual ~XGUI_ViewWindow(); + //! Returns view port object XGUI_ViewPort* viewPort() const { return myViewPort; } + //! Retrurns current interaction style XGUI::InteractionStyle interactionStyle() const { return myInteractionStyle; } + //! Disable or enable given operation type void setTransformEnabled(const OperationType, const bool); + + //! Returns true if the given operation type is enabled bool transformEnabled(const OperationType) const; + //! Returns View background object XGUI_ViewBackground background() const; + + //! Sets View background object void setBackground(const XGUI_ViewBackground& theBackground); + //! Returns true if the current view window can be closed bool closable() const { return myClosable; } + + //! Sets the current view window closable or not void setClosable( const bool isClosable ) { myClosable = isClosable; } signals: - void vpTransformationStarted(XGUI_ViewWindow::OperationType type); - void vpTransformationFinished(XGUI_ViewWindow::OperationType type); - - void Show(QShowEvent *); - void Hide(QHideEvent *); - void maximized(XGUI_ViewWindow*, bool); - void returnedTo3d(); - - void tryClosing(XGUI_ViewWindow*); - void closed( QMdiSubWindow* ); - void mousePressed(XGUI_ViewWindow*, QMouseEvent*); - void mouseReleased(XGUI_ViewWindow*, QMouseEvent*); - void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*); - void mouseMoving(XGUI_ViewWindow*, QMouseEvent*); - void keyPressed(XGUI_ViewWindow*, QKeyEvent*); - void keyReleased(XGUI_ViewWindow*, QKeyEvent*); - void contextMenuRequested(QContextMenuEvent *e); - - void viewModified(XGUI_ViewWindow*); - void viewCloned( QMdiSubWindow* theView ); + //! Emited whien view transformation operation is started + void vpTransformationStarted(XGUI_ViewWindow::OperationType type); + + //! Emited whien view transformation operation is finished + void vpTransformationFinished(XGUI_ViewWindow::OperationType type); + + //void Show(QShowEvent *); + //void Hide(QHideEvent *); + //void maximized(XGUI_ViewWindow*, bool); + //void returnedTo3d(); + + //! Emited before the window closing + void tryClosing(XGUI_ViewWindow*); + + //! Emited when window is closing + void closed( QMdiSubWindow* ); + + //! Emited on mouse press in view port + void mousePressed(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on mouse release in view port + void mouseReleased(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on mouse double click in view port + void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on mouse moving in view port + void mouseMoving(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on key press in view port + void keyPressed(XGUI_ViewWindow*, QKeyEvent*); + + //! Emited on key release in view port + void keyReleased(XGUI_ViewWindow*, QKeyEvent*); + + //! Emited on context menu request in view port + void contextMenuRequested(QContextMenuEvent *e); + + //void viewModified(XGUI_ViewWindow*); + void viewCloned( QMdiSubWindow* theView ); public slots: + //! Start zooming operation void activateZoom(); + + //! Start rotation operation void activateRotation(); + + //! Start panning operation void activatePanning(); + + //! Start window fit operation void activateWindowFit(); + + //! Start global panning operation void activateGlobalPanning(); + //! Clone the view window preserving a view point of the current view void cloneView(); + + //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps) void dumpView(); + + //! Fit all command void fitAll(); + //! Set front view void frontView(); + + //! Set back view void backView(); + + //! Set top view void topView(); + + //! Set bottom view void bottomView(); + + //! Set left view void leftView(); + + //! Set right view void rightView(); + //! Reset point of view void reset(); @@ -215,6 +280,11 @@ private: }; //****************************************************** +/*! + \class ViewerToolbar + \ingroup GUI + \brief Provides a toolbar widget with treansparent background over OCCT View window +*/ class ViewerToolbar: public QToolBar { Q_OBJECT @@ -237,6 +307,11 @@ private: }; //****************************************************** +/*! + \class ViewerToolbar + \ingroup GUI + \brief Provides a Label widget with treansparent background over OCCT View window +*/ class ViewerLabel: public QLabel { Q_OBJECT diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index e745c25af..6628d12ef 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -18,6 +18,10 @@ class ModuleBase_Operation; class Config_FeatureMessage; class Config_PointerMessage; +/**\class XGUI_Workshop + * \ingroup GUI + * \brief Class which defines a configuration of the application (Workshop) and launches it. + */ class XGUI_Workshop: public QObject, public Event_Listener { Q_OBJECT @@ -26,15 +30,19 @@ public: XGUI_Workshop(); virtual ~XGUI_Workshop(); + //! Starting of the application void startApplication(); + //! Returns main window (Desktop) of the application XGUI_MainWindow* mainWindow() const { return myMainWindow; } + //! Creates and adds a new workbench (menu group) with the given name and returns it XGUI_Workbench* addWorkbench(const QString& theName); + //! Redefinition of Event_Listener method virtual void processEvent(const Event_Message* theMessage); public slots: -- 2.39.2