From: vsv Date: Fri, 13 Jul 2018 12:04:17 +0000 (+0300) Subject: Fix for crash with creation of sketcher point on origin X-Git-Tag: SHAPER_V9_1_0RC1~123 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d34e8ead48a4c3f13728c386c790d334356f95a4;p=modules%2Fshaper.git Fix for crash with creation of sketcher point on origin --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 4b1a7117d..45edb4b36 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -103,6 +103,7 @@ SET(PROJECT_HEADERS ModuleBase_WidgetNameEdit.h ModuleBase_WidgetRadiobox.h ModuleBase_WidgetPointInput.h + ModuleBase_ITreeNode.h ) SET(PROJECT_MOC_HEADERS diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 058fe4761..3817abcb7 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -48,11 +48,13 @@ class QMouseEvent; class QKeyEvent; class QMenu; class Config_WidgetAPI; + class ModuleBase_ModelWidget; class ModuleBase_Operation; class ModuleBase_ViewerPrs; - +class ModuleBase_ITreeNode; class ModuleBase_IWorkshop; + class ModelAPI_Result; class Events_Message; @@ -377,6 +379,9 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject void getXMLRepresentation(const std::string& theFeatureId, std::string& theXmlCfg, std::string& theDescription); + /// Returns root tree node which represents a data model + virtual ModuleBase_ITreeNode* rootNode() const = 0; + signals: /// Segnal emitted when an operation is resumed /// \param theOp a resumed operation diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h new file mode 100644 index 000000000..954e72f03 --- /dev/null +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -0,0 +1,68 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#ifndef ModuleBase_ITreeNode_H +#define ModuleBase_ITreeNode_H + +#include "ModuleBase.h" + +#include + +#include +#include +#include + +class ModuleBase_ITreeNode; + +typedef QList QTreeNodesList; + +class ModuleBase_ITreeNode +{ +public: + /// Default constructor + ModuleBase_ITreeNode() : myParent(0) {} + + /// Returns name of the node + virtual QString name() const { return "Item"; } + + /// Returns icon of the node + virtual QIcon icon() const { return QIcon(); } + + /// Returns foreground color of the node + virtual QColor color() const { return Qt::black; } + + /// Returns properties flag of the item + virtual Qt::ItemFlags falg() const { return Qt::ItemIsSelectable | Qt::ItemIsEnabled; } + + /// Returns parent node of the current node + ModuleBase_ITreeNode* parent() const { return myParent; } + + /// Returns list of the node children + QTreeNodesList children() const { return myChildren; } + + /// Returns object referenced by the node (can be null) + virtual ObjectPtr object() const { return ObjectPtr(); } + +protected: + ModuleBase_ITreeNode* myParent; //!< Parent of the node + QTreeNodesList myChildren; //!< Children of the node +}; + +#endif \ No newline at end of file diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 389f4904f..2ed698518 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -58,6 +58,8 @@ SET(PROJECT_HEADERS PartSet_WidgetSketchLabel.h PartSet_CenterPrs.h PartSet_ExternalPointsMgr.h + PartSet_DataModel.h + PartSet_TreeNodes.h ) SET(PROJECT_MOC_HEADERS @@ -106,6 +108,8 @@ SET(PROJECT_SOURCES PartSet_WidgetSketchLabel.cpp PartSet_CenterPrs.cpp PartSet_ExternalPointsMgr.cpp + PartSet_DataModel.cpp + PartSet_TreeNodes.cpp ) SET(PROJECT_RESOURCES diff --git a/src/PartSet/PartSet_DataModel.cpp b/src/PartSet/PartSet_DataModel.cpp new file mode 100644 index 000000000..57f0735b5 --- /dev/null +++ b/src/PartSet/PartSet_DataModel.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#include "PartSet_DataModel.h" + +#include + +#include + +PartSet_DataModel::PartSet_DataModel() +{ + Events_Loop* aLoop = Events_Loop::loop(); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_ORDER_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)); +} + + +void PartSet_DataModel::processEvent(const std::shared_ptr& theMessage) +{ + +} diff --git a/src/PartSet/PartSet_DataModel.h b/src/PartSet/PartSet_DataModel.h new file mode 100644 index 000000000..e892ec066 --- /dev/null +++ b/src/PartSet/PartSet_DataModel.h @@ -0,0 +1,46 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#ifndef PartSet_DataModel_H +#define PartSet_DataModel_H + +#include "PartSet.h" + +#include + + +class ModuleBase_ITreeNode; + +class PartSet_DataModel : public Events_Listener +{ +public: + PartSet_DataModel(); + + /// Event Listener method + /// \param theMessage an event message + virtual void processEvent(const std::shared_ptr& theMessage); + + ModuleBase_ITreeNode* root() const { return myRoot; } + +private: + ModuleBase_ITreeNode* myRoot; +}; + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index bd06498f2..14d46deae 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -38,6 +38,7 @@ #include "PartSet_CustomPrs.h" #include "PartSet_IconFactory.h" #include "PartSet_OverconstraintListener.h" +#include "PartSet_DataModel.h" #include "PartSet_Filters.h" #include "PartSet_FilterInfinite.h" @@ -157,6 +158,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) mySketchMgr = new PartSet_SketcherMgr(this); mySketchReentrantMgr = new PartSet_SketcherReentrantMgr(theWshop); + myDataModel = new PartSet_DataModel(); + XGUI_ModuleConnector* aConnector = dynamic_cast(theWshop); XGUI_Workshop* aWorkshop = aConnector->workshop(); @@ -1219,11 +1222,6 @@ bool PartSet_Module::afterCustomisePresentation(std::shared_ptr // customize sketch dimension constraint presentation if (!aCustomized) { if (!aColor.empty()) { // otherwise presentation has the default color - AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); - aColorAttr->setSize(3); - // Set the color attribute in order do not use default colors in the perasentation object - for (int i = 0; i < 3; i++) - aColorAttr->setValue(i, aColor[i]); aCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]); } } @@ -1636,10 +1634,15 @@ XGUI_Workshop* PartSet_Module::getWorkshop() const return aConnector->workshop(); } -//****************************************************** void PartSet_Module::setDefaultConstraintShown() { myHasConstraintShown[PartSet_Tools::Geometrical] = true; myHasConstraintShown[PartSet_Tools::Dimensional] = true; myHasConstraintShown[PartSet_Tools::Expressions] = false; } + +//****************************************************** +ModuleBase_ITreeNode* PartSet_Module::rootNode() const +{ + return myDataModel->root(); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 70de7236d..d196b6bdd 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -58,6 +58,7 @@ class PartSet_MenuMgr; class PartSet_CustomPrs; class PartSet_SketcherMgr; class PartSet_SketcherReentrantMgr; +class PartSet_DataModel; class ModelAPI_Result; class QAction; @@ -393,6 +394,9 @@ public: /// \param theMessage a message of reentrant operation virtual void setReentrantPreSelection(const std::shared_ptr& theMessage); + /// Returns root tree node which represents a data model + virtual ModuleBase_ITreeNode* rootNode() const; + /// Returns the workshop XGUI_Workshop* getWorkshop() const; @@ -490,6 +494,8 @@ private: /// redisplay and restore it after PartSet_SketcherMgr::FeatureToSelectionMap myCurrentSelection; QModelIndex myActivePartIndex; + + PartSet_DataModel* myDataModel; }; #endif diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp new file mode 100644 index 000000000..3d029e57b --- /dev/null +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#include "PartSet_TreeNodes.h" + + +PartSet_RootNode::PartSet_RootNode() +{ + +} \ No newline at end of file diff --git a/src/PartSet/PartSet_TreeNodes.h b/src/PartSet/PartSet_TreeNodes.h new file mode 100644 index 000000000..6c165b198 --- /dev/null +++ b/src/PartSet/PartSet_TreeNodes.h @@ -0,0 +1,36 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#ifndef PartSet_TreeNodes_H +#define PartSet_TreeNodes_H + +#include "PartSet.h" + +#include + +class PartSet_RootNode : public ModuleBase_ITreeNode +{ +public: + PartSet_RootNode(); + +}; + + +#endif \ No newline at end of file