Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / Model / Model_ResultConstruction.cpp
index 41e1a9b166a43771fac03ba55775eae2b17f9c5c..c1fea070837f1854f1be7aeb0b692dd846724ebb 100644 (file)
@@ -6,17 +6,11 @@
 
 #include <Model_ResultConstruction.h>
 
-#include <ModelAPI_AttributeIntArray.h>
 #include <Config_PropManager.h>
 #include <GeomAPI_PlanarEdges.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
-
-void Model_ResultConstruction::initAttributes()
-{
-  // append the color attribute. It is empty, the attribute will be filled by a request
-  DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
-}
+#include <Events_Loop.h>
+#include <ModelAPI_Events.h>
 
 void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName,
                                        std::string& theDefault)
@@ -29,6 +23,8 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str
 void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
 {
   if (myShape != theShape && (!theShape.get() || !theShape->isEqual(myShape))) {
+    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+    ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
     myShape = theShape;
     if (theShape.get()) {
       myFacesUpToDate = false;
@@ -44,11 +40,9 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultConstruction::shape()
 
 Model_ResultConstruction::Model_ResultConstruction()
 {
-  myIsDisabled = true; // by default it is not initialized and false to be after created
   myIsInHistory = true;
   myIsInfinite = false;
   myFacesUpToDate = false;
-  setIsConcealed(false);
 }
 
 void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
@@ -68,13 +62,13 @@ int Model_ResultConstruction::facesNum()
       std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
       for(; aFIter != aFaces.end(); aFIter++) {
         std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
-        if (aFace.get())
+        if (aFace.get() && !aFace->isNull())
           myFaces.push_back(aFace);
       }
     }
     myFacesUpToDate = true;
   }
-  return myFaces.size();
+  return int(myFaces.size());
 }
 
 std::shared_ptr<GeomAPI_Face> Model_ResultConstruction::face(const int theIndex)
@@ -91,3 +85,8 @@ void Model_ResultConstruction::setInfinite(const bool theInfinite)
 {
   myIsInfinite = theInfinite;
 }
+
+void Model_ResultConstruction::setIsConcealed(const bool theValue)
+{
+  // do nothing: the construction element is never consealed
+}