]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Changes in the presentations of features
authorazv <azv@opencascade.com>
Mon, 30 Jun 2014 06:11:32 +0000 (10:11 +0400)
committerazv <azv@opencascade.com>
Tue, 1 Jul 2014 06:22:54 +0000 (10:22 +0400)
38 files changed:
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_AISObject.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_AISObject.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_Circ.cpp
src/GeomAPI/GeomAPI_Circ.h
src/GeomAPI/GeomAPI_Circ2d.cpp
src/GeomAPI/GeomAPI_Circ2d.h
src/GeomAPI/GeomAPI_Interface.h
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_TestOCC.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.cpp
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 28187984c9d8037f1535e21b1b173a1682d65098..e4bd74bf94f60e02d435a7b3bddca9ada1e095ab 100644 (file)
@@ -18,6 +18,7 @@ SET(PROJECT_HEADERS
     GeomAPI_Dir2d.h
     GeomAPI_Pln.h
     GeomAPI_Shape.h
+    GeomAPI_AISObject.h
 )
 
 SET(PROJECT_SOURCES
@@ -34,6 +35,7 @@ SET(PROJECT_SOURCES
     GeomAPI_Dir2d.cpp
     GeomAPI_Pln.cpp
     GeomAPI_Shape.cpp
+    GeomAPI_AISObject.cpp
 )
 
 ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS})
@@ -48,7 +50,7 @@ INCLUDE_DIRECTORIES(
   ${CAS_INCLUDE_DIRS}
 )
 
