]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Separate attributes for Extrusion and Revolution features.
authordbv <dbv@opencascade.com>
Tue, 23 Jun 2015 15:57:34 +0000 (18:57 +0300)
committerdbv <dbv@opencascade.com>
Tue, 23 Jun 2015 16:01:02 +0000 (19:01 +0300)
16 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.h
src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/extrusioncut_widget.xml
src/FeaturesPlugin/extrusionfuse_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/FeaturesPlugin/revolutioncut_widget.xml
src/FeaturesPlugin/revolutionfuse_widget.xml
src/GeomValidators/GeomValidators_ZeroOffset.cpp
src/GeomValidators/GeomValidators_ZeroOffset.h

index 31015f839abb36d5fa51821dd90da970ed525b85..8775c3ac6b4fa4ee5e46c9e967f997325de6e164 100644 (file)
@@ -43,10 +43,13 @@ void FeaturesPlugin_Extrusion::initAttributes()
   data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
 
   data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+
   data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
-  data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
@@ -58,28 +61,36 @@ void FeaturesPlugin_Extrusion::execute()
   AttributeSelectionListPtr aFaceRefs = selectionList(LIST_ID());
 
   // Getting sizes.
-  double aFromSize = real(FROM_SIZE_ID())->value();
-  double aToSize = real(TO_SIZE_ID())->value();
+  double aToSize = 0.0;
+  double aFromSize = 0.0;
+
+  if(string(CREATION_METHOD())->value() == "BySizes") {
+    aToSize = real(TO_SIZE_ID())->value();
+    aFromSize =  real(FROM_SIZE_ID())->value();
+  } else {
+    aToSize = real(TO_OFFSET_ID())->value();
+    aFromSize =  real(FROM_OFFSET_ID())->value();
+  }
 
   // Getting bounding planes.
-  std::shared_ptr<GeomAPI_Shape> aFromShape;
   std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
 
   if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(FROM_OBJECT_ID());
-    if(anObjRef.get() != NULL) {
-      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
-      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
-        aFromShape = anObjRef->context()->shape();
-      }
-    }
-    anObjRef = selection(TO_OBJECT_ID());
+    std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(TO_OBJECT_ID());
     if(anObjRef.get() != NULL) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
       if(aToShape.get() == NULL && anObjRef->context().get() != NULL) {
         aToShape =  anObjRef->context()->shape();
       }
     }
+    anObjRef = selection(FROM_OBJECT_ID());
+    if(anObjRef.get() != NULL) {
+      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+        aFromShape = anObjRef->context()->shape();
+      }
+    }
   }
 
   // for each selected face generate a result
index 2d72d49bb1817b83d968303509ff4f32257ffcf0..96546369188e7e6ade2a294543cc2dce01a4a844 100644 (file)
@@ -75,6 +75,13 @@ class FeaturesPlugin_Extrusion : public ModelAPI_Feature
     return MY_TO_OBJECT_ID;
   }
 
+  /// attribute name of extrusion offset
+  inline static const std::string& TO_OFFSET_ID()
+  {
+    static const std::string MY_TO_OFFSET_ID("to_offset");
+    return MY_TO_OFFSET_ID;
+  }
+
   /// attribute name of tool object
   inline static const std::string& FROM_OBJECT_ID()
   {
@@ -82,6 +89,13 @@ class FeaturesPlugin_Extrusion : public ModelAPI_Feature
     return MY_FROM_OBJECT_ID;
   }
 
