]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
authorszy <szy@opencascade.com>
Fri, 23 Jan 2015 14:40:04 +0000 (17:40 +0300)
committerszy <szy@opencascade.com>
Fri, 23 Jan 2015 14:40:04 +0000 (17:40 +0300)
35 files changed:
doc/CMakeLists.txt
src/Config/Config_AttributeMessage.cpp
src/Config/Config_AttributeMessage.h
src/Config/Config_Common.h
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.h
src/Config/Config_ModuleReader.cpp
src/Config/Config_ModuleReader.h
src/Config/Config_PointerMessage.h
src/Config/Config_PropManager.h
src/Config/Config_SelectionFilterMessage.h
src/Config/Config_ValidatorMessage.h
src/Config/Config_WidgetAPI.h
src/Config/Config_WidgetReader.h
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py
src/ConnectorPlugin/plugin-Connector.xml
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_Data.h
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index 095f643d5400fa0281c61e9fedc7596e730821c3..bf800eddae9ee46bb395c72f13549b7df153d7c7 100644 (file)
@@ -1,12 +1,18 @@
 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 
-FIND_PROGRAM(DOXYGEN_EXECUTABLE Doxygen)
+IF (WIN32)
+  FIND_PROGRAM(DOXYGEN_EXECUTABLE Doxygen)
+ELSE (WIN32)
+  FIND_PROGRAM(DOXYGEN_EXECUTABLE doxygen)
+ENDIF(WIN32)
 
 CONFIGURE_FILE(doxyfile.in
                "${CMAKE_CURRENT_BINARY_DIR}/doxyfile"
                IMMEDIATE @ONLY)
 
-ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE})
-
-INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tui DESTINATION doc)
+ADD_CUSTOM_TARGET(INSTALL_DOCS
+    COMMAND "${DOXYGEN_EXECUTABLE}"
+    COMMAND "${CMAKE_COMMAND}" --build "${PROJECT_BINARY_DIR}" --target install
+    WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc"
+)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tui DESTINATION doc OPTIONAL)
index cea94547e49461fd9c6d1e363902698be512fe8e..3b37a27bdcef9d45009b941ae70c779403bed470 100644 (file)
@@ -1,8 +1,5 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
-/*
- *
- */
 #include "Config_AttributeMessage.h"
 
 Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const void* theParent)
index c93565758847f1aac94c36f198f036b5ac829074..160efa7e85f84f88e27d28b2637e0762327a2c0d 100644 (file)
@@ -9,8 +9,9 @@
 
 #include <string>
 
-/*
- * Class to pass an attribute's (widget's) entry info extracted from xml file.
+/*!
+ * \class Config_AttributeMessage
+ * \brief Class to pass an attribute's (widget's) entry info extracted from xml file.
  * <widget id="tool_object" concealment="true" obligatory="0"/>
  */
 class Config_AttributeMessage : public Events_Message
index a2cc7884378b87a13006242531dc20f146aa88fb..c1379efe62a43196f39f91f581d17c6239476c72 100644 (file)
@@ -28,12 +28,12 @@ typedef xmlDoc *xmlDocPtr;
 struct _xmlDoc;
 //<<
 
-/*
+/*!
  * Returns true if theNode is XML ELEMENT node (not a "text" node ie).
  */
 CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
 
-/*
+/*!
  * Returns true if theNode is XML node with a given name.
 
  * Please note that this function should be called with NULL last argument.
@@ -43,12 +43,12 @@ CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
  */
 CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
 
-/*
+/*!
  * Checks is the given node is attribute (widget) node.
  */
 CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
 
-/*
+/*!
  * Every xml node has child. Even if there is no explicit
  * child nodes libxml gives the "Text node" as child.
  *
@@ -57,7 +57,7 @@ CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
  */
 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
 
-/*
+/*!
  * Returns named property for an id node as std::string and the parameters of the node.
  */
 CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,
@@ -76,12 +76,12 @@ CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropert
  */
 CONFIG_EXPORT std::string library(const std::string& theLibName);
 
-/*
+/*!
  * Returns named property for a given node as std::string.
  */
 CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
 