-TARGET_LINK_LIBRARIES(GeomAPI ${PROJECT_LIBRARIES} ${CAS_KERNEL} ${CAS_MODELER})
+TARGET_LINK_LIBRARIES(GeomAPI ${PROJECT_LIBRARIES} ${CAS_KERNEL} ${CAS_MODELER} ${CAS_VIEWER})
 
 SET(SWIG_SCRIPTS
   ${CMAKE_CURRENT_BINARY_DIR}/GeomAPI.py
diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp
new file mode 100644 (file)
index 0000000..5ed7c01
--- /dev/null
@@ -0,0 +1,253 @@
+// File:        GeomAPI_AISObject.cpp
+// Created:     25 Jun 2014
+// Author:      Artem ZHIDKOV
+
+#include <GeomAPI_AISObject.h>
+
+#include <GeomAPI_Circ.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Lin.h>
+#include <GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_XYZ.h>
+
+#include <Geom_Plane.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Quantity_NameOfColor.hxx>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_ParallelRelation.hxx>
+#include <AIS_PerpendicularRelation.hxx>
+#include <AIS_RadiusDimension.hxx>
+#include <AIS_Shape.hxx>
+
+
+const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
+const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+
+// Initialization of color constants
+int Colors::COLOR_BROWN = Quantity_NOC_BROWN;
+
+
+GeomAPI_AISObject::GeomAPI_AISObject()
+  : GeomAPI_Interface(new Handle(AIS_InteractiveObject)())
+{
+}
+
+void GeomAPI_AISObject::createShape(boost::shared_ptr<GeomAPI_Shape> theShape)
+{
+  const TopoDS_Shape& aTDS = (theShape && theShape->implPtr<TopoDS_Shape>()) ?
+                             theShape->impl<TopoDS_Shape>() : TopoDS_Shape();
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull())
+  {
+    Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
+    if (aShapeAIS)
+    {
+      // if the AIS object is displayed in the opened local context in some mode, additional
+      // AIS sub objects are created there. They should be rebuild for correct selecting.
+      // It is possible to correct it by closing local context before the shape set and opening
+      // after. Another workaround to thrown down the selection and reselecting the AIS.
+      // If there was a problem here, try the first solution with close/open local context.
+
+      aShapeAIS->Set(aTDS);
+      aShapeAIS->Redisplay(Standard_True);
+    }
+  }
+  else
+    setImpl(new Handle(AIS_InteractiveObject)(new AIS_Shape(aTDS)));
+}
+
+
+void GeomAPI_AISObject::createDistance(boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
+                                       boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
+                                       boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
+                                       boost::shared_ptr<GeomAPI_Pln> thePlane,
+                                       double                         theDistance)
+{
+  double aFlyout = 0;
+  if (theFlyoutPoint)
+  {
+    boost::shared_ptr<GeomAPI_Lin> aLine = 
+      boost::shared_ptr<GeomAPI_Lin>(new GeomAPI_Lin(theStartPoint, theEndPoint));
+    double aDist = aLine->distance(theFlyoutPoint);
+
+    boost::shared_ptr<GeomAPI_XYZ> aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz());
+    boost::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(theStartPoint->xyz());
+    boost::shared_ptr<GeomAPI_XYZ> aNorm = thePlane->direction()->xyz();
+    if (aLineDir->cross(aFOutDir)->dot(aNorm) < 0)
+      aDist = -aDist;
+    aFlyout = aDist;
+  }
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(
+      theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(), thePlane->impl<gp_Pln>());
+    aDimAIS->SetCustomValue(theDistance);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+    anAspect->MakeTextShaded(false);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
+    aDimAIS->SetDimensionAspect(anAspect);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
+    aDimAIS->SetFlyout(aFlyout);
+
+    setImpl(new Handle(AIS_InteractiveObject)(aDimAIS));
+  }
+  else {
+    // update presentation
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      aDimAIS->SetMeasuredGeometry(theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(), 
+                                   thePlane->impl<gp_Pln>());
+      aDimAIS->SetCustomValue(theDistance);
+      aDimAIS->SetFlyout(aFlyout);
+
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+}
+
+void GeomAPI_AISObject::createRadius(boost::shared_ptr<GeomAPI_Circ> theCircle,
+                                     boost::shared_ptr<GeomAPI_Pnt>  theFlyoutPoint,
+                                     double                          theRadius)
+{
+  boost::shared_ptr<GeomAPI_Pnt> aCenter = theCircle->center();
+
+  // TODO: a bug in AIS_RadiusDimension:
+  // The anchor point can't be myCirc.Location() - an exception is raised.
+  // But we need exactly this case...
+  // We want to show a radius dimension starting from the circle centre and 
+  // ending at the user-defined point.
+  // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all.
+  boost::shared_ptr<GeomAPI_Pnt> anAnchor = theCircle->project(theFlyoutPoint);
+  boost::shared_ptr<GeomAPI_XYZ> anAnchorXYZ = anAnchor->xyz();
+  anAnchorXYZ = anAnchorXYZ->decreased(aCenter->xyz());
+  boost::shared_ptr<GeomAPI_Dir> aDeltaDir(new GeomAPI_Dir(anAnchorXYZ));
+  const double aDelta = 1e-3;
+  anAnchor->setX(anAnchor->x() + aDelta * aDeltaDir->x());
+  anAnchor->setY(anAnchor->y() + aDelta * aDeltaDir->y());
+  anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z());
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_RadiusDimension) aDimAIS = 
+      new AIS_RadiusDimension(theCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
+    aDimAIS->SetCustomValue(theRadius);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+    anAspect->MakeTextShaded(false);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
+    aDimAIS->SetDimensionAspect (anAspect);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
+
+    setImpl(new Handle(AIS_InteractiveObject)(aDimAIS));
+  }
+  else
+  {
+    // update presentation
+    Handle(AIS_RadiusDimension) aDimAIS = Handle(AIS_RadiusDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull())
+    {
+      aDimAIS->SetMeasuredGeometry(theCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
+      aDimAIS->SetCustomValue(theRadius);
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+}
+
+void GeomAPI_AISObject::createParallel(boost::shared_ptr<GeomAPI_Shape> theLine1,
+                                       boost::shared_ptr<GeomAPI_Shape> theLine2,
+                                       boost::shared_ptr<GeomAPI_Pnt>   theFlyoutPoint,
+                                       boost::shared_ptr<GeomAPI_Pln>   thePlane)
+{
+  Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_ParallelRelation) aParallel = 
+      new AIS_ParallelRelation(theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
+    if (theFlyoutPoint)
+      aParallel->SetPosition(theFlyoutPoint->impl<gp_Pnt>());
+
+    setImpl(new Handle(AIS_InteractiveObject)(aParallel));
+  }
+  else
+  {
+    Handle(AIS_ParallelRelation) aParallel = Handle(AIS_ParallelRelation)::DownCast(anAIS);
+    if (!aParallel.IsNull())
+    {
+      aParallel->SetFirstShape(theLine1->impl<TopoDS_Shape>());
+      aParallel->SetSecondShape(theLine2->impl<TopoDS_Shape>());
+      aParallel->SetPlane(aPlane);
+      if (theFlyoutPoint)
+        aParallel->SetPosition(theFlyoutPoint->impl<gp_Pnt>());
+      aParallel->Redisplay(Standard_True);
+    }
+  }
+}
+
+void GeomAPI_AISObject::createPerpendicular(boost::shared_ptr<GeomAPI_Shape> theLine1,
+                                            boost::shared_ptr<GeomAPI_Shape> theLine2,
+                                            boost::shared_ptr<GeomAPI_Pln>   thePlane)
+{
+  Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_PerpendicularRelation) aPerpendicular = 
+      new AIS_PerpendicularRelation(theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
+
+    setImpl(new Handle(AIS_InteractiveObject)(aPerpendicular));
+  }
+  else
+  {
+    Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+    if (!aPerpendicular.IsNull())
+    {
+      aPerpendicular->SetFirstShape(theLine1->impl<TopoDS_Shape>());
+      aPerpendicular->SetSecondShape(theLine2->impl<TopoDS_Shape>());
+      aPerpendicular->SetPlane(aPlane);
+      aPerpendicular->Redisplay(Standard_True);
+    }
+  }
+}
+
+
+void GeomAPI_AISObject::setColor(const int& theColor)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+    return ;
+  anAIS->SetColor(Quantity_Color((Quantity_NameOfColor)theColor));
+}
+
+void GeomAPI_AISObject::setWidth(const double& theWidth)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+    return ;
+  anAIS->SetWidth(theWidth);
+}
+
+bool GeomAPI_AISObject::empty() const
+{
+  Handle(AIS_InteractiveObject) anAIS = 
+    const_cast<GeomAPI_AISObject*>(this)->impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+    return true;
+  return false;
+}
+
diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h
new file mode 100644 (file)
index 0000000..d3f2385
--- /dev/null
@@ -0,0 +1,92 @@
+// File:        GeomAPI_AISObject.hxx
+// Created:     25 Jun 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef GeomAPI_AISObject_HeaderFile
+#define GeomAPI_AISObject_HeaderFile
+
+#include <GeomAPI_Interface.h>
+
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Circ;
+class GeomAPI_Lin;
+class GeomAPI_Pln;
+class GeomAPI_Pnt;
+class GeomAPI_Shape;
+
+struct GEOMAPI_EXPORT Colors
+{
+  static int COLOR_BROWN;
+};
+
+/** \class GeomAPI_AISObject
+ *  \ingroup DataModel
+ *  \brief Interface for AIS_InteractiveObject
+ */
+
+class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface
+{
+public:
+  /// \brief Creation of empty AIS object
+  GeomAPI_AISObject();
+
+  /// \brief Creates AIS_Shape object using specified shape
+  void createShape(boost::shared_ptr<GeomAPI_Shape> theShape);
+
+  /** \brief Creates AIS_LengthDimension object
+   *  \param[in] theStartPoint  first point for dimension
+   *  \param[in] theEndPoint    second point for dimension
+   *  \param[in] theFlyoutPoint the flyout of dimension relative to the measured line
+   *  \param[in] thePlane       the plane which contains all points above
+   *  \param[in] theDistance    value of the distance to be shown
+   */
+  void createDistance(boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
+                      boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
+                      boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
+                      boost::shared_ptr<GeomAPI_Pln> thePlane,
+                      double                         theDistance);
+
+  /** \brief Creates AIS_RadiusDimension object
+   *  \param[in] theCircle      the radius is created for this circle
+   *  \param[in] theFlyoutPoint the flyout of dimension
+   *  \param[in] theRadius      value of the radius to be shown
+   */
+  void createRadius(boost::shared_ptr<GeomAPI_Circ> theCircle,
+                    boost::shared_ptr<GeomAPI_Pnt>  theFlyoutPoint,
+                    double                          theRadius);
+
+  /** \brief Creates AIS_ParallelRelation object for two lines
+   *  \param[in] theLine1       first parallel line
+   *  \param[in] theLine2       second parallel line
+   *  \param[in] theFlyoutPoint the flyout point for relation
+   *  \param[in] thePlane       the plane which contains the lines
+   */
+  void createParallel(boost::shared_ptr<GeomAPI_Shape> theLine1,
+                      boost::shared_ptr<GeomAPI_Shape> theLine2,
+                      boost::shared_ptr<GeomAPI_Pnt>   theFlyoutPoint,
+                      boost::shared_ptr<GeomAPI_Pln>   thePlane);
+
+  /** \brief Creates AIS_PerpendicularRelation object for two lines
+   *  \param[in] theLine1       first parallel line
+   *  \param[in] theLine2       second parallel line
+   *  \param[in] thePlane       the plane which contains the lines
+   */
+  void createPerpendicular(boost::shared_ptr<GeomAPI_Shape> theLine1,
+                           boost::shared_ptr<GeomAPI_Shape> theLine2,
+                           boost::shared_ptr<GeomAPI_Pln>   thePlane);
+
+  /** \brief Assigns the color for the shape
+   *  \param[in] theColor index of the color
+   */
+  void setColor(const int& theColor);
+
+  /// \brief Assigns the width of the lines of shape
+  void setWidth(const double& theWidth);
+
+  /// \brief Checks if the object is empty
+  bool empty() const;
+};
+
+#endif
+
index 811ef698b29cbd17d3ea1aafe52440da07a4670c..31dbfab6cd7dcbfc5cebe735f6265d8c2e02fccc 100644 (file)
@@ -61,3 +61,13 @@ const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::project(const boost::shared_p
   return aResult;
 }
 