+  /// attribute name of extrusion offset
+  inline static const std::string& FROM_OFFSET_ID()
+  {
+    static const std::string MY_FROM_OFFSET_ID("from_offset");
+    return MY_FROM_OFFSET_ID;
+  }
+
   /// Returns the kind of a feature
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
index 76bf4d291186c67625cac0c2908a084e41aaccdb..2a564e95540dae77837132b211f7484e8500d60d 100644 (file)
@@ -19,11 +19,14 @@ void FeaturesPlugin_ExtrusionBoolean::initMakeSolidsAttributes()
 {
   data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
 
-  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+
+  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-  data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
@@ -33,28 +36,36 @@ void FeaturesPlugin_ExtrusionBoolean::initMakeSolidsAttributes()
 ListOfShape FeaturesPlugin_ExtrusionBoolean::MakeSolids(const ListOfShape& theFaces)
 {
   // Getting extrusion sizes.
-  double aFromSize = real(FROM_SIZE_ID())->value();
-  double aToSize = real(TO_SIZE_ID())->value();
+  double aToSize = 0.0;
+  double aFromSize = 0.0;
+
+  if(string(CREATION_METHOD())->value() == "BySizes") {
+    aToSize = real(TO_SIZE_ID())->value();
+    aFromSize =  real(FROM_SIZE_ID())->value();
+  } else {
+    aToSize = real(TO_OFFSET_ID())->value();
+    aFromSize =  real(FROM_OFFSET_ID())->value();
+  }
 
   // Getting extrusion bounding planes.
-  std::shared_ptr<GeomAPI_Shape> aFromShape;
   std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
 
   if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(FROM_OBJECT_ID());
-    if(anObjRef.get() != NULL) {
-      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
-      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
-        aFromShape = anObjRef->context()->shape();
-      }
-    }
-    anObjRef = selection(TO_OBJECT_ID());
+    std::shared_ptr<ModelAPI_AttributeSelection> anObjRef = selection(TO_OBJECT_ID());
     if(anObjRef.get() != NULL) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
       if(aToShape.get() == NULL && anObjRef->context().get() != NULL) {
         aToShape =  anObjRef->context()->shape();
       }
     }
+    anObjRef = selection(FROM_OBJECT_ID());
+    if(anObjRef.get() != NULL) {
+      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+        aFromShape = anObjRef->context()->shape();
+      }
+    }
   }
 
   // Extrude faces.
index 8fd63449f45f3af31475a6d6785744f8eba45a42..f83ec91474e3acf91e6ca45902eb3c5de8a91d2c 100644 (file)
@@ -23,14 +23,14 @@ class FeaturesPlugin_ExtrusionBoolean : public FeaturesPlugin_CompositeBoolean
     return METHOD_ATTR;
   }
 
-  /// Attribute name of an object from which the extrusion grows.
-  inline static const std::string& FROM_OBJECT_ID()
+  /// attribute name of extrusion size
+  inline static const std::string& TO_SIZE_ID()
   {
-    static const std::string MY_FROM_OBJECT_ID("from_object");
-    return MY_FROM_OBJECT_ID;
+    static const std::string MY_TO_SIZE_ID("to_size");
+    return MY_TO_SIZE_ID;
   }
 
-  /// Attribute name of extrusion from size.
+  /// attribute name of extrusion size
   inline static const std::string& FROM_SIZE_ID()
   {
     static const std::string MY_FROM_SIZE_ID("from_size");
@@ -44,11 +44,25 @@ class FeaturesPlugin_ExtrusionBoolean : public FeaturesPlugin_CompositeBoolean
     return MY_TO_OBJECT_ID;
   }
 
-  /// Attribute name of extrusion to size.
-  inline static const std::string& TO_SIZE_ID()
+  /// attribute name of extrusion offset
+  inline static const std::string& TO_OFFSET_ID()
   {
-    static const std::string MY_TO_SIZE_ID("to_size");
-    return MY_TO_SIZE_ID;
+    static const std::string MY_TO_OFFSET_ID("to_offset");
+    return MY_TO_OFFSET_ID;
+  }
+
+  /// Attribute name of an object from which the extrusion grows.
+  inline static const std::string& FROM_OBJECT_ID()
+  {
+    static const std::string MY_FROM_OBJECT_ID("from_object");
+    return MY_FROM_OBJECT_ID;
+  }
+
+  /// attribute name of extrusion offset
+  inline static const std::string& FROM_OFFSET_ID()
+  {
+    static const std::string MY_FROM_OFFSET_ID("from_offset");
+    return MY_FROM_OFFSET_ID;
   }
 
 protected:
index 4a7795a06717745094491cfd10e4cb0666b12082..3bd64910c877776803eceff05277c89e9ef5f975 100644 (file)
@@ -41,11 +41,14 @@ void FeaturesPlugin_Revolution::initAttributes()
 
   data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
 
-  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+
+  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-  data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
@@ -70,21 +73,22 @@ void FeaturesPlugin_Revolution::execute()
   }
 
   // Getting angles.
-  double aFromAngle = real(FROM_ANGLE_ID())->value();
   double aToAngle = real(TO_ANGLE_ID())->value();
