From: vsv Date: Mon, 19 Aug 2019 16:31:40 +0000 (+0300) Subject: Crate control X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FPublish_To_Study;p=modules%2Fshaper.git Crate control --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudy.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudy.py index fe050bd20..a96a47409 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudy.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudy.py @@ -57,6 +57,13 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): def initAttributes(self): self.data().addAttribute(self.TREE_ID(), ModelAPI.ModelAPI_AttributeRefList_typeId()) + def isMacro(self): + """ + Override Feature.isMacro(). + Rectangle feature is macro: removes itself on the creation transaction finish. + """ + return True + ## Exports all shapes and groups into the GEOM module. def execute(self): pass diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 56ca62630..470bada75 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -39,6 +39,7 @@ class ModuleBase_Operation; class ModuleBase_ISelectionActivate; class ModuleBase_ViewerPrs; class QMainWindow; +class ModuleBase_ITreeNode; /** * \ingroup GUI @@ -152,6 +153,9 @@ Q_OBJECT //! \param theAIS the object which has to be activated virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS) = 0; + //! Returns pointer on data structure used in Object browser + virtual ModuleBase_ITreeNode* dataTreeRoot() const = 0; + signals: /// Signal selection changed. void selectionChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp index 7539f1aa6..82659c1dc 100644 --- a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp +++ b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.cpp @@ -19,10 +19,60 @@ #include +#include +#include #include #include +#include + + + +QVariant ModuleBase_CheckDataModel::data(const QModelIndex& theIndex, int theRole) const +{ + if (theIndex.isValid()) { + ModuleBase_ITreeNode* aNode = (ModuleBase_ITreeNode*)theIndex.internalPointer(); + return aNode->data(1, theRole); + } + return QVariant(); +} + +QModelIndex ModuleBase_CheckDataModel::index(int theRow, int theCol, + const QModelIndex& theParent) const +{ + ModuleBase_ITreeNode* aParentNode = (theParent.isValid()) ? + (ModuleBase_ITreeNode*)theParent.internalPointer() : myRoot; + ModuleBase_ITreeNode* aSubNode = aParentNode->subNode(theRow); + assert(aSubNode); + return createIndex(theRow, theCol, aSubNode); +} + +QModelIndex ModuleBase_CheckDataModel::parent(const QModelIndex& theIndex) const +{ + if (theIndex.isValid()) { + ModuleBase_ITreeNode* aNode = (ModuleBase_ITreeNode*)theIndex.internalPointer(); + ModuleBase_ITreeNode* aParent = aNode->parent(); + if (aParent == myRoot) { + return QModelIndex(); + } + else { + int aRow = aParent->parent()->nodeRow(aNode); + return createIndex(aRow, 0, aNode); + } + } + return QModelIndex(); +} + +int ModuleBase_CheckDataModel::rowCount(const QModelIndex& theParent) const +{ + ModuleBase_ITreeNode* aParentNode = (theParent.isValid()) ? + (ModuleBase_ITreeNode*)theParent.internalPointer() : myRoot; + return aParentNode->childrenCount(); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// ModuleBase_WidgetTreeDataSelect::ModuleBase_WidgetTreeDataSelect(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData) @@ -31,6 +81,9 @@ ModuleBase_WidgetTreeDataSelect::ModuleBase_WidgetTreeDataSelect(QWidget* thePar QVBoxLayout* aLayout = new QVBoxLayout(this); myTreeView = new QTreeView(this); + myTreeView->setModel(new ModuleBase_CheckDataModel(this, myWorkshop->dataTreeRoot())); + myTreeView->setHeaderHidden(true); + myTreeView->setColumnWidth(0, 200); aLayout->addWidget(myTreeView); } diff --git a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h index 8f4c8c342..c96cbac58 100644 --- a/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h +++ b/src/ModuleBase/ModuleBase_WidgetTreeDataSelect.h @@ -22,6 +22,7 @@ #include #include +#include class QTreeView; @@ -60,4 +61,31 @@ private: QTreeView* myTreeView; }; -#endif \ No newline at end of file + +class ModuleBase_ITreeNode; + +class ModuleBase_CheckDataModel : public QAbstractItemModel +{ + Q_OBJECT +public: + /// Constructor + /// \param theParent a parent object + ModuleBase_CheckDataModel(QObject* theParent, ModuleBase_ITreeNode* theRoot) : + QAbstractItemModel(theParent), myRoot(theRoot) {} + + virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const { return 1; } + + virtual QVariant data(const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const; + + virtual QModelIndex index(int theRow, int theCol, + const QModelIndex& theParent = QModelIndex()) const; + + virtual QModelIndex parent(const QModelIndex& theIndex) const; + + virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const; + +private: + ModuleBase_ITreeNode* myRoot; +}; + +#endif diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 61bc814f4..adf178e84 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -29,6 +29,7 @@ #include "XGUI_ActionsMgr.h" #include "XGUI_ErrorMgr.h" #include "XGUI_ObjectsBrowser.h" +#include "XGUI_DataModel.h" #include #include @@ -232,4 +233,9 @@ void XGUI_ModuleConnector::applyCurrentSelectionModes(const AISObjectPtr& theAIS { Handle(AIS_InteractiveObject) anIO = theAIS->impl(); myWorkshop->selectionActivate()->activate(anIO, false); -} \ No newline at end of file +} + +ModuleBase_ITreeNode* XGUI_ModuleConnector::dataTreeRoot() const +{ + return myWorkshop->objectBrowser()->dataModel()->root(); +} diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 41415fdf3..74f7ccd9c 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -136,6 +136,9 @@ Q_OBJECT //! \param theAIS the object which has to be activated virtual void applyCurrentSelectionModes(const AISObjectPtr& theAIS); + //! Returns pointer on data structure used in Object browser + virtual ModuleBase_ITreeNode* dataTreeRoot() const; + private: QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;