-/*
+/*!
  * Checks if the given XML node has the given attribute,
  * if yes - returns it's bool value, if no, or if the value can not
  * be converted to bool - returns theDefault value.
@@ -93,7 +93,7 @@ CONFIG_EXPORT bool getBooleanAttribute(xmlNodePtr theNode,
                                        const char* theAttributeName,
                                        bool theDefault);
 
-/*
+/*!
  * Returns normalized (lower case) version of string.
  * Should be used for case insensitive string matching.
  */
index f5c77fb40ead4a08b94b9c4b5e6c7061f1899371..b925ab656b00117e990b2fa1f7ddf0a366ce3e99 100644 (file)
@@ -1,8 +1,5 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
-/*
- *
- */
 #include "Config_FeatureMessage.h"
 
 Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void* theParent)
index 68bd94378fc5c54ca4f29a91c4faa11e10cef399..f890f44c3f8f42f743e6774a0e996b126eb2d8ab 100644 (file)
@@ -8,8 +8,9 @@
 \r
 #include <string>\r
 \r
-/*\r
- * Class to pass a feature entry extracted from xml file.\r
+/*!\r
+ * \class Config_FeatureMessage\r
+ * \brief Class to pass a feature entry extracted from xml file.\r
  * Example of the feature entry:\r
  * <feature id="Part" text="New part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
  */\r
index eec7889b01df91ee00b815a8373929d4956f8b9a..7986f3b59e3f8ea62efbcf78f20343e54d2a4ac0 100644 (file)
 
 class Config_FeatureMessage;
 
