1 // File: PartSet_Presentation.h
2 // Created: 02 June 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_Presentation.h>
6 #include <PartSet_Tools.h>
8 #include <PartSet_FeatureLengthPrs.h>
10 #include <ModelAPI_Feature.h>
12 #include <SketchPlugin_Sketch.h>
14 #include <AIS_InteractiveObject.hxx>
15 #include <AIS_Shape.hxx>
17 #include <Quantity_NameOfColor.hxx>
19 const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
20 const int SKETCH_WIDTH = 4; /// the plane edge width
22 Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation(
23 FeaturePtr theFeature,
25 const TopoDS_Shape& theShape,
26 Handle_AIS_InteractiveObject thePreviuos)
28 Handle(AIS_InteractiveObject) anAIS;
30 std::string aKind = theFeature->getKind();
31 if (aKind == PartSet_FeatureLengthPrs::getKind())
32 anAIS = PartSet_FeatureLengthPrs::createPresentation(theFeature, theSketch, thePreviuos);
34 anAIS = createFeature(theFeature, theShape, thePreviuos);
35 if (theFeature->getKind() == SKETCH_KIND)
37 Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
38 aShapeAIS->SetColor(Quantity_Color(SKETCH_PLANE_COLOR));
39 aShapeAIS->SetWidth(SKETCH_WIDTH);
40 aShapeAIS->Redisplay();
47 Handle(AIS_InteractiveObject) PartSet_Presentation::createFeature(
48 FeaturePtr theFeature,
49 const TopoDS_Shape& theShape,
50 Handle_AIS_InteractiveObject thePreviuos)
52 Handle(AIS_InteractiveObject) anAIS = thePreviuos;
55 Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
56 if (!aShapeAIS.IsNull()) {
57 // if the AIS object is displayed in the opened local context in some mode, additional
58 // AIS sub objects are created there. They should be rebuild for correct selecting.
59 // It is possible to correct it by closing local context before the shape set and opening
60 // after. Another workaround to thrown down the selection and reselecting the AIS.
61 // If there was a problem here, try the first solution with close/open local context.
62 aShapeAIS->Set(theShape);
63 aShapeAIS->Redisplay(Standard_True);
68 anAIS = new AIS_Shape(theShape);