From ae63f6bd99488afa68d70c6bf871fe9f3603ba4d Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 16 Jul 2014 16:49:11 +0400 Subject: [PATCH] New architecture debugging --- src/Model/Model_Document.cpp | 13 ++++++++----- src/PartSet/PartSet_Listener.cpp | 2 +- src/PartSet/PartSet_Module.cpp | 16 ++++++++-------- src/PartSet/PartSet_Module.h | 2 +- src/XGUI/XGUI_Displayer.cpp | 8 ++++---- src/XGUI/XGUI_DocumentDataModel.cpp | 5 +++-- src/XGUI/XGUI_Workshop.cpp | 3 +-- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 7718721fc..88a0914ff 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -350,16 +350,18 @@ FeaturePtr Model_Document::addFeature(std::string theID) TDF_Label anEmptyLab; FeaturePtr anEmptyFeature; FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); + boost::shared_ptr aDocToAdd = + boost::dynamic_pointer_cast(aFeature->documentToAdd()); if (aFeature) { TDF_Label aFeatureLab; if (!aFeature->isAction()) {// do not add action to the data model - TDF_Label aFeaturesLab = groupLabel(ModelAPI_Feature::group()); + TDF_Label aFeaturesLab = aDocToAdd->groupLabel(ModelAPI_Feature::group()); aFeatureLab = aFeaturesLab.NewChild(); - initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS); + aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS); // keep the feature ID to restore document later correctly TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str()); - setUniqueName(aFeature); - myObjs[ModelAPI_Feature::group()].push_back(aFeature); + aDocToAdd->setUniqueName(aFeature); + aDocToAdd->myObjs[ModelAPI_Feature::group()].push_back(aFeature); // store feature in the history of features array if (aFeature->isInHistory()) { AddToRefArray(aFeaturesLab, aFeatureLab); @@ -434,6 +436,7 @@ void Model_Document::removeFeature(FeaturePtr theFeature) boost::shared_ptr aRes = *aRIter; aRes->setData(boost::shared_ptr()); // deleted flag ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); + ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName()); } } @@ -681,7 +684,6 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) if (anObj->isInHistory()) { ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName); } - ModelAPI_EventCreator::get()->sendDeleted(aThis, aGroupName); // results of this feature must be redisplayed (hided) static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const std::list >& aResults = boost::dynamic_pointer_cast(anObj)->results(); @@ -690,6 +692,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) boost::shared_ptr aRes = *aRIter; aRes->setData(boost::shared_ptr()); // deleted flag ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); + ModelAPI_EventCreator::get()->sendDeleted(aThis, aRes->groupName()); } } else if (aDSTag < aFeatureTag) { // a new feature is inserted // create a feature diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index db10764ad..84db77027 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -50,7 +50,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) if (aFeature) { if (myModule->workshop()->displayer()->isVisible(aFeature->firstResult()) || aType == EVENT_OBJECT_CREATED) { - myModule->visualizePreview(aFeature->firstResult(), true, false); + myModule->visualizePreview(aFeature, true, false); //if (aType == EVENT_OBJECT_CREATED) myModule->activateFeature(aFeature, true); } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b52edee63..84a9ec96f 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -349,7 +349,7 @@ void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode) std::list::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) - visualizePreview((*anIt)->firstResult(), false, false); + visualizePreview((*anIt), false, false); aDisplayer->updateViewer(); } } @@ -444,7 +444,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) Events_Loop::loop()->send(aMessage); } -void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay, +void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, const bool isUpdateViewer) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); @@ -455,19 +455,19 @@ void PartSet_Module::visualizePreview(ResultPtr theFeature, bool isDisplay, if (!aPreviewOp) return; + ResultPtr aResult = theFeature->firstResult(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (isDisplay) { boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast(theFeature); - if (aSPFeature) - { + if (aSPFeature) { boost::shared_ptr anAIS = - aSPFeature->getAISObject(aDisplayer->getAISObject(theFeature)); - aDisplayer->redisplay(theFeature, anAIS, false); + aSPFeature->getAISObject(aDisplayer->getAISObject(aResult)); + aDisplayer->redisplay(aResult, anAIS, false); } } else - aDisplayer->erase(theFeature, false); + aDisplayer->erase(aResult, false); if (isUpdateViewer) aDisplayer->updateViewer(); @@ -509,7 +509,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) boost::dynamic_pointer_cast(*anIt); if (!aSPFeature) continue; - visualizePreview((*anIt)->firstResult(), true, false); + visualizePreview((*anIt), true, false); aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false); } aDisplayer->updateViewer(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index eaec86601..4133472f1 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -55,7 +55,7 @@ public: /// \param theFeature the feature instance to be displayed /// \param isDisplay the state whether the presentation should be displayed or erased /// \param isUpdateViewer the flag whether the viewer should be updated - void visualizePreview(ResultPtr theResult, bool isDisplay, + void visualizePreview(FeaturePtr theFeature, bool isDisplay, const bool isUpdateViewer = true); /// Activates the feature in the displayer diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index ac6b3af89..649e7f6bd 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -87,7 +87,7 @@ void XGUI_Displayer::erase(ResultPtr theResult, } -bool XGUI_Displayer::redisplay(ResultPtr theFeature, +bool XGUI_Displayer::redisplay(ResultPtr theResult, boost::shared_ptr theAIS, const bool isUpdateViewer) { @@ -104,12 +104,12 @@ bool XGUI_Displayer::redisplay(ResultPtr theFeature, //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); } // display or redisplay presentation - boost::shared_ptr anObj = myResult2AISObjectMap[theFeature]; - if (isVisible(theFeature) && anObj && !anObj->empty()) { + boost::shared_ptr anObj = myResult2AISObjectMap[theResult]; + if (isVisible(theResult) && anObj && !anObj->empty()) { aContext->RecomputeSelectionOnly(anAIS); } else { - myResult2AISObjectMap[theFeature] = theAIS; + myResult2AISObjectMap[theResult] = theAIS; aContext->Display(anAIS, false); isCreated = true; } diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 778cec850..a9c3f7a48 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -85,7 +85,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } if (aPartModel) { QModelIndex aIndex = aPartModel->findParent(aObject); - int aStart = aPartModel->rowCount(aIndex) - 1; + int aStart = aPartModel->rowCount(aIndex); // check this index aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); insertRow(aStart, aIndex); } @@ -101,7 +101,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) { std::string aGroup = (*aIt); if (aDoc == aRootDoc) { // If root objects - if (aGroup.compare(ModelAPI_ResultPart::group()) == 0) { // Updsate only Parts group + if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group int aStart = myPartModels.size() - 1; removeSubModel(aStart); removeRow(aStart, partFolderNode()); @@ -246,6 +246,7 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const return aVal; } if (theParent.internalId() == PartsFolder) { + int aSize = myPartModels.size(); return myPartModels.size(); } if (theParent.internalId() == HistoryNode) { diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 084a800c9..9f2d068a2 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -885,8 +885,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) QList aObjects = mySelector->selection()->selectedObjects(); if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObjects.first()); - if (aPart) - activatePart(aPart); + activatePart(aPart); } else if (theId == "DEACTIVATE_PART_CMD") activatePart(ResultPartPtr()); else if (theId == "DELETE_CMD") -- 2.39.2