+/*!
+ * \class Config_FeatureReader
+ * \brief Class to process feature's xml definition.
+ */
 class Config_FeatureReader : public Config_XMLReader
 {
  public:
-  Config_FeatureReader(const std::string& theXmlFile, const std::string& theLibraryName,
+  Config_FeatureReader(const std::string& theXmlFile,
+                       const std::string& theLibraryName,
                        const char* theEventGenerated = 0);
   virtual ~Config_FeatureReader();
-
+  /// Returns list of all features defined in reader's file
   std::list<std::string> features() const;
 
  protected:
-  void processNode(xmlNodePtr aNode);
-  bool processChildren(xmlNodePtr aNode);
+  /// Overloaded method. Defines how to process each node
+  virtual void processNode(xmlNodePtr aNode);
+  /// Overloaded method. Defines if the given node should be parsed recursively
+  virtual bool processChildren(xmlNodePtr aNode);
 
+  /// Fills feature message
   void fillFeature(xmlNodePtr theRoot, 
                    const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
 
+  /// Stores an attribute in internal map for later use.
+  /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
   void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
   std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
   std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
 
  private:
index 0b0245c5ad926af7399c7785dd04ed6f654bd65d..6acffa268d3e46e2ac66c57df2602a93688c271f 100644 (file)
@@ -48,7 +48,7 @@ const std::map<std::string, std::string>& Config_ModuleReader::featuresInFiles()
   return myFeaturesInFiles;
 }
 
-/*
+/*!
  * Get module name from plugins.xml
  * (property "module")
  */
@@ -58,9 +58,6 @@ std::string Config_ModuleReader::getModuleName()
   return getProperty(aRoot, PLUGINS_MODULE);
 }
 
-/*
- *
- */
 void Config_ModuleReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_PLUGIN, NULL)) {
index cdfae0a43f46eaa6e8e2310a3c25a728708febbb..911e5d813c8afa10b11f37a859812378cccb5202 100644 (file)
 #include <set>
 #include <string>
 
+/*!
+ * \class Config_ModuleReader
+ * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
+ */
 class Config_ModuleReader : public Config_XMLReader
 {
   enum PluginType {
index e745beb0e48dc3abc0eb83794edb8d4f86ac683c..4edb8c31e8f39dba3658f227a4ec95dda574ebf5 100644 (file)
@@ -13,8 +13,9 @@
 #include <Config_def.h>
 #include <Events_Message.h>
 
-/*
- * A general class to pass pointers over the event loop.
+/*!
+ * \class Config_PointerMessage
+ * \brief A general class to pass pointers over the event loop.
  */
 class CONFIG_EXPORT Config_PointerMessage : public Events_Message
 {
index 4df2e55635c63d168dfb2156a92802ea6ccf94c2..40e2f762a6be1c7fcb016a08c9102b8bcc7f3627 100644 (file)
@@ -14,7 +14,7 @@
 #include <string>
 #include <vector>
 
-//! Class wihich let to register properties
+//! Class which let to register properties
 class Config_PropManager
 {
  public:
index d43b41382d426986320e570d71b9024450429768..fcc54a01097c07e692fc67071233fc5e3fb48466 100644 (file)
 /// Event ID that Selection Filter is loaded (comes with Config_SelectionFilterMessage)
 static const char * EVENT_SELFILTER_LOADED = "SelectionFilterLoaded";
 
+/*!
+ * \class Config_SelectionFilterMessage
+ * \brief Transmits info about selection filters on "SelectionFilterLoaded" event
+ */
 class Config_SelectionFilterMessage : public Events_Message
 {
   std::string mySelectionFilterId;
index 1863891933a23b4476b6a0c46cc942a6a7ed7cef..d137097f9e25ae2a20f1384a23d65a59db8d0a3d 100644 (file)
 /// Event ID that Validator is loaded (comes with Config_ValidatorMessage)
 static const char * EVENT_VALIDATOR_LOADED = "ValidatorLoaded";
 
+/*!
+ * \class Config_ValidatorMessage
+ * \brief Transmits info about created validator on "ValidatorLoaded" event
+ */
 class Config_ValidatorMessage : public Events_Message
 {
   std::string myValidatorId;
index ed58bb4f50b6ff05a0d8df052359280d4e979634..2c2cd9c7165015879a397dc73dceac73e74aa717 100644 (file)
@@ -27,6 +27,10 @@ typedef xmlDoc *xmlDocPtr;
 struct _xmlDoc;
 //<<
 
+/*!
+ * \class Config_WidgetAPI
+ * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
+ */
 class CONFIG_EXPORT Config_WidgetAPI
 {
  public:
index ab60f4278d7dd63fe6163c9d4a2903445f8ab82a..783f2aa45739472641ee554d029dd9324a38a1fc 100644 (file)
 #include <map>
 #include <string>
 
+/*!
+ * \class Config_WidgetReader
+ * \brief Class that dumps xml definitions of widgets for
+ * further processing in the WidgetFactory
+ */
 class Config_WidgetReader : public Config_XMLReader
 {
  public:
-  CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_WidgetReader();
+  CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);
+  CONFIG_EXPORT virtual ~Config_WidgetReader();
 
-  CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);CONFIG_EXPORT std::string featureDescription(
-      const std::string& theFeatureName);
+  CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);
+  CONFIG_EXPORT std::string featureDescription(const std::string& theFeatureName);
 
  protected:
   void processNode(xmlNodePtr theNode);
index 856e663becd7511c6a01bd1fa9a6a4685a6ff5c0..a29eaab64cf67b41d80c4bf7350601b27b3dac59 100644 (file)
@@ -64,7 +64,7 @@ Config_XMLReader::~Config_XMLReader()
   xmlFreeDoc(myXmlDoc);
 }
 
-/*
+/*!
  * Read all nodes in associated xml file,
  * recursively if processChildren(xmlNode) is true for the xmlNode.
  * For each read node the processNode will be called.
@@ -75,7 +75,7 @@ void Config_XMLReader::readAll()
   readRecursively(aRoot);
 }
 
-/*
+/*!
  * Allows to customize reader's behavior for a node. Virtual.
  * The default impl does nothing. (In debug mode prints
  * some info)
@@ -96,7 +96,7 @@ void Config_XMLReader::processNode(xmlNodePtr theNode)
   }
 }
 
-/*
+/*!
  * Defines which nodes should be processed recursively. Virtual.
  * The default impl is to read all nodes.
  */
@@ -105,8 +105,9 @@ bool Config_XMLReader::processChildren(xmlNodePtr aNode)
   return true;
 }
 
-/*
- *
+/*!
+ * Returns xmlNodePtr to the root of reader's document
+ * or NULL if not found
  */
 xmlNodePtr Config_XMLReader::findRoot()
 {
@@ -129,7 +130,7 @@ xmlNodePtr Config_XMLReader::findRoot()
   return aRoot;
 }
 
-/*
+/*!
  * Calls processNode() for each child (for some - recursively)
  * of the given node.
  * \sa ReadAll()
@@ -151,7 +152,7 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
   }
 }
 
-/*
+/*!
  * void* -> xmlNodePtr
  */
 xmlNodePtr Config_XMLReader::node(void* theNode)
@@ -159,6 +160,9 @@ xmlNodePtr Config_XMLReader::node(void* theNode)
   return static_cast<xmlNodePtr>(theNode);
 }
 
+/*!
+ * Gets xml node name
+ */
 std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
 {
   std::string result = "";
@@ -169,6 +173,10 @@ std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
   return result;
 }
 
+/*!
+ * Retrieves all the necessary info from the validator node.
+ * Sends ValidatorLoaded event
+ */
 void Config_XMLReader::processValidator(xmlNodePtr theNode)
 {
   Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
@@ -190,6 +198,10 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode)
   aEvLoop->send(aMessage);
 }
 
+/*!
+ * Retrieves all the necessary info from the SelectionFilter node.
+ * Sends SelectionFilterLoaded event
+ */
 void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
 {
   Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
index 119bd71c132542d662f3fb5b9f152207d4955fb1..412af81a24d7cfef1b78ffac43caff7c1296a2c4 100644 (file)
@@ -27,15 +27,16 @@ typedef xmlDoc *xmlDocPtr;
 struct _xmlDoc;
 //<<
 
-/*
- * Base class for all libxml readers. Provides high-level API
+/*!
+ * \class Config_XMLReader
+ * \brief Base class for all libxml readers. Provides high-level API
  * for all xml operations.
- *
- */
+*/
 class Config_XMLReader
 {
  public:
-  CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_XMLReader();
+  CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
+  CONFIG_EXPORT virtual ~Config_XMLReader();
 
   CONFIG_EXPORT void readAll();
 
index 8b3163426638cdb97464bfe6bb8115deb36036ee..ea030b363731b7b9e352f72eede91f01d0f45496 100644 (file)
@@ -31,17 +31,25 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
         return False
 
     def initAttributes(self):
-        # This feature has no attributes, but should perfore some actions on initialization
+        # This feature has no attributes, but should perform some actions on initialization
         aSession = ModelAPI.ModelAPI_Session.get()
-        aPart = aSession.activeDocument()
+        self.Part = aSession.activeDocument()
+        self.geomObjects = []
+        self.geompy = geomBuilder.New(salome.myStudy)
+       
+        # Export bodies and groups
+        self.exportBodies()
+        self.exportGroups()
+        
+    def exportBodies(self):
         # Get all bodies
         kResultBodyType = "Bodies"
-        aPartSize = aPart.size(kResultBodyType)
+        aPartSize = self.Part.size(kResultBodyType)
         if aPartSize == 0:
             EventsAPI.Events_Error_send("No results in the active document")
             return
-
-        anObjList = [aPart.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
+          
+        anObjList = [self.Part.object(kResultBodyType, idx) for idx in xrange(aPartSize)]     
         for idx, anObject in enumerate(anObjList):
             aResult = ModelAPI.modelAPI_Result(anObject)
             aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
@@ -50,10 +58,49 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
             aShape = aBodyResult.shape()
             aDump = aShape.getShapeStream()
             # Load shape to SALOME Geom
-            geompy = geomBuilder.New(salome.myStudy)
-            aBrep = geompy.RestoreShape(aDump)
-            geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx))
+            aBrep = self.geompy.RestoreShape(aDump)
+            self.geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx + 1))
+            self.geomObjects.append([aShape, aBrep])
+
+    def exportGroups(self):
+        # iterate all features to find groups
+        aFeaturesNum = self.Part.size("Features")
+        groupIndex = 0
+        for anIndex in range(0, aFeaturesNum):
+            aFeature = self.Part.object("Features", anIndex)
+            aSelectionList = aFeature.data().selectionList("group_list")
+            # if a group has been found
+            if aSelectionList:
+                groupIndex = groupIndex + 1
+                self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex))
+                     
+    def createGroupFromList(self, theSelectionList, theGroupName):     
+        # iterate on all selected entities of the group
+        # and get the corresponding ID
+        aSelectionNum = theSelectionList.size()
+        Ids = []
+        for aSelIndex in range(0, aSelectionNum):
+            aSelection = theSelectionList.value(aSelIndex)
+            aSelectionContext = aSelection.context()
+            anID = aSelection.Id()
+            Ids.append(anID)
+            if aSelection.value().isVertex():
+                groupType = "VERTEX"
+            elif aSelection.value().isEdge():
+                groupType = "EDGE" 
+            elif aSelection.value().isFace():
+                groupType = "FACE"
+            else:
+                groupType = "SOLID"
 
