From 3b6472899555f2186d09f45f4f1fde38b3af969a Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 22 Sep 2015 19:52:07 +0300 Subject: [PATCH] Source documentation updated. Obsolete files removed --- src/ModuleBase/CMakeLists.txt | 2 - .../ModuleBase_IDocumentDataModel.cpp | 22 - .../ModuleBase_IDocumentDataModel.h | 40 - src/ModuleBase/ModuleBase_IErrorMgr.h | 6 + src/ModuleBase/ModuleBase_IModule.h | 18 +- src/ModuleBase/ModuleBase_ISelection.h | 1 + src/ModuleBase/ModuleBase_IViewer.h | 8 +- src/ModuleBase/ModuleBase_IWorkshop.h | 7 +- src/ModuleBase/ModuleBase_ModelWidget.h | 3 +- src/ModuleBase/ModuleBase_PageGroupBox.h | 1 + src/ModuleBase/ModuleBase_PageWidget.h | 1 + src/ModuleBase/ModuleBase_PagedContainer.h | 28 +- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 21 - src/ModuleBase/ModuleBase_ParamSpinBox.h | 34 +- src/ModuleBase/ModuleBase_ToolBox.h | 22 +- src/ModuleBase/ModuleBase_ViewerFilters.h | 2 +- src/ModuleBase/ModuleBase_WidgetExprEditor.h | 33 +- .../ModuleBase_WidgetFileSelector.h | 4 + src/ModuleBase/ModuleBase_WidgetLineEdit.cpp | 8 + src/ModuleBase/ModuleBase_WidgetLineEdit.h | 4 + .../ModuleBase_WidgetMultiSelector.cpp | 7 + .../ModuleBase_WidgetMultiSelector.h | 6 +- src/ModuleBase/ModuleBase_WidgetSelector.h | 6 +- src/ModuleBase/ModuleBase_WidgetSwitch.h | 10 +- src/ModuleBase/ModuleBase_WidgetToolbox.h | 11 +- src/ModuleBase/ModuleBase_WidgetValidated.h | 19 +- src/NewGeom/NewGeom_Module.h | 10 +- src/NewGeom/NewGeom_NestedButton.h | 8 +- src/PartSet/CMakeLists.txt | 8 - src/PartSet/PartSet_CustomPrs.h | 3 + src/PartSet/PartSet_DataTreeModel.cpp | 21 - src/PartSet/PartSet_DataTreeModel.h | 99 -- src/PartSet/PartSet_DocumentDataModel.cpp | 876 ------------------ src/PartSet/PartSet_DocumentDataModel.h | 210 ----- src/PartSet/PartSet_ExternalObjectsMgr.h | 3 + src/PartSet/PartSet_LockApplyMgr.h | 14 +- src/PartSet/PartSet_Module.cpp | 41 +- src/PartSet/PartSet_Module.h | 11 +- src/PartSet/PartSet_PartDataModel.cpp | 449 --------- src/PartSet/PartSet_PartDataModel.h | 119 --- src/PartSet/PartSet_SketcherMgr.h | 2 +- src/PartSet/PartSet_Tools.h | 20 +- src/PartSet/PartSet_TopDataModel.cpp | 247 ----- src/PartSet/PartSet_TopDataModel.h | 91 -- src/PartSet/PartSet_Validators.h | 3 + src/PartSet/PartSet_WidgetMultiSelector.h | 4 +- src/PartSet/PartSet_WidgetPoint2d.h | 2 + src/PartSet/PartSet_WidgetPoint2dDistance.h | 8 +- src/PartSet/PartSet_WidgetShapeSelector.h | 4 +- src/PartSet/PartSet_WidgetSketchCreator.h | 1 + src/PartSet/PartSet_WidgetSketchLabel.h | 8 +- src/XGUI/XGUI_ContextMenuMgr.h | 3 + src/XGUI/XGUI_CustomPrs.h | 3 + src/XGUI/XGUI_DataModel.cpp | 2 +- src/XGUI/XGUI_DataModel.h | 6 +- src/XGUI/XGUI_Displayer.h | 10 +- src/XGUI/XGUI_ErrorMgr.h | 10 + src/XGUI/XGUI_ModuleConnector.h | 4 +- src/XGUI/XGUI_ObjectsBrowser.cpp | 34 +- src/XGUI/XGUI_ObjectsBrowser.h | 21 +- src/XGUI/XGUI_OperationMgr.h | 12 +- src/XGUI/XGUI_PropertyPanel.h | 1 + src/XGUI/XGUI_SalomeConnector.h | 6 +- src/XGUI/XGUI_Tools.h | 12 +- src/XGUI/XGUI_Workshop.cpp | 3 - src/XGUI/XGUI_Workshop.h | 4 +- src/XGUI/XGUI_WorkshopListener.h | 11 +- 67 files changed, 321 insertions(+), 2407 deletions(-) delete mode 100644 src/ModuleBase/ModuleBase_IDocumentDataModel.cpp delete mode 100644 src/ModuleBase/ModuleBase_IDocumentDataModel.h delete mode 100644 src/PartSet/PartSet_DataTreeModel.cpp delete mode 100644 src/PartSet/PartSet_DataTreeModel.h delete mode 100644 src/PartSet/PartSet_DocumentDataModel.cpp delete mode 100644 src/PartSet/PartSet_DocumentDataModel.h delete mode 100644 src/PartSet/PartSet_PartDataModel.cpp delete mode 100644 src/PartSet/PartSet_PartDataModel.h delete mode 100644 src/PartSet/PartSet_TopDataModel.cpp delete mode 100644 src/PartSet/PartSet_TopDataModel.h diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 119a717bd..a0a85d709 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -11,7 +11,6 @@ SET(PROJECT_HEADERS ModuleBase_Filter.h ModuleBase_FilterFactory.h ModuleBase_FilterValidated.h - ModuleBase_IDocumentDataModel.h ModuleBase_IErrorMgr.h ModuleBase_IModule.h ModuleBase_IPrefMgr.h @@ -63,7 +62,6 @@ SET(PROJECT_SOURCES ModuleBase_Filter.cpp ModuleBase_FilterFactory.cpp ModuleBase_FilterValidated.cpp - ModuleBase_IDocumentDataModel.cpp ModuleBase_IErrorMgr.cpp ModuleBase_IModule.cpp ModuleBase_IPrefMgr.cpp diff --git a/src/ModuleBase/ModuleBase_IDocumentDataModel.cpp b/src/ModuleBase/ModuleBase_IDocumentDataModel.cpp deleted file mode 100644 index f59990fe1..000000000 --- a/src/ModuleBase/ModuleBase_IDocumentDataModel.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: ModuleBase_IDocumentDataModel.cpp -// Created: 28 Apr 2015 -// Author: Vitaly SMETANNIKOV - -#include "ModuleBase_IDocumentDataModel.h" - -ModuleBase_IDocumentDataModel::ModuleBase_IDocumentDataModel(QObject* theParent) : QAbstractItemModel(theParent) -{ - -} - -void ModuleBase_IDocumentDataModel::clear() -{ - -} - -void ModuleBase_IDocumentDataModel::rebuildDataTree() -{ - -} diff --git a/src/ModuleBase/ModuleBase_IDocumentDataModel.h b/src/ModuleBase/ModuleBase_IDocumentDataModel.h deleted file mode 100644 index aecb0152f..000000000 --- a/src/ModuleBase/ModuleBase_IDocumentDataModel.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: ModuleBase_IDocumentDataModel.h -// Created: 28 Apr 2015 -// Author: Vitaly SMETANNIKOV - - -#ifndef ModuleBase_IDocumentDataModel_H -#define ModuleBase_IDocumentDataModel_H - -#include "ModuleBase.h" -#include -#include - -class MODULEBASE_EXPORT ModuleBase_IDocumentDataModel : public QAbstractItemModel -{ -Q_OBJECT -public: - ModuleBase_IDocumentDataModel(QObject* theParent); - - //! Returns an object by the given Model index. - //! Returns 0 if the given index is not index of an object - virtual ObjectPtr object(const QModelIndex& theIndex) const = 0; - - //! Returns index of the object - //! \param theObject object to find - virtual QModelIndex objectIndex(const ObjectPtr theObject) const = 0; - - //! Clear internal data - virtual void clear(); - - //! Rebuild data tree - virtual void rebuildDataTree(); - - /// Returns last history object index - virtual QModelIndex lastHistoryIndex() const { return QModelIndex(); } - -}; - -#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_IErrorMgr.h b/src/ModuleBase/ModuleBase_IErrorMgr.h index d64237253..701a49f80 100644 --- a/src/ModuleBase/ModuleBase_IErrorMgr.h +++ b/src/ModuleBase/ModuleBase_IErrorMgr.h @@ -12,11 +12,17 @@ class ModuleBase_IPropertyPanel; +/** + * \class ModuleBase_IErrorMgr + * \ingroup GUI + * \brief An interface to Errors manager object + */ class MODULEBASE_EXPORT ModuleBase_IErrorMgr : public QObject { Q_OBJECT public: /// Default constructor + /// \param theParent a parent object ModuleBase_IErrorMgr(QObject* theParent = 0); /// Virtual destructor virtual ~ModuleBase_IErrorMgr(); diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 327bb4230..301bcbe5b 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -23,7 +23,6 @@ class Config_WidgetAPI; class ModuleBase_ModelWidget; class ModuleBase_Operation; class ModuleBase_IWorkshop; -class ModuleBase_IDocumentDataModel; /** * \ingroup GUI @@ -40,10 +39,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual ~ModuleBase_IModule() {} - // Add default selection filters of the module to the current viewer + /// Add default selection filters of the module to the current viewer virtual void activateSelectionFilters() {}; - // Remove default selection filters of the module from the current viewer + /// Remove default selection filters of the module from the current viewer virtual void deactivateSelectionFilters() {}; /// Reads description of features from XML file @@ -79,7 +78,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual void onOperationAborted(ModuleBase_Operation* theOperation) {} /// Realizes some functionality by an operation start - /// \param theOperation a started operation virtual ModuleBase_Operation* currentOperation() const = 0; /// Add menu items for viewer into the given menu @@ -92,15 +90,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theMenu a popup menu to be shown in the object browser virtual void addObjectBrowserMenu(QMenu* theMenu) const {}; - /// Called when it is necessary to update a command state (enable or disable it) - //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; - /// Creates custom widgets for property panel /// \param theType a type of widget /// \param theParent the parent object /// \param theWidgetApi the widget configuration. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute - /// \param theModelWidgets list of widget objects virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent, Config_WidgetAPI* theWidgetApi, std::string theParentId) { @@ -147,11 +141,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \returns true if the action is processed virtual bool deleteObjects() { return false; }; -#ifdef ModuleDataModel - /// Returns data model object for representation of data tree in Object browser - virtual ModuleBase_IDocumentDataModel* dataModel() const = 0; -#endif - /// Performs functionality on closing document virtual void closeDocument() = 0; @@ -200,8 +189,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual QString getFeatureError(const FeaturePtr& theFeature); signals: + /// Signal which is emitted when operation is launched void operationLaunched(); + /// Segnal emitted when an operation is resumed + /// \param theOp a resumed operation void operationResumed(ModuleBase_Operation* theOp); public slots: diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index a64335b83..2c60a76ac 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -60,6 +60,7 @@ class ModuleBase_ISelection */ virtual QObjectPtrList selectedObjects() const = 0; + /// Set selected objects list virtual void setSelectedObjects( const QObjectPtrList& ) const = 0; /** diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index a82b5d24a..7547d6c1f 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -79,6 +79,8 @@ Q_OBJECT /// Update current viewer virtual void update() = 0; + /// Returns a scale factor of the given view + /// \param theView a view object const double Scale(const Handle(V3d_View)& theView) { if (!myWindowScale.contains(theView)) @@ -86,13 +88,16 @@ Q_OBJECT return myWindowScale[theView]; } + /// Remember a scale factor for the view object + /// \param theView a view object + /// \param theVal a scale factor void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; } /// Method returns True if the viewer can process editing objects /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const { return true; } - // Fit all along Z (perpendicular to display) + /// Fit all along Z (perpendicular to display) virtual void Zfitall() = 0; signals: @@ -140,6 +145,7 @@ signals: void viewTransformed(int theTransformation); protected: + /// A map for storing a scale factors dependent on view object QMap myWindowScale; }; diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 67fed3b81..77f4cfe3f 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -80,22 +80,25 @@ Q_OBJECT virtual ModuleBase_Operation* findStartedOperation(const QString& theId) = 0; //! Returns true if the operation with id theId can be stopped - //! \param theId a stopped operation + //! \param theOperation a stopped operation //! \return boolean result virtual bool canStopOperation(ModuleBase_Operation* theOperation) = 0; //! Aborts the operation. - //! \param theId an aborted operation + //! \param theOperation an aborted operation virtual void abortOperation(ModuleBase_Operation* theOperation) = 0; //! Returns AIS object by data object + //! \param theObject a data object virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0; //! Returns data object by AIS + //! \param theAIS a presentation virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0; //! Select features clearing previous selection. //! If the list is empty then selection will be cleared + //! \param theValues a list of presentations virtual void setSelected(const QList& theValues) = 0; signals: diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index bc01dc9a2..175305244 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -80,7 +80,7 @@ Q_OBJECT /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values - /// \param toValidate the boolean value whether the value should be checked by filters + /// \param theToValidate the boolean value whether the value should be checked by filters virtual bool setSelection(QList& theValues, const bool theToValidate) { @@ -137,6 +137,7 @@ Q_OBJECT } /// Set feature which is processing by active operation + /// \param theFeature a feature object /// \param theToStoreValue a value about necessity to store the widget value to the feature void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false); diff --git a/src/ModuleBase/ModuleBase_PageGroupBox.h b/src/ModuleBase/ModuleBase_PageGroupBox.h index ee28287ed..a5f33f9f2 100644 --- a/src/ModuleBase/ModuleBase_PageGroupBox.h +++ b/src/ModuleBase/ModuleBase_PageGroupBox.h @@ -19,6 +19,7 @@ class QGridLayout; /*! + * \ingroup GUI * Represent a property panel's list of ModuleBase_ModelWidgets. */ class MODULEBASE_EXPORT ModuleBase_PageGroupBox : public QGroupBox, public ModuleBase_PageBase diff --git a/src/ModuleBase/ModuleBase_PageWidget.h b/src/ModuleBase/ModuleBase_PageWidget.h index 33d552d5f..2528843bb 100644 --- a/src/ModuleBase/ModuleBase_PageWidget.h +++ b/src/ModuleBase/ModuleBase_PageWidget.h @@ -18,6 +18,7 @@ class ModuleBase_ModelWidget; class QGridLayout; /*! + * \ingroup GUI * Represent a property panel's list of ModuleBase_ModelWidgets. */ class MODULEBASE_EXPORT ModuleBase_PageWidget : public QFrame, public ModuleBase_PageBase diff --git a/src/ModuleBase/ModuleBase_PagedContainer.h b/src/ModuleBase/ModuleBase_PagedContainer.h index 59730cd7d..b98055fc9 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.h +++ b/src/ModuleBase/ModuleBase_PagedContainer.h @@ -21,30 +21,54 @@ class MODULEBASE_EXPORT ModuleBase_PagedContainer : public ModuleBase_ModelWidge { Q_OBJECT public: + /// A constructor + /// \param theParent a parent widget + /// \param theData a data of the widget + /// \param theParentId an Id of the parent object ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); virtual ~ModuleBase_PagedContainer(); + /// Add a new page + /// \param theWidget a page object + /// \param theName a name of the page + /// \param theCaseId an Id of the page + /// \param theIcon aqn Icon of the page virtual int addPage( ModuleBase_PageBase* theWidget, const QString& theName, const QString& theCaseId, const QPixmap& theIcon ); - // ModuleBase_ModelWidget + /// Redefinition of virtual function virtual QList getControls() const; + + /// Redefinition of virtual function virtual bool focusTo(); + + /// Redefinition of virtual function virtual void setHighlighted(bool isHighlighted); + + /// Redefinition of virtual function virtual void enableFocusProcessing(); protected: + /// Returns index of current page virtual int currentPageIndex() const = 0; + + /// Set current page by index virtual void setCurrentPageIndex(int ) = 0; - // ModuleBase_ModelWidget + + /// Redefinition of virtual function virtual void activateCustom(); + + /// Redefinition of virtual function virtual bool storeValueCustom() const; + + /// Redefinition of virtual function virtual bool restoreValueCustom(); protected slots: + /// A slot called on page change void onPageChanged(); private: diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index febd29bad..bfd082386 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -16,19 +16,7 @@ #include #include -/*! - \class ModuleBase_ParamSpinBox - */ - -/*! - \brief Constructor. - - Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, - a step value of 1.0 and a precision of 2 decimal places. - The value is initially set to 0.00. - \param parent parent object - */ ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrecision) : ModuleBase_DoubleSpinBox(theParent, thePrecision), myAcceptVariables(true) @@ -69,20 +57,11 @@ void ModuleBase_ParamSpinBox::connectSignalsAndSlots() this, SLOT(onTextChanged(const QString&))); } -/*! - \brief This function is called when value is changed. - */ void ModuleBase_ParamSpinBox::onTextChanged(const QString& text) { myTextValue = text; } -/*! - \brief Interpret text entered by the user as a value. - \param text text entered by the user - \return mapped value - \sa textFromValue() - */ double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const { if (!hasVariable(theText)) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.h b/src/ModuleBase/ModuleBase_ParamSpinBox.h index 7d14e9511..f771b5656 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.h +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.h @@ -8,6 +8,10 @@ #include +/** +* \ingroup GUI +* An extension of a double spin box which let to use parameters and expressions for value definition +*/ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBox { Q_OBJECT @@ -15,6 +19,16 @@ class MODULEBASE_EXPORT ModuleBase_ParamSpinBox : public ModuleBase_DoubleSpinBo enum State { Invalid = 0, NoVariable, Incompatible, Acceptable }; public: + /*! + \brief Constructor. + + Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, + a step value of 1.0 and a precision of 2 decimal places. + The value is initially set to 0.00. + + \param theParent a parent object + \param thePrecision a precision of values display + */ explicit ModuleBase_ParamSpinBox( QWidget* theParent = 0, int thePrecision = -12 ); virtual ~ModuleBase_ParamSpinBox(); @@ -29,26 +43,36 @@ public: virtual void setText(const QString&); + /// Set a flag about accepted variable void setAcceptVariables(const bool); + + /// Returns accepted variables flag bool isAcceptVariables() const; - bool hasVariable() const; -//signals: - //void textChanged(const QString&); + /// Returns True if the input value contains variable + bool hasVariable() const; protected: + /// Returns True if the given text contains variable + /// \param theText a text string bool hasVariable(const QString& theText) const; + + /// Returns state of the control State isValid(const QString&, double&) const; + /// Returns True if the given value is within min and max of the control bool checkRange(const double) const; - bool findVariable(const QString&, double&) const; + /// Finds a variable by its name. Rreturns true in success + /// \param theName a name of variable + /// \param outValue an output val;ue of the variable + bool findVariable(const QString& theName, double& outValue) const; protected: - //virtual void keyPressEvent(QKeyEvent*); virtual void showEvent(QShowEvent*); protected slots: + /// A slot called on text change void onTextChanged(const QString&); private: diff --git a/src/ModuleBase/ModuleBase_ToolBox.h b/src/ModuleBase/ModuleBase_ToolBox.h index 4462f80ed..1c2c1ef7d 100644 --- a/src/ModuleBase/ModuleBase_ToolBox.h +++ b/src/ModuleBase/ModuleBase_ToolBox.h @@ -15,23 +15,43 @@ class QFrame; class QHBoxLayout; class QStackedWidget; +/** + * \class ModuleBase_ToolBox + * \ingroup GUI + * \brief An extension of QFrame object + */ class MODULEBASE_EXPORT ModuleBase_ToolBox : public QFrame { Q_OBJECT public: + /// Constructor + /// \param theParent a parent widget ModuleBase_ToolBox( QWidget* theParent ); virtual ~ModuleBase_ToolBox(); + /// Add a new item to the tool box + /// \param thePage a widget of the new item + /// \param theName a name of the item + /// \param theIcon an icon of the item void addItem( QWidget* thePage, const QString& theName, const QPixmap& theIcon ); + + /// \return number of items int count() const; + + /// \return index of current widget int currentIndex() const; - void setCurrentIndex( const int ); + + /// Set current item + /// \param theIdx an index + void setCurrentIndex( const int theIdx); signals: + /// A signal which is emited on current item changed void currentChanged( int ); private slots: + /// A slot called on button press void onButton( int ); private: diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.h b/src/ModuleBase/ModuleBase_ViewerFilters.h index 9c1ad9b46..8314f7054 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.h +++ b/src/ModuleBase/ModuleBase_ViewerFilters.h @@ -60,7 +60,7 @@ public: Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {} /// Set working plane - /// \param thePane plane object + /// \param thePlane a plane object void setPlane(const std::shared_ptr& thePlane) { myPlane = thePlane; } /// Returns current working plane diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index c5ad7b264..39ae98235 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -23,27 +23,51 @@ class QWidget; class QStringListModel; class QCompleter; +/** +* \ingroup GUI +* A multi-line text editor which lets to input formula and provides a list of completion strings +*/ class ExpressionEditor: public QPlainTextEdit { Q_OBJECT - public: + /// Constructor + /// \param theParent a parent widget explicit ExpressionEditor(QWidget* theParent = 0); virtual ~ExpressionEditor(); + /// Set list of completion strings void setCompletionList(QStringList&); + /// Set a text which will be shown when the listr is empty void setPlaceHolderText( const QString& ); + + /// Returns placeholder list QString placeHolderText() const; public slots: - void insertCompletion(const QString&, bool isSingleWord = false); + /// Insert additional string for completion + /// \param theCompletion a string to insert + /// \param isSingleWord a flag shows that inserted string is single word or not + void insertCompletion(const QString& theCompletion, bool isSingleWord = false); + + /// Perform completion void performCompletion(); protected: + /// Perform completion by prefix + /// \param theCompletionPrefix a prefix for looking for completion void performCompletion(const QString& theCompletionPrefix); + + /// Redefinition of virtual method + /// \param theEvent a key press event virtual void keyPressEvent(QKeyEvent* theEvent); + + /// Key events processing + /// theEvent a key event bool handledCompletedAndSelected(QKeyEvent* theEvent); + + /// Redefinition of virtual method virtual void paintEvent( QPaintEvent* ); private: @@ -55,7 +79,7 @@ class ExpressionEditor: public QPlainTextEdit /** * \ingroup GUI -* TODO(sbh) add doc +* A Widget which provides an input of an expression */ class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWidget { @@ -65,12 +89,14 @@ class MODULEBASE_EXPORT ModuleBase_WidgetExprEditor : public ModuleBase_ModelWid /// \param theParent the parent object /// \param theData the widget configuration. /// \param theParentId is Id of a parent of the current attribute + /// \param thePlaceHolder a placeholder string ModuleBase_WidgetExprEditor( QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId, const std::string& thePlaceHolder ); virtual ~ModuleBase_WidgetExprEditor(); + /// Redefinition of virtual method virtual QList getControls() const; public slots: @@ -82,6 +108,7 @@ protected: /// \return True in success virtual bool storeValueCustom() const; + /// Redefinition of virtual method virtual bool restoreValueCustom(); private: diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.h b/src/ModuleBase/ModuleBase_WidgetFileSelector.h index e1f402b03..ba6a4e019 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.h @@ -86,6 +86,10 @@ protected: /// Returns string containing formats QString filterString() const; + /// Add an extension to file name if the extension is not defined + /// \param theFileName a file name + /// \param theFilter a file filter + /// \return the file name with extension static QString applyExtension(const QString& theFileName, const QString& theFilter); protected: diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp index 273cc9020..defdbee48 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp @@ -28,9 +28,15 @@ #include #include +/** +* Customization of Line edit control +*/ class CustomLineEdit : public QLineEdit { public: + /// Constructor + /// \param theParent a parent widget + /// \param thePlaceHolder a string which is shown when text is empty CustomLineEdit( QWidget* theParent, const QString& thePlaceHolder ) : QLineEdit( theParent ), myPlaceHolder( thePlaceHolder ) { @@ -40,6 +46,8 @@ public: { } + /// Redefiniotion of virtual method + /// \param theEvent a paint event virtual void paintEvent( QPaintEvent* theEvent ) { QLineEdit::paintEvent( theEvent ); diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.h b/src/ModuleBase/ModuleBase_WidgetLineEdit.h index d812bc158..1f5f3fd71 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.h +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.h @@ -33,12 +33,14 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge /// \param theParent the parent object /// \param theData the widget configuration. /// \param theParentId is Id of a parent of the current attribute + /// \param thePlaceHolder a string of placeholder ModuleBase_WidgetLineEdit( QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId, const std::string& thePlaceHolder ); virtual ~ModuleBase_WidgetLineEdit(); + /// Redefinition of virtual method virtual QList getControls() const; public slots: @@ -49,6 +51,8 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success virtual bool storeValueCustom() const; + + /// Redefinition of virtual method virtual bool restoreValueCustom(); private: diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 8a703d320..af676208c 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -36,14 +36,20 @@ #include #include +/** +* Customization of a List Widget to make it to be placed on full width of container +*/ class CustomListWidget : public QListWidget { public: + /// Constructor + /// \param theParent a parent widget CustomListWidget( QWidget* theParent ) : QListWidget( theParent ) { } + /// Redefinition of virtual method virtual QSize sizeHint() const { int aHeight = 2*QFontMetrics( font() ).height(); @@ -51,6 +57,7 @@ public: return QSize( aSize.width(), aHeight ); } + /// Redefinition of virtual method virtual QSize minimumSizeHint() const { int aHeight = 2*QFontMetrics( font() ).height(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 403847ddf..d3a9b8a09 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -69,11 +69,12 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values + /// \param theToValidate a validation of the values flag virtual bool setSelection(QList& theValues, const bool theToValidate); /// Checks the widget validity. By default, it returns true. - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); @@ -103,7 +104,7 @@ protected: /// Clear attribute virtual void clearAttribute(); - // Set the focus on the last item in the list + /// Set the focus on the last item in the list virtual void updateFocus(); /// Computes and updates name of selected object in the widget @@ -163,6 +164,7 @@ protected: /// Variable of GeomSelection int mySelectionCount; // number of elements in the attribute selection list when store + /// A flag to store use_choice parameter state bool myIsUseChoice; }; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 99af3ad74..0deb253bd 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -43,12 +43,12 @@ Q_OBJECT virtual bool isViewerSelector() { return true; } /// Checks the widget validity. By default, it returns true. - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner + /// \param thePrs a selected owner virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// The methiod called when widget is deactivated @@ -66,7 +66,7 @@ protected: /// Set an empty value to attribute virtual void clearAttribute() = 0; - // Update focus after the attribute value change + /// Update focus after the attribute value change virtual void updateFocus() = 0; /// Return the attribute values wrapped in a list of viewer presentations diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.h b/src/ModuleBase/ModuleBase_WidgetSwitch.h index 8addb375c..1f278042b 100644 --- a/src/ModuleBase/ModuleBase_WidgetSwitch.h +++ b/src/ModuleBase/ModuleBase_WidgetSwitch.h @@ -25,7 +25,9 @@ class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public ModuleBase_PagedContain Q_OBJECT public: /// Constructor - /// \param parent a parent widget + /// \param theParent the parent object + /// \param theData the widget configuration. The attribute of the model widget is obtained from + /// \param theParentId is Id of a parent of the current attribute ModuleBase_WidgetSwitch(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); @@ -38,14 +40,18 @@ class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public ModuleBase_PagedContain /// Add a page to the widget /// \param theWidget a page widget /// \param theName a name of page + /// \param theCaseId an Id of the page + /// \param theIcon an icon of the page virtual int addPage( ModuleBase_PageBase* theWidget, const QString& theName, const QString& theCaseId, const QPixmap& theIcon ); protected: + /// Returns index of the current page virtual int currentPageIndex() const; - /// Set current page by index + + /// Set current page by index /// \param index index of the page virtual void setCurrentPageIndex(int index); diff --git a/src/ModuleBase/ModuleBase_WidgetToolbox.h b/src/ModuleBase/ModuleBase_WidgetToolbox.h index 44565db2c..28e48c0fc 100644 --- a/src/ModuleBase/ModuleBase_WidgetToolbox.h +++ b/src/ModuleBase/ModuleBase_WidgetToolbox.h @@ -22,6 +22,10 @@ class MODULEBASE_EXPORT ModuleBase_WidgetToolbox : public ModuleBase_PagedContai { Q_OBJECT public: + /// Constructor + /// \param theParent the parent object + /// \param theData the widget configuration. The attribute of the model widget is obtained from + /// \param theParentId is Id of a parent of the current attribute ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); virtual ~ModuleBase_WidgetToolbox(); @@ -30,7 +34,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetToolbox : public ModuleBase_PagedContai /// \return false because this is an info widget virtual bool canSetValue() const { return false; }; - /// Overrides ModuleBase_PagedContainer + /// Add a page to the widget + /// \param theWidget a page widget + /// \param theName a name of page + /// \param theCaseId an Id of the page + /// \param theIcon an icon of the page virtual int addPage( ModuleBase_PageBase* theWidget, const QString& theName, const QString& theCaseId, @@ -39,6 +47,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetToolbox : public ModuleBase_PagedContai protected: /// Implements ModuleBase_PagedContainer virtual int currentPageIndex() const; + /// Implements ModuleBase_PagedContainer virtual void setCurrentPageIndex(int); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 70405e695..f1a5ef17e 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -36,6 +36,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg public: /// Constructor /// \param theParent the parent object + /// \param theWorkshop a reference to workshop /// \param theData the widget configuation. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute ModuleBase_WidgetValidated(QWidget* theParent, @@ -45,8 +46,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg virtual ~ModuleBase_WidgetValidated(); /// Checks whether all active viewer filters validate the presentation - /// \param theWorkshop an active workshop - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs); @@ -60,6 +60,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg /// The method is called by the current operation to process the operation preselection. /// It is redefined to check the value validity and if it is, fill the attribute with by value /// \param theValues the wrapped selection values + /// \param theToValidate a flag on validation of the values virtual bool setSelection(QList& theValues, const bool theToValidate); @@ -67,7 +68,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; /// It obtains selection filters from the workshop and activates them in the active viewer - /// \param theWorkshop an active workshop /// \param toActivate a flag about activation or deactivation the filters void activateFilters(const bool toActivate); @@ -84,12 +84,12 @@ protected: virtual void restoreAttributeValue(const bool theValid); /// Checks the widget validity. By default, it returns true. - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner + /// \param thePrs a selected owner virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0; /// Checks the current attibute in all attribute validators @@ -110,7 +110,7 @@ protected: /// \param theValid a valid state void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid); - // Removes all presentations from internal maps. + /// Removes all presentations from internal maps. void clearValidState(); /// Returns a list of selected presentations in the viewer and object browser @@ -124,8 +124,11 @@ protected: void filterPresentations(QList& theValues); protected: - ModuleBase_IWorkshop* myWorkshop; /// Reference to workshop - bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not + /// Reference to workshop + ModuleBase_IWorkshop* myWorkshop; + + /// The widget is in validation mode: store is performed, restore is not + bool myIsInValidate; private: ObjectPtr myPresentedObject; /// back up of the filtered object diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index d537b8a8d..3a2875dde 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -57,13 +57,17 @@ Q_OBJECT virtual QAction* addFeature(const QString& theWBName, const ActionInfo& theInfo); + /// Add a nested feature + /// \param theWBName a workbench name + /// \param theInfo the action parameters + /// \param theNestedActions a list of nested actions virtual QAction* addFeatureOfNested(const QString& theWBName, const ActionInfo& theInfo, const QList& theNestedActions); //! Returns true if the feature action is a nested action, in other words, //! it is created by addNestedFeature(). - //! \param theId - an action of a feature + //! \param theAction - an action of a feature //! returns boolean result virtual bool isFeatureOfNested(const QAction* theAction); @@ -76,6 +80,9 @@ Q_OBJECT virtual void addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition = 10); + /// Add an action to a tool bar + /// \param theAction an ation to add + /// \param theToolBarTitle a name of tool bar virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ); virtual QMainWindow* desktop() const; @@ -164,6 +171,7 @@ Q_OBJECT /// Create popup menu manager virtual QtxPopupMgr* popupMgr(); + /// Abort all operations virtual bool abortAllOperations(); private: diff --git a/src/NewGeom/NewGeom_NestedButton.h b/src/NewGeom/NewGeom_NestedButton.h index bc39376c4..69d8bc297 100644 --- a/src/NewGeom/NewGeom_NestedButton.h +++ b/src/NewGeom/NewGeom_NestedButton.h @@ -23,16 +23,22 @@ class NewGeom_NestedButton : public QWidgetAction { Q_OBJECT public: - NewGeom_NestedButton(QObject *parent, const QList& theNestedActions); + /// Constructor + /// \param theParent a parent objects + /// \param theNestedActions a list of nested actions + NewGeom_NestedButton(QObject* theParent, const QList& theNestedActions); virtual ~NewGeom_NestedButton(); private slots: /// Shows/hides the additional buttons widget void showAdditionalButtons(bool); + + /// Slot called on action state void actionStateChanged(); protected: /// Creates the button representation + /// \param theParent a parent widget virtual QWidget * createWidget(QWidget * theParent); private: diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 388a735fb..0db713356 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -26,11 +26,7 @@ SET(PROJECT_HEADERS PartSet_FilterInfinite.h PartSet_SketcherMgr.h PartSet_MenuMgr.h - PartSet_DocumentDataModel.h - PartSet_PartDataModel.h - PartSet_DataTreeModel.h PartSet_WidgetSketchCreator.h - PartSet_TopDataModel.h PartSet_IconFactory.h ) @@ -54,11 +50,7 @@ SET(PROJECT_SOURCES PartSet_FilterInfinite.cpp PartSet_SketcherMgr.cpp PartSet_MenuMgr.cpp - PartSet_DocumentDataModel.cpp - PartSet_PartDataModel.cpp - PartSet_DataTreeModel.cpp PartSet_WidgetSketchCreator.cpp - PartSet_TopDataModel.cpp PartSet_IconFactory.cpp ) diff --git a/src/PartSet/PartSet_CustomPrs.h b/src/PartSet/PartSet_CustomPrs.h index d21bdd0e3..c12768e0e 100755 --- a/src/PartSet/PartSet_CustomPrs.h +++ b/src/PartSet/PartSet_CustomPrs.h @@ -29,6 +29,8 @@ class XGUI_Workshop; class PartSet_CustomPrs { public: + /// Constructor + /// \param theWorkshop a reference to workshop PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop); PARTSET_EXPORT virtual ~PartSet_CustomPrs() {}; @@ -48,6 +50,7 @@ public: /// If the presentation is active[displayed], the shapes of the presentation is recomputed /// and the presentation is redisplayed. + /// \param theObject an object to redisplay /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly /// \returns true if the presentation is redisplayed bool redisplay(const ObjectPtr& theObject, const bool theUpdateViewer); diff --git a/src/PartSet/PartSet_DataTreeModel.cpp b/src/PartSet/PartSet_DataTreeModel.cpp deleted file mode 100644 index 2c433f78b..000000000 --- a/src/PartSet/PartSet_DataTreeModel.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#include "PartSet_DataTreeModel.h" - -PartSet_FeaturesModel::PartSet_FeaturesModel(QObject* theParent) -: QAbstractItemModel(theParent), - myItemsColor(Qt::black) -{ - -} - -PartSet_PartModel::PartSet_PartModel(QObject* theParent) -: PartSet_FeaturesModel(theParent) -{ - -} - -PartSet_PartModel::~PartSet_PartModel() -{ - myPart = FeaturePtr(); -} diff --git a/src/PartSet/PartSet_DataTreeModel.h b/src/PartSet/PartSet_DataTreeModel.h deleted file mode 100644 index 0fa8f6380..000000000 --- a/src/PartSet/PartSet_DataTreeModel.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#ifndef PartSet_DataTreeModel_H -#define PartSet_DataTreeModel_H - -#include "PartSet.h" - -#include -#include -#include -#include - -#include -#include - -/**\class PartSet_FeaturesModel - * \ingroup GUI - * \brief Abstaract class of model object which operates with features data. - */ -class PARTSET_EXPORT PartSet_FeaturesModel : public QAbstractItemModel -{ - public: - /// Constructor - /// \param theParent a parent object - PartSet_FeaturesModel(QObject* theParent); - - //! Returns Feature object by the given Model index. - //! Returns 0 if the given index is not index of a feature - /// \param theIndex a model index - virtual ObjectPtr object(const QModelIndex& theIndex) const = 0; - - //! Returns QModelIndex which corresponds to the given feature - //! If the feature is not found then index is not valid - virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0; - - //! Returns parent index of the given feature - virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0; - - //! Returns index corresponded to the group - //! \param theGroup a group name - virtual QModelIndex findGroup(const std::string& theGroup) const = 0; - - //! Set color of items - void setItemsColor(const QColor& theColor) - { - myItemsColor = theColor; - } - - //! Returns color of items - QColor itemsColor() const - { - return myItemsColor; - } - - protected: - /// Color of items - QColor myItemsColor; -}; - -/**\class PartSet_PartModel - * \ingroup GUI - * \brief Abstaract class of model object which operates with parts data. - */ -class PartSet_PartModel : public PartSet_FeaturesModel -{ - public: - /// Constructor - /// \param theParent a parent object - PartSet_PartModel(QObject* theParent); - /// Destructor - ~PartSet_PartModel(); - - /// Set part id - /// \param theId a new id - void setPart(FeaturePtr thePart) - { - myPart = thePart; - } - - /// Returns Id of the part - FeaturePtr part() const { return myPart; } - - //! Returns true if the given document is a sub-document of this tree - //! \param theDoc a document to check - virtual bool hasDocument(const DocumentPtr& theDoc) const = 0; - - /// Returns position of the part in history - int position() const - { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - return aRootDoc->index(myPart); - } - - protected: - //! Id of the current part object in the document - FeaturePtr myPart; -}; - -#endif diff --git a/src/PartSet/PartSet_DocumentDataModel.cpp b/src/PartSet/PartSet_DocumentDataModel.cpp deleted file mode 100644 index 84ac7a169..000000000 --- a/src/PartSet/PartSet_DocumentDataModel.cpp +++ /dev/null @@ -1,876 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#include "PartSet_DocumentDataModel.h" -#include "PartSet_PartDataModel.h" -#include "PartSet_TopDataModel.h" -#include "PartSet_Module.h" -//#include "XGUI_Tools.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#define ACTIVE_COLOR QColor(0,72,140) -#define PASSIVE_COLOR Qt::black - -QMap PartSet_DocumentDataModel::myIcons; - - -PartSet_DocumentDataModel::PartSet_DocumentDataModel(QObject* theParent) - : ModuleBase_IDocumentDataModel(theParent), - myActivePartModel(0) -{ - // Create a top part of data tree model - myModel = new PartSet_TopDataModel(this); - myModel->setItemsColor(ACTIVE_COLOR); - - Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); - aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT())); -} - -PartSet_DocumentDataModel::~PartSet_DocumentDataModel() -{ - clearModelIndexes(); - clearSubModels(); -} - -void PartSet_DocumentDataModel::processEvent(const std::shared_ptr& theMessage) -{ - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - - - // Created object event ******************* - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - std::shared_ptr aUpdMsg = - std::dynamic_pointer_cast(theMessage); - std::set aObjects = aUpdMsg->objects(); - - std::set::const_iterator aIt; - for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { - ObjectPtr aObject = (*aIt); - FeaturePtr aFeature = std::dynamic_pointer_cast(aObject); - if (aFeature && (!aFeature->isInHistory())) - continue; - - DocumentPtr aDoc = aObject->document(); - if (aDoc == aRootDoc) { // If root objects - if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group - // Add a new part - int aStart = aRootDoc->size(ModelAPI_ResultPart::group()); - if (aStart > 0) { - FeaturePtr aPartFeature = ModelAPI_Feature::feature(aObject); - PartSet_PartDataModel* aModel = new PartSet_PartDataModel(this); - int anId = aRootDoc->index(aPartFeature); - aModel->setPart(aPartFeature); - myPartModels.append(aModel); - insertRow(aStart, partFolderNode(0)); - } - } else { // Update top groups (other except parts - QModelIndex aIndex = myModel->findParent(aObject); - int aStart = myModel->rowCount(aIndex) - 1; - if (aStart < 0) - aStart = 0; - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); - insertRow(aStart, aIndex); - } - } else { // if sub-objects of first level nodes - PartSet_PartModel* aPartModel = 0; - foreach (PartSet_PartModel* aPart, myPartModels) { - if (aPart->hasDocument(aDoc)) { - aPartModel = aPart; - break; - } - } - if (aPartModel) { - QModelIndex aIndex = aPartModel->findParent(aObject); - int aStart = aPartModel->rowCount(aIndex); // check this index - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); - insertRow(aStart, aIndex); - } else - reset(); - } - } - // Deleted object event *********************** - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - std::shared_ptr aUpdMsg = - std::dynamic_pointer_cast(theMessage); - DocumentPtr aDoc = aUpdMsg->document(); - std::set aGroups = aUpdMsg->groups(); - - std::set::const_iterator aIt; - for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) { - std::string aGroup = (*aIt); - if (aDoc == aRootDoc) { // If root objects - if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group - PartSet_PartModel* aDelPartModel = 0; - foreach (PartSet_PartModel* aPartModel, myPartModels) { - if (aPartModel->position() == -1) { - aDelPartModel = aPartModel; - break; - } - } - if (aDelPartModel) { - deactivatePart(); - int aStart = myPartModels.size() - 1; - removeSubModel(aDelPartModel); - removeRow(aStart, partFolderNode(0)); - } - } if (aGroup == ModelAPI_Feature::group()) { // Update History node - int aRow = historyOffset() + aRootDoc->size(ModelAPI_Feature::group()); - removeRow(aRow); - } else { // Update top groups (other except parts - QModelIndex aIndex = myModel->findGroup(aGroup); - int aStart = myModel->rowCount(aIndex); - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); - removeRow(aStart, aIndex); - } - } else { - PartSet_PartModel* aPartModel = 0; - foreach (PartSet_PartModel* aPart, myPartModels) { - if (aPart->hasDocument(aDoc)) { - aPartModel = aPart; - break; - } - } - if (aPartModel) { - QModelIndex aIndex = aPartModel->findGroup(aGroup); - if (aIndex.isValid()) { - int aStart = aPartModel->rowCount(aIndex); - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); - removeRow(aStart, aIndex); - } else { - int aRow = aPartModel->rowCount(); - aIndex = createIndex(aPartModel->position() + historyOffset(), 0, HistoryNode); - removeRow(aRow, aIndex); - } - } - } - } - // Deleted object event *********************** - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { - //std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); - //ObjectPtr aFeature = aUpdMsg->feature(); - //DocumentPtr aDoc = aFeature->document(); - - // TODO: Identify the necessary index by the modified feature - QModelIndex aIndex; - emit dataChanged(aIndex, aIndex); - - // Reset whole tree ************************** - } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) { - std::shared_ptr aFeatureMsg = - std::dynamic_pointer_cast(theMessage); - if (!aFeatureMsg->isInternal()) { - ActionInfo aFeatureInfo; - aFeatureInfo.initFrom(aFeatureMsg); - // Remember features icons - myIcons[QString::fromStdString(aFeatureMsg->id())] = aFeatureInfo.iconFile; - } - } else { - rebuildDataTree(); - } -} - -void PartSet_DocumentDataModel::rebuildDataTree() -{ - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - - beginResetModel(); - clearModelIndexes(); - - // Delete extra models - ObjectPtr aObj; - FeaturePtr aFeature; - QList aDelList; - foreach (PartSet_PartModel* aPartModel, myPartModels) { - if (aPartModel->position() == -1) - aDelList.append(aPartModel); - } - foreach (PartSet_PartModel* aPartModel, aDelList) { - removeSubModel(aPartModel); - } - // Add non existing models - int aHistNb = aRootDoc->size(ModelAPI_Feature::group()); - for (int i = 0; i < aHistNb; i++) { - aObj = aRootDoc->object(ModelAPI_Feature::group(), i); - aFeature = std::dynamic_pointer_cast(aObj); - if (aFeature->getKind() == PartSetPlugin_Part::ID()) { - if (!findPartModel(aFeature)) { - PartSet_PartDataModel* aModel = new PartSet_PartDataModel(this); - aModel->setPart(aFeature); - myPartModels.append(aModel); - } - } - } - endResetModel(); -} - -QVariant PartSet_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const -{ - if (!theIndex.isValid()) - return QVariant(); - - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - QModelIndex aParent = theIndex.parent(); - if ((theIndex.column() == 1) ) { - if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { - if (ModelAPI_Session::get()->activeDocument() == aRootDoc) { - if (!aParent.isValid()) { - switch (theRole) { - case Qt::DecorationRole: - if (theIndex.row() == lastHistoryRow()) - return QIcon(":pictures/arrow.png"); - } - } - } - } else { - QModelIndex* aIndex = toSourceModelIndex(theIndex); - const QAbstractItemModel* aModel = aIndex->model(); - if (isPartSubModel(aModel)) { - return aModel->data(*aIndex, theRole); - } - } - return QVariant(); - } - - switch (theIndex.internalId()) { - case PartsFolder: - switch (theRole) { - case Qt::DisplayRole: - return tr("Parts") + QString(" (%1)").arg(rowCount(theIndex)); - case Qt::DecorationRole: - return QIcon(":pictures/constr_folder.png"); - case Qt::ToolTipRole: - return tr("Parts folder"); - case Qt::ForegroundRole: - if (myActivePartIndex.isValid()) - return QBrush(PASSIVE_COLOR); - else - return QBrush(ACTIVE_COLOR); - default: - return QVariant(); - } - break; - case HistoryNode: - { - int aOffset = historyOffset(); - ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); - FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); - if (!aFeature) - return QVariant(); - switch (theRole) { - case Qt::DisplayRole: - if (aFeature) - return aFeature->data()->name().c_str(); - else - return QVariant(); - case Qt::DecorationRole: - return featureIcon(aFeature); - case Qt::ToolTipRole: - { - ResultPtr aResult = aFeature->firstResult(); - bool isResultAndNotLoaded = false; - if( aResult.get() ) - { - ResultPartPtr aResultPart = std::dynamic_pointer_cast( aResult ); - if( aResultPart.get() ) - isResultAndNotLoaded = !aResultPart->isActivated(); - } - if( isResultAndNotLoaded ) - return tr( "The part should be activated before the user may edit it" ); - else - return tr( "Feature object" ); - } - case Qt::ForegroundRole: - if (theIndex.row() > lastHistoryRow()) - return QBrush(Qt::lightGray); - else { - if (myActivePartIndex.isValid()) - return QBrush(PASSIVE_COLOR); - else - return QBrush(ACTIVE_COLOR); - } - default: - return QVariant(); - } - } - break; - case PartResult: - { - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), theIndex.row()); - if (aObject) { - switch (theRole) { - case Qt::DisplayRole: - return std::dynamic_pointer_cast(aObject)->data()->name().c_str(); - case Qt::DecorationRole: - return QIcon(":pictures/part_ico.png"); - case Qt::ForegroundRole: - { - if (theIndex == myActivePartIndex) - return QBrush(ACTIVE_COLOR); - else - return QBrush(PASSIVE_COLOR); - } - default: - return QVariant(); - } - } - } - break; - } - if (aParent.internalId() == HistoryNode) { - int aId = aParent.row() - historyOffset(); - QModelIndex* aIndex = toSourceModelIndex(theIndex); - return findPartModel(aId)->data(*aIndex, theRole); - } - return toSourceModelIndex(theIndex)->data(theRole); -} - -QVariant PartSet_DocumentDataModel::headerData(int theSection, Qt::Orientation theOrient, - int theRole) const -{ - return QVariant(); -} - -int PartSet_DocumentDataModel::rowCount(const QModelIndex& theParent) const -{ - SessionPtr aSession = ModelAPI_Session::get(); - if (!aSession->hasModuleDocument()) - return 0; - DocumentPtr aRootDoc = aSession->moduleDocument(); - if (!theParent.isValid()) { - // Size of external models - int aVal = historyOffset(); - // Plus history size - aVal += aRootDoc->size(ModelAPI_Feature::group()); - return aVal; - } - if (theParent.internalId() == PartsFolder) { - return aRootDoc->size(ModelAPI_ResultPart::group()); - //int aSize = myPartModels.size(); - //return myPartModels.size(); - } - if (theParent.internalId() == HistoryNode) { - int aId = theParent.row() - historyOffset(); - PartSet_PartModel* aModel = findPartModel(aId); - if (aModel) - return aModel->rowCount(QModelIndex()); - return 0; - } - if (theParent.internalId() == PartResult) - return 0; - - QModelIndex* aParent = toSourceModelIndex(theParent); - const QAbstractItemModel* aModel = aParent->model(); - if (!isSubModel(aModel)) - return 0; - - /*if (isPartSubModel(aModel)) { - if (aModel != myActivePart) - return 0; - }*/ - return aModel->rowCount(*aParent); -} - -int PartSet_DocumentDataModel::columnCount(const QModelIndex& theParent) const -{ - return 2; -} - -QModelIndex PartSet_DocumentDataModel::index(int theRow, int theColumn, - const QModelIndex& theParent) const -{ - QModelIndex aIndex; - if (!theParent.isValid()) { - int aOffs = myModel->rowCount(); - if (theRow < aOffs) { - aIndex = myModel->index(theRow, theColumn, theParent); - aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex)); - } else { - if (theRow == aOffs) // Create Parts node - aIndex = partFolderNode(theColumn); - else { - // create history node - aIndex = createIndex(theRow, theColumn, HistoryNode); - } - } - } else { - if (theParent.internalId() == PartsFolder) { - aIndex = createIndex(theRow, theColumn, PartResult); - } else { - if (theParent.internalId() == HistoryNode) { - int aId = theParent.row() - historyOffset(); - aIndex = findPartModel(aId)->index(theRow, theColumn, QModelIndex()); - } else { - QModelIndex* aParent = (QModelIndex*) theParent.internalPointer(); - aIndex = aParent->model()->index(theRow, theColumn, (*aParent)); - } - aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex)); - } - } - return aIndex; -} - -QModelIndex PartSet_DocumentDataModel::parent(const QModelIndex& theIndex) const -{ - if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode)) - return QModelIndex(); - - if (theIndex.internalId() == PartResult) - return partFolderNode(0); - - QModelIndex* aIndex = toSourceModelIndex(theIndex); - const QAbstractItemModel* aModel = aIndex->model(); - if (!isSubModel(aModel)) - return QModelIndex(); - - QModelIndex aIndex1 = aModel->parent(*aIndex); - const PartSet_PartModel* aPartModel = dynamic_cast(aModel); - if (aPartModel && (!aIndex1.isValid())) { - int aId = aPartModel->position(); - int aRow = aId + historyOffset(); - return createIndex(aRow, 0, (qint32) HistoryNode); - } - - if (aIndex1.isValid()) - return createIndex(aIndex1.row(), 0, (void*) getModelIndex(aIndex1)); - return aIndex1; -} - -bool PartSet_DocumentDataModel::hasChildren(const QModelIndex& theParent) const -{ - if (!theParent.isValid()) - return true; - return rowCount(theParent) > 0; -} - -QModelIndex* PartSet_DocumentDataModel::toSourceModelIndex(const QModelIndex& theProxy) const -{ - QModelIndex* aIndexPtr = static_cast(theProxy.internalPointer()); - return aIndexPtr; -} - -QModelIndex* PartSet_DocumentDataModel::findModelIndex(const QModelIndex& theIndex) const -{ - QList::const_iterator aIt; - for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt) { - QModelIndex* aIndex = (*aIt); - if ((*aIndex) == theIndex) - return aIndex; - } - return 0; -} - -QModelIndex* PartSet_DocumentDataModel::getModelIndex(const QModelIndex& theIndex) const -{ - QModelIndex* aIndexPtr = findModelIndex(theIndex); - if (!aIndexPtr) { - aIndexPtr = new QModelIndex(theIndex); - PartSet_DocumentDataModel* that = (PartSet_DocumentDataModel*) this; - that->myIndexes.append(aIndexPtr); - } - return aIndexPtr; -} - -void PartSet_DocumentDataModel::clearModelIndexes() -{ - foreach (QModelIndex* aIndex, myIndexes) - delete aIndex; - myIndexes.clear(); -} - -void PartSet_DocumentDataModel::clearSubModels() -{ - foreach (PartSet_PartModel* aPart, myPartModels) - delete aPart; - myPartModels.clear(); - myActivePartModel = 0; -} - -ObjectPtr PartSet_DocumentDataModel::object(const QModelIndex& theIndex) const -{ - if (theIndex.internalId() == PartsFolder) - return ObjectPtr(); - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - if (theIndex.internalId() == HistoryNode) { - int aOffset = historyOffset(); - return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); - } - if (theIndex.internalId() == PartResult) { - return aRootDoc->object(ModelAPI_ResultPart::group(), theIndex.row()); - } - QModelIndex* aIndex = toSourceModelIndex(theIndex); - if (!isSubModel(aIndex->model())) - return ObjectPtr(); - - const PartSet_FeaturesModel* aModel = dynamic_cast(aIndex->model()); - return aModel->object(*aIndex); -} - -bool PartSet_DocumentDataModel::insertRows(int theRow, int theCount, const QModelIndex& theParent) -{ - beginInsertRows(theParent, theRow, theRow + theCount - 1); - //endInsertRows(); - - // Update history - QModelIndex aRoot; - int aRow = rowCount(aRoot); - beginInsertRows(aRoot, aRow, aRow); - endInsertRows(); - - return true; -} - -bool PartSet_DocumentDataModel::removeRows(int theRow, int theCount, const QModelIndex& theParent) -{ - beginRemoveRows(theParent, theRow, theRow + theCount - 1); - endRemoveRows(); - return true; -} - -void PartSet_DocumentDataModel::removeSubModel(int theModelId) -{ - PartSet_PartModel* aModel = myPartModels.at(theModelId); - removeSubModel(aModel); -} - -void PartSet_DocumentDataModel::removeSubModel(PartSet_PartModel* theModel) -{ - QIntList aToRemove; - for (int i = 0; i < myIndexes.size(); i++) { - if (myIndexes.at(i)->model() == theModel) - aToRemove.append(i); - } - int aId; - while (aToRemove.size() > 0) { - aId = aToRemove.last(); - delete myIndexes.at(aId); - myIndexes.removeAt(aId); - aToRemove.removeLast(); - } - if (theModel == myActivePartModel) - myActivePartModel = 0; - myPartModels.removeAll(theModel); - delete theModel; -} - - -bool PartSet_DocumentDataModel::isSubModel(const QAbstractItemModel* theModel) const -{ - if (theModel == myModel) - return true; - return isPartSubModel(theModel); -} - -bool PartSet_DocumentDataModel::isPartSubModel(const QAbstractItemModel* theModel) const -{ - return myPartModels.contains((PartSet_PartModel*) theModel); -} - -QModelIndex PartSet_DocumentDataModel::partFolderNode(int theColumn) const -{ - int aPos = myModel->rowCount(QModelIndex()); - return createIndex(aPos, theColumn, PartsFolder); -} - -int PartSet_DocumentDataModel::historyOffset() const -{ - // Nb of rows of top model + Parts folder - return myModel->rowCount(QModelIndex()) + 1; -} - -bool PartSet_DocumentDataModel::activatePart(const QModelIndex& theIndex) -{ - if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode)) - return false; - - if (theIndex.isValid() && (theIndex.internalId() == PartResult)) { - myActivePartIndex = theIndex; - myModel->setItemsColor(PASSIVE_COLOR); - if (myActivePartModel) - myActivePartModel->setItemsColor(PASSIVE_COLOR); - - // Find activated part feature by its ID - ResultPartPtr aPartRes = activePart(); - FeaturePtr aFeature = ModelAPI_Feature::feature(aPartRes); - if (aFeature.get()) { - myActivePartModel = findPartModel(aFeature); - myActivePartModel->setItemsColor(ACTIVE_COLOR); - } - } - return true; -} - -ResultPartPtr PartSet_DocumentDataModel::activePart() const -{ - if (myActivePartIndex.isValid()) { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myActivePartIndex.row()); - return std::dynamic_pointer_cast(aObj); - } - return ResultPartPtr(); -} - -QModelIndex PartSet_DocumentDataModel::activePartTree() const -{ - if (myActivePartModel) { - return createIndex(myActivePartModel->position() + historyOffset(), 0, HistoryNode); - } - return QModelIndex(); -} - -void PartSet_DocumentDataModel::deactivatePart() -{ - if (myActivePartIndex.isValid()) { - if (myActivePartModel) - myActivePartModel->setItemsColor(PASSIVE_COLOR); - myActivePartModel = 0; - myActivePartIndex = QModelIndex(); - myModel->setItemsColor(ACTIVE_COLOR); - } -} - -Qt::ItemFlags PartSet_DocumentDataModel::flags(const QModelIndex& theIndex) const -{ - if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { - Qt::ItemFlags aFlags = Qt::ItemIsSelectable; - if (object(theIndex).get()) { - aFlags |= Qt::ItemIsEditable; - } - // Disable items which are below of last history row - // Do not disable second column - if (theIndex.internalId() == HistoryNode) { - if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1)) - aFlags |= Qt::ItemIsEnabled; - } else - aFlags |= Qt::ItemIsEnabled; - return aFlags; - } else { - QModelIndex* aIndex = toSourceModelIndex(theIndex); - const QAbstractItemModel* aModel = aIndex->model(); - Qt::ItemFlags aFlags = aModel->flags(*aIndex); - if (aModel == myModel) { - if (myModel->object(*aIndex).get()) - aFlags |= Qt::ItemIsEditable; - } - return aFlags; - } -} - -QModelIndex PartSet_DocumentDataModel::partIndex(const ResultPartPtr& theObject) const -{ - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - int aNb = aRootDoc->size(ModelAPI_ResultPart::group()); - for (int aId = 0; aId < aNb; aId++) { - if (theObject == aRootDoc->object(ModelAPI_ResultPart::group(), aId)) - return createIndex(aId, 0, PartResult); - } - return QModelIndex(); -} - -QModelIndex PartSet_DocumentDataModel::objectIndex(const ObjectPtr theObject) const -{ - // Check that this feature belongs to root document - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - DocumentPtr aDoc = theObject->document(); - if (aDoc == aRootDoc) { - // This feature belongs to histrory or top model - FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); - if (aFeature) { - int aId; - int aNb = aRootDoc->size(ModelAPI_Feature::group()); - for (aId = 0; aId < aNb; aId++) { - if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId)) - break; - } - if (aId < aNb) - return index(aId + historyOffset(), 0, QModelIndex()); - } else { - QModelIndex aIndex = myModel->objectIndex(theObject); - return - aIndex.isValid() ? - createIndex(aIndex.row(), 0, (void*) getModelIndex(aIndex)) : - QModelIndex(); - } - } else { - PartSet_PartModel* aPartModel = 0; - foreach(PartSet_PartModel* aModel, myPartModels) { - if (aModel->hasDocument(aDoc)) { - aPartModel = aModel; - break; - } - } - if (aPartModel) { - QModelIndex aIndex = aPartModel->objectIndex(theObject); - return aIndex.isValid() ? - createIndex(aIndex.row(), 0, (void*) getModelIndex(aIndex)) : - QModelIndex(); - } - } - return QModelIndex(); -} - - -void PartSet_DocumentDataModel::clear() -{ - clearModelIndexes(); - clearSubModels(); - //myActivePart = 0; - myActivePartIndex = QModelIndex(); - myModel->setItemsColor(ACTIVE_COLOR); -} - -int PartSet_DocumentDataModel::lastHistoryRow() const -{ - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - FeaturePtr aFeature = aRootDoc->currentFeature(true); - if (aFeature.get()) - return historyOffset() + aRootDoc->index(aFeature); - else - return historyOffset() - 1; -} - -void PartSet_DocumentDataModel::setLastHistoryItem(const QModelIndex& theIndex) -{ - SessionPtr aMgr = ModelAPI_Session::get(); - DocumentPtr aRootDoc = aMgr->moduleDocument(); - std::string aOpName = tr("History change").toStdString(); - if (theIndex.internalId() == HistoryNode) { - ObjectPtr aObject = object(theIndex); - aMgr->startOperation(aOpName); - aRootDoc->setCurrentFeature(std::dynamic_pointer_cast(aObject), true); - aMgr->finishOperation(); - } else { - aMgr->startOperation(aOpName); - aRootDoc->setCurrentFeature(FeaturePtr(), true); - aMgr->finishOperation(); - } -} - -QModelIndex PartSet_DocumentDataModel::lastHistoryItem() const -{ - return index(lastHistoryRow(), 1); -} - - -QIcon PartSet_DocumentDataModel::featureIcon(const FeaturePtr& theFeature) -{ - QIcon anIcon; - - std::string aKind = theFeature->getKind(); - QString aId(aKind.c_str()); - if (!myIcons.contains(aId)) - return anIcon; - - QString anIconString = myIcons[aId]; - - ModelAPI_ExecState aState = theFeature->data()->execState(); - switch(aState) { - case ModelAPI_StateDone: - case ModelAPI_StateNothing: { - anIcon = QIcon(anIconString); - } - break; - case ModelAPI_StateMustBeUpdated: { - anIcon = ModuleBase_Tools::lighter(anIconString); - } - break; - case ModelAPI_StateExecFailed: { - anIcon = ModuleBase_Tools::composite(":icons/exec_state_failed.png", anIconString); - } - break; - case ModelAPI_StateInvalidArgument: { - anIcon = ModuleBase_Tools::composite(":icons/exec_state_invalid_parameters.png", - anIconString); - } - break; - default: break; - } - return anIcon; -} - -void PartSet_DocumentDataModel::onMouseDoubleClick(const QModelIndex& theIndex) -{ - if (theIndex.column() != 1) - return; - if (flags(theIndex) == 0) - return; - QTreeView* aTreeView = dynamic_cast(sender()); - if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { - if (myActivePartModel) - // It means that the root document is not active - return; - QModelIndex aNewIndex; - if (theIndex.internalId() == HistoryNode) - aNewIndex = theIndex; - int aOldId = lastHistoryRow(); - setLastHistoryItem(theIndex); - int aStartRow = std::min(aOldId, theIndex.row()); - int aEndRow = std::max(aOldId, theIndex.row()); - for (int i = aStartRow; i <= aEndRow; i++) { - aTreeView->update(createIndex(i, 0, HistoryNode)); - aTreeView->update(createIndex(i, 1, HistoryNode)); - } - - } else { - QModelIndex* aIndex = toSourceModelIndex(theIndex); - const QAbstractItemModel* aModel = aIndex->model(); - if (isPartSubModel(aModel)) { - PartSet_PartDataModel* aPartModel = (PartSet_PartDataModel*)aModel; - QModelIndex aOldItem = aPartModel->lastHistoryItem(); - aPartModel->setLastHistoryItem(*aIndex); - QModelIndex aOldIndex = createIndex(aOldItem.row(), aOldItem.column(), (void*) getModelIndex(aOldItem)); - int aStartRow = std::min(aOldItem.row(), aIndex->row()); - int aEndRow = std::max(aOldItem.row(), aIndex->row()); - for (int i = aStartRow; i <= aEndRow; i++) { - QModelIndex aInd1 = aPartModel->index(i, 0); - QModelIndex aInd2 = createIndex(i, 0, (void*) getModelIndex(aInd1)); - aTreeView->update(aInd2); - aInd1 = aPartModel->index(i, 1); - aInd2 = createIndex(i, 1, (void*) getModelIndex(aInd1)); - aTreeView->update(aInd2); - } - } - } -} - - -PartSet_PartModel* PartSet_DocumentDataModel::findPartModel(FeaturePtr thePart) const -{ - foreach (PartSet_PartModel* aModel, myPartModels) { - if (aModel->part() == thePart) - return aModel; - } - return 0; -} - -PartSet_PartModel* PartSet_DocumentDataModel::findPartModel(int thePosition) const -{ - foreach (PartSet_PartModel* aModel, myPartModels) { - if (aModel->position() == thePosition) - return aModel; - } - return 0; -} \ No newline at end of file diff --git a/src/PartSet/PartSet_DocumentDataModel.h b/src/PartSet/PartSet_DocumentDataModel.h deleted file mode 100644 index e059a1f4e..000000000 --- a/src/PartSet/PartSet_DocumentDataModel.h +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#ifndef PartSet_DocumentDataModel_H -#define PartSet_DocumentDataModel_H - -#include "PartSet.h" -#include -#include -#include -#include - -#include -#include -#include - -class ModelAPI_Document; -class PartSet_PartModel; -class PartSet_TopDataModel; - -/**\class PartSet_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 PARTSET_EXPORT PartSet_DocumentDataModel : public ModuleBase_IDocumentDataModel, public Events_Listener -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent a parent object - PartSet_DocumentDataModel(QObject* theParent); - virtual ~PartSet_DocumentDataModel(); - - /// Event Listener method - /// \param theMessage an event message - virtual void processEvent(const std::shared_ptr& theMessage); - - /// Returns the data stored under the given role for the item referred to by the index. - /// \param theIndex a model index - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant data(const QModelIndex& theIndex, int theRole) const; - - /// Returns the data for the given role and section in the header with the specified orientation. - /// \param theSection a section - /// \param theOrient an orientation - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole = - Qt::DisplayRole) const; - - /// Returns the number of rows under the given parent. When the parent is valid it means that - /// rowCount is returning the number of children of parent. - /// \param theParent a parent model index - virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const; - - /// Returns the number of columns for the children of the given parent. - /// It has a one column - /// \param theParent a parent model index - virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const; - - /// Returns the index of the item in the model specified by the given row, column and parent index. - /// \param theRow a row - /// \param theColumn a column - /// \param theParent a parent model index - virtual QModelIndex index(int theRow, int theColumn, const QModelIndex &theParent = - QModelIndex()) const; - - /// Returns the parent of the model item with the given index. - /// If the item has no parent, an invalid QModelIndex is returned. - /// \param theIndex a model index - virtual QModelIndex parent(const QModelIndex& theIndex) const; - - /// Returns true if parent has any children; otherwise returns false. - /// \param theParent a parent model index - virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const; - - /// Inserts count rows into the model before the given row. - /// Items in the new row will be children of the item represented by the parent model index. - /// \param theRow a start row - /// \param theCount a nember of rows to insert - /// \param theParent a parent model index - bool insertRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex()); - - /// Removes count rows starting with the given row under parent parent from the model. - /// \param theRow a start row - /// \param theCount a nember of rows to remove - /// \param theParent a parent model index - bool removeRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex()); - - /// Returns the item flags for the given index. - /// \param theIndex a model index - virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const; - - //! Returns an object by the given Model index. - //! Returns 0 if the given index is not index of an object - virtual ObjectPtr object(const QModelIndex& theIndex) const; - - //! Returns index of the object - //! \param theObject object to find - virtual QModelIndex objectIndex(const ObjectPtr theObject) const; - - //! Returns QModelIndex which corresponds to the given part - //! If the object is not found then index is not valid - //! \param thePart a part for analysis - QModelIndex partIndex(const ResultPartPtr& thePart) const; - - //! Activates a part data model if the index is a Part node index. - //! Returns true if active part changed. - //! \param theIndex a model index - bool activatePart(const QModelIndex& theIndex); - - //! Retrurns active part - ResultPartPtr activePart() const; - - //! Retrurns QModelIndex of active part - QModelIndex activePartIndex() const - { - return myActivePartIndex; - } - - //! Returns parent index of active part tree (index of Part feature) - QModelIndex activePartTree() const; - - //! Deactivates a Part - void deactivatePart(); - - //! Rebuild data tree - virtual void rebuildDataTree(); - - //! Clear internal data - virtual void clear(); - - //! Set an Index which will be considered as a last history index - //! \param theIndex a last index for history - void setLastHistoryItem(const QModelIndex& theIndex); - - //! Returns last history item - QModelIndex lastHistoryItem() const; - - //! Returns icon name according to feature - static QIcon featureIcon(const FeaturePtr& theFeature); - - public slots: - void onMouseDoubleClick(const QModelIndex& theIndex); - - private: - - enum - { - PartsFolder, - HistoryNode, - PartResult - }; - - //! Converts QModelIndex of this model to QModelIndex of a one of sub-models. - QModelIndex* toSourceModelIndex(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(); - - //! Deletes all saved pointers on QModelIndex objects. - void clearSubModels(); - - //! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model - void removeSubModel(int theModelId); - - //! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model - void removeSubModel(PartSet_PartModel* theModel); - - //! Returns true if the given model is a one of sub-models (of both types) - bool isSubModel(const QAbstractItemModel* theModel) const; - - //! Returns true if the given model is a one of sub-models of Part type - bool isPartSubModel(const QAbstractItemModel* theModel) const; - - //! Returns Parts Folder node - //! \param theColumn an Id of column - QModelIndex partFolderNode(int theColumn) const; - - int lastHistoryRow() const; - - int historyOffset() const; - - PartSet_PartModel* findPartModel(FeaturePtr thePart) const; - - PartSet_PartModel* findPartModel(int thePosition) const; - - //! Data model of top part of data tree (not parts object) - PartSet_TopDataModel* myModel; - - //! Data models for Parts data tree representation (one data model per a one part) - QList myPartModels; - - //! Active part in part editing mode - PartSet_PartModel* myActivePartModel; - - QModelIndex myActivePartIndex; - - //! List of saved QModelIndexes created by sub-models - QList myIndexes; - - static QMap myIcons; -}; - -#endif diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h index 3d292afce..05d7f5b61 100755 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -39,6 +39,9 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr /// Returns the state whether the external object is used bool useExternal() const { return myUseExternal; } + /// Checks validity of the given object + /// \param theObject an object to check + /// \return valid or not valid bool isValidObject(const ObjectPtr& theObject); /// Finds or create and external object diff --git a/src/PartSet/PartSet_LockApplyMgr.h b/src/PartSet/PartSet_LockApplyMgr.h index bf6fed7dd..a73cb1437 100755 --- a/src/PartSet/PartSet_LockApplyMgr.h +++ b/src/PartSet/PartSet_LockApplyMgr.h @@ -25,21 +25,27 @@ class PARTSET_EXPORT PartSet_LockApplyMgr : public QObject public: /// Constructor - /// \param theExternal the external state - /// \param theDefaultValue the default value for the external object using + /// \param theParent a parent object + /// \param theWorkshop a reference to workshop PartSet_LockApplyMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop); virtual ~PartSet_LockApplyMgr() {} + /// Activates the object void activate(); + + /// Deactivates the object void deactivate(); + + /// Unlocks validation in operations manager void valuesChanged(); protected slots: - // Set lock validating in the operation manager. Set apply is disabled + /// Set lock validating in the operation manager. Set apply is disabled void onLockValidating(); - // Set unlock validating in the operation manager. Call method to update the apply state. + + /// Set unlock validating in the operation manager. Call method to update the apply state. void onUnlockValidating(); private: diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 00ba380b2..0cbbf1759 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -128,9 +128,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) new PartSet_IconFactory(); mySketchMgr = new PartSet_SketcherMgr(this); -#ifdef ModuleDataModel - myDataModel = new PartSet_DocumentDataModel(this); -#endif XGUI_ModuleConnector* aConnector = dynamic_cast(theWshop); XGUI_Workshop* aWorkshop = aConnector->workshop(); @@ -880,12 +877,6 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) aOB->treeView()->setExpandsOnDoubleClick(false); connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), SLOT(onTreeViewDoubleClick(const QModelIndex&))); -#ifdef ModuleDataModel - connect(aOB, SIGNAL(headerMouseDblClicked(const QModelIndex&)), - SLOT(onTreeViewDoubleClick(const QModelIndex&))); - connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), - myDataModel, SLOT(onMouseDoubleClick(const QModelIndex&))); -#endif } } @@ -987,38 +978,13 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aActiveDoc = aMgr->activeDocument(); -#ifdef ModuleDataModel - QModelIndex aOldIndex = myDataModel->activePartTree(); - DocumentPtr aDoc = aMgr->moduleDocument(); - if (aActiveDoc == aDoc) { - if (aOldIndex.isValid()) - aTreeView->setExpanded(aOldIndex, false); - myDataModel->deactivatePart(); - aPalet.setColor(QPalette::Text, QColor(0, 72, 140)); - } else { - std::string aGrpName = ModelAPI_ResultPart::group(); - for (int i = 0; i < aDoc->size(aGrpName); i++) { - ResultPartPtr aPart = std::dynamic_pointer_cast(aDoc->object(aGrpName, i)); - if (aPart->partDoc() == aActiveDoc) { - QModelIndex aIndex = myDataModel->partIndex(aPart); - if (myDataModel->activatePart(aIndex)) { - if (aOldIndex.isValid()) - aTreeView->setExpanded(aOldIndex, false); - aTreeView->setExpanded(myDataModel->activePartTree(), true); - aPalet.setColor(QPalette::Text, Qt::black); - } - break; - } - } - } -#else if (aActivePartIndex.isValid()) aTreeView->setExpanded(aActivePartIndex, false); XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); aActivePartIndex = aDataModel->documentRootIndex(aActiveDoc); if (aActivePartIndex.isValid()) aTreeView->setExpanded(aActivePartIndex, true); -#endif + aLabel->setPalette(aPalet); aWorkshop->updateCommandStatus(); @@ -1048,9 +1014,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) } if (theIndex.column() != 0) // Use only first column return; -#ifdef ModuleDataModel - ObjectPtr aObj = myDataModel->object(theIndex); -#else + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); XGUI_Workshop* aWorkshop = aConnector->workshop(); XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); @@ -1058,7 +1022,6 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0) return; ObjectPtr aObj = aDataModel->object(theIndex); -#endif ResultPartPtr aPart = std::dynamic_pointer_cast(aObj); if (!aPart.get()) { // Probably this is Feature diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index f43efaf94..a475b5f65 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -4,7 +4,6 @@ #define PartSet_Module_H #include "PartSet.h" -#include "PartSet_DocumentDataModel.h" #include #include @@ -21,6 +20,7 @@ #include #include #include +#include #include @@ -155,13 +155,9 @@ public: /// \return true if items are added and there is no necessity to provide standard menu bool isMouseOverWindow(); + /// Returns sketch manager object PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; } -#ifdef ModuleDataModel - /// Returns data model object for representation of data tree in Object browser - virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; } -#endif - /// Performs functionality on closing document virtual void closeDocument(); @@ -287,9 +283,6 @@ protected slots: int myVisualLayerId; bool myHasConstraintShown; -#ifdef ModuleDataModel - PartSet_DocumentDataModel* myDataModel; -#endif QModelIndex aActivePartIndex; }; diff --git a/src/PartSet/PartSet_PartDataModel.cpp b/src/PartSet/PartSet_PartDataModel.cpp deleted file mode 100644 index fff14f9d4..000000000 --- a/src/PartSet/PartSet_PartDataModel.cpp +++ /dev/null @@ -1,449 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#include "PartSet_PartDataModel.h" -#include "PartSet_Module.h" -#include "PartSet_DocumentDataModel.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - - -PartSet_PartDataModel::PartSet_PartDataModel(QObject* theParent) - : PartSet_PartModel(theParent) -{ -} - -PartSet_PartDataModel::~PartSet_PartDataModel() -{ -} - -QVariant PartSet_PartDataModel::data(const QModelIndex& theIndex, int theRole) const -{ - DocumentPtr aPartDoc = partDocument(); - if (theIndex.column() == 1) { - DocumentPtr aActiveDoc = ModelAPI_Session::get()->activeDocument(); - QModelIndex aParent = theIndex.parent(); - if (aActiveDoc == aPartDoc) { - if (!aParent.isValid()) { - switch (theRole) { - case Qt::DecorationRole: - if (theIndex.row() == lastHistoryRow()) - return QIcon(":pictures/arrow.png"); - } - } - } - return QVariant(); - } - - if (theIndex.internalId() >= 0) { - ObjectPtr aObj = object(theIndex); - switch (theRole) { - case Qt::DisplayRole: - return aObj->data()->name().c_str(); - case Qt::DecorationRole: - { - FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); - if (aFeature) - return PartSet_DocumentDataModel::featureIcon(aFeature); - } - break; - case Qt::ForegroundRole: - if (theIndex.internalId() > lastHistoryRow()) - return QBrush(Qt::lightGray); - return QBrush(myItemsColor); - } - } - - switch (theRole) { - case Qt::DisplayRole: - // return a name - switch (theIndex.internalId()) { - //case MyRoot: { - // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - // ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); - // if (aObject) - // return std::dynamic_pointer_cast(aObject)->data()->name().c_str(); - //} - case ParamsFolder: - return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); - case ConstructFolder: - return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); - case BodiesFolder: - return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); - case GroupsFolder: - return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex)); - case ParamObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultParameter::group(), theIndex.row()); - if (aObject) { - ResultParameterPtr aParam = std::dynamic_pointer_cast(aObject); - AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); - QString aVal = QString::number(aValueAttribute->value()); - QString aTitle = QString(aObject->data()->name().c_str()); - return aTitle + " = " + aVal; - } - } - break; - case ConstructObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - if (aObject) - return std::dynamic_pointer_cast(aObject)->data()->name().c_str(); - } - break; - case BodiesObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); - } - break; - case GroupObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultGroup::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); - } - case HistoryObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber()); - if (aObject) - return aObject->data()->name().c_str(); - } - } - break; - case Qt::DecorationRole: - // return an Icon - switch (theIndex.internalId()) { - //case MyRoot: - // return QIcon(":pictures/part_ico.png"); - case ParamsFolder: - return QIcon(":pictures/params_folder.png"); - case ConstructFolder: - case BodiesFolder: - return QIcon(":pictures/constr_folder.png"); - case GroupsFolder: - return QIcon(":pictures/constr_folder.png"); - case ConstructObject: - case GroupObject: - case BodiesObject: { - std::string aGroup; - if (theIndex.internalId() == ConstructObject) - aGroup = ModelAPI_ResultConstruction::group(); - else if (theIndex.internalId() == BodiesObject) - aGroup = ModelAPI_ResultBody::group(); - else if (theIndex.internalId() == GroupObject) - aGroup = ModelAPI_ResultGroup::group(); - if (aGroup.length() > 0) { - ObjectPtr anObject = aPartDoc->object(aGroup, theIndex.row()); - if (anObject && anObject->data() && - anObject->data()->execState() == ModelAPI_StateMustBeUpdated) { - return QIcon(":pictures/constr_object_modified.png"); - } - } - return QIcon(":pictures/constr_object.png"); - } - case HistoryObject: { - ObjectPtr aObject = aPartDoc->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber()); - FeaturePtr aFeature = std::dynamic_pointer_cast(aObject); - if (aFeature) - return PartSet_DocumentDataModel::featureIcon(aFeature); - } - } - break; - case Qt::ToolTipRole: - // return Tooltip - break; - case Qt::ForegroundRole: - if (theIndex.internalId() == HistoryObject) { - if (theIndex.row() > lastHistoryRow()) - return QBrush(Qt::lightGray); - } - return QBrush(myItemsColor); - } - return QVariant(); -} - -QVariant PartSet_PartDataModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - return QVariant(); -} - -int PartSet_PartDataModel::rowCount(const QModelIndex& parent) const -{ - if (!parent.isValid()) { - DocumentPtr aDoc = partDocument(); - if (aDoc.get()) { - return getRowsNumber() + aDoc->size(ModelAPI_Feature::group()); - } else - return 0; - } - switch (parent.internalId()) { - case ParamsFolder: - return partDocument()->size(ModelAPI_ResultParameter::group()); - case ConstructFolder: - return partDocument()->size(ModelAPI_ResultConstruction::group()); - case BodiesFolder: - return partDocument()->size(ModelAPI_ResultBody::group()); - case GroupsFolder: - return partDocument()->size(ModelAPI_ResultGroup::group()); - case HistoryObject: - { - ObjectPtr aObj = object(parent); - CompositeFeaturePtr aCompFeature = - std::dynamic_pointer_cast(aObj); - if (aCompFeature.get()) { - return aCompFeature->numberOfSubs(true); - } - } - } - return 0; -} - -int PartSet_PartDataModel::columnCount(const QModelIndex &parent) const -{ - return 2; -} - -QModelIndex PartSet_PartDataModel::index(int theRow, int theColumn, const QModelIndex &theParent) const -{ - if (!theParent.isValid()) { - switch (theRow) { - case 0: - return createIndex(theRow, theColumn, (qint32) ParamsFolder); - case 1: - return createIndex(theRow, theColumn, (qint32) ConstructFolder); - case 2: - return createIndex(theRow, theColumn, (qint32) BodiesFolder); - case 3: - { - int aSize = partDocument()->size(ModelAPI_ResultGroup::group()); - if (aSize > 0) - return createIndex(theRow, theColumn, (qint32) GroupsFolder); - else - return createIndex(theRow, theColumn, (qint32) HistoryObject); - } - default: - return createIndex(theRow, theColumn, (qint32) HistoryObject); - } - } else { - int aId = (int) theParent.internalId(); - switch (aId) { - case ParamsFolder: - return createIndex(theRow, theColumn, (qint32) ParamObject); - case ConstructFolder: - return createIndex(theRow, theColumn, (qint32) ConstructObject); - case BodiesFolder: - return createIndex(theRow, theColumn, (qint32) BodiesObject); - case GroupsFolder: - return createIndex(theRow, theColumn, (qint32) GroupObject); - case HistoryObject: - { - return createIndex(theRow, theColumn, (qint32) theParent.row()); - } - } - } - return QModelIndex(); -} - -QModelIndex PartSet_PartDataModel::parent(const QModelIndex& theIndex) const -{ - if (theIndex.internalId() >= 0) { - int aPRow = theIndex.internalId(); - return createIndex(aPRow, 0, (qint32) HistoryObject); - } - switch (theIndex.internalId()) { - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - case GroupsFolder: - case HistoryObject: - return QModelIndex(); - - case ParamObject: - return createIndex(0, 0, (qint32) ParamsFolder); - case ConstructObject: - return createIndex(1, 0, (qint32) ConstructFolder); - case BodiesObject: - return createIndex(2, 0, (qint32) BodiesFolder); - case GroupObject: - return createIndex(3, 0, (qint32) GroupsFolder); - } - return QModelIndex(); -} - -bool PartSet_PartDataModel::hasChildren(const QModelIndex& theParent) const -{ - return rowCount(theParent) > 0; -} - -DocumentPtr PartSet_PartDataModel::partDocument() const -{ - ResultPartPtr aPart = std::dynamic_pointer_cast(myPart->firstResult()); - if (aPart.get()) // this may be null is Part feature is disabled - return aPart->partDoc(); - return DocumentPtr(); -} - -ObjectPtr PartSet_PartDataModel::object(const QModelIndex& theIndex) const -{ - if (theIndex.internalId() >= 0) { - int aPRow = theIndex.internalId(); - ObjectPtr aObj = - partDocument()->object(ModelAPI_Feature::group(), aPRow - getRowsNumber()); - CompositeFeaturePtr aCompFeature = - std::dynamic_pointer_cast(aObj); - if (aCompFeature.get()) { - return aCompFeature->subFeature(theIndex.row(), true); - } - return ObjectPtr(); - } - switch (theIndex.internalId()) { - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - case GroupsFolder: - return ObjectPtr(); - - case ParamObject: - return partDocument()->object(ModelAPI_ResultParameter::group(), theIndex.row()); - case ConstructObject: - return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - case BodiesObject: - return partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row()); - case GroupObject: - return partDocument()->object(ModelAPI_ResultGroup::group(), theIndex.row()); - case HistoryObject: - return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber()); - } - return ObjectPtr(); -} - -bool PartSet_PartDataModel::hasDocument(const DocumentPtr& theDoc) const -{ - return (partDocument() == theDoc); -} - -QModelIndex PartSet_PartDataModel::findParent(const ObjectPtr& theObject) const -{ - return findGroup(theObject->groupName().c_str()); -} - -QModelIndex PartSet_PartDataModel::findGroup(const std::string& theGroup) const -{ - if (theGroup == ModelAPI_ResultParameter::group()) - return createIndex(0, 0, (qint32) ParamsFolder); - if (theGroup == ModelAPI_ResultConstruction::group()) - return createIndex(1, 0, (qint32) ConstructFolder); - if (theGroup == ModelAPI_ResultBody::group()) - return createIndex(2, 0, (qint32) BodiesFolder); - if (theGroup == ModelAPI_ResultGroup::group()) - return createIndex(3, 0, (qint32) GroupsFolder); - return QModelIndex(); -} - -QModelIndex PartSet_PartDataModel::objectIndex(const ObjectPtr& theObject) const -{ - QModelIndex aIndex; - if (theObject) { - if (part() == theObject) - return aIndex; - - std::string aGroup = theObject->groupName(); - DocumentPtr aDoc = theObject->document(); - int aNb = aDoc->size(aGroup); - int aRow = -1; - for (int i = 0; i < aNb; i++) { - if (aDoc->object(aGroup, i) == theObject) { - aRow = i; - break; - } - } - if (aRow == -1) - return aIndex; - if (aGroup == ModelAPI_ResultParameter::group()) - return createIndex(aRow, 0, (qint32) ParamObject); - else if (aGroup == ModelAPI_ResultConstruction::group()) - return createIndex(aRow, 0, (qint32) ConstructObject); - else if (aGroup == ModelAPI_ResultBody::group()) - return createIndex(aRow, 0, (qint32) BodiesObject); - else if (aGroup == ModelAPI_ResultGroup::group()) - return createIndex(aRow, 0, (qint32) GroupObject); - else - return createIndex(aRow + getRowsNumber(), 0, (qint32) HistoryObject); - } - return aIndex; -} - - -int PartSet_PartDataModel::getRowsNumber() const -{ - int aSize = partDocument()->size(ModelAPI_ResultGroup::group()); - if (aSize == 0) // If there are no groups then do not show group folder - return 3; - return 4; -} - -int PartSet_PartDataModel::lastHistoryRow() const -{ - DocumentPtr aDoc = partDocument(); - FeaturePtr aFeature = aDoc->currentFeature(true); - if (aFeature.get()) - return getRowsNumber() + aDoc->index(aFeature); - else - return getRowsNumber() - 1; -} - -void PartSet_PartDataModel::setLastHistoryItem(const QModelIndex& theIndex) -{ - SessionPtr aMgr = ModelAPI_Session::get(); - DocumentPtr aDoc = partDocument(); - std::string aOpName = tr("History change").toStdString(); - if (theIndex.internalId() == HistoryObject) { - ObjectPtr aObject = object(theIndex); - aMgr->startOperation(aOpName); - aDoc->setCurrentFeature(std::dynamic_pointer_cast(aObject), true); - aMgr->finishOperation(); - } else { - aMgr->startOperation(aOpName); - aDoc->setCurrentFeature(FeaturePtr(), true); - aMgr->finishOperation(); - } -} - -QModelIndex PartSet_PartDataModel::lastHistoryItem() const -{ - return index(lastHistoryRow(), 1); -} - -Qt::ItemFlags PartSet_PartDataModel::flags(const QModelIndex& theIndex) const -{ - // Disable sub-features at column 1 - if ((theIndex.column() == 1) && (theIndex.internalId() >= 0)) - return 0; - - Qt::ItemFlags aFlags = Qt::ItemIsSelectable; - if (object(theIndex)) { - aFlags |= Qt::ItemIsEditable; - } - - if (theIndex.internalId() == HistoryObject) { - if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1)) - aFlags |= Qt::ItemIsEnabled; - } else - aFlags |= Qt::ItemIsEnabled; - return aFlags; -} diff --git a/src/PartSet/PartSet_PartDataModel.h b/src/PartSet/PartSet_PartDataModel.h deleted file mode 100644 index 1012f2d6f..000000000 --- a/src/PartSet/PartSet_PartDataModel.h +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#ifndef PartSet_PartDataModel_H -#define PartSet_PartDataModel_H - -#include "PartSet.h" -#include "PartSet_DataTreeModel.h" - - -/**\class PartSet_PartDataModel - * \ingroup GUI - * \brief This is a data model for Object Browser (QTreeView). - * It represents data tree only of a one part - */ -class PartSet_PartDataModel : public PartSet_PartModel -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent a parent object - PartSet_PartDataModel(QObject* theParent); - virtual ~PartSet_PartDataModel(); - - // Reimpl from QAbstractItemModel - - /// Returns the data stored under the given role for the item referred to by the index. - /// \param theIndex a model index - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant data(const QModelIndex& theIndex, int theRole) const; - - /// Returns the data for the given role and section in the header with the specified orientation. - /// \param theSection a section - /// \param theOrient an orientation - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant headerData(int theSection, Qt::Orientation theOrient, - int theRole = Qt::DisplayRole) const; - - /// Returns the number of rows under the given parent. When the parent is valid it means that - /// rowCount is returning the number of children of parent. - /// \param theParent a parent model index - virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const; - - /// Returns the number of columns for the children of the given parent. - /// It has a one column - /// \param theParent a parent model index - virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const; - - /// Returns the item flags for the given index. - /// \param theIndex a model index - virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const; - - /// Returns the index of the item in the model specified by the given row, column and parent index. - /// \param theRow a row - /// \param theColumn a column - /// \param theParent a parent model index - virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent = - QModelIndex()) const; - - /// Returns the parent of the model item with the given index. - /// If the item has no parent, an invalid QModelIndex is returned. - /// \param theIndex a model index - virtual QModelIndex parent(const QModelIndex& theIndex) const; - - /// Returns true if parent has any children; otherwise returns false. - /// \param theParent a parent model index - virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const; - - //! Returns object by the given Model index. - //! Returns 0 if the given index is not index of a object - virtual ObjectPtr object(const QModelIndex& theIndex) const; - - //! Returns QModelIndex which corresponds to the given object - //! If the object is not found then index is not valid - virtual QModelIndex objectIndex(const ObjectPtr& theObject) const; - - //! Returns true if the given document is a sub-document of this tree - virtual bool hasDocument(const DocumentPtr& theDoc) const; - - //! Returns parent index of the given object - virtual QModelIndex findParent(const ObjectPtr& theObject) const; - - //! Returns index corresponded to the group - virtual QModelIndex findGroup(const std::string& theGroup) const; - - //! Set an Index which will be considered as a last history index - //! \param theIndex a last index for history - void setLastHistoryItem(const QModelIndex& theIndex); - - //! Returns last history item - QModelIndex lastHistoryItem() const; - - private: - - //! Returns document of the current part - DocumentPtr partDocument() const; - - //! Returns defult number of rows - int getRowsNumber() const; - - int lastHistoryRow() const; - - //! Types of QModelIndexes - //! All types have negative Id's. Positive Id means sub-feature and contains row of its parent - enum DataIds - { - //MyRoot, - ParamsFolder = -100, - ParamObject, - ConstructFolder, - ConstructObject, - BodiesFolder, - BodiesObject, - GroupsFolder, - GroupObject, - HistoryObject - }; -}; - -#endif diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 8344edf2b..94540d988 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -164,7 +164,7 @@ public: /// Saves the current selection in the viewer into an internal container /// It obtains the selected attributes. The highlighted objects can be processes as the selected ones - /// \param theHighlightedUse a boolean flag + /// \param theHighlightedOnly a boolean flag void storeSelection(const bool theHighlightedOnly = false); /// Restores previously saved selection state diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index ad5fbcbcf..f204d3df4 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -71,22 +71,6 @@ class PARTSET_EXPORT PartSet_Tools /// Returns pointer to the root document. static std::shared_ptr document(); - /// Find an attribute which corresponds to a given pont coordinates - /// \param theSketch the sketch feature - /// \param theX X coordinate - /// \param theY Y coordinate - /// \param theTolerance tolerance - /// \param theIgnore list of features which has to be ignored - //static std::shared_ptr findAttributePoint(CompositeFeaturePtr theSketch, - // double theX, double theY, double theTolerance, const QList& theIgnore = QList()); - - /// Returns a point attribute of the feature by the coordinates if it is - /// \param theFeature the feature - /// \param theX the horizontal coordinate - /// \param theY the vertical coordinate - //static std::shared_ptr getFeaturePoint(FeaturePtr theFeature, - // double theX, double theY); - /// \brief Save the double to the feature. If the attribute is double, it is filled. /// \param theFeature the feature /// \param theX the horizontal coordinate @@ -201,12 +185,14 @@ class PARTSET_EXPORT PartSet_Tools /** * Finds an attribute value in attribute reference attribute value * \param theAttribute - an attribure reference filled with an attribute + * \param theWorkshop a reference to workshop * \return a geometry shape */ static GeomShapePtr findShapeBy2DPoint(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop); - /* Returns point of coincidence feature + /** + * Returns point of coincidence feature * \param theFeature the coincidence feature * \param theAttribute the attribute name */ diff --git a/src/PartSet/PartSet_TopDataModel.cpp b/src/PartSet/PartSet_TopDataModel.cpp deleted file mode 100644 index 67f8cb8e8..000000000 --- a/src/PartSet/PartSet_TopDataModel.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -#include "PartSet_TopDataModel.h" -#include "PartSet_Module.h" -#include "PartSet_DocumentDataModel.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - - -PartSet_TopDataModel::PartSet_TopDataModel(QObject* theParent) - : PartSet_FeaturesModel(theParent) -{ -} - -PartSet_TopDataModel::~PartSet_TopDataModel() -{ -} - -QVariant PartSet_TopDataModel::data(const QModelIndex& theIndex, int theRole) const -{ - if (theIndex.column() == 1) - return QVariant(); - - switch (theRole) { - case Qt::DisplayRole: - // return a name - switch (theIndex.internalId()) { - case ParamsFolder: - return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); - case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row()); - if (aObject) { - ResultParameterPtr aParam = std::dynamic_pointer_cast(aObject); - AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); - QString aVal = QString::number(aValueAttribute->value()); - QString aTitle = QString(aObject->data()->name().c_str()); - return aTitle + " = " + aVal; - } - } - break; - case ConstructFolder: - return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); - case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), - theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); - } - break; - //case GroupsFolder: - // return tr("Groups") + QString(" (%1)").arg(rowCount(theIndex)); - //case GroupObject: { - // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - // ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultGroup::group(), - // theIndex.row()); - // if (aObject) - // return aObject->data()->name().c_str(); - //} - // break; - } - break; - - case Qt::DecorationRole: - { - // return an Icon - switch (theIndex.internalId()) { - case ParamsFolder: - return QIcon(":pictures/params_folder.png"); - case ConstructFolder: - return QIcon(":pictures/constr_folder.png"); - case ConstructObject: - return QIcon(":pictures/constr_object.png"); - //case GroupsFolder: - // return QIcon(":pictures/constr_folder.png"); - } - } - break; - - case Qt::ToolTipRole: - // return Tooltip - break; - case Qt::ForegroundRole: - return QBrush(myItemsColor); - break; - } - return QVariant(); -} - -QVariant PartSet_TopDataModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - return QVariant(); -} - -int PartSet_TopDataModel::rowCount(const QModelIndex& theParent) const -{ - if (!theParent.isValid()) - return 2; // In case of groups using it has to be +1 - - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - if (theParent.internalId() == ParamsFolder) - return aRootDoc->size(ModelAPI_ResultParameter::group()); - - if (theParent.internalId() == ConstructFolder) - return aRootDoc->size(ModelAPI_ResultConstruction::group()); - - //if (theParent.internalId() == GroupsFolder) - // return aRootDoc->size(ModelAPI_ResultGroup::group()); - - return 0; -} - -int PartSet_TopDataModel::columnCount(const QModelIndex &parent) const -{ - return 1; -} - -QModelIndex PartSet_TopDataModel::index(int theRow, int theColumn, const QModelIndex& theParent) const -{ - if (!theParent.isValid()) { - switch (theRow) { - case 0: - return createIndex(theRow, theColumn, (qint32) ParamsFolder); - case 1: - return createIndex(theRow, theColumn, (qint32) ConstructFolder); - //case 2: - // return createIndex(theRow, theColumn, (qint32) GroupsFolder); - } - } else { - if (theParent.internalId() == ParamsFolder) - return createIndex(theRow, theColumn, (qint32) ParamObject); - - if (theParent.internalId() == ConstructFolder) - return createIndex(theRow, theColumn, (qint32) ConstructObject); - - //if (theParent.internalId() == GroupsFolder) - // return createIndex(theRow, theColumn, (qint32) GroupObject); - } - return QModelIndex(); -} - -QModelIndex PartSet_TopDataModel::parent(const QModelIndex& theIndex) const -{ - int aId = (int) theIndex.internalId(); - switch (aId) { - case ParamsFolder: - case ConstructFolder: - //case GroupsFolder: - return QModelIndex(); - case ParamObject: - return createIndex(0, 0, (qint32) ParamsFolder); - case ConstructObject: - return createIndex(1, 0, (qint32) ConstructFolder); - //case GroupObject: - // return createIndex(2, 0, (qint32) GroupsFolder); - } - return QModelIndex(); -} - -bool PartSet_TopDataModel::hasChildren(const QModelIndex& theParent) const -{ - return rowCount(theParent) > 0; -} - -ObjectPtr PartSet_TopDataModel::object(const QModelIndex& theIndex) const -{ - switch (theIndex.internalId()) { - case ParamsFolder: - case ConstructFolder: - return ObjectPtr(); - case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - return aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row()); - } - case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - } - //case GroupObject: { - // DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - // return aRootDoc->object(ModelAPI_ResultGroup::group(), theIndex.row()); - //} - } - return ObjectPtr(); -} - -QModelIndex PartSet_TopDataModel::findParent(const ObjectPtr& theObject) const -{ - return findGroup(theObject->groupName().c_str()); -} - -QModelIndex PartSet_TopDataModel::findGroup(const std::string& theGroup) const -{ - if (theGroup == ModelAPI_ResultParameter::group()) - return createIndex(0, 0, (qint32) ParamsFolder); - if (theGroup == ModelAPI_ResultConstruction::group()) - return createIndex(1, 0, (qint32) ConstructFolder); - //if (theGroup == ModelAPI_ResultGroup::group()) - // return createIndex(2, 0, (qint32) ConstructFolder); - return QModelIndex(); -} - -QModelIndex PartSet_TopDataModel::objectIndex(const ObjectPtr& theObject) const -{ - QModelIndex aIndex; - if (theObject) { - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - std::string aGroup = theObject->groupName(); - int aNb = aRootDoc->size(aGroup); - int aRow = -1; - for (int i = 0; i < aNb; i++) { - if (aRootDoc->object(aGroup, i) == theObject) { - aRow = i; - break; - } - } - if (aRow != -1) { - if (aGroup == ModelAPI_ResultParameter::group()) - return createIndex(aRow, 0, (qint32) ParamObject); - if (aGroup == ModelAPI_ResultConstruction::group()) - return createIndex(aRow, 0, (qint32) ConstructObject); - //if (aGroup == ModelAPI_ResultGroup::group()) - // return createIndex(aRow, 0, (qint32) GroupObject); - } - } - return aIndex; -} - diff --git a/src/PartSet/PartSet_TopDataModel.h b/src/PartSet/PartSet_TopDataModel.h deleted file mode 100644 index 8b72db69e..000000000 --- a/src/PartSet/PartSet_TopDataModel.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> -#ifndef PartSet_TopDataModel_H -#define PartSet_TopDataModel_H - -#include "PartSet.h" -#include "PartSet_DataTreeModel.h" - -/**\class PartSet_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 PARTSET_EXPORT PartSet_TopDataModel : public PartSet_FeaturesModel -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent a parent object - PartSet_TopDataModel(QObject* theParent); - virtual ~PartSet_TopDataModel(); - - // Reimpl from QAbstractItemModel - - /// Returns the data stored under the given role for the item referred to by the index. - /// \param theIndex a model index - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant data(const QModelIndex& theIndex, int theRole) const; - - /// Returns the data for the given role and section in the header with the specified orientation. - /// \param theSection a section - /// \param theOrient an orientation - /// \param theRole a data role (see Qt::ItemDataRole) - virtual QVariant headerData(int theSection, Qt::Orientation theOrient, - int theRole = Qt::DisplayRole) const; - - /// Returns the number of rows under the given parent. When the parent is valid it means that - /// rowCount is returning the number of children of parent. - /// \param theParent a parent model index - virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const; - - /// Returns the number of columns for the children of the given parent. - /// It has a one column - /// \param theParent a parent model index - virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const; - - - /// Returns the index of the item in the model specified by the given row, column and parent index. - /// \param theRow a row - /// \param theColumn a column - /// \param theParent a parent model index - virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent = - QModelIndex()) const; - - /// Returns the parent of the model item with the given index. - /// If the item has no parent, an invalid QModelIndex is returned. - /// \param theIndex a model index - virtual QModelIndex parent(const QModelIndex& theIndex) const; - - /// Returns true if parent has any children; otherwise returns false. - /// \param theParent a parent model index - virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const; - - //! Returns object by the given Model index. - //! Returns 0 if the given index is not index of a object - virtual ObjectPtr object(const QModelIndex& theIndex) const; - - //! Returns QModelIndex which corresponds to the given object - //! If the object is not found then index is not valid - virtual QModelIndex objectIndex(const ObjectPtr& theObject) const; - - //! Returns parent index of the given object - virtual QModelIndex findParent(const ObjectPtr& theObject) const; - - //! Returns index corresponded to the group - virtual QModelIndex findGroup(const std::string& theGroup) const; - - private: - //! Types of QModelIndexes - enum DataIds - { - ParamsFolder, - ParamObject, - ConstructFolder, - ConstructObject - //GroupsFolder, - //GroupObject - }; - -}; - -#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 0e02a0e9f..23706f81c 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -126,6 +126,7 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator //! Returns true if the attribute is good for the feature attribute //! \param theAttribute an attribute //! \param theArguments a list of arguments (names of attributes to check) + //! \param theError an output error string virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const; @@ -149,6 +150,7 @@ class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator //! Returns true if the attribute is good for the feature attribute //! \param theAttribute an attribute //! \param theArguments a list of arguments (names of attributes to check) + //! \param theError an output error string virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const; @@ -165,6 +167,7 @@ class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator //! returns true if attribute is valid //! \param theAttribute the checked attribute //! \param theArguments arguments of the attribute + //! \param theError an output error string virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const; diff --git a/src/PartSet/PartSet_WidgetMultiSelector.h b/src/PartSet/PartSet_WidgetMultiSelector.h index bf745d643..5207201cb 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.h +++ b/src/PartSet/PartSet_WidgetMultiSelector.h @@ -48,7 +48,7 @@ Q_OBJECT protected: /// Checks the widget validity. By default, it returns true. - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); @@ -67,7 +67,9 @@ protected: GeomShapePtr& theShape); protected: + /// Manager of external objects PartSet_ExternalObjectsMgr* myExternalObjectMgr; + /// Pointer to a sketch CompositeFeaturePtr mySketch; }; diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index a07107f66..c85ad2082 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -56,6 +56,7 @@ Q_OBJECT /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValues the wrapped widget values + /// \param theToValidate a validation flag virtual bool setSelection(QList& theValues, const bool theToValidate); @@ -114,6 +115,7 @@ protected: /// Returns true if the feature contains Point2D attribute with the same coordinates /// The attribute of the widget is not processed. + /// \param theFeature a feature /// \param theX the X coordinate /// \param theY the Y coordinate /// \return boolean result diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h index 889ee2ed0..f300f2fb8 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.h +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.h @@ -90,10 +90,16 @@ private slots: void onValuesChanged(); protected: + /// A reference to workshop ModuleBase_IWorkshop* myWorkshop; - PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP + + /// A manager to lock/unlock Apply button in PP + PartSet_LockApplyMgr* myLockApplyMgr; + /// A name of the first point std::string myFirstPntName; + + /// Reference to sketch CompositeFeaturePtr mySketch; }; diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h index a2ba2d2bd..4d2da507b 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.h +++ b/src/PartSet/PartSet_WidgetShapeSelector.h @@ -44,7 +44,7 @@ Q_OBJECT protected: /// Checks the widget validity. By default, it returns true. - /// \param theValue a selected presentation in the view + /// \param thePrs a selected presentation in the view /// \return a boolean value virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); @@ -83,7 +83,9 @@ protected: void setPointAttribute(ObjectPtr theSelectedObject, GeomShapePtr theShape); protected: + /// A reference to external objects manager PartSet_ExternalObjectsMgr* myExternalObjectMgr; + /// Pointer to a sketch CompositeFeaturePtr mySketch; }; diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index 5f1d8d996..f92285d37 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -30,6 +30,7 @@ Q_OBJECT public: /// Constructor /// \param theParent the parent object + /// \param theModule a reference to a module object /// \param theData the widget configuation. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule, diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 2bc8d85d6..25807c81b 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -40,8 +40,10 @@ Q_OBJECT public: /// Constructor /// \param theParent the parent object + /// \param theWorkshop a reference to workshop /// \param theData the widget configuation. The attribute of the model widget is obtained from /// \param theParentId is Id of a parent of the current attribute + /// \param toShowConstraints a current show constraints state PartSet_WidgetSketchLabel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId, bool toShowConstraints); @@ -53,6 +55,7 @@ Q_OBJECT /// The method is called by the current operation to process the operation preselection. /// It is redefined to do nothing if the plane of the sketch has been already set. /// \param theValues the wrapped selection values + /// \param theToValidate a validation flag virtual bool setSelection(QList& theValues, const bool theToValidate); @@ -71,12 +74,15 @@ Q_OBJECT virtual void setHighlighted(bool) { /*do nothing*/ }; virtual void enableFocusProcessing(); + /// Set show constraints state + /// \param theOn a flag show constraints or not void showConstraints(bool theOn); signals: /// Signal on plane selection void planeSelected(const std::shared_ptr& thePln); + /// A show constraint toggled signal void showConstraintToggled(bool); protected: @@ -92,7 +98,7 @@ protected: virtual void restoreAttributeValue(const bool theValid); /// Fills the attribute with the value of the selected owner - /// \param theOwner a selected owner + /// \param thePrs a selected owner virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// Saves the internal parameters to the given feature diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index db0e71e85..40de3f533 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -49,7 +49,10 @@ Q_OBJECT /// Connect to viewer from workshop. Has to called at creation of viewer. void connectViewer(); + /// Add menu items for Object browser pop-up void addObjBrowserMenu(QMenu*) const; + + /// Add menu items for Viewer pop-up void addViewerMenu(QMenu*) const; /// Returns a list of object group names of the action diff --git a/src/XGUI/XGUI_CustomPrs.h b/src/XGUI/XGUI_CustomPrs.h index a1e636a5c..36014cfec 100644 --- a/src/XGUI/XGUI_CustomPrs.h +++ b/src/XGUI/XGUI_CustomPrs.h @@ -25,6 +25,9 @@ public: virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theCustomPrs); + /// Returns color of a result object + /// \param theResult a result object + /// \param theColor a color in form of RGB vector static void getResultColor(ResultPtr theResult, std::vector& theColor); }; diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 2485d367c..bac4aedae 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -58,7 +58,7 @@ ModelAPI_Document* getSubDocument(void* theObj) // Constructor ************************************************* -XGUI_DataModel::XGUI_DataModel(QObject* theParent) : ModuleBase_IDocumentDataModel(theParent) +XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent) { myXMLReader.readAll(); diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index 9c5966277..d08ccc42a 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -13,9 +13,9 @@ #include #include #include -#include #include +#include /**\class XGUI_DataModel * \ingroup GUI @@ -27,10 +27,12 @@ * - An index which contains internal pointer as ModelAPI_Object its the object * - An index which contains internal pointer as ModelAPI_Document is a folder which belongs to this document */ -class XGUI_EXPORT XGUI_DataModel : public ModuleBase_IDocumentDataModel, public Events_Listener +class XGUI_EXPORT XGUI_DataModel : public QAbstractItemModel, public Events_Listener { Q_OBJECT public: + /// Constructor + /// \param theParent a parent object XGUI_DataModel(QObject* theParent); /// Event Listener method diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index c4ac99b1c..b189189f6 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -118,7 +118,7 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly void closeLocalContexts(const bool theUpdateViewer = true); - // Remove default selection filters of the module from the current viewer + /// Remove default selection filters of the module from the current viewer void deactivateSelectionFilters(); /// \brief Add selection filter @@ -145,12 +145,15 @@ class XGUI_EXPORT XGUI_Displayer: public QObject void updateViewer() const; /// Activate interactive context - /// \param theIO - /// \param theMode + /// \param theIO an interactive object + /// \param theMode activation mode + /// \param theUpdateViewer update viewer flag void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode, const bool theUpdateViewer) const; /// Activate interactive context. It is necessary to call ClearOutdatedSelection after deactivation + /// \param theIO an interactive object + /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode = -1) const; /// Searches the interactive object by feature @@ -186,6 +189,7 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// Activates in local context displayed outside of the context. /// \param theModes - modes on which it has to be activated (can be empty) /// \param theObjList - list of objects which has to be activated. + /// \param theUpdateViewer an update viewer flag void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList, const bool theUpdateViewer = true); diff --git a/src/XGUI/XGUI_ErrorMgr.h b/src/XGUI/XGUI_ErrorMgr.h index c339d6cf0..89deaeef9 100644 --- a/src/XGUI/XGUI_ErrorMgr.h +++ b/src/XGUI/XGUI_ErrorMgr.h @@ -18,14 +18,24 @@ class QAction; class QDialog; class QLabel; +/** + * \class XGUI_ErrorMgr + * \ingroup GUI + * \brief Class of Errors manager object + */ class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr { Q_OBJECT public: + /// Constructor + /// \param theParent a parent object + /// \param theWorkshop a workshop object XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop); /// Virtual destructor virtual ~XGUI_ErrorMgr(); + /// Update actions for the given feature + /// \param theFeature a feature void updateActions(const FeaturePtr& theFeature); /// Update enable state of AcceptAll action if the feature uses it diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 27aaa47c8..598c7a22e 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -63,12 +63,12 @@ Q_OBJECT virtual ModuleBase_Operation* findStartedOperation(const QString& theId); //! Returns true if the operation with id theId can be stopped. The operation manager is called. - //! \param theId a stopped operation + //! \param theOperation a stopped operation //! \return boolean result virtual bool canStopOperation(ModuleBase_Operation* theOperation); //! Aborts the operation. The operation manager is called. - //! \param theId an aborted operation + //! \param theOperation an aborted operation void abortOperation(ModuleBase_Operation* theOperation); //! Returns AIS object by data object diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index c43ca86fa..d89d6171b 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -44,7 +43,7 @@ public: { QLineEdit* aEditor = dynamic_cast(editor); if (aEditor) { - ModuleBase_IDocumentDataModel* aModel = myTreedView->dataModel(); + XGUI_DataModel* aModel = myTreedView->dataModel(); ObjectPtr aObj = aModel->object(index); if (aObj.get() != NULL) { aEditor->setText(aObj->data()->name().c_str()); @@ -69,19 +68,17 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent) setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this)); -#ifndef ModuleDataModel connect(this, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(onDoubleClick(const QModelIndex&))); -#endif } XGUI_DataTree::~XGUI_DataTree() { } -ModuleBase_IDocumentDataModel* XGUI_DataTree::dataModel() const +XGUI_DataModel* XGUI_DataTree::dataModel() const { - return static_cast(model()); + return static_cast(model()); } void XGUI_DataTree::contextMenuEvent(QContextMenuEvent* theEvent) @@ -95,7 +92,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (aEditor) { QString aName = aEditor->text(); QModelIndexList aIndexList = selectionModel()->selectedIndexes(); - ModuleBase_IDocumentDataModel* aModel = dataModel(); + XGUI_DataModel* aModel = dataModel(); ObjectPtr aObj = aModel->object(aIndexList.first()); SessionPtr aMgr = ModelAPI_Session::get(); aMgr->startOperation("Rename"); @@ -112,8 +109,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor) void XGUI_DataTree::clear() { - ModuleBase_IDocumentDataModel* aModel = dataModel(); - aModel->clear(); + dataModel()->clear(); reset(); } @@ -134,7 +130,7 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex) // When operation is opened then we can not change history if (aMgr->isOperation()) return; - ModuleBase_IDocumentDataModel* aModel = dataModel(); + XGUI_DataModel* aModel = dataModel(); if (aModel->flags(theIndex) == 0) return; ObjectPtr aObj = aModel->object(theIndex); @@ -219,13 +215,11 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setFrameShape(myTreeView->frameShape()); aLabelWgt->setFrameShadow(myTreeView->frameShadow()); -#ifndef ModuleDataModel myDocModel = new XGUI_DataModel(this); myTreeView->setModel(myDocModel); QItemSelectionModel* aSelMod = myTreeView->selectionModel(); connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); -#endif connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onLabelContextMenuRequested(const QPoint&))); @@ -382,18 +376,6 @@ void XGUI_ObjectsBrowser::clearContent() myTreeView->clear(); } -#ifdef ModuleDataModel -void XGUI_ObjectsBrowser::setDataModel(ModuleBase_IDocumentDataModel* theModel) -{ - myDocModel = theModel; - //myDocModel = new XGUI_DataModel(this); - myTreeView->setModel(myDocModel); - QItemSelectionModel* aSelMod = myTreeView->selectionModel(); - connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), - this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); -} -#endif - void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected) { @@ -404,11 +386,7 @@ QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) { QObjectPtrList aList; QModelIndexList aIndexes = selectedIndexes(); -#ifdef ModuleDataModel - ModuleBase_IDocumentDataModel* aModel = dataModel(); -#else XGUI_DataModel* aModel = dataModel(); -#endif QModelIndexList::const_iterator aIt; for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) { if ((*aIt).column() == 0) { diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index d92788abe..53e9a5fb5 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -16,8 +16,6 @@ class ModuleBase_IDocumentDataModel; class QLineEdit; class XGUI_DataModel; -//#define ModuleDataModel - /** * \ingroup GUI * Implementation of Data Tree object for Object Browser @@ -33,7 +31,7 @@ Q_OBJECT virtual ~XGUI_DataTree(); /// Returns current data model - ModuleBase_IDocumentDataModel* dataModel() const; + XGUI_DataModel* dataModel() const; signals: //! Emited on context menu request @@ -47,6 +45,7 @@ public slots: /// Commit modified data (used for renaming of objects) virtual void commitData(QWidget* theEditor); + /// A slot which is called on mouse double click void onDoubleClick(const QModelIndex&); protected: @@ -72,17 +71,10 @@ Q_OBJECT virtual ~XGUI_ObjectsBrowser(); //! Returns Model which provides access to data objects -#ifdef ModuleDataModel - ModuleBase_IDocumentDataModel* dataModel() const - { - return myDocModel; - } -#else XGUI_DataModel* dataModel() const { return myDocModel; } -#endif //! Returns list of currently selected objects //! \param theIndexes - output list of corresponded indexes (can be NULL) @@ -113,11 +105,6 @@ Q_OBJECT /// Resets the object browser into initial state void clearContent(); - /// Set Data Model for the Object Browser -#ifdef ModuleDataModel - void setDataModel(ModuleBase_IDocumentDataModel* theModel); -#endif - public slots: //! Called on Edit command request void onEditItem(); @@ -152,11 +139,7 @@ signals: void closeDocNameEditing(bool toSave); //! Internal model -#ifdef ModuleDataModel - ModuleBase_IDocumentDataModel* myDocModel; -#else XGUI_DataModel* myDocModel; -#endif QLineEdit* myActiveDocLbl; XGUI_DataTree* myTreeView; }; diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 3cd0f9a37..5ea3af47c 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -35,10 +35,14 @@ Q_OBJECT public: /// Constructor /// \param theParent the parent + /// \param theWorkshop a reference to workshop XGUI_OperationMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop); + /// Destructor virtual ~XGUI_OperationMgr(); + /// Set reference to workshop + /// \param theWorkshop reference to workshop void setWorkshop(ModuleBase_IWorkshop* theWorkshop) { myWorkshop = theWorkshop; }; @@ -139,14 +143,6 @@ signals: /// Emitted when current operation is aborted void operationAborted(ModuleBase_Operation* theOperation); - /// Signal is emitted after the apply enable state changed. - //void validationStateChanged(bool); - - /// Signal is emitted after the model is modified. It is emitted for all active operations. - /// \param theFeatureKind a feature id - /// \param theState validity of the operation with the feature kind - //void nestedStateChanged(const std::string& theFeatureKind, const bool theState); - /// Signal is emitted after the current operation is filled with existing preselection. void operationActivatedByPreselection(); diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index aba338e69..083242fd1 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -115,6 +115,7 @@ Q_OBJECT virtual void activateWidget(ModuleBase_ModelWidget* theWidget); protected: + /// A header widget QWidget* myHeaderWidget; private: diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index 807e1868f..50c622f01 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -48,13 +48,14 @@ class XGUI_EXPORT XGUI_SalomeConnector //! Creates a feature (command) in SALOME desktop //! \param theWBName - name of toolbar (workbench) //! \param theInfo - information about action (icon, text, etc) + //! \param theNestedActions a list of nested actions virtual QAction* addFeatureOfNested(const QString& theWBName, const ActionInfo& theInfo, const QList& theNestedActions) = 0; //! Returns true if the feature action is a nested action, in other words, //! it is created by addFeatureOfNested(). - //! \param theId - an action of a feature + //! \param theAction - an action of a feature //! returns boolean result virtual bool isFeatureOfNested(const QAction* theAction) = 0; @@ -78,6 +79,9 @@ class XGUI_EXPORT XGUI_SalomeConnector virtual void addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition = 10) = 0; + /// Add an action into tool bar + /// \param theAction the Action object + /// \param theToolBarTitle the toolbar name virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 0; //! Returns desktop window of SALOME diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index 178b8b2a4..7cf55846e 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -54,7 +54,7 @@ QString XGUI_EXPORT file(const QString& path, bool withExt = true); */ QString XGUI_EXPORT addSlash(const QString& path); -/// The model concerning tools +// The model concerning tools /*! Returns true if the feature is a model object @@ -73,18 +73,22 @@ std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature); all objects in the list are not PartSet document. It shows the warning control if the result is false. \param theParent a parent for the warning control - \param theList a list of object + \param aList a list of object \return a boolean value */ bool XGUI_EXPORT canRemoveOrRename(QWidget* theParent, const QObjectPtrList& aList); /*! - Returns true if theObject can be renamed in theName + Check possibility to rename object + \param theParent a parent widget + \param theObject an object to rename + \param theName a name */ bool canRename(QWidget* theParent, const ObjectPtr& theObject, const QString& theName); /*! Returns true if there are no parts in the document, which are not activated + \param theNotActivatedNames out string which contains not activated names \return a boolean value */ bool XGUI_EXPORT allDocumentsActivated(QString& theNotActivatedNames); @@ -115,6 +119,8 @@ bool XGUI_EXPORT isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& which has the object as a sub object. \param theSourceObject an object, which references are searched \param theObject an intermediate recursive object, should be set in the source object + \param theDirectRefFeatures direct references + \param theIndirectRefFeatures indirect references \param theAlreadyProcessed set of processed elements, used for optimization (do not reanalyse processed) \return a boolean value */ diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 971502814..4f20df5ef 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -973,9 +973,6 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) aObjDock->setStyleSheet( "::title { position: relative; padding-left: 5px; text-align: left center }"); myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock); -#ifdef ModuleDataModel - myObjectBrowser->setDataModel(myModule->dataModel()); -#endif myModule->customizeObjectBrowser(myObjectBrowser); aObjDock->setWidget(myObjectBrowser); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 03195947a..628e721ce 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -62,10 +62,10 @@ Q_OBJECT //! Starting of the application void startApplication(); - // Activates the module controls. Should be called after module creation + /// Activates the module controls. Should be called after module creation void activateModule(); - // Deactivates the module controls. Should be called after module creation + /// Deactivates the module controls. Should be called after module creation void deactivateModule(); //! Returns main window (Desktop) of the application diff --git a/src/XGUI/XGUI_WorkshopListener.h b/src/XGUI/XGUI_WorkshopListener.h index 14c2edbfd..cf611cb26 100755 --- a/src/XGUI/XGUI_WorkshopListener.h +++ b/src/XGUI/XGUI_WorkshopListener.h @@ -28,9 +28,8 @@ class XGUI_EXPORT XGUI_WorkshopListener : public QObject, public Events_Listener { Q_OBJECT public: - /// Constructor - /// \param theConnector a Salome connector object. - /// Used only if the workshop is launched in Salome environment + /// Constructor. Used only if the workshop is launched in Salome environment + /// \param theWorkshop a reference to workshop. XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop); virtual ~XGUI_WorkshopListener(); @@ -44,12 +43,6 @@ signals: /// Emitted when error in applivation happens void errorOccurred(const QString&); -protected slots: - /// Updates Apply All button state of the feature to the state if the feature has the button - /// \param theFeatureId an index of the feature, the action is searched, which state is to be changed - /// \param theState an action enable state - //void onNestedStateChanged(const std::string& theFeatureId, const bool theState); - protected: /// Procedure to process postponed events bool event(QEvent * theEvent); -- 2.39.2