From: nds Date: Wed, 25 Jun 2014 12:37:39 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~236 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45eaa24352984fab066a7e0a3a59048d91cae1c8;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc 1. Circle AIS check. --- diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index ef6ecf13f..cca6599bb 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -41,25 +41,27 @@ const boost::shared_ptr& SketchPlugin_Circle::preview() // compute a circle point in 3D view boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast(data()->attribute(CIRCLE_ATTR_CENTER)); - boost::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); - // make a visible point - boost::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); - aShapes.push_back(aCenterPointShape); - - // make a visible circle - boost::shared_ptr aNDir = - boost::dynamic_pointer_cast(aSketch->data()->attribute(SKETCH_ATTR_NORM)); - bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); - if (aHasPlane) { - boost::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); - // compute the circle radius - AttributeDoublePtr aRadiusAttr = - boost::dynamic_pointer_cast(data()->attribute(CIRCLE_ATTR_RADIUS)); - double aRadius = aRadiusAttr->value(); - - boost::shared_ptr aCircleShape = - GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius); - aShapes.push_back(aCircleShape); + if (aCenterAttr->isInitialized()) { + boost::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); + // make a visible point + boost::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); + aShapes.push_back(aCenterPointShape); + + // make a visible circle + boost::shared_ptr aNDir = + boost::dynamic_pointer_cast(aSketch->data()->attribute(SKETCH_ATTR_NORM)); + bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); + if (aHasPlane) { + boost::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); + // compute the circle radius + AttributeDoublePtr aRadiusAttr = + boost::dynamic_pointer_cast(data()->attribute(CIRCLE_ATTR_RADIUS)); + double aRadius = aRadiusAttr->value(); + + boost::shared_ptr aCircleShape = + GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius); + aShapes.push_back(aCircleShape); + } } boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); setPreview(aCompound); diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index cd32b5528..a423f27e1 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -27,19 +27,19 @@ - +