+const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::center() const
+{
+  const gp_Pnt& aCenter = MY_CIRC->Location();
+  return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+}
+
+double GeomAPI_Circ::radius() const
+{
+  return MY_CIRC->Radius();
+}
index c1a23bbf65f68d8c6fa694a4a71b76135fc5c6a8..dda6923c66dd1daa9674e4f03d7e915dec856154 100644 (file)
@@ -24,6 +24,12 @@ public:
                const boost::shared_ptr<GeomAPI_Dir>& theDir,
                double theRadius);
 
+  /// Return center of the circle
+  const boost::shared_ptr<GeomAPI_Pnt> center() const;
+
+  /// Return radius of the circle
+  double radius() const;
+
   /// Project point on circle
   const boost::shared_ptr<GeomAPI_Pnt> project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
 };
index 27854d2a943194acfa1dc3536051feb6b42ce235..78c26d69f12049724139dcf49f75b2f26cedbe5d 100644 (file)
@@ -85,3 +85,14 @@ const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(const boost::shar
   return aResult;
 }
 
+const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::center() const
+{
+  const gp_Pnt2d& aCenter = MY_CIRC2D->Location();
+  return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
+}
+
+double GeomAPI_Circ2d::radius() const
+{
+  return MY_CIRC2D->Radius();
+}
+
index 11d18f6b665abdb313630e0fbc30e19a23bb0691..e95d8643c670fb551e31953f3ddc4d69a2f17c71 100644 (file)
@@ -28,6 +28,12 @@ public:
                  const boost::shared_ptr<GeomAPI_Dir2d>& theDir,
                  double theRadius);
 
+  /// Return center of the circle
+  const boost::shared_ptr<GeomAPI_Pnt2d> center() const;
+
+  /// Return radius of the circle
+  double radius() const;
+
   /// Project point on line
   const boost::shared_ptr<GeomAPI_Pnt2d> project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
 };
index bd9a77ab13078880e6a961b4a9ab86df08e55900..f77131de6f821dc5fb1b52fad1dfaaa6965ee511 100644 (file)
@@ -28,7 +28,7 @@ public:
   virtual ~GeomAPI_Interface();
 
   /// Returns the pointer to the impl
-  template<class T> inline T* implPtr() {return dynamic_cast<T*>(myImpl);}
+  template<class T> inline T* implPtr() {return static_cast<T*>(myImpl);}
   /// Returns the reference object of the impl
   template<class T> inline const T& impl() {return *(static_cast<T*>(myImpl));}
   /// Updates the impl (deletes the old one)
index 5941efbec62f9f9085b84df486587b98e3936733..c5c8588d401e552013b22a2fd761afdb11da84f7 100644 (file)
@@ -128,6 +128,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
 
   BOPCol_IndexedDataMapOfShapeListOfShape aMapVE; // map between vertexes and edges
   BOPTools::MapShapesAndAncestors(aFeaturesCompound, TopAbs_VERTEX, TopAbs_EDGE, aMapVE);
+  if (aMapVE.IsEmpty()) // in case of not-initialized circle
+    return;
 
   gp_Dir aDirX = theDirX->impl<gp_Dir>();
   gp_Dir aDirY = theDirY->impl<gp_Dir>();
@@ -250,10 +252,16 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
     {
       std::list<TopoDS_Shape>::reverse_iterator aVRIter = aProcVertexes.rbegin();
       std::list<TopoDS_Shape>::reverse_iterator aERIter = aProcEdges.rbegin();
-      for (++aERIter, ++aVRIter; aERIter != aProcEdges.rend(); aERIter++, aVRIter++)
+      if (aVRIter != aProcVertexes.rend())
+        aVRIter++;
+      if (aERIter != aProcEdges.rend())
+        aERIter++;
+
+      for ( ; aERIter != aProcEdges.rend(); aERIter++, aVRIter++)
         if (aMapVE.FindFromKey(*aVRIter).Size() > 2)
           break;
-      if (aERIter != aProcEdges.rend() || aMapVE.FindFromKey(*aVRIter).Size() == 1)
+      if (aERIter != aProcEdges.rend() || 
+         (aVRIter != aProcVertexes.rend() && aMapVE.FindFromKey(*aVRIter).Size() == 1))
       { // the branching vertex was found or current list of edges is a wire without branches
         std::list<TopoDS_Shape>::iterator aEIter;
         TopoDS_Shape aCurEdge;
@@ -295,7 +303,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces(
         aProcVertexes.reverse();
         aProcEdges.reverse();
         aNextVertex = aProcVertexes.back();
-        aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
+        aNextDir = aProcEdges.empty() ? aDirY : 
+                   getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
       }
     }
 
@@ -497,7 +506,8 @@ void createFace(const TopoDS_Shape&                      theStartVertex,
   for ( ; anEdgeIter != theEndOfEdges; anEdgeIter++)
   {
     TopoDS_Edge anEdge = *((TopoDS_Edge*)(&(*anEdgeIter)));
-    addEdgeToWire(anEdge, aBuilder, aCurVertex, aResWire);
+    if (!anEdge.IsNull())
+      addEdgeToWire(anEdge, aBuilder, aCurVertex, aResWire);
   }
 
   BRepBuilderAPI_MakeFace aFaceBuilder(thePlane, aResWire);
index 206bbaa5baf315cbcc56ceeb352745f6bb5f6a7a..1cef3112f2c00cc61e0f8e0d4b31df7b45b5c319 100644 (file)
@@ -40,9 +40,7 @@
 #include <Events_Error.h>
 
 #include <GeomAPI_Shape.h>
-
-#include <AIS_ListOfInteractive.hxx>
-//#include <AIS_DimensionSelectionMode.hxx>
+#include <GeomAPI_AISObject.h>
 
 #include <QObject>
 #include <QMouseEvent>
@@ -439,7 +437,8 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
     if (aSPFeature)
     {
-      Handle(AIS_InteractiveObject) anAIS = aSPFeature->getAISShape(aDisplayer->getAISObject(theFeature));
+      boost::shared_ptr<GeomAPI_AISObject> anAIS = 
+        aSPFeature->getAISObject(aDisplayer->getAISObject(theFeature));
       aDisplayer->redisplay(theFeature, anAIS, false);
     }
   }
index 75a16c52d89e7e93b0c65db9786cce3690752ed6..00ff7cef268779659b4f9f56ba623a9837172229 100644 (file)
@@ -37,8 +37,8 @@ void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
                                theWorkshop->viewer()->activeView());
     PartSet_TestOCC::changeTestLine(theWorkshop);
   }
