#include <AIS_PerpendicularRelation.hxx>
#include <AIS_RadiusDimension.hxx>
#include <AIS_Shape.hxx>
+#include <AIS_FixRelation.hxx>
const double tolerance = 1e-7;
}
}
+
+void GeomAPI_AISObject::createFixed(boost::shared_ptr<GeomAPI_Shape> theShape,
+ 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_FixRelation) aFixPrs =
+ new AIS_FixRelation(theShape->impl<TopoDS_Shape>(), aPlane);
+
+ setImpl(new Handle(AIS_InteractiveObject)(aFixPrs));
+ } else {
+ Handle(AIS_PerpendicularRelation) aFixPrs =
+ Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+ if (!aFixPrs.IsNull()) {
+ aFixPrs->SetFirstShape(theShape->impl<TopoDS_Shape>());
+ aFixPrs->SetPlane(aPlane);
+ aFixPrs->Redisplay(Standard_True);
+ }
+ }
+}
+
+
+
void GeomAPI_AISObject::setColor(const int& theColor)
{
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
boost::shared_ptr<GeomAPI_Shape> theLine2,
boost::shared_ptr<GeomAPI_Pln> thePlane);
+ /** \brief Creates AIS_FixedRelation object for an object
+ * \param[in] theShape the object
+ * \param[in] thePlane the plane which contains the lines
+ */
+ void createFixed(boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Pln> thePlane);
+
/** \brief Assigns the color for the shape
* \param[in] theColor index of the color
*/
#include "SketchPlugin_ConstraintRigid.h"
+#include <ModelAPI_ResultConstruction.h>
+
SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
{
}
void SketchPlugin_ConstraintRigid::execute()
{
}
+
+AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious)
+{
+ if (!sketch())
+ return thePrevious;
+
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ if (!anAttr || !anAttr->isObject())
+ return thePrevious;
+
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
+ if (!aConst)
+ return thePrevious;
+
+ boost::shared_ptr<GeomAPI_Shape> aShape;
+ aShape = aConst->shape();
+
+ AISObjectPtr anAIS = thePrevious;
+ if (!anAIS)
+ anAIS = AISObjectPtr(new GeomAPI_AISObject);
+
+ boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
+ anAIS->createFixed(aShape, aPlane);
+
+ // Set color from preferences
+ //std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color",
+ // PERPENDICULAR_COLOR);
+ //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+
+ return anAIS;
+}
\ No newline at end of file
return MY_KIND;
}
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+
/// \brief Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();