+  double aFromAngle = real(FROM_ANGLE_ID())->value();
+
+  if(string(CREATION_METHOD())->value() == "ByAngles") {
+    aToAngle = real(TO_ANGLE_ID())->value();
+    aFromAngle =  real(FROM_ANGLE_ID())->value();
+  } else {
+    aToAngle = real(TO_OFFSET_ID())->value();
+    aFromAngle =  real(FROM_OFFSET_ID())->value();
+  }
 
   // Getting bounding planes.
-  std::shared_ptr<GeomAPI_Shape> aFromShape;
   std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
 
   if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
-    anObjRef = selection(FROM_OBJECT_ID());
-    if(anObjRef.get() != NULL) {
-      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
-      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
-        aFromShape = anObjRef->context()->shape();
-      }
-    }
     anObjRef = selection(TO_OBJECT_ID());
     if(anObjRef.get() != NULL) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
@@ -92,6 +96,13 @@ void FeaturesPlugin_Revolution::execute()
         aToShape =  anObjRef->context()->shape();
       }
     }
+    anObjRef = selection(FROM_OBJECT_ID());
+    if(anObjRef.get() != NULL) {
+      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+        aFromShape = anObjRef->context()->shape();
+      }
+    }
   }
 
   // for each selected face generate a result
index 9edc1dc0ec00526e4301b880619f07d74c5ae2e3..57150bdf73a3d3060467c76cb38f44b73321fc65 100644 (file)
@@ -74,6 +74,13 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature
     return MY_TO_OBJECT_ID;
   }
 
+  /// attribute name of extrusion offset.
+  inline static const std::string& TO_OFFSET_ID()
+  {
+    static const std::string MY_TO_OFFSET_ID("to_offset");
+    return MY_TO_OFFSET_ID;
+  }
+
   /// Attribute name of tool object.
   inline static const std::string& FROM_OBJECT_ID()
   {
@@ -81,6 +88,13 @@ class FeaturesPlugin_Revolution : public ModelAPI_Feature
     return MY_FROM_OBJECT_ID;
   }
 
+  /// attribute name of extrusion offset.
+  inline static const std::string& FROM_OFFSET_ID()
+  {
+    static const std::string MY_FROM_OFFSET_ID("from_offset");
+    return MY_FROM_OFFSET_ID;
+  }
+
   /// \return the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
index a5f5140a3bd85f036cc5d08af9bf353d01701271..ef3af8ec681fefc767839551d2aa0a006affb61e 100644 (file)
@@ -23,11 +23,14 @@ void FeaturesPlugin_RevolutionBoolean::initMakeSolidsAttributes()
 
   data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
 
-  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+
+  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-  data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TO_OBJECT_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FROM_OBJECT_ID());
@@ -50,21 +53,22 @@ ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theF
   }
 
   // Getting revolution angles.
-  double aFromAngle = real(FROM_ANGLE_ID())->value();
   double aToAngle = real(TO_ANGLE_ID())->value();
+  double aFromAngle = real(FROM_ANGLE_ID())->value();
+
+  if(string(CREATION_METHOD())->value() == "ByAngles") {
+    aToAngle = real(TO_ANGLE_ID())->value();
+    aFromAngle =  real(FROM_ANGLE_ID())->value();
+  } else {
+    aToAngle = real(TO_OFFSET_ID())->value();
+    aFromAngle =  real(FROM_OFFSET_ID())->value();
+  }
 
   // Getting revolution bounding planes.
-  std::shared_ptr<GeomAPI_Shape> aFromShape;
   std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
 
   if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
-    anObjRef = selection(FROM_OBJECT_ID());
-    if(anObjRef.get() != NULL) {
-      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
-      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
-        aFromShape = anObjRef->context()->shape();
-      }
-    }
     anObjRef = selection(TO_OBJECT_ID());
     if(anObjRef.get() != NULL) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
@@ -72,6 +76,13 @@ ListOfShape FeaturesPlugin_RevolutionBoolean::MakeSolids(const ListOfShape& theF
         aToShape =  anObjRef->context()->shape();
       }
     }
+    anObjRef = selection(FROM_OBJECT_ID());
+    if(anObjRef.get() != NULL) {
+      aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anObjRef->value());
+      if(aFromShape.get() == NULL && anObjRef->context().get() != NULL) {
+        aFromShape = anObjRef->context()->shape();
+      }
+    }
   }
 
   // Revol faces.
index 354f5badce048f6c30915df19c872104ac133be9..3e8576aad1484019b304eea28ff92e5ef9781b82 100644 (file)
@@ -29,11 +29,11 @@ public:
     return METHOD_ATTR;
   }
 