-  Handle(AIS_InteractiveObject) anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
-  if (!anIO.IsNull()) {
+  boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
+  if (!anIO->empty()) {
     theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView());
     theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, theWorkshop->viewer()->activeView());
   }
@@ -147,10 +147,11 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
 
     XGUI_Displayer* aDisplayer = theWorkshop->displayer();
 
+    boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-    Handle(AIS_InteractiveObject) anAIS = aSPFeature->getAISShape(NULL);
-    if (!anAIS.IsNull())
+    boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+    if (!anAIS->empty())
       aDisplayer->redisplay(aFeature, anAIS, false);
 
     std::list<int> aModes;
@@ -202,11 +203,11 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
   boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
 
-  Handle(AIS_InteractiveObject) aPrevAIS;
+  boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
   boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
     boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-  Handle(AIS_InteractiveObject) anAIS = aSPFeature->getAISShape(aPrevAIS);
-  if (!anAIS.IsNull())
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+  if (!anAIS->empty())
     theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
   //std::list<int> aModes;
   //aModes.clear();
index 1533afdda50b5979fb45aee180cb348497a660f1..2bbac462f940c751ece8b64baf53f40b23b029ba 100644 (file)
@@ -39,15 +39,13 @@ SET(PROJECT_LIBRARIES
     GeomAPI
     GeomAlgoAPI
     ModelAPI
-    ${CAS_KERNEL}
-    ${CAS_VIEWER}
 )
 
 SET(XML_RESOURCES
   plugin-Sketch.xml
 )
 
-ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS} ${CAS_DEFINITIONS})
+ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
 ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
 TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
@@ -56,7 +54,6 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomDataAPI
-  ${CAS_INCLUDE_DIRS}
 )
 
 INSTALL(TARGETS SketchPlugin DESTINATION plugins)
index c0891d80d8b70e7ee4f293c53d0f7dff3f10f9e1..e166608d14d5c0347845dad6aa07d0c79ab6a376 100644 (file)
@@ -16,7 +16,7 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
-#include <Precision.hxx>
+const double tolerance = 1e-7;
 
 SketchPlugin_Arc::SketchPlugin_Arc()
   : SketchPlugin_Feature()
@@ -68,7 +68,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
           boost::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
             new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
           boost::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
-          if (aProjection && anEndAttr->pnt()->distance(aProjection) > Precision::Confusion())
+          if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance)
             anEndAttr->setValue(aProjection);
         }
         boost::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
@@ -85,6 +85,12 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
   return getPreview();
 }
 
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Arc::getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+{
+  return prepareAISShape(thePrevious);
+}
+
 void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
index b40024b8bad181b235bb3e15a30c9c38b7c6903d..94660779572dff92f9044b4d74d06a056b68d7bb 100644 (file)
@@ -43,6 +43,10 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(
index cca6599bb9ca0f2172e71de0b1f650ceb1aa5831..9d2cda07ba75f07aca6484a297c04332382a88e5 100644 (file)
@@ -69,6 +69,12 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
   return getPreview();
 }
 
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Circle::getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+{
+  return prepareAISShape(thePrevious);
+}
+
 void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
