Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Fri, 27 Feb 2015 10:12:57 +0000 (13:12 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 27 Feb 2015 10:12:57 +0000 (13:12 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Events.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetConstraintShapeSelector.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.h
src/SketchPlugin/plugin-Sketch.xml

index be3489d7bc7687c097a6da5954c4f33fee43f5ba..32ae6102648ffdb3c727c403ae78acb019d19c2b 100644 (file)
@@ -405,7 +405,7 @@ void Model_Document::abortOperation()
     subDoc(*aSubIter)->abortOperation();
 }
 
-bool Model_Document::isOperation()
+bool Model_Document::isOperation() const
 {
   // operation is opened for all documents: no need to check subs
   return myDoc->HasOpenCommand() == Standard_True ;
@@ -495,12 +495,15 @@ void Model_Document::redo()
 std::list<std::string> Model_Document::undoList() const
 {
   std::list<std::string> aResult;
+  // the number of skipped current operations (on undo they will be aborted)
+  int aSkipCurrent = isOperation() ? 1 : 0;
   std::list<Transaction>::const_reverse_iterator aTrIter = myTransactions.crbegin();
   int aNumUndo = myTransactions.size();
   if (!myNestedNum.empty())
     aNumUndo = *myNestedNum.rbegin();
   for( ; aNumUndo > 0; aTrIter++, aNumUndo--) {
-    aResult.push_back(aTrIter->myId);
+    if (aSkipCurrent == 0) aResult.push_back(aTrIter->myId);
+    else aSkipCurrent--;
   }
   return aResult;
 }
index 62bd3ad40710380d92ebddb4c99ac84c967808b4..bffcc81bcf5012b1f32ceec10658c328d3f52394 100644 (file)
@@ -61,7 +61,7 @@ class Model_Document : public ModelAPI_Document
   //! Aborts the operation 
   MODEL_EXPORT virtual void abortOperation();
   //! Returns true if operation has been started, but not yet finished or aborted
-  MODEL_EXPORT virtual bool isOperation();
+  MODEL_EXPORT virtual bool isOperation() const;
   //! Returns true if document was modified (since creation/opening)
   MODEL_EXPORT virtual bool isModified();
 
index f7293bb6dd5c8a270d94a3c890dc346ba1ec8939..96395a997f9407c668521c29ba3624a79c7dfa43 100644 (file)
@@ -141,25 +141,25 @@ public:
 };
 
 /// Message that document (Part, PartSet) was created
-class MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage : public Events_Message
+class ModelAPI_DocumentCreatedMessage : public Events_Message
 {
   DocumentPtr myDocument;
 
  public:
   /// Creates an empty message
-  ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
+  MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
   /// The virtual destructor
-  virtual ~ModelAPI_DocumentCreatedMessage();
+  MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
 
-  static Events_ID eventId()
+  MODELAPI_EXPORT static Events_ID eventId()
   {
     static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
     return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
   }
 
 
-  DocumentPtr document() const;
-  void setDocument(DocumentPtr theDocument);
+  MODELAPI_EXPORT DocumentPtr document() const;
+  MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
 };
 
 #endif
index 280c107f6d893509c408498e56716c5cdc59ff5c..60388bb2b90d155ed946041041759df8116c481e 100644 (file)
@@ -12,6 +12,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetSketchLabel.h
        PartSet_Validators.h
        PartSet_WidgetPoint2d.h
+       PartSet_WidgetConstraintShapeSelector.h
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
        PartSet_Filters.h
@@ -23,6 +24,7 @@ SET(PROJECT_SOURCES
        PartSet_Tools.cpp
        PartSet_WidgetSketchLabel.cpp
        PartSet_Validators.cpp
+       PartSet_WidgetConstraintShapeSelector.cpp
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
index 129273faddaffda402b9af50f2806fb81d9ef71e..2c90b65a8d20c421ea28829492e1be55a238288b 100644 (file)
@@ -7,6 +7,7 @@
 #include <PartSet_WidgetPoint2d.h>
 #include <PartSet_WidgetPoint2dDistance.h>
 #include <PartSet_WidgetShapeSelector.h>
+#include <PartSet_WidgetConstraintShapeSelector.h>
 #include <PartSet_SketcherMgr.h>
 
 #include <ModuleBase_Operation.h>
diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp
new file mode 100644 (file)
index 0000000..5e1ebe9
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.cpp
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+#include "PartSet_WidgetConstraintShapeSelector.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <PartSet_Tools.h>
+#include <SketchPlugin_Feature.h>
+
+
+//*********************************************
+bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const
+{
+  FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
+  if (aFeature) {
+    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    if ((!aSPFeature) && (!myShape->isNull())) {
+      ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+                                                                  mySelectedObject, mySketch);
+      if (aObj) {
+        PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
+        that->mySelectedObject = aObj;
+      } else 
+        return false;
+    }
+  }
+  return ModuleBase_WidgetShapeSelector::storeValueCustom();
+}
diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.h b/src/PartSet/PartSet_WidgetConstraintShapeSelector.h
new file mode 100644 (file)
index 0000000..900e4ce
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.h
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+
+#ifndef PartSet_WidgetConstraintShapeSelector_H
+#define PartSet_WidgetConstraintShapeSelector_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetShapeSelector in order to provide 
+* working with constraints.
+*/
+class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theWorkshop instance of workshop interface
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from
+  /// \param theParentId is Id of a parent of the current attribute
+  PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+    const Config_WidgetAPI* theData, const std::string& theParentId)
+    : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
+
+  virtual ~PartSet_WidgetConstraintShapeSelector() {}
+
+  /// Set sketcher
+  /// \param theSketch a sketcher object
+  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+  /// Retrurns installed sketcher
+  CompositeFeaturePtr sketch() const { return mySketch; }
+
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom() const;
+
+private:
+  /// Pointer to a sketch 
+  CompositeFeaturePtr mySketch;
+};
+
+#endif
\ No newline at end of file
index 76561e4e6e79b1dc42cda0ec95525736c9ba9e83..bd9e1ce81cbbcc4d253a54955adeab7c7b09b2a3 100644 (file)
@@ -125,22 +125,3 @@ bool PartSet_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<Geom
   return true;
 }
 