+        # iterate on exported objects and check if the current
+        # group refers to this object
+        for obj in self.geomObjects: 
+            if aSelectionContext.shape().isEqual(obj[0]):
+                aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
+                self.geompy.UnionIDs(aGroup,Ids)
+                self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
+          
     def execute(self):
         # Nothing to execute: all logic would be in the initAttributes
         pass
index c3199e151f7cbb2baa2fd3168972150ef4faf00a..8ecabaf4d057b1c91a465c461eab6e4f3b2f6a02 100644 (file)
@@ -4,7 +4,7 @@
       <feature
         id="ExportToGEOM"
         title="Export to GEOM"
-        tooltip="Export all bodies into GEOM module"
+        tooltip="Export all bodies and groups into GEOM module"
         icon=":icons/geom_export.png"/>
     </group>
   </workbench>
index 7d2c9fa1b4b9a9a4d06794a53b78569c5459611c..33d1b25f5302f26d72bf60d2da27c8e19fbb2710 100644 (file)
@@ -1033,3 +1033,20 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const
   }
 
 }
+
+int Model_AttributeSelection::Id()
+{
+  std::shared_ptr<GeomAPI_Shape> aSelection = value();
+  std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
+  const TopoDS_Shape& aMainShape = aContext->impl<TopoDS_Shape>();
+  const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
+  int anID = 0;
+  if (aSelection && !aSelection->isNull() &&
+      aContext   && !aContext->isNull())
+  {
+    TopTools_IndexedMapOfShape aSubShapesMap;
+    TopExp::MapShapes(aMainShape, aSubShapesMap);
+    anID = aSubShapesMap.FindIndex(aSubShape);
+  }
+  return anID;
+}
index 4ca2ef3db2230fcd79ebd748144f3f6bce4ddf9e..8708c136dc932defde1ecfba2c0761475841ee7f 100644 (file)
@@ -41,6 +41,12 @@ public:
 
   /// Returns a textual string of the selection
   MODEL_EXPORT virtual std::string namingName();