index e81107b30cb1982cb7d0d489b579256fd3850ef2..bb47c214de03db6987bb77b26d0346aa1ddbc172 100644 (file)
@@ -41,6 +41,10 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(
index 70a980aec7598e054d5c1c55ee9c450bcef8f142..5e8727687f0407e6cfb4fb7dd119b6382691f7b9 100644 (file)
@@ -4,9 +4,8 @@
 
 #include "SketchPlugin_Constraint.h"
 
-#include <AIS_InteractiveObject.hxx>
-
-Handle_AIS_InteractiveObject SketchPlugin_Constraint::getAISShape(Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Constraint::getAISObject(
+                              boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 { 
   return thePrevious;
 }
index 632243ba608557cc11ea325f61724794fde566ce..5db923562970fa009ed3939fc100e20c5d53c083 100644 (file)
@@ -12,9 +12,6 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <list>
 
-const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
-const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
-
 
 /*  Description: 
  *    Each constraint uses a set of parameters. In the SolveSpace library 
@@ -69,7 +66,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index 0e8d30b6accfa5057a0347a7a0282ca73090d3dd..faa2d7b62270e966b31fd6b295149e2111d4628d 100644 (file)
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
-#include <AIS_LengthDimension.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pln.hxx>
-
 /// Obtain the point object from specified constraint parameter
 static boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(
             DataPtr             theData,
@@ -50,8 +46,8 @@ void SketchPlugin_ConstraintDistance::execute()
   }
 }
 
-Handle(AIS_InteractiveObject) SketchPlugin_ConstraintDistance::getAISShape(
-  Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObject(
+                    boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
   if (!sketch())
     return thePrevious;
@@ -64,62 +60,24 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintDistance::getAISShape(
   if (!aPoint_A || !aPoint_B)
     return thePrevious;
 
-  // fly out calculation
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
-  double aFlyout = 0;
-  if (aFlyOutAttr->isInitialized()) {
-    boost::shared_ptr<GeomAPI_Pnt2d> aFlyOutPnt = aFlyOutAttr->pnt();
-
-    boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = 
-      boost::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aPoint_A->x(), aPoint_A->y(),
-                                                         aPoint_B->x(), aPoint_B->y()));
-    boost::shared_ptr<GeomAPI_Pnt2d> aProjectedPoint = aFeatureLin->project(aFlyOutPnt);
-    double aDistance = aFlyOutPnt->distance(aProjectedPoint);
-    if (!aFeatureLin->isRight(aFlyOutPnt))
-      aDistance = -aDistance;
-    aFlyout = aDistance;
-  }
 
-  //Build dimension here
   boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPoint_A->x(), aPoint_A->y());
   boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPoint_B->x(), aPoint_B->y());
+  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ? 
+                                              sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : 
+                                              boost::shared_ptr<GeomAPI_Pnt>();
 
   // value calculation
   boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
   double aValue = aValueAttr->value();
 
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_LengthDimension) aDimAIS = 
-      new AIS_LengthDimension(aPoint1->impl<gp_Pnt>(), aPoint2->impl<gp_Pnt>(), aPlane->impl<gp_Pln>());
-    aDimAIS->SetCustomValue(aValue);
-
-    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
-    anAspect->MakeArrows3d (Standard_False);
-    anAspect->MakeText3d(false);
-    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false);
-    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
-    aDimAIS->SetDimensionAspect (anAspect);
-    aDimAIS->SetFlyout(aFlyout);
-    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
-
-    anAIS = aDimAIS;
-  }
-  else {
-    // update presentation
-    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
-    if (!aDimAIS.IsNull()) {
-      aDimAIS->SetMeasuredGeometry(aPoint1->impl<gp_Pnt>(), aPoint2->impl<gp_Pnt>(), aPlane->impl<gp_Pln>());
-      aDimAIS->SetCustomValue(aValue);
-      aDimAIS->SetFlyout(aFlyout);
-
-      aDimAIS->Redisplay(Standard_True);
-    }
-  }
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
+  if (!anAIS)
+    anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
+  anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
   return anAIS;
 }
 
index 4ffbaf9c7c928b61395562e64a182a06ab30e8d9..4350e3cb4b528c82d279c6e9d0801e875ff0621c 100644 (file)
@@ -39,7 +39,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index dac5f926b3824aa66eefcaf3f7237fe8d296f549..71a35c4f189624649c2501a7f66d36799a437ad2 100644 (file)
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
 
-#include <AIS_LengthDimension.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pln.hxx>
-
 SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
 {
 }
@@ -54,8 +50,8 @@ void SketchPlugin_ConstraintLength::execute()
   }
 }
 
-Handle(AIS_InteractiveObject) SketchPlugin_ConstraintLength::getAISShape(
-  Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject(
+                    boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
   if (!sketch())
     return thePrevious;
@@ -70,81 +66,30 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintLength::getAISShape(
   if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
     return thePrevious;
 
-  // fly out calculation
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
-  double aFlyout = 0;
-  if (aFlyOutAttr->isInitialized()) {
-    boost::shared_ptr<GeomAPI_Pnt2d> aFlyOutPnt = aFlyOutAttr->pnt();
-
-    boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_START));
-    boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint =
-       boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_END));
-
-    boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = boost::shared_ptr<GeomAPI_Lin2d>
-                                               (new GeomAPI_Lin2d(aStartPoint->x(), aStartPoint->y(),
-                                                                  anEndPoint->x(), anEndPoint->y()));
-    boost::shared_ptr<GeomAPI_Pnt2d> aProjectedPoint = aFeatureLin->project(aFlyOutPnt);
-    double aDistance = aFlyOutPnt->distance(aProjectedPoint);
-    if (!aFeatureLin->isRight(aFlyOutPnt))
-      aDistance = -aDistance;
-    aFlyout = aDistance;
-  }
-  // value
+
+  DataPtr aData = aFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint =
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y());
+  boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(anEndPoint->x(),  anEndPoint->y());
+  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ? 
+                                              sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : 
+                                              boost::shared_ptr<GeomAPI_Pnt>();
+
+  // value calculation
   boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
   double aValue = aValueAttr->value();
 
-  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-  if (!aData->isValid())
-    return thePrevious;
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-  //Build dimension here
-  boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPointStart->x(), aPointStart->y());
-  boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPointEnd->x(),   aPointEnd->y());
-
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_LengthDimension) aDimAIS = 
-      new AIS_LengthDimension(aPoint1->impl<gp_Pnt>(), aPoint2->impl<gp_Pnt>(), aPlane->impl<gp_Pln>());
-    aDimAIS->SetCustomValue(aValue);
-
-    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
-    anAspect->MakeArrows3d (Standard_False);
-    anAspect->MakeText3d(false/*is text 3d*/);
-    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false/*is test shaded*/);
-    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
-    /*if (isUnitsDisplayed)
-    {
-      aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
-    }*/
-    aDimAIS->SetDimensionAspect (anAspect);
-    aDimAIS->SetFlyout(aFlyout);
-    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
-
-    anAIS = aDimAIS;
-  }
-  else
-  {
-    // update presentation
-    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
-    if (!aDimAIS.IsNull()) 
-    {
-      aDimAIS->SetMeasuredGeometry(aPoint1->impl<gp_Pnt>(), aPoint2->impl<gp_Pnt>(), aPlane->impl<gp_Pln>());
-      aDimAIS->SetCustomValue(aValue);
-      aDimAIS->SetFlyout(aFlyout);
-
-      aDimAIS->Redisplay(Standard_True);
-    }
-  }
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
+  if (!anAIS)
+    anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
+  anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
   return anAIS;
 }
 
index 85675da3b88c22cccce3945fa6eec1c5ccc9aa72..3d07ce186929081c2db4997500e57c724e5ebec2 100644 (file)
@@ -39,7 +39,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index f77c95d27ad041f871daaaabb84a9542b5e882e5..e45980582cfeb4eee9aa8817d17dd31ef3ee4f24 100644 (file)
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
 
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_ParallelRelation.hxx>
-#include <Geom_Plane.hxx>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
@@ -40,11 +36,11 @@ const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintParallel::previe
 }
 
 
-Handle_AIS_InteractiveObject SketchPlugin_ConstraintParallel::getAISShape(Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObject(
+                    boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
   if (!sketch())
-    return anAIS;
+    return thePrevious;
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = 
@@ -53,42 +49,26 @@ Handle_AIS_InteractiveObject SketchPlugin_ConstraintParallel::getAISShape(Handle
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
   if (!anAttr1 || !anAttr1->isFeature() || 
       !anAttr2 || !anAttr2->isFeature())
-    return anAIS;
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
   if (!aLine1Feature || !aLine2Feature)
-    return anAIS;
+    return thePrevious;
 
+  boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
   boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
   boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
-  Handle(Geom_Plane) aPlane = new Geom_Plane(sketch()->plane()->impl<gp_Pln>());
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
-  boost::shared_ptr<GeomAPI_Pnt2d> aFOPnt2d = aFlyoutAttr->pnt();
-  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFOPnt2d->x(), aFOPnt2d->y());
-
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_ParallelRelation) aParallel = 
-      new AIS_ParallelRelation(aLine1->impl<TopoDS_Shape>(), aLine2->impl<TopoDS_Shape>(), aPlane);
-    aParallel->SetPosition(aFlyoutPnt->impl<gp_Pnt>());
-    anAIS = aParallel;
-  }
-  else
-  {
-    Handle(AIS_ParallelRelation) aParallel = Handle(AIS_ParallelRelation)::DownCast(anAIS);
-    if (!aParallel.IsNull())
-    {
-      aParallel->SetFirstShape(aLine1->impl<TopoDS_Shape>());
-      aParallel->SetSecondShape(aLine2->impl<TopoDS_Shape>());
-      aParallel->SetPlane(aPlane);
-      aParallel->SetPosition(aFlyoutPnt->impl<gp_Pnt>());
-      aParallel->Redisplay(Standard_True);
-    }
-  }
+  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
+
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
+  if (!anAIS)
+    anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
+  anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane);
   return anAIS;
 }
 
index 9496f0722138a2e2adb5553f2e3667d6e64aed39..7f92e2e568c8202e24321684490b3ec965d43298 100644 (file)
@@ -40,7 +40,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index 1b6cc4d095d270e16afd86d21c85ec0a690d04b0..d4d73b0030663c7297aceef84687864f7606666b 100644 (file)
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
 
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_PerpendicularRelation.hxx>
-#include <Geom_Plane.hxx>
-
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
@@ -39,11 +35,11 @@ const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintPerpendicular::p
   return getPreview();
 }
 
