]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1650: Added option to create axis by line.
authordbv <dbv@opencascade.com>
Fri, 15 Jul 2016 14:05:33 +0000 (17:05 +0300)
committerdbv <dbv@opencascade.com>
Fri, 15 Jul 2016 14:05:33 +0000 (17:05 +0300)
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Axis.h
src/ConstructionPlugin/axis_widget.xml

index 90d9dcf312998d7a6ab5e24d038b9563722c3211..876b7989712649ba7906319340c82c94031ddbcd 100644 (file)
@@ -68,6 +68,9 @@ void ConstructionPlugin_Axis::initAttributes()
                        ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(ConstructionPlugin_Axis::DZ(),
                        ModelAPI_AttributeDouble::typeId());
+
+  /// Attributes for axis by line.
+  data()->addAttribute(LINE(), ModelAPI_AttributeSelection::typeId());
 }
 
 void ConstructionPlugin_Axis::createAxisByTwoPoints()
@@ -162,6 +165,22 @@ void ConstructionPlugin_Axis::createAxisByDimensions()
   setResult(aConstr);    
 }
 
+void ConstructionPlugin_Axis::createAxisByLine()
+{
+  // Get edge.
+  AttributeSelectionPtr anEdgeSelection = selection(LINE());
+  GeomShapePtr aLineShape = anEdgeSelection->value();
+  if(!aLineShape.get()) {
+    aLineShape = anEdgeSelection->context()->shape();
+  }
+  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+
+  ResultConstructionPtr aConstr = document()->createConstruction(data());
+  aConstr->setInfinite(true);
+  aConstr->setShape(anEdge);
+  setResult(aConstr);
+}
+
 void ConstructionPlugin_Axis::execute()
 {
   AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
@@ -174,6 +193,9 @@ void ConstructionPlugin_Axis::execute()
     createAxisByPointAndDirection();
   } else if (aMethodType == "AxisByDimensionsCase") {
     createAxisByDimensions();
+  } else if(aMethodType == CREATION_METHOD_BY_LINE()) {
+    createAxisByLine();
+
   }
 }
 
index 63f8e01a72106f9794a8ffc90220949840385a8b..c0116e81c712c73f3e09a4a34a6a0efd70705fc9 100644 (file)
@@ -41,6 +41,14 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP
     static const std::string METHOD_ATTR("CreationMethod");
     return METHOD_ATTR;
   }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_LINE()
+  {
+    static const std::string METHOD_ATTR("by_line");
+    return METHOD_ATTR;
+  }
+
   /// attribute name for first point
   inline static const std::string& POINT_FIRST()
   {
@@ -99,6 +107,13 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP
     return ATTR_Z_DIRECTION;
   }
 
+  /// Attribute name for line.
+  inline static const std::string& LINE()
+  {
+    static const std::string ATTR_ID("line");
+    return ATTR_ID;
+  }
+
   /// Returns a minimal length for axis
   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
 
@@ -127,6 +142,7 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP
   void createAxisByCylindricalFace();
   /// Creates a new axis by point and direction
   void createAxisByPointAndDirection();
+  void createAxisByLine();
 };
 
 
index 654420e6be106fb182efc61b38add146af15b389..243d0c7947185b30123fd42eb2acd0b8fed88eed 100644 (file)
       <doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
       <doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
     </box>
+    <box id="by_line" title="By line" icon="icons/Construction/axis_by_line_32x32.png">
+      <shape_selector id="line"
+                      label="Line"
+                      tooltip="Select line."
+                      icon="icons/Construction/edge.png"
+                      shape_types="edge">
+        <validator id="GeomValidators_ShapeType" parameters="line"/>
+      </shape_selector>
+    </box>
   </toolbox>
   
 </source>