-//*********************************************
-bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
-  if (aFeature) {
-    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
-            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-    if ((!aSPFeature) && (!myShape->isNull())) {
-      ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
-                                                                  mySelectedObject, mySketch);
-      if (aObj) {
-        PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
-        that->mySelectedObject = aObj;
-      } else 
-        return false;
-    }
-  }
-  return ModuleBase_WidgetShapeSelector::storeValueCustom();
-}
index e38cdf7984b21e924f8dd7a0a4fea33aace27a69..b69c66648c351c04fdc8a109da761d8feefabefa 100644 (file)
@@ -55,41 +55,4 @@ private:
   CompositeFeaturePtr mySketch;
 };
 
-/**
-* \ingroup Modules
-* Customosation of ModuleBase_WidgetShapeSelector in order to provide 
-* working with constraints.
-*/
-class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \param theParent the parent object
-  /// \param theWorkshop instance of workshop interface
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from
-  /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
-    const Config_WidgetAPI* theData, const std::string& theParentId)
-    : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
-
-  virtual ~PartSet_WidgetConstraintShapeSelector() {}
-
-  /// Set sketcher
-  /// \param theSketch a sketcher object
-  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
-
-  /// Retrurns installed sketcher
-  CompositeFeaturePtr sketch() const { return mySketch; }
-
-protected:
-  /// Saves the internal parameters to the given feature
-  /// \return True in success
-  virtual bool storeValueCustom() const;
-
-private:
-  /// Pointer to a sketch 
-  CompositeFeaturePtr mySketch;
-};
-
 #endif
\ No newline at end of file
index 7447a8fa7624e93f210ba13279cd4901b652e5d4..cc23f8e008231950cec71b37267a609564b6379e 100644 (file)
         <sketch-2dpoint_selector id="ArcEndPoint" title="End point" tooltip="End point"/>
       </feature>
     </group>
-         
+      
     <group id="Constraints">
       <feature
         id="SketchConstraintCoincidence"
         title="Coincident"
         tooltip="Create constraint for the coincidence of two points"
         internal="1" />
-       <!--  SketchConstraintDistance  -->
+    <!--  SketchConstraintDistance  -->
       <feature
         id="SketchConstraintDistance"
         title="Distance"
               shape_types="edge vertex">
           <selection_filter id="MultiFilter" parameters="line,vertex"/>
         </sketch_shape_selector>/>
-               <sketch_shape_selector 
+        <sketch_shape_selector 
           id="ConstraintEntityB" 
           label="Last object" 
           tooltip="Select point, line end point, line, center of circle or arc." 
-                           shape_types="edge vertex">
-                       <validator id="SketchPlugin_DifferentObjects"/>
+                shape_types="edge vertex">
+            <validator id="SketchPlugin_DifferentObjects"/>
       <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
       <selection_filter id="MultiFilter" parameters="line,vertex"/>
     </sketch_shape_selector>
-               
+        
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         
-               <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
+        <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
         
-               <validator id="PartSet_DistanceValidator"/>
+        <validator id="PartSet_DistanceValidator"/>
       </feature>
