From 66d913fb8f4a0b7764fbb79a4139785db4b3b346 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 12 Apr 2016 15:41:38 +0300 Subject: [PATCH] Parameters manager implementation --- src/Config/Config_DataModelReader.cpp | 35 +++++ src/Config/Config_DataModelReader.h | 10 ++ src/Config/Config_FeatureMessage.cpp | 10 ++ src/Config/Config_FeatureMessage.h | 5 + src/Config/Config_FeatureReader.cpp | 2 + src/Config/Config_Keywords.h | 2 + src/Config/dataModel.xml | 6 +- src/ModuleBase/ModuleBase_ActionInfo.cpp | 2 + src/ModuleBase/ModuleBase_ActionInfo.h | 1 + src/ParametersPlugin/CMakeLists.txt | 10 ++ .../ParametersPlugin_ParametersMgr.cpp | 27 ++++ .../ParametersPlugin_ParametersMgr.h | 56 ++++++++ .../ParametersPlugin_Plugin.cpp | 11 ++ .../ParametersPlugin_WidgetCreator.cpp | 35 +++++ .../ParametersPlugin_WidgetCreator.h | 44 +++++++ .../ParametersPlugin_WidgetParamsMgr.cpp | 62 +++++++++ .../ParametersPlugin_WidgetParamsMgr.h | 46 +++++++ src/ParametersPlugin/plugin-Parameters.xml | 8 +- src/PartSet/PartSet_icons.qrc | 2 + .../pictures => PartSet/icons}/expression.png | Bin src/PartSet/icons/paper_roll.png | Bin 0 -> 517 bytes src/XGUI/XGUI_ContextMenuMgr.cpp | 55 +++++++- src/XGUI/XGUI_ContextMenuMgr.h | 2 + src/XGUI/XGUI_DataModel.cpp | 123 +++++++++--------- src/XGUI/XGUI_DataModel.h | 11 +- src/XGUI/XGUI_ObjectsBrowser.cpp | 12 +- src/XGUI/XGUI_ObjectsBrowser.h | 3 + src/XGUI/XGUI_Workshop.cpp | 6 + src/XGUI/XGUI_Workshop.h | 8 +- src/XGUI/XGUI_pictures.qrc | 1 - 30 files changed, 521 insertions(+), 74 deletions(-) create mode 100644 src/ParametersPlugin/ParametersPlugin_ParametersMgr.cpp create mode 100644 src/ParametersPlugin/ParametersPlugin_ParametersMgr.h create mode 100644 src/ParametersPlugin/ParametersPlugin_WidgetCreator.cpp create mode 100644 src/ParametersPlugin/ParametersPlugin_WidgetCreator.h create mode 100644 src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp create mode 100644 src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h rename src/{XGUI/pictures => PartSet/icons}/expression.png (100%) create mode 100644 src/PartSet/icons/paper_roll.png diff --git a/src/Config/Config_DataModelReader.cpp b/src/Config/Config_DataModelReader.cpp index e9113e85e..b02ae823c 100644 --- a/src/Config/Config_DataModelReader.cpp +++ b/src/Config/Config_DataModelReader.cpp @@ -33,6 +33,7 @@ void Config_DataModelReader::processNode(xmlNodePtr theNode) std::string aIcon = getProperty(theNode, NODE_ICON); std::string aEmpty = getProperty(theNode, SHOW_EMPTY); + std::string aFeatures = getProperty(theNode, FOLDER_FEATURES); std::string::iterator aIt; for (aIt = aEmpty.begin(); aIt != aEmpty.end(); aIt++) { (*aIt) = toupper(*aIt); @@ -44,11 +45,13 @@ void Config_DataModelReader::processNode(xmlNodePtr theNode) myRootFolderTypes.push_back(aGroupType); myRootFolderIcons.push_back(aIcon); myRootFolderShowEmpty.push_back(aIsEmpty); + myRootFeaturesList.push_back(aFeatures); } else { mySubFolderNames.push_back(aName); mySubFolderTypes.push_back(aGroupType); mySubFolderIcons.push_back(aIcon); mySubFolderShowEmpty.push_back(aIsEmpty); + mySubFeaturesList.push_back(aFeatures); } } else if (isNode(theNode, ROOT_DOCUMENT, NULL)) { isRootReading = true; @@ -86,3 +89,35 @@ int Config_DataModelReader::subFolderId(std::string theType) const } return -1; } + +std::string getFolderFeatures(const std::string& theFolderName, + const std::vector& theNames, + const std::vector& theFeatures) +{ + int aId; + bool aFound = false; + std::vector::const_iterator aIt; + for(aIt = theNames.cbegin(), aId = 0; aIt != theNames.cend(); ++aIt, ++aId) { + if ((*aIt) == theFolderName) { + aFound = true; + break; + } + } + if (aFound) + return theFeatures.at(aId); + return std::string(); +} + +std::string Config_DataModelReader:: + subFolderFeatures(const std::string& theFolderName) const +{ + return getFolderFeatures(theFolderName, mySubFolderNames, mySubFeaturesList); +} + + +std::string Config_DataModelReader:: + rootFolderFeatures(const std::string& theFolderName) const +{ + return getFolderFeatures(theFolderName, myRootFolderNames, myRootFeaturesList); +} + diff --git a/src/Config/Config_DataModelReader.h b/src/Config/Config_DataModelReader.h index b5d9b5874..d40fee1af 100644 --- a/src/Config/Config_DataModelReader.h +++ b/src/Config/Config_DataModelReader.h @@ -58,6 +58,9 @@ class Config_DataModelReader : public Config_XMLReader /// \param theId id of the folder CONFIG_EXPORT bool rootShowEmpty(int theId) const { return myRootFolderShowEmpty[theId]; } + /// Returns list of features attached to folder with name theFolderName in sub-document + /// \param theFolderName a name of the folder + CONFIG_EXPORT std::string rootFolderFeatures(const std::string& theFolderName) const; // SUB folders propertiues ******************** @@ -87,6 +90,11 @@ class Config_DataModelReader : public Config_XMLReader /// \param theType type of objects in folder CONFIG_EXPORT int subFolderId(std::string theType) const; + /// Returns list of features attached to folder with name theFolderName in sub-document + /// \param theFolderName a name of the folder + CONFIG_EXPORT std::string subFolderFeatures(const std::string& theFolderName) const; + + /// Returns true if the sub-document data tree has to be attached to Part Result node /// Otherwise it has to be connected to Part feature node CONFIG_EXPORT bool isAttachToResult() const { return myIsResultLink; } @@ -102,6 +110,7 @@ private: std::vector myRootFolderNames; std::vector myRootFolderTypes; std::vector myRootFolderIcons; + std::vector myRootFeaturesList; std::vector myRootFolderShowEmpty; std::string myRootTypes; @@ -110,6 +119,7 @@ private: std::vector mySubFolderNames; std::vector mySubFolderTypes; std::vector mySubFolderIcons; + std::vector mySubFeaturesList; std::vector mySubFolderShowEmpty; bool myIsResultLink; diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index a5fd9fd45..2ed47f4df 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -130,6 +130,11 @@ bool Config_FeatureMessage::isAutoPreview() const return myIsAutoPreview; } +bool Config_FeatureMessage::isModal() const +{ + return myModal; +} + void Config_FeatureMessage::setUseInput(bool isUseInput) { myUseInput = isUseInput; @@ -140,6 +145,11 @@ void Config_FeatureMessage::setInternal(bool isInternal) myInternal = isInternal; } +void Config_FeatureMessage::setModal(bool isModal) +{ + myModal = isModal; +} + const std::string& Config_FeatureMessage::nestedFeatures() const { return myNestedFeatures; diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 481bbf97b..d2f758513 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -32,6 +32,7 @@ class Config_FeatureMessage : public Events_Message bool myUseInput; ///setPluginLibrary(myLibraryName); outFeatureMessage->setNestedFeatures(getProperty(theFeatureNode, FEATURE_NESTED)); outFeatureMessage->setActionsWhenNested(getNormalizedProperty(theFeatureNode, FEATURE_WHEN_NESTED)); + outFeatureMessage->setModal(getBooleanAttribute(theFeatureNode, FEATURE_MODAL, false)); bool isInternal = getBooleanAttribute(theFeatureNode, ATTR_INTERNAL, false); outFeatureMessage->setInternal(isInternal); @@ -127,6 +128,7 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode, //Internal feature has no visual representation. return; } + outFeatureMessage->setText(getProperty(theFeatureNode, FEATURE_TEXT)); outFeatureMessage->setTooltip(getProperty(theFeatureNode, FEATURE_TOOLTIP)); outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON)); diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 7824c685d..471d0b9da 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -63,6 +63,7 @@ const static char* FEATURE_WHEN_NESTED = "when_nested"; const static char* FEATURE_WHEN_NESTED_ACCEPT = "accept"; const static char* FEATURE_WHEN_NESTED_ABORT = "abort"; const static char* FEATURE_DOC = WORKBENCH_DOC; +const static char* FEATURE_MODAL = "modal"; const static char* FEATURE_AUTO_PREVIEW = "auto_preview"; // NODE_VALIDATOR properties, NODE_SELFILTER properties const static char* _PARAMETERS = "parameters"; @@ -117,5 +118,6 @@ const static char* SUB_DOCUMENT = "sub_document"; const static char* NODE_ICON = "icon"; const static char* SHOW_EMPTY = "show_empty"; const static char* LINK_ITEM = "from_result"; +const static char* FOLDER_FEATURES = "folder_features"; #endif /* CONFIG_KEYWORDS_H_ */ diff --git a/src/Config/dataModel.xml b/src/Config/dataModel.xml index cfc47b4f6..c9742ab12 100644 --- a/src/Config/dataModel.xml +++ b/src/Config/dataModel.xml @@ -1,12 +1,14 @@ - + - + diff --git a/src/ModuleBase/ModuleBase_ActionInfo.cpp b/src/ModuleBase/ModuleBase_ActionInfo.cpp index 897805b73..7966f3461 100644 --- a/src/ModuleBase/ModuleBase_ActionInfo.cpp +++ b/src/ModuleBase/ModuleBase_ActionInfo.cpp @@ -65,6 +65,8 @@ void ModuleBase_ActionInfo::initFrom(std::shared_ptr theM } // If feature requires PropertyPannel for input, it should be checkable checkable = theMessage->isUseInput(); + // If Feature requires modal Dialog box for input + modal = theMessage->isModal(); } QAction* ModuleBase_ActionInfo::makeAction(QObject* theParent) diff --git a/src/ModuleBase/ModuleBase_ActionInfo.h b/src/ModuleBase/ModuleBase_ActionInfo.h index 16ac4e331..a726d137f 100644 --- a/src/ModuleBase/ModuleBase_ActionInfo.h +++ b/src/ModuleBase/ModuleBase_ActionInfo.h @@ -28,6 +28,7 @@ struct MODULEBASE_EXPORT ModuleBase_ActionInfo bool checked; //!< action's checked state bool enabled; //!< action's enabled state bool visible; //!< action's visibility state + bool modal; //!< = true if the acton is a modal dialog box else property panel (==false by default) QIcon icon; //!< action's icon QString text; //!< action's text QString iconText; //!< action's descriptive icon text diff --git a/src/ParametersPlugin/CMakeLists.txt b/src/ParametersPlugin/CMakeLists.txt index b2683044d..de8a14c2c 100644 --- a/src/ParametersPlugin/CMakeLists.txt +++ b/src/ParametersPlugin/CMakeLists.txt @@ -1,6 +1,7 @@ INCLUDE(Common) INCLUDE(FindPython) INCLUDE(UnitTest) +SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS ParametersPlugin.h @@ -9,6 +10,9 @@ SET(PROJECT_HEADERS ParametersPlugin_PyInterp.h ParametersPlugin_Validators.h ParametersPlugin_EvalListener.h + ParametersPlugin_WidgetCreator.h + ParametersPlugin_ParametersMgr.h + ParametersPlugin_WidgetParamsMgr.h ) SET(PROJECT_SOURCES @@ -17,6 +21,9 @@ SET(PROJECT_SOURCES ParametersPlugin_PyInterp.cpp ParametersPlugin_Validators.cpp ParametersPlugin_EvalListener.cpp + ParametersPlugin_WidgetCreator.cpp + ParametersPlugin_ParametersMgr.cpp + ParametersPlugin_WidgetParamsMgr.cpp ) SET(XML_RESOURCES @@ -28,6 +35,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomDataAPI + ${PROJECT_SOURCE_DIR}/src/ModuleBase ${SUIT_INCLUDE} ${PYTHON_INCLUDE_DIR} ) @@ -38,8 +46,10 @@ SET(PROJECT_LIBRARIES Events Config ModelAPI + ModuleBase ${PyInterp} ${PYTHON_LIBRARIES} + ${QT_LIBRARIES} ) ADD_DEFINITIONS(-DPARAMETERSPLUGIN_EXPORTS -DHAVE_DEBUG_PYTHON) diff --git a/src/ParametersPlugin/ParametersPlugin_ParametersMgr.cpp b/src/ParametersPlugin/ParametersPlugin_ParametersMgr.cpp new file mode 100644 index 000000000..4c3b40298 --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_ParametersMgr.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: ParametersPlugin_ParametersMgr.cpp +// Created: 07 April 2016 +// Author: vsv + +#include + +#include "ParametersPlugin_ParametersMgr.h" + + +ParametersPlugin_ParametersMgr::ParametersPlugin_ParametersMgr() + : ModelAPI_Feature() +{ +} + +ParametersPlugin_ParametersMgr::~ParametersPlugin_ParametersMgr() +{ +} + +void ParametersPlugin_ParametersMgr::initAttributes() +{ +} + +void ParametersPlugin_ParametersMgr::execute() +{ +} diff --git a/src/ParametersPlugin/ParametersPlugin_ParametersMgr.h b/src/ParametersPlugin/ParametersPlugin_ParametersMgr.h new file mode 100644 index 000000000..374399a75 --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_ParametersMgr.h @@ -0,0 +1,56 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: ParametersPlugin_ParametersMgr.h +// Created: 07 April 2016 +// Author: vsv + +#ifndef PARAMETERSPLUGIN_PARAMETERSMGR_H_ +#define PARAMETERSPLUGIN_PARAMETERSMGR_H_ + +#include "ParametersPlugin.h" +#include + +/** + * \class ParametersPlugin_ParametersMgr + * \ingroup Plugins + * \brief A macro feature which manages list of parameters in the current document. + */ + +class ParametersPlugin_ParametersMgr : public ModelAPI_Feature +{ +public: + /// Feature kind + inline static const std::string& ID() + { + static const std::string MY_PARAMSMGR_ID("ParametersMgr"); + return MY_PARAMSMGR_ID; + } + + /// Use plugin manager for features creation + ParametersPlugin_ParametersMgr(); + + /// Destructor + virtual ~ParametersPlugin_ParametersMgr(); + + /// Request for initialization of data model of the feature: adding all attributes + PARAMETERSPLUGIN_EXPORT virtual void initAttributes(); + + /// Returns the unique kind of a feature + PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = ParametersPlugin_ParametersMgr::ID(); + return MY_KIND; + }; + + /// Computes or recomputes the results + PARAMETERSPLUGIN_EXPORT virtual void execute(); + + /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true. + PARAMETERSPLUGIN_EXPORT virtual bool isMacro() const { return true; } + + /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false. + PARAMETERSPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; } +}; + + +#endif \ No newline at end of file diff --git a/src/ParametersPlugin/ParametersPlugin_Plugin.cpp b/src/ParametersPlugin/ParametersPlugin_Plugin.cpp index e82a5f67d..975ca1e3a 100644 --- a/src/ParametersPlugin/ParametersPlugin_Plugin.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Plugin.cpp @@ -4,7 +4,11 @@ #include #include +#include #include +#include + +#include #include #include @@ -17,6 +21,10 @@ static ParametersPlugin_Plugin* MY_PARAMETERSPLUGIN_INSTANCE = new ParametersPlu ParametersPlugin_Plugin::ParametersPlugin_Plugin() { // register this plugin + WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get(); + aWidgetCreatorFactory->registerCreator( + std::shared_ptr(new ParametersPlugin_WidgetCreator())); + SessionPtr aSession = ModelAPI_Session::get(); aSession->registerPlugin(this); @@ -35,6 +43,9 @@ FeaturePtr ParametersPlugin_Plugin::createFeature(std::string theFeatureID) if (theFeatureID == ParametersPlugin_Parameter::ID()) { return FeaturePtr(new ParametersPlugin_Parameter); } + if (theFeatureID == ParametersPlugin_ParametersMgr::ID()) { + return FeaturePtr(new ParametersPlugin_ParametersMgr); + } return FeaturePtr(); } diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetCreator.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetCreator.cpp new file mode 100644 index 000000000..f78e8a247 --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_WidgetCreator.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ParametersPlugin_WidgetCreator.cpp +// Created: 11 Apr 2016 +// Author: Vitaly SMETANNIKOV + +#include +#include + + +ParametersPlugin_WidgetCreator::ParametersPlugin_WidgetCreator() + : ModuleBase_IWidgetCreator() +{ +} + + +void ParametersPlugin_WidgetCreator::widgetTypes(std::set& theTypes) +{ + theTypes.clear(); + theTypes.insert("parameters-manager"); +} + + +ModuleBase_ModelWidget* + ParametersPlugin_WidgetCreator::createWidgetByType(const std::string& theType, + QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + ModuleBase_IWorkshop* /*theWorkshop*/) +{ + ModuleBase_ModelWidget* aModelWidget = 0; + if (theType == "parameters-manager") { + aModelWidget = new ParametersPlugin_WidgetParamsMgr(theParent, theWidgetApi); + } + return aModelWidget; +} diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetCreator.h b/src/ParametersPlugin/ParametersPlugin_WidgetCreator.h new file mode 100644 index 000000000..872fd5511 --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_WidgetCreator.h @@ -0,0 +1,44 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ParametersPlugin_WidgetCreator.h +// Created: 11 Apr 2016 +// Author: Vitaly SMETANNIKOV + +#ifndef ParametersPlugin_WidgetCreator_H +#define ParametersPlugin_WidgetCreator_H + +#include "ParametersPlugin.h" + +#include + +#include +#include + +/** +* \ingroup GUI +* Interface to WidgetCreator which can create specific widgets by type +*/ +class ParametersPlugin_WidgetCreator : public ModuleBase_IWidgetCreator +{ +public: + /// Default constructor + ParametersPlugin_WidgetCreator(); + + /// Returns a container of possible widget types, which this creator can process + /// \param a list of type names + virtual void widgetTypes(std::set& theTypes); + + /// Create widget by its type + /// The default implementation is empty + /// \param theType a type + /// \param theParent a parent widget + /// \param theData a low-level API for reading xml definitions of widgets + /// \param theWorkshop a current workshop + /// \return a created model widget or null + virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, + QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + ModuleBase_IWorkshop* /*theWorkshop*/); +}; + +#endif diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp new file mode 100644 index 000000000..0328741fe --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.cpp @@ -0,0 +1,62 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: ParametersPlugin_WidgetParamsMgr.cpp +// Created: 11 Apr 2016 +// Author: Vitaly SMETANNIKOV + +#include "ParametersPlugin_WidgetParamsMgr.h" + +#include +#include +#include +#include + +ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData) + : ModuleBase_ModelWidget(theParent, theData) +{ + QVBoxLayout* aLayout = new QVBoxLayout(this); + + myTable = new QTreeWidget(this); + myTable->setColumnCount(4); + QStringList aHeaders; + aHeaders << tr("Name") << tr("Equation") << tr("Result") << tr("Comment"); + myTable->setHeaderLabels(aHeaders); + aLayout->addWidget(myTable); + + QHBoxLayout* aBtnLayout = new QHBoxLayout(this); + + QToolButton* aUpBtn = new QToolButton(this); + aUpBtn->setArrowType(Qt::DownArrow); + aBtnLayout->addWidget(aUpBtn); + QToolButton* aDownBtn = new QToolButton(this); + aDownBtn->setArrowType(Qt::UpArrow); + aBtnLayout->addWidget(aDownBtn); + + aBtnLayout->addStretch(); + + QPushButton* aAddBtn = new QPushButton(tr("Add"), this); + aBtnLayout->addWidget(aAddBtn); + QPushButton* aInsertBtn = new QPushButton(tr("Insert"), this); + aBtnLayout->addWidget(aInsertBtn); + QPushButton* aRemoveBtn = new QPushButton(tr("Remove"), this); + aBtnLayout->addWidget(aRemoveBtn); + + aLayout->addLayout(aBtnLayout); +} + +QList ParametersPlugin_WidgetParamsMgr::getControls() const +{ + QList aList; + + return aList; +} + +bool ParametersPlugin_WidgetParamsMgr::storeValueCustom() const +{ + return true; +} + +bool ParametersPlugin_WidgetParamsMgr::restoreValueCustom() +{ + return true; +} diff --git a/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h new file mode 100644 index 000000000..22fe78d74 --- /dev/null +++ b/src/ParametersPlugin/ParametersPlugin_WidgetParamsMgr.h @@ -0,0 +1,46 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: ParametersPlugin_WidgetParamsMgr.h +// Created: 11 Apr 2016 +// Author: Vitaly SMETANNIKOV + +#ifndef ParametersPlugin_WidgetParamsMgr_H_ +#define ParametersPlugin_WidgetParamsMgr_H_ + +#include + +class QTreeWidget; + +/*! + * \ingroup GUI + * Represent a content of the property panel to show/modify parameters of some feature. + */ +class ParametersPlugin_WidgetParamsMgr : public ModuleBase_ModelWidget +{ + Q_OBJECT +public: + /// Constructs a model widget + ParametersPlugin_WidgetParamsMgr(QWidget* theParent, const Config_WidgetAPI* theData); + + /// Destructs the model widget + virtual ~ParametersPlugin_WidgetParamsMgr() {} + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + +protected: + /// Saves the internal parameters to the given feature + /// \return True in success + virtual bool storeValueCustom() const; + + /// Restore value from attribute data to the widget's control + virtual bool restoreValueCustom(); + +private: + + QTreeWidget* myTable; +}; + + +#endif \ No newline at end of file diff --git a/src/ParametersPlugin/plugin-Parameters.xml b/src/ParametersPlugin/plugin-Parameters.xml index 3bab3831f..7eb78f185 100644 --- a/src/ParametersPlugin/plugin-Parameters.xml +++ b/src/ParametersPlugin/plugin-Parameters.xml @@ -3,14 +3,18 @@ - - + + + + + + diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 270a9428f..d4b209b39 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -10,5 +10,7 @@ icons/hand_point.png icons/move_to_end.png icons/sketch_shape.png + icons/expression.png + icons/paper_roll.png diff --git a/src/XGUI/pictures/expression.png b/src/PartSet/icons/expression.png similarity index 100% rename from src/XGUI/pictures/expression.png rename to src/PartSet/icons/expression.png diff --git a/src/PartSet/icons/paper_roll.png b/src/PartSet/icons/paper_roll.png new file mode 100644 index 0000000000000000000000000000000000000000..001b7596049b92f55434336f903b6d2dd96e7300 GIT binary patch literal 517 zcmV+g0{Z=lP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;(#7eog=Y0d`45K~y+Tl~J)u13?g7G>VFn%O!VdY-|(+ zAxe;3Vsat7C)&6du(0quEK=E9SzGuS7J{vxU?GUu2%?~$*k}Xwk^7XBrD?&Ajs6j1yw0UM>i5D8%-)Z7ewAQL!urIT0$-BiLc2(Rd zrC5@-#~-QxmRoNgBdv1%DOYZ&iCp1=!RdVv^wZ2p>Z^Qh^FWUbzeLIxWEV#0#E`geyD@uRww?=KC3#;@lDP!xim{ zxq=Bua=1kLp?8q=rR8#YL)IK_>2?)TE+AfTwX%Js}sl) z1$0T1(S{_V0S*sOuy$HIyZB83`W1j^Vb7YAlMfe+2mdMx-NvvB{I`QoS00000NkvXX Hu0mjf&HCH? literal 0 HcmV?d00001 diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index bfd87b0ed..101a18722 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -11,6 +11,7 @@ #include "XGUI_DataModel.h" #include "XGUI_OperationMgr.h" #include "XGUI_Tools.h" +#include "XGUI_ActionsMgr.h" #ifndef HAVE_SALOME #include @@ -28,6 +29,8 @@ #include #include +#include + #include #include #include @@ -39,6 +42,7 @@ #include #include #include +#include XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) @@ -510,9 +514,11 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const aActions.append(action("DELETE_CMD")); } theMenu->addActions(aActions); + addFeatures(theMenu); - theMenu->addSeparator(); - theMenu->addActions(myWorkshop->objectBrowser()->actions()); + // It is commented out because Object Browser does not have actions + //theMenu->addSeparator(); + //theMenu->addActions(myWorkshop->objectBrowser()->actions()); } void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const @@ -611,3 +617,48 @@ void XGUI_ContextMenuMgr::onRename() myWorkshop->objectBrowser()->setObjectsSelected(anObjects); myWorkshop->objectBrowser()->onEditItem(); } + +void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const +{ + SessionPtr aMgr = ModelAPI_Session::get(); + DocumentPtr aActiveDoc = aMgr->activeDocument(); + + XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); + XGUI_ActionsMgr* aActionMgr = myWorkshop->actionsMgr(); + const Config_DataModelReader* aDataModelXML = myWorkshop->dataModelXMLReader(); + QModelIndexList aSelectedIndexes = aSelMgr->selection()->selectedIndexes(); + + QString aName; + int aLen = 0; + bool aIsRoot = false; + foreach(QModelIndex aIdx, aSelectedIndexes) { + // Process only first column + if (aIdx.column() == 0) { + aIsRoot = !aIdx.parent().isValid(); + // Exit if the selected index belongs to non active document + if (aIsRoot && (aActiveDoc != aMgr->moduleDocument())) + return; + if ((!aIsRoot) && (aIdx.internalPointer() != aActiveDoc.get())) + return; + + // Get name of the selected index + aName = aIdx.data().toString(); + aLen = aName.indexOf('('); + if (aLen != -1) { + aName = aName.left(--aLen); + } + std::string aFeaturesStr = aIsRoot? + aDataModelXML->rootFolderFeatures(aName.toStdString()) : + aDataModelXML->subFolderFeatures(aName.toStdString()); + if (aFeaturesStr.length() > 0) { + QStringList aFeturesList = + QString(aFeaturesStr.c_str()).split(",", QString::SkipEmptyParts); + foreach(QString aFea, aFeturesList) { + QAction* aAction = aActionMgr->action(aFea); + if (aAction) + theMenu->addAction(aAction); + } + } + } + } +} diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index 34e3d7b92..52c1e6381 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -95,6 +95,8 @@ signals: */ void addAction(const QString& theId, QAction* theAction); + void addFeatures(QMenu* theMenu) const; + /// Updates menu for object browser void updateObjectBrowserMenu(); diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 5e1c15d71..3e7b0e796 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -64,8 +65,6 @@ ModelAPI_Document* getSubDocument(void* theObj) // Constructor ************************************************* XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent) { - myXMLReader.readAll(); - Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); @@ -74,12 +73,16 @@ XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParen aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)); } +XGUI_DataModel::~XGUI_DataModel() +{ +} + //****************************************************** void XGUI_DataModel::processEvent(const std::shared_ptr& theMessage) { DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - std::string aRootType = myXMLReader.rootType(); - std::string aSubType = myXMLReader.subType(); + std::string aRootType = myXMLReader->rootType(); + std::string aSubType = myXMLReader->subType(); int aNbFolders = foldersCount(); // Created object event ******************* @@ -104,7 +107,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess foreach (QString aNotEmptyFolder, aNotEmptyFolders) { if ((aNotEmptyFolder.toStdString() == aObjType) && (aRootDoc->size(aObjType) == 1)) // Appears first object in folder which can not be shown empty - insertRow(myXMLReader.rootFolderId(aObjType)); + insertRow(myXMLReader->rootFolderId(aObjType)); } // Insert new object int aRow = aRootDoc->size(aObjType) - 1; @@ -112,7 +115,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess if (aObjType == aRootType) { insertRow(aRow + aNbFolders + 1); } else { - int aFolderId = myXMLReader.rootFolderId(aObjType); + int aFolderId = myXMLReader->rootFolderId(aObjType); if (aFolderId != -1) { insertRow(aRow, createIndex(aFolderId, 0, -1)); } @@ -127,7 +130,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess foreach (QString aNotEmptyFolder, aNotEmptyFolders) { if ((aNotEmptyFolder.toStdString() == aObjType) && (aDoc->size(aObjType) == 1)) // Appears first object in folder which can not be shown empty - insertRow(myXMLReader.subFolderId(aObjType), aDocRoot); + insertRow(myXMLReader->subFolderId(aObjType), aDocRoot); } int aRow = aDoc->index(aObject); if (aRow != -1) { @@ -171,7 +174,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess rebuildBranch(aNbFolders, aRow); } else { // Process root sub-folder - int aFolderId = myXMLReader.rootFolderId(aGroup); + int aFolderId = myXMLReader->rootFolderId(aGroup); if (aFolderId != -1) { QModelIndex aFolderIndex = createIndex(aFolderId, 0, -1); removeRow(aRow, aFolderIndex); @@ -183,8 +186,8 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess foreach (QString aNotEmptyFolder, aNotEmptyFolders) { if ((aNotEmptyFolder.toStdString() == aGroup) && (aRootDoc->size(aGroup) == 0)) { // Appears first object in folder which can not be shown empty - removeRow(myXMLReader.rootFolderId(aGroup)); - //rebuildBranch(0, aNbFolders + aDoc->size(myXMLReader.rootType())); + removeRow(myXMLReader->rootFolderId(aGroup)); + //rebuildBranch(0, aNbFolders + aDoc->size(myXMLReader->rootType())); break; } } @@ -213,8 +216,8 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess foreach (QString aNotEmptyFolder, aNotEmptyFolders) { if ((aNotEmptyFolder.toStdString() == aGroup) && (aSize == 0)) { // Appears first object in folder which can not be shown empty - removeRow(myXMLReader.subFolderId(aGroup), aDocRoot); - //rebuildBranch(0, aNbSubFolders + aDoc->size(myXMLReader.subType()), aDocRoot); + removeRow(myXMLReader->subFolderId(aGroup), aDocRoot); + //rebuildBranch(0, aNbSubFolders + aDoc->size(myXMLReader->subType()), aDocRoot); break; } } @@ -244,13 +247,13 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess int aStartId = 0; if (aDoc == aRootDoc) { // Update a group under root - if (aGroup == myXMLReader.rootType()) // Update objects under root + if (aGroup == myXMLReader->rootType()) // Update objects under root aStartId = foldersCount(); else // Update objects in folder under root aParent = createIndex(folderId(aGroup), 0, -1); } else { // Update a sub-document - if (aGroup == myXMLReader.subType()) { + if (aGroup == myXMLReader->subType()) { // Update sub-document root aParent = findDocumentRootIndex(aDoc.get()); aStartId = foldersCount(aDoc.get()); @@ -342,10 +345,10 @@ QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const } SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); - if (aDoc == aRootDoc && myXMLReader.rootType() == aType) { + if (aDoc == aRootDoc && myXMLReader->rootType() == aType) { // The object from root document aRow += foldersCount(); - } else if (myXMLReader.subType() == aType) { + } else if (myXMLReader->subType() == aType) { // The object from sub document aRow += foldersCount(aDoc.get()); } @@ -370,10 +373,10 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const if (aParentId == -1) { // root folders switch (theRole) { case Qt::DisplayRole: - return QString(myXMLReader.rootFolderName(theIndexRow).c_str()) + + return QString(myXMLReader->rootFolderName(theIndexRow).c_str()) + QString(" (%1)").arg(rowCount(theIndex)); case Qt::DecorationRole: - return ModuleBase_IconFactory::loadIcon(myXMLReader.rootFolderIcon(theIndexRow).c_str()); + return QIcon(myXMLReader->rootFolderIcon(theIndexRow).c_str()); case Qt::ForegroundRole: { Qt::ItemFlags aFlags = theIndex.flags(); @@ -403,10 +406,10 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const switch (theRole) { case Qt::DisplayRole: - return QString(myXMLReader.subFolderName(aRow).c_str()) + + return QString(myXMLReader->subFolderName(aRow).c_str()) + QString(" (%1)").arg(rowCount(theIndex)); case Qt::DecorationRole: - return ModuleBase_IconFactory::loadIcon(myXMLReader.subFolderIcon(aRow).c_str()); + return QIcon(myXMLReader->subFolderIcon(aRow).c_str()); } } else { ModelAPI_Object* aObj = (ModelAPI_Object*)theIndex.internalPointer(); @@ -421,7 +424,7 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const return aTitle + " = " + aVal; } QString aSuffix; - if (aObj->groupName() == myXMLReader.subType()) { + if (aObj->groupName() == myXMLReader->subType()) { ResultPartPtr aPartRes = getPartResult(aObj); if (aPartRes.get()) { if (aPartRes->partDoc().get() == NULL) @@ -456,7 +459,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const // Return number of items in root int aNbFolders = foldersCount(); int aNbItems = 0; - std::string aType = myXMLReader.rootType(); + std::string aType = myXMLReader->rootType(); if (!aType.empty()) aNbItems = aRootDoc->size(aType); return aNbFolders + aNbItems; @@ -466,7 +469,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const if (aId == -1) { // this is a folder under root int aParentPos = theParent.row(); - std::string aType = myXMLReader.rootFolderType(aParentPos); + std::string aType = myXMLReader->rootFolderType(aParentPos); return aRootDoc->size(aType); } else { // It is an object which could have children @@ -477,7 +480,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const int aRow = theParent.row(); while (aMissedIdx.contains(aRow)) aRow++; - std::string aType = myXMLReader.subFolderType(aRow); + std::string aType = myXMLReader->subFolderType(aRow); return aDoc->size(aType); } else { ModelAPI_Object* aObj = (ModelAPI_Object*)theParent.internalPointer(); @@ -490,7 +493,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const int aNbSubFolders = foldersCount(aSubDoc.get()); int aNbSubItems = 0; - std::string aSubType = myXMLReader.subType(); + std::string aSubType = myXMLReader->subType(); if (!aSubType.empty()) aNbSubItems = aSubDoc->size(aSubType); return aNbSubItems + aNbSubFolders; @@ -527,7 +530,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & if (theRow < aNbFolders) // Return first level folder index return createIndex(theRow, theColumn, -1); else { // return object under root index - std::string aType = myXMLReader.rootType(); + std::string aType = myXMLReader->rootType(); int aObjId = theRow - aNbFolders; if (aObjId < aRootDoc->size(aType)) { ObjectPtr aObj = aRootDoc->object(aType, aObjId); @@ -538,7 +541,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & int aId = theParent.internalId(); int aParentPos = theParent.row(); if (aId == -1) { // return object index inside of first level of folders - std::string aType = myXMLReader.rootFolderType(aParentPos); + std::string aType = myXMLReader->rootFolderType(aParentPos); if (theRow < aRootDoc->size(aType)) { ObjectPtr aObj = aRootDoc->object(aType, theRow); aIndex = objectIndex(aObj); @@ -552,7 +555,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & QIntList aMissedIdx = missedFolderIndexes(aDoc); while (aMissedIdx.contains(aParentRow)) aParentRow++; - std::string aType = myXMLReader.subFolderType(aParentRow); + std::string aType = myXMLReader->subFolderType(aParentRow); if (theRow < aDoc->size(aType)) { ObjectPtr aObj = aDoc->object(aType, theRow); aIndex = objectIndex(aObj); @@ -569,7 +572,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & aIndex = createIndex(theRow, theColumn, aSubDoc.get()); } else { // this is an object under sub document root - std::string aType = myXMLReader.subType(); + std::string aType = myXMLReader->subType(); ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders); aIndex = objectIndex(aObj); } @@ -635,20 +638,20 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const DocumentPtr aRootDoc = aSession->moduleDocument(); DocumentPtr aSubDoc = aObj->document(); if (aSubDoc == aRootDoc) { - if (aType == myXMLReader.rootType()) + if (aType == myXMLReader->rootType()) return QModelIndex(); else { // return first level of folder index - int aFolderId = myXMLReader.rootFolderId(aType); + int aFolderId = myXMLReader->rootFolderId(aType); // Items in a one row must have the same parent return createIndex(aFolderId, 0, -1); } } else { - if (aType == myXMLReader.subType()) + if (aType == myXMLReader->subType()) return findDocumentRootIndex(aSubDoc.get()); else { // return first level of folder index - int aFolderId = myXMLReader.subFolderId(aType); + int aFolderId = myXMLReader->subFolderId(aType); // Items in a one row must have the same parent return createIndex(aFolderId, 0, aSubDoc.get()); } @@ -753,7 +756,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo { SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); - if (myXMLReader.isAttachToResult()) { // If document is attached to result + if (myXMLReader->isAttachToResult()) { // If document is attached to result int aNb = aRootDoc->size(ModelAPI_ResultPart::group()); ObjectPtr aObj; ResultPartPtr aPartRes; @@ -762,7 +765,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo aPartRes = std::dynamic_pointer_cast(aObj); if (aPartRes.get() && (aPartRes->partDoc().get() == theDoc)) { int aRow = i; - if (myXMLReader.rootType() == ModelAPI_Feature::group()) { + if (myXMLReader->rootType() == ModelAPI_Feature::group()) { aRow += foldersCount(); } return createIndex(aRow, 0, aObj.get()); @@ -777,7 +780,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo aPartRes = getPartResult(aObj.get()); if (aPartRes.get() && (aPartRes->partDoc().get() == theDoc)) { int aRow = i; - if (myXMLReader.rootType() == ModelAPI_Feature::group()) + if (myXMLReader->rootType() == ModelAPI_Feature::group()) aRow += foldersCount(); return createIndex(aRow, 0, aObj.get()); } @@ -804,20 +807,20 @@ int XGUI_DataModel::foldersCount(ModelAPI_Document* theDoc) const SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); if ((theDoc == 0) || (theDoc == aRootDoc.get())) { - for (int i = 0; i < myXMLReader.rootFoldersNumber(); i++) { - if (myXMLReader.rootShowEmpty(i)) + for (int i = 0; i < myXMLReader->rootFoldersNumber(); i++) { + if (myXMLReader->rootShowEmpty(i)) aNb++; else { - if (aRootDoc->size(myXMLReader.rootFolderType(i)) > 0) + if (aRootDoc->size(myXMLReader->rootFolderType(i)) > 0) aNb++; } } } else { - for (int i = 0; i < myXMLReader.subFoldersNumber(); i++) { - if (myXMLReader.subShowEmpty(i)) + for (int i = 0; i < myXMLReader->subFoldersNumber(); i++) { + if (myXMLReader->subShowEmpty(i)) aNb++; else { - if (theDoc->size(myXMLReader.subFolderType(i)) > 0) + if (theDoc->size(myXMLReader->subFolderType(i)) > 0) aNb++; } } @@ -833,16 +836,16 @@ QIntList XGUI_DataModel::missedFolderIndexes(ModelAPI_Document* theDoc) const SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aRootDoc = aSession->moduleDocument(); if ((theDoc == 0) || (theDoc == aRootDoc.get())) { - for (int i = 0; i < myXMLReader.rootFoldersNumber(); i++) { - if (!myXMLReader.rootShowEmpty(i)) { - if (aRootDoc->size(myXMLReader.rootFolderType(i)) == 0) + for (int i = 0; i < myXMLReader->rootFoldersNumber(); i++) { + if (!myXMLReader->rootShowEmpty(i)) { + if (aRootDoc->size(myXMLReader->rootFolderType(i)) == 0) aList.append(i); } } } else { - for (int i = 0; i < myXMLReader.subFoldersNumber(); i++) { - if (!myXMLReader.subShowEmpty(i)) { - if (theDoc->size(myXMLReader.subFolderType(i)) == 0) + for (int i = 0; i < myXMLReader->subFoldersNumber(); i++) { + if (!myXMLReader->subShowEmpty(i)) { + if (theDoc->size(myXMLReader->subFolderType(i)) == 0) aList.append(i); } } @@ -856,14 +859,14 @@ QStringList XGUI_DataModel::listOfShowNotEmptyFolders(bool fromRoot) const { QStringList aResult; if (fromRoot) { - for (int i = 0; i < myXMLReader.rootFoldersNumber(); i++) { - if (!myXMLReader.rootShowEmpty(i)) - aResult << myXMLReader.rootFolderType(i).c_str(); + for (int i = 0; i < myXMLReader->rootFoldersNumber(); i++) { + if (!myXMLReader->rootShowEmpty(i)) + aResult << myXMLReader->rootFolderType(i).c_str(); } } else { - for (int i = 0; i < myXMLReader.subFoldersNumber(); i++) { - if (!myXMLReader.subShowEmpty(i)) - aResult << myXMLReader.subFolderType(i).c_str(); + for (int i = 0; i < myXMLReader->subFoldersNumber(); i++) { + if (!myXMLReader->subShowEmpty(i)) + aResult << myXMLReader->subFolderType(i).c_str(); } } return aResult; @@ -898,20 +901,20 @@ int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) int aRes = -1; if (aUseSubDoc) { - int aId = myXMLReader.subFolderId(theType); + int aId = myXMLReader->subFolderId(theType); aRes = aId; for (int i = 0; i < aId; i++) { - if (!myXMLReader.subShowEmpty(i)) { - if (aDoc->size(myXMLReader.subFolderType(i)) == 0) + if (!myXMLReader->subShowEmpty(i)) { + if (aDoc->size(myXMLReader->subFolderType(i)) == 0) aRes--; } } } else { - int aId = myXMLReader.rootFolderId(theType); + int aId = myXMLReader->rootFolderId(theType); aRes = aId; for (int i = 0; i < aId; i++) { - if (!myXMLReader.rootShowEmpty(i)) { - if (aDoc->size(myXMLReader.rootFolderType(i)) == 0) + if (!myXMLReader->rootShowEmpty(i)) { + if (aDoc->size(myXMLReader->rootFolderType(i)) == 0) aRes--; } } diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index d08ccc42a..47b0f7b6b 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -12,11 +12,12 @@ #include #include #include -#include #include #include +class Config_DataModelReader; + /**\class XGUI_DataModel * \ingroup GUI * \brief This is a data model for Object Browser (QTreeView). @@ -35,6 +36,9 @@ public: /// \param theParent a parent object XGUI_DataModel(QObject* theParent); + /// Destructor + virtual ~XGUI_DataModel(); + /// Event Listener method /// \param theMessage an event message virtual void processEvent(const std::shared_ptr& theMessage); @@ -116,6 +120,9 @@ public: /// Returns last history object index virtual QModelIndex lastHistoryIndex() const; + /// Initialises XML data model reader. It must be initialised before DataModel using. + void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; } + private: /// Find a root index which contains objects of the given document /// \param theDoc the document object @@ -145,7 +152,7 @@ private: /// \param fromRoot - root document flag QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const; - Config_DataModelReader myXMLReader; + Config_DataModelReader* myXMLReader; }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 7eb50de34..8c25035f0 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -361,10 +361,6 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setPalette(aPalet); myDocModel = new XGUI_DataModel(this); - myTreeView->setModel(myDocModel); - - // It has to be done after setting of model - myActiveDocLbl->setTreeView(myTreeView); QItemSelectionModel* aSelMod = myTreeView->selectionModel(); connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), @@ -379,6 +375,14 @@ XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser() { } +void XGUI_ObjectsBrowser::setXMLReader(Config_DataModelReader* theReader) +{ + myDocModel->setXMLReader(theReader); + myTreeView->setModel(myDocModel); + + // It has to be done after setting of model + myActiveDocLbl->setTreeView(myTreeView); +} //*************************************************** void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index b1a70d487..c71206dcc 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -15,6 +15,7 @@ class ModuleBase_IDocumentDataModel; class XGUI_DataModel; +class Config_DataModelReader; /** * \ingroup GUI @@ -180,6 +181,8 @@ Q_OBJECT /// Resets the object browser into initial state void clearContent(); + void setXMLReader(Config_DataModelReader* theReader); + public slots: //! Called on Edit command request void onEditItem(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 4949ecd94..540991d64 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -77,6 +77,7 @@ #include #include #include +#include #include @@ -135,6 +136,9 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) QLocale::setDefault( QLocale::system() ); #endif + myDataModelXMLReader = new Config_DataModelReader(); + myDataModelXMLReader->readAll(); + myDisplayer = new XGUI_Displayer(this); mySelector = new XGUI_SelectionMgr(this); @@ -200,6 +204,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) XGUI_Workshop::~XGUI_Workshop(void) { delete myDisplayer; + delete myDataModelXMLReader; } //****************************************************** @@ -1078,6 +1083,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) aObjDock->setStyleSheet( "::title { position: relative; padding-left: 5px; text-align: left center }"); myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock); + myObjectBrowser->setXMLReader(myDataModelXMLReader); myModule->customizeObjectBrowser(myObjectBrowser); aObjDock->setWidget(myObjectBrowser); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 6cbc1429c..086f691ab 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -47,7 +47,7 @@ class QDockWidget; class QMainWindow; class QAction; - +class Config_DataModelReader; /**\class XGUI_Workshop * \ingroup GUI @@ -288,6 +288,10 @@ Q_OBJECT /// features found in the given list void highlightResults(const QObjectPtrList& theObjects); + /// Returns Data Model XML reader which contains information about + /// Data structure configuration + const Config_DataModelReader* dataModelXMLReader() const { return myDataModelXMLReader; } + /// A constant string used for "Move to end" command definition /// It is used for specific processing of Undo/Redo for this command. static QString MOVE_TO_END_COMMAND; @@ -537,6 +541,8 @@ private: QString myCurrentDir; int myViewerSelMode; + + Config_DataModelReader* myDataModelXMLReader; }; #endif diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 989cb501c..86cc1b28f 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -43,7 +43,6 @@ pictures/module.png pictures/shading.png pictures/wireframe.png - pictures/expression.png pictures/arrow.png pictures/solid.png -- 2.39.2