+  
+  /// Returns an Id of the selection
+  /// NOTE: This method has been added for temporary export of groups towards old GEOM
+  /// It should then be removed when a direct use of objects from NewGeom
+  /// will be possible from SMESH module of SALOME.
+  MODEL_EXPORT virtual int Id();
 
   /// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name
   MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName);
index 01b66978090198dfd92624ff87ca61e941e795de..64479abe1243c553a1f0c09fd23e9b27dea11e2a 100644 (file)
@@ -160,14 +160,16 @@ class Model_Data : public ModelAPI_Data
   // returns all objects referenced to this
   MODEL_EXPORT virtual const std::set<AttributePtr>& refsToMe() {return myRefsToMe;}
 
+  // returns all references by attributes of this data
+  // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+  MODEL_EXPORT virtual void referencesToObjects(
+    std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
+
 private:
   // removes all information about back references
   void eraseBackReferences();
   // adds a back reference (with identifier which attribute references to this object
   void addBackReference(FeaturePtr theFeature, std::string theAttrID);
-  // returns all references by attributes of this data
-  // \param the returned list of pairs: id of referenced attribute and list of referenced objects
-  void referencesToObjects(std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
 };
 
 #endif
index fb6ebf8e46e9605955054ab3b3d86ed55851fd5e..f1f10b103763dca05342c19888f0d014678b9146 100644 (file)
@@ -370,7 +370,7 @@ void Model_Document::abortOperation()
 {
   if (!myNestedNum.empty() && !myDoc->HasOpenCommand()) {  // abort all what was done in nested
     compactNested();
-    undo();
+    undoInternal(false);
     myDoc->ClearRedos();
     myRedos.clear();
   } else { // abort the current
@@ -418,7 +418,7 @@ bool Model_Document::canUndo()
   return false;
 }
 
-void Model_Document::undo()
+void Model_Document::undoInternal(const bool theWithSubs)
 {
   int aNumTransactions = *myTransactions.rbegin();
   myTransactions.pop_back();
@@ -429,12 +429,19 @@ void Model_Document::undo()
   for(int a = 0; a < aNumTransactions; a++)
     myDoc->Undo();
 
-  synchronizeFeatures(true, true);
-  // undo for all subs
-  const std::set<std::string> aSubs = subDocuments(true);
-  std::set<std::string>::iterator aSubIter = aSubs.begin();
-  for (; aSubIter != aSubs.end(); aSubIter++)
-    subDoc(*aSubIter)->undo();
+  if (theWithSubs) {
+    synchronizeFeatures(true, true);
+    // undo for all subs
+    const std::set<std::string> aSubs = subDocuments(true);
+    std::set<std::string>::iterator aSubIter = aSubs.begin();
+    for (; aSubIter != aSubs.end(); aSubIter++)
+      subDoc(*aSubIter)->undo();
+  }
+}
+
+void Model_Document::undo()
+{
+  undoInternal(true);
 }
 
 bool Model_Document::canRedo()
index 2c9dd21234ad3e434df3609493045b5396fabba9..56490a15c337b60a825b729215da58567411df97 100644 (file)
@@ -189,6 +189,9 @@ class Model_Document : public ModelAPI_Document
   //! Returns all sub documents
   const std::set<std::string> subDocuments(const bool theActivatedOnly) const;
 
+  //! The implementation of undo: with or without recoursive calls in the sub-documents
+  void undoInternal(const bool theWithSubs);
+
   friend class Model_Application;
   friend class Model_Session;
   friend class Model_Update;
index 3778ecdd4d30acc48d75b552e9ebb62df3c67378..fc7675f48b196a8ef2f8a5a251f6a521448e58d4 100644 (file)
@@ -46,6 +46,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
 
   /// Returns a textual string of the selection
   virtual std::string namingName() = 0;
+  
+  /// Returns an id of the selection
+  virtual int Id() = 0;
 
 
   /// Selects sub-shape by the textual Name
index 14d191b08bb4556e9cca2264e68dc34ff07f6829..03e21b36fef4ae3f239c4f87f496b714607e82fb 100644 (file)
@@ -26,6 +26,7 @@ class ModelAPI_Attribute;
 class ModelAPI_Feature;
 class ModelAPI_AttributeSelection;
 class ModelAPI_AttributeSelectionList;
+class ModelAPI_Object;
 class GeomAPI_Shape;
 
 /// Enumeration that contains the execution status of the Object
@@ -126,6 +127,10 @@ class MODELAPI_EXPORT ModelAPI_Data
  // returns all objects referenced to this
   virtual const std::set<std::shared_ptr<ModelAPI_Attribute> >& refsToMe() = 0;
 
+  // returns all references by attributes of this data
+  // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+  virtual void referencesToObjects(
+    std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > >& theRefs) = 0;
  protected:
   /// Objects are created for features automatically
   ModelAPI_Data()
