Salome HOME
Merge branch 'master' of newgeom:newgeom
authornds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 12:08:55 +0000 (16:08 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 12:08:55 +0000 (16:08 +0400)
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Constraint.cpp

index 37ed734c03bc32deea16ecb277ca1e31e696518f..6007743f5248434f95cb489e300ac6031a98987d 100644 (file)
@@ -31,7 +31,7 @@ ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature()
 
 bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
 {
-  if (!theFeature && myFeatureKinds.contains(theFeature->getKind().c_str()))
+  if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str()))
     return false;
 
   //bool isBlocked = this->blockSignals(true);
index 27c0e068903862ffdb2c2de754ff04e55ca0d09f..ada0fdf35d619432ee9afd71aa63130b447d485e 100644 (file)
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -55,8 +59,13 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
 bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 {
   return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
-         theId == SKETCH_CONSTRAINT_DISTANCE_KIND || theId == SKETCH_CIRCLE_KIND /*||
-         theId == SKETCH_ARC_KIND*/;
+         theId == SKETCH_CIRCLE_KIND /*||
+         theId == SKETCH_ARC_KIND*/ ||
+         theId == SKETCH_CONSTRAINT_DISTANCE_KIND ||
+         theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
+         theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
+         theId == SKETCH_CONSTRAINT_PARALLEL_KIND ||
+         theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND;
 }
 
 bool PartSet_OperationFeatureCreate::canBeCommitted() const
index b5fe8fca3e3d126c2b837017d352ced5e515f2e1..7218a5341a6cafca97d0d5359bb0609bff2207d0 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "SketchPlugin_ConstraintLength.h"
 
+#include <GeomDataAPI_Point2D.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
@@ -15,6 +17,7 @@ void SketchPlugin_ConstraintLength::initAttributes()
 {
   data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
 }
 
index dc6b959aa2f0eb423a1ddce9fdba71e1152d1f33..8cff21c494fe019dc8d8894c5632cbaf29f95dec 100644 (file)
@@ -1,7 +1,7 @@
 <plugin>
   <workbench id="Sketch">
     <group id="Basic">
-      <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
+      <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
         <label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
         <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
         <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
         <feature_selector id="ConstraintEntityB" keysequence="SketchPoint" internal="1"/>
-        <point_selector id="ConstraintFlyoutValuePnt" title="Flyout point" tooltip="Flyout" internal="1"/>
-        <doublevalue_editor id="ConstraintValue" min="0" step="1.0" tooltip="Constraint value"/>
+        <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintRadius" title="Radius of a circle or an arc" tooltip="Create constraint for the given radius of a circle or an arc">
         <label title="Select two points on a circle or an arc of circle on which to calculate radius" tooltip="Select two points on a circle or an arc of circle on which to calculate radius"/>
+        <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
+        <point_selector id="CirclePoint" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
+      </feature>
+      <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines">
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
+      </feature>
+      <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines">
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
       </feature>
-      <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines" internal="1"/>
-      <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines" internal="1"/>
     </group>
   </workbench>
 </plugin>
index 1b92bf9470a579a40d4822933defd1918fdbce08..67a177038088fffb546b35af925fa8483aab67e6 100644 (file)
@@ -183,7 +183,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
-      if (!anAttr || !anAttr->isFeature()) continue;
+      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
       if (aKind.compare(SKETCH_LINE_KIND) == 0)
       {