X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultBody.cpp;h=9c5fa59cc1d25ea72ab16fe652160712dd5bad7c;hb=5303dd1fa6ad4411e38f8d36103c72109957e05c;hp=1fad264d8122ff265b11deea8178ad15d0ce9bce;hpb=ed165fd07e71c11885fdc5f475a8522a5914e00d;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 1fad264d8..9c5fa59cc 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -1,117 +1,46 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Model_ResultBody.cpp // Created: 08 Jul 2014 // Author: Mikhail PONIKAROV #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +// DEB +//#include +//#include +//#define DEB_IMPORT 1 Model_ResultBody::Model_ResultBody() { - setIsConcealed(false); -} - -void Model_ResultBody::store(const boost::shared_ptr& theShape) -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - // remove the previous history - clean(); - aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID()); - for(TDF_ChildIterator anIter(aShapeLab); anIter.More(); anIter.Next()) { - anIter.Value().ForgetAllAttributes(); - } - // store the new shape as primitive - TNaming_Builder aBuilder(aShapeLab); - if (!theShape) - return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) - return; // null shape inside - - aBuilder.Generated(aShape); - } -} - -boost::shared_ptr Model_ResultBody::shape() -{ - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - Handle(TNaming_NamedShape) aName; - if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aShape = aName->Get(); - if (!aShape.IsNull()) { - boost::shared_ptr aRes(new GeomAPI_Shape); - aRes->setImpl(new TopoDS_Shape(aShape)); - return aRes; - } - } - } - return boost::shared_ptr(); -} + myBuilder = new Model_BodyBuilder(this); -boost::shared_ptr Model_ResultBody::owner() -{ - return myOwner; + myIsDisabled = true; // by default it is not initialized and false to be after created + setIsConcealed(false); } -void Model_ResultBody::clean() +void Model_ResultBody::initAttributes() { - std::vector::iterator aBuilder = myBuilders.begin(); - for(; aBuilder != myBuilders.end(); aBuilder++) - delete *aBuilder; + // 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()); } -Model_ResultBody::~Model_ResultBody() +void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName, + std::string& theDefault) { - clean(); + theSection = "Visualization"; + theName = "result_body_color"; + theDefault = DEFAULT_COLOR(); } -TNaming_Builder* Model_ResultBody::builder(const int theTag) +bool Model_ResultBody::setDisabled(std::shared_ptr theThis, const bool theFlag) { - if (myBuilders.size() < (unsigned int)theTag) { - myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL); + bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag); + if (aChanged) { // state is changed, so modifications are needed + myBuilder->evolutionToSelection(theFlag); } - if (!myBuilders[theTag]) { - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); - myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag)); - } - return myBuilders[theTag]; -} - -void Model_ResultBody::generated( - const boost::shared_ptr& theNewShape, const int theTag) -{ - TopoDS_Shape aShape = theNewShape->impl(); - builder(theTag)->Generated(aShape); -} - -void Model_ResultBody::generated(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) -{ - TopoDS_Shape anOldShape = theOldShape->impl(); - TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Generated(anOldShape, aNewShape); -} - - -void Model_ResultBody::modified(const boost::shared_ptr& theOldShape, - const boost::shared_ptr& theNewShape, const int theTag) -{ - TopoDS_Shape anOldShape = theOldShape->impl(); - TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Modify(anOldShape, aNewShape); -} - -void Model_ResultBody::deleted(const boost::shared_ptr& theOldShape, - const int theTag) -{ - TopoDS_Shape aShape = theOldShape->impl(); - builder(theTag)->Delete(aShape); + return aChanged; }