index 3e24e1e767126bee62b7a0435315f64795c76024..a298dd29723c13b92e42b45c7d781673d795f09c 100644 (file)
@@ -28,18 +28,10 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
     if (aWirePtr->hasPlane() ) {
       // If this is a wire with plane defined thin it is a sketch-like object
       // It must have invisible faces
-      GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-        aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
-
-      myOriginalShape = aWirePtr->impl<TopoDS_Shape>();
-      Set(myOriginalShape);
       myIsSketchMode = true;
-    } else {
-      Set(aWirePtr->impl<TopoDS_Shape>());
     }
-  } else {
-    Set(aShapePtr->impl<TopoDS_Shape>());
   }
+  Set(aShapePtr->impl<TopoDS_Shape>());
 }
 
 
@@ -50,6 +42,13 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
   if (!aShapePtr)
     return;
+  if (myIsSketchMode) {
+    std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
+      std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
+    myFacesList.clear();
+    GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
+      aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
+  }
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
   if (!myOriginalShape.IsNull()) {
     Set(aShapePtr->impl<TopoDS_Shape>());
index 42c1a3d3b42ed61df1073f39b3b79847c4d4f9b5..ca51046f90cf9adbc2608f1a475025f0101d052c 100644 (file)
@@ -196,9 +196,10 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
   // because the displayed objects should be removed from the viewer, but
   // the AIS context is obtained from the selector.
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
-  if (anOperation)
+  while (anOperation) {
     anOperation->abort();
-
+    anOperation = myWorkshop->operationMgr()->currentOperation();
+  }
   // Delete selector because it has to be redefined on next activation
   if (mySelector) {
     myProxyViewer->setSelector(0);
index 288b0c02aa85ff29852469f9155cea9b894e6f5f..0613d66243959e0efcc1ed29da32efc6039d2639 100644 (file)
@@ -207,12 +207,12 @@ void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
 //**********************************************
 void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
 {
-  //mySelector->viewer()->enableSelection(isEnabled);
+  if (mySelector)
+    mySelector->viewer()->enableSelection(isEnabled);
   // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
   // After this is corrected, the first row should be recommented, the last - removed
-  if (mySelector)
-    mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
-                                                        : SUIT_ViewModel::KEY_FREE);
+    //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+    //                                                    : SUIT_ViewModel::KEY_FREE);
 }
 
 //**********************************************
index 7937a60c337249dc43e58308367d78e723b3951f..0da5482f9a72bfeb51b4f133c175f3ef6e9b85a6 100644 (file)
@@ -132,6 +132,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
   if (!(theEvent->buttons() & Qt::LeftButton))
     return;
 
+  // Clear dragging mode
+  myIsDragging = false;
+
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
   // Use only for sketch operations
@@ -181,7 +184,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
     if (isSketcher) {
       myIsDragging = true;
-
       get2dPoint(theWnd, theEvent, myCurX, myCurY);
       myDragDone = false;
       launchEditing();
@@ -205,30 +207,28 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
 {
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_Operation* aOp = aWorkshop->currentOperation();
-  if (!aOp)
-    return;
-  if (!sketchOperationIdList().contains(aOp->id()))
-    return;
-
-  // Only for sketcher operations
-  ModuleBase_IViewer* aViewer = aWorkshop->viewer();
-  if (myIsDragging) {
-    aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
-    myIsDragging = false;
-    if (myDragDone) {
-      //aOp->commit();
-      myFeature2AttributeMap.clear();
-
-      // Reselect edited object
-      /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
-      if (theEvent->modifiers() & Qt::ShiftModifier)
-        aViewer->AISContext()->ShiftSelect();
-      else
-        aViewer->AISContext()->Select();
-        */
-      return;
+  if (aOp) {
+    if (sketchOperationIdList().contains(aOp->id())) {
+      // Only for sketcher operations
+      ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+      if (myIsDragging) {
+        if (myDragDone) {
+          //aOp->commit();
+          myFeature2AttributeMap.clear();
+
+          // Reselect edited object
+          /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
+          if (theEvent->modifiers() & Qt::ShiftModifier)
+            aViewer->AISContext()->ShiftSelect();
+          else
+            aViewer->AISContext()->Select();
+            */
+        }
+      }
     }
   }
+  aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
+  myIsDragging = false;
 }
 
 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -246,6 +246,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     aViewer->enableSelection(false);
 
     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
+    if (!aOperation)
+      return;
     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
       return; // No edit operation activated
 
index 69c488639f9e7287e05406cb7b1ba60b7f7e06ae..278c3e637906497337b4230cf972e978c90ed773 100644 (file)
@@ -16,6 +16,7 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_Object.h>
 
 #include <SketchPlugin_Sketch.h>
 
@@ -163,14 +164,37 @@ bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
                                                 const std::list<std::string>& theArguments,
                                                 const AttributePtr& theAttribute) const
 {
-  // not implemented
-  return true;
+  return PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments);
 }
 
 bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
                                                 const std::list<std::string>& theArguments) const
 {
-  // not implemented
+  std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
+  if (theAttribute->owner().get() && theAttribute->owner()->data().get())
+    theAttribute->owner()->data()->referencesToObjects(allRefs);
+  // collect object referenced by theAttribute
+  std::list<ObjectPtr>* anAttrObjs = 0;
+  std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefIter = allRefs.begin();
+  for(; aRefIter != allRefs.end(); aRefIter++) {
+    if (theAttribute->id() == aRefIter->first)
+      anAttrObjs = &(aRefIter->second);
+  }
+  if (!anAttrObjs || anAttrObjs->empty())
+    return true; // theAttribute does not references to anything
+  // check with all others
+  for(aRefIter = allRefs.begin(); aRefIter != allRefs.end(); aRefIter++) {
+    if (theAttribute->id() == aRefIter->first)
+      continue; // do not check with myself
+    std::list<ObjectPtr>::iterator aReferenced = aRefIter->second.begin();
+    for(; aReferenced != aRefIter->second.end(); aReferenced++) {
+      std::list<ObjectPtr>::iterator aReferencedByMe = anAttrObjs->begin();
+      for(; aReferencedByMe != anAttrObjs->end(); aReferencedByMe++) {
+        if (*aReferenced == *aReferencedByMe) // found same objects!
+          return false;
+      }
+    }
+  }
   return true;
 }
 
index f9d8fcf6b059d19a28ac5399288d7aac30bb5ec9..21f885c64ee4dadac4f2aefc45fca1368230f1a2 100644 (file)
@@ -263,7 +263,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
   std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt = 
     PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
   if (aAttrPnt.get() != NULL) {
-
+    aFeaturePoint->setValue(aAttrPnt->pnt());
     PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
     emit vertexSelected();
   }
index 9fff4686996f5bad134648b16a32382df9218baf..bf48108641a3d72338b4904b8d7e1931c75a2314 100644 (file)
@@ -274,8 +274,6 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
 
 void PartSet_WidgetSketchLabel::setSketchingMode()
 {
-  qDebug("### Set sketching mode");
-
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   // Clear standard selection modes if they are defined
   //aDisp->activateObjects(aModes);
index f544c5b438f710b6707b64d3856619005e75f5f2..cab65bc08482e14ab69d345d0552761245f01289 100644 (file)
@@ -145,7 +145,6 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
       closeLocalContexts(false);
     }
     aContext->Display(anAISIO, false);
-    qDebug("### Display %i", (long)anAISIO.Access());
 
     aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
     // Customization of presentation
@@ -243,7 +242,6 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject)
     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     aContext->Deactivate(anAIS);
