GeomAPI_IPresentable.h
GeomAPI_Curve.h
GeomAPI_DataMapOfShapeShape.h
+ GeomAPI_ICustomPrs.h
)
SET(PROJECT_SOURCES
#include <AIS_RadiusDimension.hxx>
#include <AIS_Shape.hxx>
#include <AIS_FixRelation.hxx>
+#include <Prs3d_PointAspect.hxx>
const double tolerance = 1e-7;
return false;
}
+int GeomAPI_AISObject::getShapeType() const
+{
+ Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
+ ->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (!aAISShape.IsNull()) {
+ return aAISShape->Shape().ShapeType();
+ }
+ }
+ return -1;
+}
+
+void GeomAPI_AISObject::setPointMarker(int theType, double theScale)
+{
+ Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+ if (aDrawer->HasPointAspect()) {
+ Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
+ aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
+ aPA->SetScale(theScale);
+ } else {
+ Quantity_NameOfColor aCol = Quantity_NOC_YELLOW;
+ aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale));
+ }
+ }
+}
/// \brief Checks if the object is empty
bool empty() const;
+
+ /// Return shape type according to TopAbs_ShapeEnum if the AIS is AIS_Shape
+ /// Otherwise returns -1
+ int getShapeType() const;
+
+ /// Sets marker type for vertex.
+ /// The type has to be defined according to Acpect_TypeOfMarker
+ void setPointMarker(int theType, double theScale);
};
//! Pointer on attribute object
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_ICustomPrs.hxx
+// Created: 11 Dec 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef GeomAPI_ICustomPrs_H
+#define GeomAPI_ICustomPrs_H
+
+#include "GeomAPI_AISObject.h"
+
+/**
+* Interface of a class which can provide specific customization of
+* object presentation
+*/
+class GeomAPI_ICustomPrs
+{
+public:
+ virtual void customisePresentation(AISObjectPtr thePrs) = 0;
+};
+
+typedef std::shared_ptr<GeomAPI_ICustomPrs> GeomCustomPrsPtr;
+
+#endif
\ No newline at end of file
* \ingroup DataModel
* \brief Feature for creation of the new circle in PartSet.
*/
-class SketchPlugin_Circle : public SketchPlugin_Feature //, public GeomAPI_IPresentable
+class SketchPlugin_Circle : public SketchPlugin_Feature
{
public:
/// Circle feature kind
/// Request for initialization of data model of the feature: adding all attributes
SKETCHPLUGIN_EXPORT virtual void initAttributes();
- /// Returns the AIS preview
- virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
- {
- return simpleAISObject(firstResult(), thePrevious);
- }
-
/// Adds sub-feature of the higher level feature (sub-element of the sketch)
/// \param theFeature sub-feature
SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature)
return mySketch;
}
-AISObjectPtr SketchPlugin_Feature::simpleAISObject(std::shared_ptr<ModelAPI_Result> theRes,
- AISObjectPtr thePrevious)
-{
- std::shared_ptr<ModelAPI_ResultConstruction> aConstr = std::dynamic_pointer_cast<
- ModelAPI_ResultConstruction>(theRes);
-
- std::shared_ptr<GeomAPI_Shape> aPreview;
- if (aConstr)
- aPreview = aConstr->shape();
- AISObjectPtr aResult = thePrevious;
- if (!aResult)
- aResult = AISObjectPtr(new GeomAPI_AISObject());
- aResult->createShape(aPreview);
- return aResult;
-}
+void SketchPlugin_Feature::customisePresentation(AISObjectPtr thePrs)
+{
+ // if this is an edge
+ if (thePrs->getShapeType() == 6)
+ thePrs->setWidth(3);
+ // if this is a vertex
+ else if (thePrs->getShapeType() == 7)
+ thePrs->setPointMarker(6, 2.);
+}
\ No newline at end of file
#include <GeomAPI_AISObject.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeSelection.h>
+#include <GeomAPI_ICustomPrs.h>
class SketchPlugin_Sketch;
class GeomAPI_Pnt2d;
* \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
* an interface to create the sketch feature preview.
*/
-class SketchPlugin_Feature : public ModelAPI_Feature
+class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
{
public:
- /// Simple creation of interactive object by the result of the object
- static AISObjectPtr simpleAISObject(std::shared_ptr<ModelAPI_Result> theRes,
- AISObjectPtr thePrevious);
-
/// Reference to the external edge or vertex as a AttributeSelection
inline static const std::string& EXTERNAL_ID()
{
return false;
}
+ /// Customize presentation of the feature
+ virtual void customisePresentation(AISObjectPtr thePrs);
+
/// Returns the sketch of this feature
SketchPlugin_Sketch* sketch();
protected:
/// Request for initialization of data model of the feature: adding all attributes
SKETCHPLUGIN_EXPORT virtual void initAttributes();
- /// Returns the AIS preview
- SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
- {
- return simpleAISObject(firstResult(), thePrevious);
- }
-
/// Moves the feature
/// \param theDeltaX the delta for X coordinate is moved
/// \param theDeltaY the delta for Y coordinate is moved
/// Request for initialization of data model of the feature: adding all attributes
SKETCHPLUGIN_EXPORT virtual void initAttributes();
- /// Returns the AIS preview
- virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
- {
- return simpleAISObject(firstResult(), thePrevious);
- }
-
/// Moves the feature
/// \param theDeltaX the delta for X coordinate is moved
/// \param theDeltaY the delta for Y coordinate is moved
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_ICustomPrs.h>
#include <AIS_InteractiveContext.hxx>
#include <AIS_LocalContext.hxx>
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
myResult2AISObjectMap[theObject] = theAIS;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() != NULL) {
+ GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
+ if (aCustPrs.get() != NULL)
+ aCustPrs->customisePresentation(theAIS);
+ }
aContext->Display(anAISIO, false);
aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer);
if (aContext->HasOpenedContext()) {