-Handle_AIS_InteractiveObject SketchPlugin_ConstraintPerpendicular::getAISShape(Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAISObject(
+                    boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
   if (!sketch())
-    return anAIS;
+    return thePrevious;
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = 
@@ -52,42 +48,22 @@ Handle_AIS_InteractiveObject SketchPlugin_ConstraintPerpendicular::getAISShape(H
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
   if (!anAttr1 || !anAttr1->isFeature() || 
       !anAttr2 || !anAttr2->isFeature())
-    return anAIS;
+    return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
     boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
   if (!aLine1Feature || !aLine2Feature)
-    return anAIS;
+    return thePrevious;
 
+  boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
   boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
   boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
-  Handle(Geom_Plane) aPlane = new Geom_Plane(sketch()->plane()->impl<gp_Pln>());
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
-  boost::shared_ptr<GeomAPI_Pnt2d> aFOPnt2d = aFlyoutAttr->pnt();
-  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFOPnt2d->x(), aFOPnt2d->y());
 
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_PerpendicularRelation) aPerpendicular = 
-      new AIS_PerpendicularRelation(aLine1->impl<TopoDS_Shape>(), aLine2->impl<TopoDS_Shape>(), aPlane);
-    aPerpendicular->SetPosition(aFlyoutPnt->impl<gp_Pnt>());
-    anAIS = aPerpendicular;
-  }
-  else
-  {
-    Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
-    if (!aPerpendicular.IsNull())
-    {
-      aPerpendicular->SetFirstShape(aLine1->impl<TopoDS_Shape>());
-      aPerpendicular->SetSecondShape(aLine2->impl<TopoDS_Shape>());
-      aPerpendicular->SetPlane(aPlane);
-      aPerpendicular->SetPosition(aFlyoutPnt->impl<gp_Pnt>());
-      aPerpendicular->Redisplay(Standard_True);
-    }
-  }
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
+  if (!anAIS)
+    anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
+  anAIS->createPerpendicular(aLine1, aLine2, aPlane);
   return anAIS;
 }
 
index c960f50e869f3b94dc724de2e3825fd621290598..2bb4a7b63fed77fdbed361b65d058502ce284c94 100644 (file)
@@ -40,7 +40,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index 391dbd451e43d63421abdf8d4abd1e3bee1eb2c6..65ab125b5474f361543530bdc5dd2a79539e0ac0 100644 (file)
@@ -19,9 +19,6 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Dir.h>
 
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_RadiusDimension.hxx>
-
 SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius()
 {
 }
@@ -65,35 +62,30 @@ void SketchPlugin_ConstraintRadius::execute()
   }
 }
 
-Handle(AIS_InteractiveObject) SketchPlugin_ConstraintRadius::getAISShape(
-  Handle_AIS_InteractiveObject thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject(
+                    boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
   if (!sketch())
-    return anAIS;
+    return thePrevious;
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
   if (!anAttr)
-    return anAIS;
+    return thePrevious;
   FeaturePtr aFeature = anAttr->feature();
   std::string aKind = aFeature ? aFeature->getKind() : "";
   if (aKind != SKETCH_CIRCLE_KIND && aKind != SKETCH_ARC_KIND)
-    return anAIS;
-
-  boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
-  double aValue = aValueAttr->value();
+    return thePrevious;
 
-  // an anchor point
-  boost::shared_ptr<GeomDataAPI_Point2D> aAnchorAttr = 
+  // Flyout point
+  boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
-  if (!aAnchorAttr->isInitialized())
-    return anAIS;
-  boost::shared_ptr<GeomAPI_Pnt2d> anAnchor2D = aAnchorAttr->pnt();
-  boost::shared_ptr<GeomAPI_Pnt> anAnchor = sketch()->to3D(anAnchor2D->x(), anAnchor2D->y());
+  if (!aFlyoutAttr->isInitialized())
+    return thePrevious;
+  boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
 
+  // Prepare a circle
   aData = aFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
   double aRadius;
@@ -110,58 +102,23 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintRadius::getAISShape(
     aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
   }
 
-  // a circle
   boost::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterAttr->x(), aCenterAttr->y());
-
   boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(sketch()->data()->attribute(SKETCH_ATTR_NORM));
   boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
-
   boost::shared_ptr<GeomAPI_Circ> aCircle(new GeomAPI_Circ(aCenter, aNormal, aRadius));
 
-  anAnchor = aCircle->project(anAnchor);
-  // TODO: a bug in AIS_RadiusDimension:
-  // The anchor point can't be myCirc.Location() - an exception is raised.
-  // But we need exactly this case...
-  // We want to show a radius dimension starting from the circle centre and 
-  // ending at the user-defined point.
-  // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all.
-  boost::shared_ptr<GeomAPI_XYZ> anAnchorXYZ = anAnchor->xyz();
-  anAnchorXYZ = anAnchorXYZ->decreased(aCenter->xyz());
-  boost::shared_ptr<GeomAPI_Dir> aDeltaDir(new GeomAPI_Dir(anAnchorXYZ));
-  const double aDelta = 1e-3;
-  anAnchor->setX(anAnchor->x() + aDelta * aDeltaDir->x());
-  anAnchor->setY(anAnchor->y() + aDelta * aDeltaDir->y());
-  anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z());
-
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_RadiusDimension) aDimAIS = 
-      new AIS_RadiusDimension(aCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
-    aDimAIS->SetCustomValue(aValue);
-
-    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
-    anAspect->MakeArrows3d (Standard_False);
-    anAspect->MakeText3d(false);
-    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false);
-    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
-    aDimAIS->SetDimensionAspect (anAspect);
-    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
-
-    anAIS = aDimAIS;
-  }
-  else
-  {
-    // update presentation
-    Handle(AIS_RadiusDimension) aDimAIS = Handle(AIS_RadiusDimension)::DownCast(anAIS);
-    if (!aDimAIS.IsNull())
-    {
-      aDimAIS->SetMeasuredGeometry(aCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
-      aDimAIS->SetCustomValue(aValue);
-      aDimAIS->Redisplay(Standard_True);
-    }
-  }
+  // Value
+  boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+  double aValue = aRadius;
+  if (aValueAttr && aValueAttr->isInitialized())
+   aValue = aValueAttr->value();
+
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
+  if (!anAIS)
+    anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
+  anAIS->createRadius(aCircle, aFlyoutPnt, aValue);
   return anAIS;
 }
 
index a8ef9bb6bd48d1fde32294b4b85808a4452c723e..a2e9abad84379c431137fe3d4cbc4ebe3cdcb08d 100644 (file)
@@ -38,7 +38,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
index 6a7e12f5d83590a12b2f591d48c5de0aa4e4483a..4404ea1b80cb0fa5947abf5c718c5d99037bcfaf 100644 (file)
@@ -5,10 +5,6 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_AttributeRefList.h>
 
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Shape.hxx>
-#include <TopoDS_Shape.hxx>
-
 SketchPlugin_Feature::SketchPlugin_Feature()
 {
   mySketch = 0;
@@ -48,29 +44,13 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
   return mySketch;
 }
 