-    qDebug("### Deactivate obj %i", (long)anAIS.Access());
   }
 }
 
@@ -268,12 +266,10 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
       foreach(int aMode, theModes) {
         //aContext->Load(anAIS, aMode, true);
         aContext->Activate(anAIS, aMode);
-        qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
       }
     } else {
       //aContext->Load(anAIS, 0, true);
       aContext->Activate(anAIS);
-      qDebug("### 2. Activate obj %i", (long)anAIS.Access());
     }
   }
 }
@@ -337,12 +333,10 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
       if (myActiveSelectionModes.size() == 0) {
         //aContext->Load(anAISIO, 0, true);
         aContext->Activate(anAISIO);
-        qDebug("### 2. Activate all %i", (long)anAISIO.Access());
       } else {
         foreach(int aMode, myActiveSelectionModes) {
           //aContext->Load(anAISIO, aMode, true);
           aContext->Activate(anAISIO, aMode);
-          qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
         }
       }
     }
@@ -368,11 +362,6 @@ void XGUI_Displayer::deactivateObjects()
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
     aContext->Deactivate(anAISIO);
-    //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
-    //if (aTrihedron.IsNull()) {
-    //  qDebug("### Deactivate all %i", (long)anAISIO.Access());
-    //  //aContext->Activate(anAISIO);
-    //}
   }
 }
 