-       <!--  SketchConstraintLength  -->      
+    <!--  SketchConstraintLength  -->      
       <feature id="SketchConstraintLength" title="Length" tooltip="Set fixed length of a line segment" icon=":icons/length.png">
         <label title="Select a line on which to calculate length" tooltip="Select a line on which to calculate length"/>
-               <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line" 
-                       shape_types="edge" >
-                       <validator id="SketchPlugin_ResultLine"/>
+        <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line" 
+            shape_types="edge" >
+            <validator id="SketchPlugin_ResultLine"/>
       <selection_filter id="EdgeFilter" parameters="line"/>
+      <validator id="SketchPlugin_ResultLine"/>
     </shape_selector>
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
         </doublevalue_editor>
         <validator id="PartSet_LengthValidator"/>
       </feature>
-       <!--  SketchConstraintRadius  -->
+    <!--  SketchConstraintRadius  -->
       <feature id="SketchConstraintRadius" title="Radius" tooltip="Set fixed radius of a circle or an arc" icon=":icons/radius_constr.png">
         <label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
-               <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc" 
-                       shape_types="edge">
-                       <validator id="SketchPlugin_ResultArc"/>
-                       <selection_filter id="EdgeFilter" parameters="circle"/>
-               </shape_selector>
+        <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc" 
+            shape_types="edge">
+            <validator id="SketchPlugin_ResultArc"/>
+            <selection_filter id="EdgeFilter" parameters="circle"/>
+        </shape_selector>
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed"/>
         <validator id="PartSet_RadiusValidator"/>
       </feature>
-       <!--  SketchConstraintParallel  -->
+    <!--  SketchConstraintParallel  -->
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
-               <sketch_constraint_shape_selector id="ConstraintEntityA" 
-                       label="First line" tooltip="Select a line" shape_types="edge">
-                       <selection_filter id="EdgeFilter" parameters="line"/>
-               </sketch_constraint_shape_selector>
-               
-               <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line" 
-                       shape_types="edge">
-                       <selection_filter id="EdgeFilter" parameters="line"/>
-                       <validator id="SketchPlugin_DifferentObjects"/>
-               </sketch_constraint_shape_selector>
-               
+        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+            label="First line" tooltip="Select a line" shape_types="edge">
+            <selection_filter id="EdgeFilter" parameters="line"/>
+        </sketch_constraint_shape_selector>
+        
+        <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select a line" 
+            shape_types="edge">
+            <selection_filter id="EdgeFilter" parameters="line"/>
+            <validator id="SketchPlugin_DifferentObjects"/>
+        </sketch_constraint_shape_selector>
+        
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
         <validator id="PartSet_ParallelValidator"/>
       </feature>
-       <!--  SketchConstraintPerpendicular  -->
+    <!--  SketchConstraintPerpendicular  -->
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
-               <sketch_constraint_shape_selector id="ConstraintEntityA" 
-                       label="First line" tooltip="Select an line" 
-                       shape_types="edge">
+        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+            label="First line" tooltip="Select an line" 
+            shape_types="edge">
       <selection_filter id="EdgeFilter" parameters="line"/>
     </sketch_constraint_shape_selector>
-               
-               <sketch_constraint_shape_selector id="ConstraintEntityB" 
-                       label="Last line" tooltip="Select an line" 
-                       shape_types="edge">
-                       <validator id="SketchPlugin_DifferentObjects"/>
+        
+        <sketch_constraint_shape_selector id="ConstraintEntityB" 
+            label="Last line" tooltip="Select an line" 
+            shape_types="edge">
+            <validator id="SketchPlugin_DifferentObjects"/>
       <selection_filter id="EdgeFilter" parameters="line"/>
     </sketch_constraint_shape_selector>
         <validator id="PartSet_PerpendicularValidator"/>
       </feature>
-       <!--  SketchConstraintRigid  -->
+    <!--  SketchConstraintRigid  -->
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Fix an object" icon=":icons/fixed.png">
         <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select an object" 
-                       shape_types="edge vertex">
-                   <validator id="SketchPlugin_ResultPoint"/>
-                       <validator id="SketchPlugin_ResultLine"/>
-                       <validator id="SketchPlugin_ResultArc"/>
-               </shape_selector>
-           <validator id="PartSet_RigidValidator"/>
+            shape_types="edge vertex">
+               <validator id="SketchPlugin_ResultPoint"/>
+            <validator id="SketchPlugin_ResultLine"/>
+            <validator id="SketchPlugin_ResultArc"/>
+        </shape_selector>
+        <validator id="PartSet_RigidValidator"/>
       </feature>
     </group>
   </workbench>