]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 12:37:39 +0000 (16:37 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 12:37:39 +0000 (16:37 +0400)
1. Circle AIS check.

src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/plugin-Sketch.xml

index ef6ecf13fd738360e8ab86d806a8f5dd027d4bad..cca6599bb9ca0f2172e71de0b1f650ceb1aa5831 100644 (file)
@@ -41,25 +41,27 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
     // compute a circle point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
       boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CIRCLE_ATTR_CENTER));
-    boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
-    // make a visible point
-    boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
-    aShapes.push_back(aCenterPointShape);
-
-    // make a visible circle
-    boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
-    bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
-    if (aHasPlane) {
-      boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
-      // compute the circle radius
-      AttributeDoublePtr aRadiusAttr = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CIRCLE_ATTR_RADIUS));
-      double aRadius = aRadiusAttr->value();
-
-      boost::shared_ptr<GeomAPI_Shape> aCircleShape = 
-                              GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
-      aShapes.push_back(aCircleShape);
+    if (aCenterAttr->isInitialized()) {
+      boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
+      // make a visible point
+      boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+      aShapes.push_back(aCenterPointShape);
+
+      // make a visible circle
+      boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
+        boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
+      bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
+      if (aHasPlane) {
+        boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
+        // compute the circle radius
+        AttributeDoublePtr aRadiusAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CIRCLE_ATTR_RADIUS));
+        double aRadius = aRadiusAttr->value();
+
+        boost::shared_ptr<GeomAPI_Shape> aCircleShape = 
+                                GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
+        aShapes.push_back(aCircleShape);
+      }
     }
     boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
     setPreview(aCompound);
index cd32b5528c18e33a311113fb28e06504751d4697..a423f27e1660585a2384b481baabb99a78227967 100644 (file)
         <feature_selector id="ConstraintEntityA" label="First point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
         <feature_selector id="ConstraintEntityB" label="Last point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
-        <doublevalue_editor id="ConstraintValue"/>
+        <doublevalue_editor label="Value" tooltip="Constraint value" 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" label="Line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
-        <doublevalue_editor id="ConstraintValue"/>
+        <doublevalue_editor label="Value" tooltip="Constraint value" 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" label="Circle or Arc" tooltip="Select an entity in the viewer" keysequence="SketchCircle SketchArc"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
-        <doublevalue_editor id="ConstraintValue"/>
+        <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines">
         <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>