@@ -472,7 +461,6 @@ void XGUI_Displayer::openLocalContext()
 
     //aContext->ClearCurrents();
     aContext->OpenLocalContext();
-    qDebug("### Open context");
     //aContext->NotUseDisplayedObjects();
 
     //myUseExternalObjects = false;
@@ -505,7 +493,6 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 
     //aContext->ClearSelected();
     aContext->CloseAllContexts(false);
-    qDebug("### Close context");
 
     // Redisplay all object if they were displayed in localContext
     Handle(AIS_InteractiveObject) aAISIO;
@@ -584,7 +571,6 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
     aContext->OpenLocalContext();
-    qDebug("### Open context");
   }
   return aContext;
 }
index a0ee892600a6e08320351deda27c4a0bf7d845ee..0f056a94f63ac057c2f3a324551af85c1b159096 100644 (file)
@@ -1239,6 +1239,7 @@ void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
     myObjectBrowser->activatePart(theFeature);
     myPartActivating = false;
   }
+  updateCommandStatus();
 }
 
 //**************************************************************
@@ -1356,6 +1357,11 @@ void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode)
 //**************************************************************
 void XGUI_Workshop::closeDocument()
 {
+  ModuleBase_Operation* anOperation = operationMgr()->currentOperation();
+  while (anOperation) {
+    anOperation->abort();
+    anOperation = operationMgr()->currentOperation();
+  }
   myDisplayer->closeLocalContexts();
   myDisplayer->eraseAll();
   objectBrowser()->clearContent();