-Handle(AIS_InteractiveObject) SketchPlugin_Feature::getAISShape(Handle(AIS_InteractiveObject) thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::prepareAISShape(
+                        boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
   boost::shared_ptr<GeomAPI_Shape> aPreview = preview();
-
-  Handle(AIS_InteractiveObject) anAIS = thePrevious;
-  const TopoDS_Shape& aShape = aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape();
-  if (!anAIS.IsNull())
-  {
-    Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
-    if (!aShapeAIS.IsNull()) {
-      // if the AIS object is displayed in the opened local context in some mode, additional
-      // AIS sub objects are created there. They should be rebuild for correct selecting.
-      // It is possible to correct it by closing local context before the shape set and opening
-      // after. Another workaround to thrown down the selection and reselecting the AIS.
-      // If there was a problem here, try the first solution with close/open local context.
-
-      aShapeAIS->Set(aShape);
-      aShapeAIS->Redisplay(Standard_True);
-    }
-  }
-  else
-  {
-    anAIS = new AIS_Shape(aShape);
-  }
-  return anAIS;
+  boost::shared_ptr<GeomAPI_AISObject> aResult = thePrevious;
+  if (!aResult)
+    aResult = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+  aResult->createShape(aPreview);
+  return aResult;
 }
index 08476395845b4718e3b2c028a27d435cbe171677..1cddba03f6f54600fe7abd634387d3fc96c83fde 100644 (file)
@@ -8,6 +8,7 @@
 #include "SketchPlugin.h"
 #include <ModelAPI_Feature.h>
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_AISObject.h>
 
 class SketchPlugin_Sketch;
 class GeomAPI_Pnt2d;
@@ -27,7 +28,8 @@ public:
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
 
   /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious) = 0;
 
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
@@ -53,6 +55,9 @@ protected:
   /// Return the shape from the internal preview field
   /// \return theShape a preview shape
   const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
+  /// Common method for other features to produce AIS shape
+  boost::shared_ptr<GeomAPI_AISObject> prepareAISShape(
+                      boost::shared_ptr<GeomAPI_AISObject> thePrevious);
   /// Sets the higher-level feature for the sub-feature (sketch for line)
   void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
   /// Returns the sketch of this feature
index 8f8df83040257ecee86f031dfbde797eabb7c462..3175ac13f0cb7277a3d33776028d43519f01ac3f 100644 (file)
@@ -13,8 +13,6 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomDataAPI_Point2D.h>
 
-#include <AIS_InteractiveObject.hxx>
-
 using namespace std;
 
 // face of the square-face displayed for selection of general plane
@@ -56,6 +54,13 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
   return getPreview();
 }
 
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Line::getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+{
+  return prepareAISShape(thePrevious);
+}
+
+
 void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
index c6d23b2efd5cede1f15bbec2aa5bda2c7263796d..f440bac1dfa0b3d6d479a159701484187897939e 100644 (file)
@@ -42,6 +42,10 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(
index 74860bb6290c7e4384ac8bc546b1bd9fa53b18ce..984d98919a8b6c7fc323f7350e2a3e351804080f 100644 (file)
@@ -42,6 +42,12 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
   return getPreview();
 }
 
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Point::getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
+{
+  return prepareAISShape(thePrevious);
+}
+
 void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
index be36d016fb9f8ea6ad53eb3a6de5bc88c4b3fcfa..31fad0ea488fa7a703bb490b1a938e8d250e3f5d 100644 (file)
@@ -40,6 +40,10 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
+
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(
index 81ead9d7ded55fffa4dd660608b21e10f8e138dd..50506850e5dc305db18fb8bafe4383e81de3d843 100644 (file)
@@ -5,6 +5,7 @@
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <GeomAPI_AISObject.h>
 #include <GeomAPI_XYZ.h>
 #include <GeomDataAPI_Dir.h>
 #include <GeomDataAPI_Point.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
 
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Shape.hxx>
 
-#include <Quantity_NameOfColor.hxx>
-
-const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
-const int SKETCH_WIDTH = 4; /// the plane edge width
+const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
+const double SKETCH_WIDTH = 4.0; /// the plane edge width
 
 using namespace std;
 
@@ -80,13 +77,13 @@ void SketchPlugin_Sketch::execute()
   data()->store(aCompound);
 }
 
-Handle(AIS_InteractiveObject) SketchPlugin_Sketch::getAISShape(Handle(AIS_InteractiveObject) thePrevious)
+boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
 {
-  Handle(AIS_InteractiveObject) anAIS = SketchPlugin_Feature::getAISShape(thePrevious);
-  Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
-  aShapeAIS->SetColor(Quantity_Color(SKETCH_PLANE_COLOR));
-  aShapeAIS->SetWidth(SKETCH_WIDTH);
-  aShapeAIS->Redisplay();
+  boost::shared_ptr<GeomAPI_AISObject> anAIS = prepareAISShape(thePrevious);
+  anAIS->setColor(SKETCH_PLANE_COLOR);
+  anAIS->setWidth(SKETCH_WIDTH);
+  //anAIS->Redisplay();
   return anAIS;
 }
 
index 1f16d72ca90f1dfa2e5d5c6c2705eaf699b11d18..d88267bed29d83b43bec9b3c963ca73bfedb039e 100644 (file)
@@ -49,8 +49,9 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
-  /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
+                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
 
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
index 3da77af534343c163e538677df8afae6c4514fa5..f93b9502d64ff5540e053bc485086b9ce5e507ca 100644 (file)
@@ -47,20 +47,22 @@ void XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer)
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
 
   if (aShapePtr) {
-    TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
-    display(aFeature, aShape, isUpdateViewer);
+    boost::shared_ptr<GeomAPI_AISObject> anAIS(new GeomAPI_AISObject());
+    anAIS->createShape(aShapePtr);
+    display(aFeature, anAIS, isUpdateViewer);
   }
 }
 
 void XGUI_Displayer::display(FeaturePtr theFeature,
-                             const TopoDS_Shape& theShape, bool isUpdateViewer)
+                             boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
-  Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
-  myFeature2AISObjectMap[theFeature] = anAIS;
+  myFeature2AISObjectMap[theFeature] = theAIS;
 
-  aContext->Display(anAIS, isUpdateViewer);
+  Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAISIO.IsNull())
+    aContext->Display(anAISIO, isUpdateViewer);
 }
 
 