-  /// Attribute name of an object from which the revolution grows.
-  inline static const std::string& FROM_OBJECT_ID()
+  /// Attribute name of revolution to angle.
+  inline static const std::string& TO_ANGLE_ID()
   {
-    static const std::string MY_FROM_OBJECT_ID("from_object");
-    return MY_FROM_OBJECT_ID;
+    static const std::string MY_TO_ANGLE_ID("to_angle");
+    return MY_TO_ANGLE_ID;
   }
 
   /// Attribute name of revolution from angle.
@@ -42,19 +42,33 @@ public:
     static const std::string MY_FROM_ANGLE_ID("from_angle");
     return MY_FROM_ANGLE_ID;
   }
-
-  /// attribute name of an object to which the revolution grows.
+  
+  /// Attribute name of an object to which the revolution grows.
   inline static const std::string& TO_OBJECT_ID()
   {
     static const std::string MY_TO_OBJECT_ID("to_object");
     return MY_TO_OBJECT_ID;
   }
 
-  /// Attribute name of revolution to angle.
-  inline static const std::string& TO_ANGLE_ID()
+  /// Attribute name of extrusion offset.
+  inline static const std::string& TO_OFFSET_ID()
   {
-    static const std::string MY_TO_ANGLE_ID("to_angle");
-    return MY_TO_ANGLE_ID;
+    static const std::string MY_TO_OFFSET_ID("to_offset");
+    return MY_TO_OFFSET_ID;
+  }
+
+  /// Attribute name of an object from which the revolution grows.
+  inline static const std::string& FROM_OBJECT_ID()
+  {
+    static const std::string MY_FROM_OBJECT_ID("from_object");
+    return MY_FROM_OBJECT_ID;
+  }
+
+  /// Attribute name of extrusion offset.
+  inline static const std::string& FROM_OFFSET_ID()
+  {
+    static const std::string MY_FROM_OFFSET_ID("from_offset");
+    return MY_FROM_OFFSET_ID;
   }
 
 protected:
index 85f3179d3d0eeac1ae7c065a5524f0b9140b4d13..5e1c3fe8e6f59e52edb90630376caf0e7fdd2b0b 100644 (file)
@@ -10,7 +10,7 @@
     <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <toolbox id="CreationMethod">
-    <box id="ByOffsets" title="By offsets">
+    <box id="BySizes" title="By sizes">
       <groupbox>
         <doublevalue
           id="to_size"
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
         <doublevalue
-          id="to_size"
-          label="Size"
+          id="to_offset"
+          label="Offset"
           min="0"
           step="1.0"
-          default="10"
+          default="0"
           icon=":icons/dimension_up.png"
-          tooltip="Size">
+          tooltip="Offset">
         </doublevalue>
       </groupbox>
       <groupbox title="From">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
         <doublevalue
-          id="from_size"
-          label="Size"
+          id="from_offset"
+          label="Offset"
           min="0"
           step="1.0"
           default="0"
           icon=":icons/dimension_down.png"
-          tooltip="Size">
+          tooltip="Offset">
         </doublevalue>
       </groupbox>
     </box>    
   </toolbox>
-  <validator id="GeomValidators_ZeroOffset" parameters="from_object,to_object,from_size,to_size"/>
+  <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
 </source>
index 4c1a3c256c6a78e7803c5c28f2a925df746dcae3..0b9f14a6e459e432e4934c1aca8857c203b44056 100755 (executable)
@@ -8,14 +8,14 @@
       tooltip="Create or edit a sketch">
     </sketch_launcher>
     <toolbox id="CreationMethod">
-      <box id="ByOffsets" title="By offsets">
+      <box id="BySizes" title="By sizes">
         <groupbox>
           <doublevalue
             id="to_size"
             label="Size"
             min="0"
             step="1.0"
-            default="10"
+            default="0"
             icon=":icons/dimension_up.png"
             tooltip="Size">
           </doublevalue>
@@ -26,7 +26,7 @@
             label="Size"
             min="0"
             step="1.0"
-            default="0"
+            default="10"
             icon=":icons/dimension_down.png"
             tooltip="Size">
           </doublevalue>
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue  id="to_size"
-            label="Size" min="0" step="1.0" default="0"
+          <doublevalue  id="to_offset"
+            label="Offset" min="0" step="1.0" default="0"
             icon=":icons/dimension_up.png"
