]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_Feature.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.cpp
1 #include "SketchPlugin_Feature.h"
2 #include "SketchPlugin_Sketch.h"
3 #include <ModelAPI_Document.h>
4 #include <ModelAPI_Data.h>
5 #include <ModelAPI_AttributeRefList.h>
6
7 SketchPlugin_Feature::SketchPlugin_Feature()
8 {
9   mySketch = 0;
10 }
11
12 void SketchPlugin_Feature::setData(boost::shared_ptr<ModelAPI_Data> theData)
13 {
14   ModelAPI_Feature::setData(theData);
15
16   // find sketch that references to this feature
17   int aSketches = document()->size("Construction");
18   for(int a = 0; a < aSketches && !mySketch; a++) {
19     boost::shared_ptr<SketchPlugin_Sketch> aSketch = 
20       boost::dynamic_pointer_cast<SketchPlugin_Sketch>(document()->feature("Construction", a));
21     if (aSketch) {
22       std::list<boost::shared_ptr<ModelAPI_Feature> > aList = 
23         aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
24       std::list<boost::shared_ptr<ModelAPI_Feature> >::iterator aSub = aList.begin();
25       for(; aSub != aList.end(); aSub++) {
26         if ((*aSub)->data()->isEqual(theData)) {
27           mySketch = aSketch.get();
28           break;
29         }
30       }
31     }
32   }
33 }
34
35 void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape)
36 {
37   myPreview = theShape;
38 }
39
40 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::getPreview() const
41 {
42   return myPreview;
43 }