Salome HOME
Do not show Rigid symbol on external objects
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintRigid.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_ConstraintRigid.cpp
4 // Created: 13 Oct 2014
5 // Author:  Artem ZHIDKOV
6
7 #include "SketchPlugin_ConstraintRigid.h"
8 #include "SketchPlugin_ConstraintParallel.h"
9 #include "SketchPlugin_Feature.h"
10
11 #include <SketcherPrs_Factory.h>
12
13 #include <ModelAPI_ResultConstruction.h>
14 #include <Config_PropManager.h>
15
16 #include <GeomDataAPI_Point2D.h>
17 #include <GeomAlgoAPI_PointBuilder.h>
18
19 SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
20 {
21 }
22
23 void SketchPlugin_ConstraintRigid::initAttributes()
24 {
25   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
26 }
27
28 void SketchPlugin_ConstraintRigid::execute()
29 {
30 }
31
32 AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious)
33 {
34   if (!sketch())
35     return thePrevious;
36
37   AISObjectPtr anAIS = thePrevious;
38   if (anAIS.get() == NULL) {
39     std::shared_ptr<ModelAPI_Data> aData = data();
40     std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
41       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
42     ObjectPtr aObj = anAttr->object();
43     if (aObj.get() != NULL) {
44       FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
45       std::shared_ptr<SketchPlugin_Feature> aSkFea = 
46         std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
47       if (!aSkFea->isExternal()) 
48         anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane());
49     }
50   }
51
52   return anAIS;
53 }