-            tooltip="Size">
+            tooltip="Offset">
           </doublevalue>
-        </groupbox>        
+        </groupbox>
         <groupbox title="From">
           <shape_selector id="from_object"
                           icon=":icons/plane.png"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue id="from_size" label="Size"
-            min="0" step="1.0" default="10"
+          <doublevalue id="from_offset"
+            label="Offset" min="0" step="1.0" default="0"
             icon=":icons/dimension_down.png"
-            tooltip="Size">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
       </box>
index 08a2605f801dce5ec956f623cae4dd2417e5096c..70579aa19ea833942b602962dec4ddc360dc8d92 100644 (file)
@@ -8,7 +8,7 @@
       tooltip="Create or edit a sketch">
     </sketch_launcher>
     <toolbox id="CreationMethod">
-      <box id="ByOffsets" title="By offsets">
+      <box id="BySizes" title="By sizes">
         <groupbox>
           <doublevalue
             id="to_size"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue  id="to_size"
-            label="Size" min="0" step="1.0" default="0"
+          <doublevalue  id="to_offset"
+            label="Offset" min="0" step="1.0" default="0"
             icon=":icons/dimension_up.png"
-            tooltip="Size">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
         <groupbox title="From">
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue id="from_size" label="Size"
-            min="0" step="1.0" default="10"
+          <doublevalue id="from_offset"
+            label="Offset" min="0" step="1.0" default="0"
             icon=":icons/dimension_down.png"
-            tooltip="Size">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
       </box>
index c11aa4c19fa304c9e7577204c284d2ad03ea5d0f..47b5ee04e7c4344daba778d77ee3d217ceb71f8f 100644 (file)
@@ -17,7 +17,7 @@
     <validator id="GeomValidators_ShapeType" parameters="line"/>
   </shape_selector>
   <toolbox id="CreationMethod">
-    <box id="ByOffsets" title="By offsets">
+    <box id="ByAngles" title="By angles">
       <groupbox>
         <doublevalue
           id="to_angle"
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
         <doublevalue
-          id="to_angle"
-          label="Angle"
+          id="to_offset"
+          label="Offset"
           min="0"
           step="1.0"
-          default="360"
+          default="0"
           icon=":icons/angle_up.png"
-          tooltip="Angle">
+          tooltip="Offset">
         </doublevalue>
       </groupbox>
       <groupbox title="From">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
         <doublevalue
-          id="from_angle"
-          label="Angle"
+          id="from_offset"
+          label="Offset"
           min="0"
           step="1.0"
           default="0"
           icon=":icons/angle_down.png"
-          tooltip="Angle">
+          tooltip="Offset">
         </doublevalue>
       </groupbox>
     </box>
   </toolbox>
-  <validator id="GeomValidators_ZeroOffset" parameters="from_object,to_object,from_angle,to_angle"/>
+  <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
 </source>
\ No newline at end of file
index 6d1683b35242582b9aee11537fd6f03ddb67d400..93bfdcf066e594ee38aff01e1d410c94d7eb9c17 100644 (file)
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
     <toolbox id="CreationMethod">
-      <box id="ByOffsets" title="By offsets">
+      <box id="ByAngles" title="By angles">
         <groupbox>
           <doublevalue
             id="to_angle"
             label="Angle"
             min="0"
             step="1.0"
-            default="360"
+            default="0"
             icon=":icons/angle_up.png"
             tooltip="Angle">
           </doublevalue>
@@ -34,7 +34,7 @@
             label="Angle"
             min="0"
             step="1.0"
-            default="0"
+            default="10"
             icon=":icons/angle_down.png"
             tooltip="Angle">
           </doublevalue>
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue  id="to_angle" label="Angle"
+          <doublevalue  id="to_offset" label="Offset"
             min="0" step="1.0" default="0"
             icon=":icons/angle_up.png"
-            tooltip="Angle">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
         <groupbox title="From">
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue id="from_angle" label="Angle"
+          <doublevalue id="from_offset" label="Offset"
             min="0" step="1.0" default="0"
             icon=":icons/angle_down.png"
-            tooltip="Angle">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
       </box>
index a039094de3e1a7ac1c7a931b13170041ba048ae0..6bbcd32705ae9d68389279e4eed432a9b83506ea 100644 (file)
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
     <toolbox id="CreationMethod">
