From: vsv Date: Tue, 22 Jul 2014 09:07:08 +0000 (+0400) Subject: Selection problems X-Git-Tag: V_0.4.4~162 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b79c515f93a0a63c5cea6e02daf0ea92442bb225;p=modules%2Fshaper.git Selection problems --- diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index af017fbba..7cef128b1 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -57,8 +57,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) } myModule->workshop()->displayer()->updateViewer(); } - if (aType == EVENT_OBJECT_DELETED) - { + if (aType == EVENT_OBJECT_DELETED) { const ModelAPI_ObjectDeletedMessage* aDelMsg = dynamic_cast(theMessage); boost::shared_ptr aDoc = aDelMsg->document(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 757d759c3..b41cf3005 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -344,8 +344,23 @@ void PartSet_Module::onCloseLocalContext() void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode) { + ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); + PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); + if (aPrevOp) { + std::list aList = aPrevOp->subFeatures(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); + std::list::iterator aSFIt; + for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) { + std::list aResults = (*aSFIt)->results(); + std::list::iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + aDisplayer->activateInLocalContext((*aIt), aModes, false); + } + } + } ModelAPI_EventCreator::get()->sendUpdated(theFeature, - Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; // TODO visualizePreview(theFeature, isDisplay, false); @@ -494,6 +509,14 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi XGUI_Displayer* aDisplayer = myWorkshop->displayer(); aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), isUpdateViewer); +/* FeaturePtr aFeature = aPreviewOp->feature(); + if (aFeature) { + std::list aResList = aFeature->results(); + std::list::iterator aIt; + for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) { + aDisplayer->deactivate((*aIt), false); + } + }*/ } } @@ -523,7 +546,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) if (!aSPFeature) continue; //visualizePreview((*anIt), true, false); - aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false); + aDisplayer->activateInLocalContext((*anIt), aModes, false); } aDisplayer->updateViewer(); } diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 859dbc93f..1c8c5836b 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -271,7 +271,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess //myFeaturePrs->init(aNewFeature); //myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint); - emit featureConstructed(aNewFeature, FM_Activation); +//TODO emit featureConstructed(aNewFeature, FM_Activation); if (theFlushMessage) flushCreated(); return aNewFeature; diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 8d2b7e5fc..5adc7e035 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -137,7 +137,12 @@ void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) std::list PartSet_OperationSketch::subFeatures() const { - boost::shared_ptr aData = feature()->data(); + std::list aFeaList; + FeaturePtr aFeature = feature(); + if (!aFeature) + return aFeaList; + + boost::shared_ptr aData = aFeature->data(); if (!aData->isValid()) return std::list(); boost::shared_ptr aRefList = @@ -145,7 +150,6 @@ std::list PartSet_OperationSketch::subFeatures() const std::list aList = aRefList->list(); std::list::iterator aIt; - std::list aFeaList; for (aIt = aList.begin(); aIt != aList.end(); ++aIt) { FeaturePtr aFeature = boost::dynamic_pointer_cast(*aIt); if (aFeature) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index ed92f3845..d92a5f6e2 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -165,14 +165,9 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, aContext->ClearCurrents(false); aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); } -/* std::list::const_iterator anIt; - for (anIt = theModes.begin(); anIt != theModes.end(); anIt++) - aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt)); - */ // display or redisplay presentation Handle(AIS_InteractiveObject) anAIS; - if (isVisible(theResult)) - { + if (isVisible(theResult)) { boost::shared_ptr anObj = myResult2AISObjectMap[theResult]; if (anObj) anAIS = anObj->impl(); @@ -180,12 +175,12 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, // Activate selection of objects from prs if (!anAIS.IsNull()) { + aContext->ClearSelected(false); // ToCheck aContext->Load(anAIS, -1, true/*allow decomposition*/); aContext->Deactivate(anAIS); std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); - for (; anIt != aLast; anIt++) - { + for (; anIt != aLast; anIt++) { aContext->Activate(anAIS, (*anIt)); } } @@ -194,6 +189,17 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, updateViewer(); } +void XGUI_Displayer::deactvate(ObjectPtr theObject, bool toUpdate) +{ + if (isVisible(theObject)) { + Handle(AIS_InteractiveContext) aContext = AISContext(); + + boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + aContext->Deactivate(anAIS); + } +} + void XGUI_Displayer::stopSelection(const QList& theResults, const bool isStop, const bool isUpdateViewer) { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 226a18c7b..9a742cb1b 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -120,6 +120,8 @@ public: /// \return feature the feature or NULL if it not visualized ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const; + void deactvate(ObjectPtr theFeature, bool toUpdate); + protected: /// Deactivate local selection /// \param isUpdateViewer the state wether the viewer should be updated immediatelly