@@ -133,20 +135,24 @@ void XGUI_Displayer::erase(FeaturePtr theFeature,
     return;
 
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  Handle(AIS_InteractiveObject) anAIS = myFeature2AISObjectMap[aFeature];
-  if (!anAIS.IsNull())
+  boost::shared_ptr<GeomAPI_AISObject> anObject = myFeature2AISObjectMap[aFeature];
+  if (anObject)
   {
-    aContext->Erase(anAIS, isUpdateViewer);
+    Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
+    if (!anAIS.IsNull())
+      aContext->Erase(anAIS, isUpdateViewer);
   }
   myFeature2AISObjectMap.erase(aFeature);
 }
 
 
 bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
-                               Handle(AIS_InteractiveObject) theAIS,
+                               boost::shared_ptr<GeomAPI_AISObject> theAIS,
                                const bool isUpdateViewer)
 {
   bool isCreated = false;
+  Handle(AIS_InteractiveObject) anAIS = 
+    theAIS ? theAIS->impl<Handle(AIS_InteractiveObject)>() : Handle(AIS_InteractiveObject)();
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) {
@@ -157,12 +163,13 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
     //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
   }
   // display or redisplay presentation
-  if (isVisible(theFeature) && !myFeature2AISObjectMap[theFeature].IsNull()) {
-      aContext->RecomputeSelectionOnly(theAIS);
+  boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[theFeature];
+  if (isVisible(theFeature) && anObj && !anObj->empty()) {
+      aContext->RecomputeSelectionOnly(anAIS);
   }
   else {
     myFeature2AISObjectMap[theFeature] = theAIS;
-    aContext->Display(theAIS, false);
+    aContext->Display(anAIS, false);
     isCreated = true;
   }
   if (isUpdateViewer)
@@ -179,10 +186,12 @@ void XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer)
 
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
   if (aShapePtr) {
-    Handle(AIS_InteractiveObject) aAISObj = getAISObject(aFeature);
-    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj);
-    aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
+    boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(aFeature);
+    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
+    if (!aAISShape.IsNull())
+      return;
 
+    aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
     AISContext()->Redisplay(aAISShape);
   }
 }
@@ -199,18 +208,22 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
   // display or redisplay presentation
   Handle(AIS_InteractiveObject) anAIS;
   if (isVisible(theFeature))
-    anAIS = Handle(AIS_InteractiveObject)::DownCast(myFeature2AISObjectMap[theFeature]);
+  {
+    boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[theFeature];
+    if (anObj)
+      anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+  }
 
   // Activate selection of objects from prs
   if (!anAIS.IsNull()) {
-       aContext->Load(anAIS, -1, true/*allow decomposition*/);
+    aContext->Load(anAIS, -1, true/*allow decomposition*/);
     aContext->Deactivate(anAIS);
 
     std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
     for (; anIt != aLast; anIt++)
     {
       aContext->Activate(anAIS, (*anIt));
-       }
+    }
   }
 
   if (isUpdateViewer)
@@ -228,7 +241,7 @@ void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool i
   for (; anIt != aLast; anIt++) {
     aFeature = *anIt;
     if (isVisible(aFeature))
-      anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
+      anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
     if (anAIS.IsNull())
       continue;
 
@@ -262,9 +275,13 @@ void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isU
     if (myFeature2AISObjectMap.find(aRFeature) == myFeature2AISObjectMap.end()) 
       return;
 
-    Handle(AIS_InteractiveObject) anAIS = myFeature2AISObjectMap[aRFeature];
-    if (!anAIS.IsNull())
-      aContext->AddOrRemoveSelected(anAIS, false);
+    boost::shared_ptr<GeomAPI_AISObject> anObj = myFeature2AISObjectMap[aRFeature];
+    if (anObj)
+    {
+      Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+      if (!anAIS.IsNull())
+        aContext->AddOrRemoveSelected(anAIS, false);
+    }
   }
   if (isUpdateViewer)
     updateViewer();
@@ -302,7 +319,9 @@ void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer)
   {
     FeaturePtr aFeature = (*aFIt).first;
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
-      Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+      boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+      if (!anObj) continue;
+      Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
       if (!anAIS.IsNull()) {
         aContext->Erase(anAIS, false);
         aRemoved.push_back(aFeature);
@@ -324,10 +343,10 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
   closeAllContexts(true);
 }
 
-Handle(AIS_InteractiveObject) XGUI_Displayer::getAISObject(
+boost::shared_ptr<GeomAPI_AISObject> XGUI_Displayer::getAISObject(
                                               FeaturePtr theFeature) const
 {
-  Handle(AIS_InteractiveObject) anIO;
+  boost::shared_ptr<GeomAPI_AISObject> anIO;
   if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end())
     anIO = (myFeature2AISObjectMap.find(theFeature))->second;
   return anIO;
@@ -339,7 +358,9 @@ FeaturePtr XGUI_Displayer::getFeature(Handle(AIS_InteractiveObject) theIO) const
   FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
                                   aFLast = myFeature2AISObjectMap.end();
   for (; aFIt != aFLast && !aFeature; aFIt++) {
-    Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+    boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
+    if (!anObj) continue;
+    Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     if (anAIS != theIO)
       continue;
     aFeature = (*aFIt).first;
index f5402c3519fdf70b242dde9141de052331288851..7652165fad52950fd1f4853032979cef7cce58c6 100644 (file)
@@ -11,6 +11,8 @@
 #include <QString>
 #include <boost/shared_ptr.hpp>
 
+#include <GeomAPI_AISObject.h>
+
 #include <TopoDS_Shape.hxx>
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_InteractiveContext.hxx>
@@ -56,9 +58,9 @@ public:
 
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
-  /// \param theShape a shape
+  /// \param theAIS AIS presentation
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void display(FeaturePtr theFeature, const TopoDS_Shape& theShape, bool isUpdateViewer = true);
+  void display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
   
   /// Returns a list of viewer selected presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
@@ -81,7 +83,8 @@ public:
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   /// \returns true if the presentation is created
   bool redisplay(FeaturePtr theFeature,
-                 Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
+                 boost::shared_ptr<GeomAPI_AISObject> theAIS, 
+                 const bool isUpdateViewer = true);
 
   /** Redisplay the shape if it was displayed
   * \param theFeature a feature instance
@@ -139,7 +142,7 @@ public:
   /// Searches the interactive object by feature
   /// \param theFeature the feature or NULL if it not visualized
   /// \return theIO an interactive object
-  Handle(AIS_InteractiveObject) getAISObject(FeaturePtr theFeature) const;
+  boost::shared_ptr<GeomAPI_AISObject> getAISObject(FeaturePtr theFeature) const;
 
 protected:
   /// Searches the feature by interactive object
@@ -156,7 +159,7 @@ protected:
 protected:
   XGUI_Workshop* myWorkshop;
 
-  typedef std::map<FeaturePtr, Handle(AIS_InteractiveObject) > FeatureToAISMap;
+  typedef std::map<FeaturePtr, boost::shared_ptr<GeomAPI_AISObject> > FeatureToAISMap;
   FeatureToAISMap myFeature2AISObjectMap;
 };