bool Model_Data::isDisplayed()
{
- return myFlags->Value(kFlagDisplayed) == Standard_True;
+ return myObject.get() && myObject->document().get() && myObject->document()->isActive() &&
+ myFlags->Value(kFlagDisplayed) == Standard_True;
}
void Model_Data::setDisplayed(const bool theDisplay)
static const int TAG_CURRENT_FEATURE = 1; ///< where the reference to the current feature label is located (or no attribute if null feature)
Model_Document::Model_Document(const std::string theID, const std::string theKind)
- : myID(theID), myKind(theKind),
+ : myID(theID), myKind(theKind), myIsActive(false),
myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format
{
myObjs = new Model_Objects(myDoc->Main());
{
return myObjs->allFeatures();
}
+
+void Model_Document::setActive(const bool theFlag)
+{
+ if (theFlag != myIsActive) {
+ myIsActive = theFlag;
+ // redisplay all the objects of this part
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
+ for(int a = size(ModelAPI_Feature::group()) - 1; a >= 0; a--) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
+ object(ModelAPI_Feature::group(), a));
+ if (aFeature.get() && aFeature->data()->isValid()) {
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResList = aFeature->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResList.begin();
+ for(; aRes != aResList.end(); aRes++) {
+ ModelAPI_EventCreator::get()->sendUpdated(*aRes, aRedispEvent);
+ }
+ }
+ }
+ }
+}
+
+bool Model_Document::isActive() const
+{
+ return myIsActive;
+}
//! Returns the list of Ids of the operations that can be redoed (called for the root document)
std::list<std::string> redoList() const;
- /// Internally makes document know that feature was removed or added in history after creation
+ //! Internally makes document know that feature was removed or added in history after creation
virtual void updateHistory(const std::shared_ptr<ModelAPI_Object> theObject);
- /// Internally makes document know that feature was removed or added in history after creation
+ //! Internally makes document know that feature was removed or added in history after creation
virtual void updateHistory(const std::string theGroup);
- /// Returns true if the document is root module document
+ //! Returns true if the document is root module document
bool isRoot() const;
- /// Sets shared pointer to this
+ //! Sets shared pointer to this
void setThis(DocumentPtr theDoc);
- /// Returns the objects manager
+ //! Returns the objects manager
Model_Objects* objects() {return myObjs;}
+ ///! Informs the document that it becomes active and some actions must be performed
+ virtual void setActive(const bool theFlag);
+ //! Returns true if this document is currently active
+ virtual bool isActive() const;
+
friend class Model_Application;
friend class Model_Session;
friend class Model_Update;
Model_Objects *myObjs; ///< data manager of this document
- /// counter value of transaction on the last "save" call, used for "IsModified" method
+ //! counter value of transaction on the last "save" call, used for "IsModified" method
int myTransactionSave;
- /// number of nested transactions performed (list becasue may be nested inside of nested)
- /// the list is empty if not nested transaction is performed
+ //! number of nested transactions performed (list becasue may be nested inside of nested)
+ //! the list is empty if not nested transaction is performed
std::list<int> myNestedNum;
- /// Information related to the every user-transaction
+ //! Information related to the every user-transaction
struct Transaction {
int myOCAFNum; ///< number of OCAF transactions related to each "this" transaction, may be 0
std::string myId; ///< user-identifier string of transaction
- /// default constructor with default Id
+ //! default constructor with default Id
Transaction(): myOCAFNum(0), myId("") {}
};
- /// transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
- /// in myDocument connected to this operation (may be zero for empty transaction)
+ //! transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
+ //! in myDocument connected to this operation (may be zero for empty transaction)
std::list<Transaction> myTransactions;
- /// list of info about transactions undone (first is oldest undone)
+ //! list of info about transactions undone (first is oldest undone)
std::list<Transaction> myRedos;
- /// Optimization for finding the shape-label by topological naming names
+ //! Optimization for finding the shape-label by topological naming names
std::map<std::string, TDF_Label> myNamingNames;
- /// If it is true, features are not executed on update (on abort, undo, redo)
+ //! If it is true, features are not executed on update (on abort, undo, redo)
bool myExecuteFeatures;
+
+ bool myIsActive; ///< flag that stores the active/not active state
};
#endif
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultBody.h>
+
+#include <TopoDS_Compound.hxx>
+#include <BRep_Builder.hxx>
std::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
{
}
return false;
}
+
+std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
+{
+ DocumentPtr aDoc = Model_ResultPart::partDoc();
+ if (aDoc.get()) {
+ const std::string& aBodyGroup = ModelAPI_ResultBody::group();
+ TopoDS_Compound aResultComp;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aResultComp);
+ int aNumSubs = 0;
+ for(int a = aDoc->size(aBodyGroup) - 1; a >= 0; a--) {
+ ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(aDoc->object(aBodyGroup, a));
+ if (aBody.get() && aBody->shape().get()) {
+ TopoDS_Shape aShape = *(aBody->shape()->implPtr<TopoDS_Shape>());
+ if (!aShape.IsNull()) {
+ aBuilder.Add(aResultComp, aShape);
+ aNumSubs++;
+ }
+ }
+ }
+ if (aNumSubs) {
+ std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
+ aResult->setImpl(new TopoDS_Shape(aResultComp));
+ return aResult;
+ }
+ }
+ return std::shared_ptr<GeomAPI_Shape>();
+}
MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
const bool theFlag);
+ /// Result shape of part document is compound of bodies inside of this part
+ MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+
protected:
/// makes a result on a temporary feature (an action)
Model_ResultPart();
std::shared_ptr<ModelAPI_Document> theDoc, bool theSendSignal)
{
if (myCurrentDoc != theDoc) {
+ if (myCurrentDoc.get())
+ myCurrentDoc->setActive(false);
+ if (theDoc.get())
+ theDoc->setActive(true);
+
std::shared_ptr<ModelAPI_Document> aPrevious = myCurrentDoc;
myCurrentDoc = theDoc;
if (theDoc.get() && theSendSignal) {
//! Makes the current feature one feature upper
virtual void setCurrentFeatureUp() = 0;
- /// To virtually destroy the fields of successors
+ //! To virtually destroy the fields of successors
MODELAPI_EXPORT virtual ~ModelAPI_Document();
- /// Creates a construction cresults
+ //! Creates a construction cresults
virtual std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
- /// Creates a body results
+ //! Creates a body results
virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
- /// Creates a part results
+ //! Creates a part results
virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
- /// Creates a group results
+ //! Creates a group results
virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
virtual std::shared_ptr<ModelAPI_Feature> feature(
const std::shared_ptr<ModelAPI_Result>& theResult) = 0;
- ///! Returns all features of the document including the hidden features which are not in
- ///! history. Not very fast method, for calling once, not in big cycles.
+ //! Returns all features of the document including the hidden features which are not in
+ //! history. Not very fast method, for calling once, not in big cycles.
virtual std::list<std::shared_ptr<ModelAPI_Feature> > allFeatures() = 0;
+ //! Informs the document that it becomes active and some actions must be performed
+ virtual void setActive(const bool theFlag) = 0;
+ //! Returns true if this document is currently active
+ virtual bool isActive() const = 0;
+
protected:
- /// Only for SWIG wrapping it is here
+ //! Only for SWIG wrapping it is here
MODELAPI_EXPORT ModelAPI_Document();
- /// Internally makes document know that feature was removed or added in history after creation
+ //! Internally makes document know that feature was removed or added in history after creation
MODELAPI_EXPORT virtual void updateHistory(const std::shared_ptr<ModelAPI_Object> theObject) = 0;
- /// Internally makes document know that feature was removed or added in history after creation
+ //! Internally makes document know that feature was removed or added in history after creation
MODELAPI_EXPORT virtual void updateHistory(const std::string theGroup) = 0;
friend class ModelAPI_Object; // to add or remove from the history
void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
{
foreach (ObjectPtr aObj, theList) {
+ /*
ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
if (aPartRes) {
DocumentPtr aDoc = aPartRes->partDoc();
SET_DISPLAY_GROUP(ModelAPI_ResultConstruction::group(), isVisible)
SET_DISPLAY_GROUP(ModelAPI_ResultGroup::group(), isVisible)
} else {
+ */
aObj->setDisplayed(isVisible);
- }
+ //}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
// Show only objects from the list
foreach (ObjectPtr aObj, theList) {
+ /*
ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
if (aPartRes) {
DocumentPtr aDoc = aPartRes->partDoc();
SET_DISPLAY_GROUP(ModelAPI_ResultConstruction::group(), true)
SET_DISPLAY_GROUP(ModelAPI_ResultGroup::group(), true)
} else {
+ */
aObj->setDisplayed(true);
- }
+ //}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));