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
class ModuleBase_ISelectionActivate;
class ModuleBase_ViewerPrs;
class QMainWindow;
+class ModuleBase_ITreeNode;
/**
* \ingroup GUI
//! \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();
#include <ModuleBase_WidgetTreeDataSelect.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ITreeNode.h>
#include <QVBoxLayout>
#include <QTreeView>
+#include <cassert>
+
+
+
+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)
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);
}
#include <ModuleBase.h>
#include <ModuleBase_ModelWidget.h>
+#include <QAbstractItemModel>
class QTreeView;
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
#include "XGUI_ActionsMgr.h"
#include "XGUI_ErrorMgr.h"
#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_DataModel.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_ViewerPrs.h>
{
Handle(AIS_InteractiveObject) anIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
myWorkshop->selectionActivate()->activate(anIO, false);
-}
\ No newline at end of file
+}
+
+ModuleBase_ITreeNode* XGUI_ModuleConnector::dataTreeRoot() const
+{
+ return myWorkshop->objectBrowser()->dataModel()->root();
+}
//! \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;