X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_DocumentDataModel.cpp;h=2744d196d4114b08b7ae71f7ed55397bb2b75454;hb=ed165fd07e71c11885fdc5f475a8522a5914e00d;hp=0fcbd794be563e6dd1c141aab7aeee2b3fc31fa0;hpb=daeab27f92af64bc3d0fd5328ce61d1d525c4802;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 0fcbd794b..2744d196d 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -29,9 +29,10 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) myActivePart(0) { // Register in event loop - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + //Events_Loop* aLoop = Events_Loop::loop(); + //aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + //aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + //aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); // Create a top part of data tree model myModel = new XGUI_TopDataModel(this); @@ -43,14 +44,14 @@ XGUI_DocumentDataModel::~XGUI_DocumentDataModel() clearModelIndexes(); } -void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) +void XGUI_DocumentDataModel::processEvent(const boost::shared_ptr& theMessage) { - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); // Created object event ******************* if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); std::set aObjects = aUpdMsg->objects(); std::set::const_iterator aIt; @@ -96,8 +97,8 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - const ModelAPI_ObjectDeletedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); DocumentPtr aDoc = aUpdMsg->document(); std::set aGroups = aUpdMsg->groups(); @@ -139,7 +140,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { - //const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + //boost::shared_ptr aUpdMsg = boost::dynamic_pointer_cast(theMessage); //ObjectPtr aFeature = aUpdMsg->feature(); //DocumentPtr aDoc = aFeature->document(); @@ -155,7 +156,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) void XGUI_DocumentDataModel::rebuildDataTree() { - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); beginResetModel(); clearModelIndexes(); @@ -200,7 +201,7 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) case HistoryNode: { int aOffset = historyOffset(); - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); if (!aFeature) @@ -242,7 +243,7 @@ QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theO int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const { if (!theParent.isValid()) { - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); // Size of external models int aVal = historyOffset(); // Plus history size @@ -371,7 +372,7 @@ ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const if (theIndex.internalId() == PartsFolder) return ObjectPtr(); if (theIndex.internalId() == HistoryNode) { - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); int aOffset = historyOffset(); return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); } @@ -476,7 +477,7 @@ bool XGUI_DocumentDataModel::activatedIndex(const QModelIndex& theIndex) myActivePart->setItemsColor(ACTIVE_COLOR); myModel->setItemsColor(PASSIVE_COLOR); } else - myModel->setItemsColor(ACTIVE_COLOR); + myModel->setItemsColor(ACTIVE_COLOR); return true; } } @@ -529,7 +530,7 @@ QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) co QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const { // Check that this feature belongs to root document - DocumentPtr aRootDoc = ModelAPI_Session::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); DocumentPtr aDoc = theObject->document(); if (aDoc == aRootDoc) { // This feature belongs to histrory or top model