GeomAPI_Dir2d.h
GeomAPI_Pln.h
GeomAPI_Shape.h
+ GeomAPI_AISObject.h
)
SET(PROJECT_SOURCES
GeomAPI_Dir2d.cpp
GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
+ GeomAPI_AISObject.cpp
)
ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS})
${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
--- /dev/null
+// 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;
+}
+
--- /dev/null
+// 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
+
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();
+}
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;
};
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();
+}
+
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;
};
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)
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>();
{
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;
aProcVertexes.reverse();
aProcEdges.reverse();
aNextVertex = aProcVertexes.back();
- aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
+ aNextDir = aProcEdges.empty() ? aDirY :
+ getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
}
}
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);
#include <Events_Error.h>
#include <GeomAPI_Shape.h>
-
-#include <AIS_ListOfInteractive.hxx>
-//#include <AIS_DimensionSelectionMode.hxx>
+#include <GeomAPI_AISObject.h>
#include <QObject>
#include <QMouseEvent>
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);
}
}
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());
}
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;
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();
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})
../GeomAPI
../GeomAlgoAPI
../GeomDataAPI
- ${CAS_INCLUDE_DIRS}
)
INSTALL(TARGETS SketchPlugin DESTINATION plugins)
#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
-#include <Precision.hxx>
+const double tolerance = 1e-7;
SketchPlugin_Arc::SketchPlugin_Arc()
: SketchPlugin_Feature()
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()));
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();
/// 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(
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();
/// 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(
#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;
}
#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
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
#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,
}
}
-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;
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;
}
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
#include <GeomAPI_Lin2d.h>
#include <GeomAPI_Pnt2d.h>
-#include <AIS_LengthDimension.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pln.hxx>
-
SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
{
}
}
}
-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;
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;
}
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
#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>
}
-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 =
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;
}
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
#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>
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 =
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;
}
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
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Dir.h>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_RadiusDimension.hxx>
-
SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius()
{
}
}
}
-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;
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;
}
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
#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;
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;
}
#include "SketchPlugin.h"
#include <ModelAPI_Feature.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_AISObject.h>
class SketchPlugin_Sketch;
class GeomAPI_Pnt2d;
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
/// 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
#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
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();
/// 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(
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();
/// 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(
#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;
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;
}
/// 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
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);
}
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()) {
//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)
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);
}
}
// 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)
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;
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();
{
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);
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;
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;
#include <QString>
#include <boost/shared_ptr.hpp>
+#include <GeomAPI_AISObject.h>
+
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_InteractiveContext.hxx>
/// 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
/// \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
/// 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
protected:
XGUI_Workshop* myWorkshop;
- typedef std::map<FeaturePtr, Handle(AIS_InteractiveObject) > FeatureToAISMap;
+ typedef std::map<FeaturePtr, boost::shared_ptr<GeomAPI_AISObject> > FeatureToAISMap;
FeatureToAISMap myFeature2AISObjectMap;
};