-      <box id="ByOffsets" title="By offsets">
+      <box id="ByAngles" title="By angles">
         <groupbox>
           <doublevalue
             id="to_angle"
             label="Angle"
             min="0"
             step="1.0"
-            default="360"
+            default="10"
             icon=":icons/angle_up.png"
             tooltip="Angle">
           </doublevalue>
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue  id="to_angle" label="Angle"
+          <doublevalue  id="to_offset" label="Offset"
             min="0" step="1.0" default="0"
             icon=":icons/angle_up.png"
-            tooltip="Angle">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
         <groupbox title="From">
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
-          <doublevalue id="from_angle" label="Angle"
+          <doublevalue id="from_offset" label="Offset"
             min="0" step="1.0" default="0"
             icon=":icons/angle_down.png"
-            tooltip="Angle">
+            tooltip="Offset">
           </doublevalue>
         </groupbox>
       </box>
index 8c532b0ba0fa02ed62cc98b78ec0b41bb50d9780..6eb651f57a71d49668eb547619845932317954d0 100644 (file)
@@ -9,29 +9,50 @@
 #include <GeomAPI_Shape.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
 
 //=================================================================================================
 bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                         const std::list<std::string>& theArguments) const
 {
-  if(theArguments.size() < 4) {
+  if(theArguments.size() != 8) {
     return false;
   }
 
   std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
 
-  std::shared_ptr<GeomAPI_Shape> aFromShape;
-  std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::string aSelectedMethod;
+  if(theFeature->string(*anIt)) {
+    aSelectedMethod = theFeature->string(*anIt)->value();
+  }
+  anIt++;
+  std::string aCreationMethod = *anIt;
+  anIt++;
+  
+  double aToSize = 0.0;
+  double aFromSize = 0.0;
 
-  std::shared_ptr<ModelAPI_AttributeSelection> anAttrSel = theFeature->selection(*anIt);
-  if(anAttrSel) {
-    aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
-    if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) {
-      aFromShape = anAttrSel->context()->shape();
-    }
+  if(theFeature->real(*anIt)) {
+    aToSize = theFeature->real(*anIt)->value();
   }
   anIt++;
-  anAttrSel = theFeature->selection(*anIt);
+  if(theFeature->real(*anIt)) {
+    aFromSize = theFeature->real(*anIt)->value();
+  }
+  anIt++;
+
+  if(aSelectedMethod == aCreationMethod) {
+    if(aToSize == 0.0 && aFromSize == 0.0) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  std::shared_ptr<GeomAPI_Shape> aToShape;
+  std::shared_ptr<GeomAPI_Shape> aFromShape;
+
+  std::shared_ptr<ModelAPI_AttributeSelection> anAttrSel = theFeature->selection(*anIt);
   if(anAttrSel) {
     aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
     if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) {
@@ -40,21 +61,28 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
   }
   anIt++;
 
-  double aFromOffset = 0.0;
-  double aToOffset = 0.0;
-
   std::shared_ptr<ModelAPI_AttributeDouble> anAttrDouble = theFeature->real(*anIt);
   if(anAttrDouble) {
-    aFromOffset = anAttrDouble->value();
+    aToSize = anAttrDouble->value();
+  }
+  anIt++;
+
+  anAttrSel = theFeature->selection(*anIt);
+  if(anAttrSel) {
+    aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
+    if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) {
+      aFromShape = anAttrSel->context()->shape();
+    }
   }
   anIt++;
+
   anAttrDouble = theFeature->real(*anIt);
   if(anAttrDouble) {
-    aToOffset = anAttrDouble->value();
+    aFromSize = anAttrDouble->value();
   }
 
   if(((!aFromShape && !aToShape) || ((aFromShape && aToShape) && aFromShape->isEqual(aToShape)))
-    && (aFromOffset == 0.0 && aToOffset == 0.0)) {
+    && (aFromSize == 0.0 && aToSize == 0.0)) {
     return false;
   }
 
index b0ce4eb67001e8aa55b790088a6282d3e4256f0f..d9f7f07afa62012609b8c86cf2bf946a09373304 100644 (file)
@@ -21,8 +21,6 @@ public:
   /** \brief Returns true if feature and/or attributes are valid.
    *  \param[in] theFeature the validated feature.
    *  \param[in] theArguments the arguments in the configuration file for this validator.
-   *  \n First pair of arguments should be bounding planes id.
-   *  \n Second pair of arguments should be offsets id.
    *  \returns true if feature is valid.
    */
   GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,