Salome HOME
Fix for crash with creation of sketcher point on origin
authorvsv <vsv@opencascade.com>
Fri, 13 Jul 2018 12:04:17 +0000 (15:04 +0300)
committervsv <vsv@opencascade.com>
Fri, 13 Jul 2018 12:04:30 +0000 (15:04 +0300)
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ITreeNode.h [new file with mode: 0644]
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_DataModel.cpp [new file with mode: 0644]
src/PartSet/PartSet_DataModel.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_TreeNodes.cpp [new file with mode: 0644]
src/PartSet/PartSet_TreeNodes.h [new file with mode: 0644]

index 4b1a7117d991496f04d0b66124ac8de356802aea..45edb4b36cece3009ebca640798f108a185ac055 100644 (file)
@@ -103,6 +103,7 @@ SET(PROJECT_HEADERS
   ModuleBase_WidgetNameEdit.h
   ModuleBase_WidgetRadiobox.h
   ModuleBase_WidgetPointInput.h
+  ModuleBase_ITreeNode.h
 )
 
 SET(PROJECT_MOC_HEADERS
index 058fe4761978f2e216f2debe4f9d8ac30c97d1ca..3817abcb7bf4bf247df66385bb58a2239456bd08 100755 (executable)
@@ -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 (file)
index 0000000..954e72f
--- /dev/null
@@ -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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ITreeNode_H
+#define ModuleBase_ITreeNode_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Object.h>
+
+#include <QList>
+#include <QString>
+#include <QIcon>
+
+class ModuleBase_ITreeNode;
+
+typedef QList<ModuleBase_ITreeNode*> 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
index 389f4904fb89266639dd814f4d8165a018c1213e..2ed698518e31c3da57347612e08108a4ad4ae6a2 100644 (file)
@@ -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 (file)
index 0000000..57f0735
--- /dev/null
@@ -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<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "PartSet_DataModel.h"
+
+#include <ModelAPI_Events.h>
+
+#include <Events_Loop.h>
+
+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<Events_Message>& theMessage)
+{
+
+}
diff --git a/src/PartSet/PartSet_DataModel.h b/src/PartSet/PartSet_DataModel.h
new file mode 100644 (file)
index 0000000..e892ec0
--- /dev/null
@@ -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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef PartSet_DataModel_H
+#define PartSet_DataModel_H
+
+#include "PartSet.h"
+
+#include <Events_Listener.h>
+
+
+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<Events_Message>& theMessage);
+
+  ModuleBase_ITreeNode* root() const { return myRoot; }
+
+private:
+  ModuleBase_ITreeNode* myRoot;
+};
+
+#endif
\ No newline at end of file
index bd06498f248abf9d2747e21fd145764205ea3efa..14d46deaed39edc733f30129b06ff47af82786c3 100755 (executable)
@@ -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<XGUI_ModuleConnector*>(theWshop);
   XGUI_Workshop* aWorkshop = aConnector->workshop();
 
@@ -1219,11 +1222,6 @@ bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result>
   // 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();
+}
index 70de7236d9c54db8df08983fa3336f5394bff575..d196b6bdd392d4ccbfc823627cc95cb613af6421 100755 (executable)
@@ -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<Events_Message>& 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 (file)
index 0000000..3d029e5
--- /dev/null
@@ -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<mailto: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 (file)
index 0000000..6c165b1
--- /dev/null
@@ -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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef PartSet_TreeNodes_H
+#define PartSet_TreeNodes_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_ITreeNode.h>
+
+class PartSet_RootNode : public ModuleBase_ITreeNode
+{
+public:
+  PartSet_RootNode();
+
+};
+
+
+#endif
\ No newline at end of file