From: vsv Date: Wed, 24 Dec 2014 13:44:43 +0000 (+0300) Subject: Activation of objects after close/open context is corrected X-Git-Tag: V_0.7.0_rc1~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=855c60ad60508ed7b28c04a405e262caee9e71d9;p=modules%2Fshaper.git Activation of objects after close/open context is corrected --- diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 00e90732e..e9cfa075f 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -72,21 +72,6 @@ bool ModuleBase_Operation::isValid() const return aFactory->validate(myFeature); } -//void ModuleBase_Operation::storeCustomValue() -//{ -// if (!myFeature) { -//#ifdef _DEBUG -// qDebug() << "ModuleBase_Operation::storeCustom: " << -// "trying to store value without opening a transaction."; -//#endif -// return; -// } -// -// ModuleBase_ModelWidget* aCustom = dynamic_cast(sender()); -// if (aCustom) -// aCustom->storeValue(); -//} - bool ModuleBase_Operation::canBeCommitted() const { @@ -171,15 +156,13 @@ void ModuleBase_Operation::start() void ModuleBase_Operation::postpone() { - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); + postponeOperation(); emit postponed(); } void ModuleBase_Operation::resume() { - // connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), - // this, SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); + resumeOperation(); emit resumed(); } @@ -187,8 +170,6 @@ void ModuleBase_Operation::abort() { abortOperation(); emit aborted(); - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); stopOperation(); @@ -199,9 +180,6 @@ void ModuleBase_Operation::abort() bool ModuleBase_Operation::commit() { if (canBeCommitted()) { - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); - commitOperation(); // check whether there are modifications performed during the current operation // in the model @@ -347,8 +325,6 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) { myPropertyPanel = theProp; myPropertyPanel->setEditingMode(isEditOperation()); - //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, - // SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); // Do not activate widgets by default if the current operation is editing operation // Because we don't know which widget is going to be edited. diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index a9333a7e8..593758907 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -205,6 +205,9 @@ signals: /// Virtual method called after operation committed (see commit() method for more description) virtual void afterCommitOperation() {} + /// Virtual method called after operation resume (see resume() method for more description) + virtual void resumeOperation() {} + /// Send update message by loop void flushUpdated(); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 3f0846de1..09bc3494f 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -144,11 +144,10 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, if (aCustPrs.get() != NULL) aCustPrs->customisePresentation(theAIS); } - if (aCanBeShaded) + if (aCanBeShaded) { openLocalContext(); - - aContext->Load(anAISIO, -1, true); - activate(theObject); + activateObjects(myActiveSelectionModes); + } } if (isUpdateViewer) updateViewer(); @@ -230,16 +229,16 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes) AISObjectPtr anObj = myResult2AISObjectMap[theObject]; Handle(AIS_InteractiveObject) anAIS = anObj->impl(); aContext->Deactivate(anAIS); - //if (aContext->HasOpenedContext()) { - // aContext->Load(anAIS, -1, true); - //} + aContext->Load(anAIS, -1, true); // In order to clear active modes list if (theModes.size() > 0) { foreach(int aMode, theModes) { + //aContext->Load(anAIS, aMode, true); aContext->Activate(anAIS, aMode); qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode); } } else { + //aContext->Load(anAIS, 0, true); aContext->Activate(anAIS); qDebug("### 2. Activate obj %i", (long)anAIS.Access()); } @@ -249,11 +248,12 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes) void XGUI_Displayer::activateObjects(const QIntList& theModes) { // In order to avoid doblications of selection modes - myActiveSelectionModes.clear(); + QIntList aNewModes; foreach (int aMode, theModes) { - if (!myActiveSelectionModes.contains(aMode)) - myActiveSelectionModes.append(aMode); + if (!aNewModes.contains(aMode)) + aNewModes.append(aMode); } + myActiveSelectionModes = aNewModes; Handle(AIS_InteractiveContext) aContext = AISContext(); // Open local context if there is no one if (!aContext->HasOpenedContext()) @@ -270,6 +270,7 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes) Handle(AIS_InteractiveObject) anAISIO; for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){ anAISIO = aLIt.Value(); + aContext->Load(anAISIO, -1, true); aContext->Deactivate(anAISIO); aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO); //Deactivate trihedron which can be activated in local selector @@ -277,10 +278,12 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes) //aContext->Load(anAISIO, -1, true); // In order to clear active modes list if (myActiveSelectionModes.size() == 0) { + //aContext->Load(anAISIO, 0, true); aContext->Activate(anAISIO); qDebug("### 2. Activate all %i", (long)anAISIO.Access()); } else { foreach(int aMode, myActiveSelectionModes) { + //aContext->Load(anAISIO, aMode, true); aContext->Activate(anAISIO, aMode); qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode); } @@ -303,17 +306,16 @@ void XGUI_Displayer::deactivateObjects() displayedObjects(aContext, aPrsList); AIS_ListIteratorOfListOfInteractive aLIt; - Handle(AIS_Trihedron) aTrihedron; + //Handle(AIS_Trihedron) aTrihedron; Handle(AIS_InteractiveObject) anAISIO; for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){ anAISIO = aLIt.Value(); aContext->Deactivate(anAISIO); - aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO); - if (aTrihedron.IsNull()) { - //aContext->Load(anAISIO, -1, true); - qDebug("### Deactivate all %i", (long)anAISIO.Access()); - //aContext->Activate(anAISIO); - } + //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO); + //if (aTrihedron.IsNull()) { + // qDebug("### Deactivate all %i", (long)anAISIO.Access()); + // //aContext->Activate(anAISIO); + //} } } @@ -333,42 +335,6 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const return aModes.Extent() > 0; } -void XGUI_Displayer::stopSelection(const QObjectPtrList& theResults, const bool isStop, - const bool isUpdateViewer) -{ - Handle(AIS_InteractiveContext) aContext = AISContext(); - if (aContext.IsNull()) - return; - - Handle(AIS_Shape) anAIS; - QObjectPtrList::const_iterator anIt = theResults.begin(), aLast = theResults.end(); - ObjectPtr aFeature; - for (; anIt != aLast; anIt++) { - aFeature = *anIt; - if (isVisible(aFeature)) - anAIS = Handle(AIS_Shape)::DownCast( - myResult2AISObjectMap[aFeature]->impl()); - if (anAIS.IsNull()) - continue; - - if (isStop) { - QColor aColor(Qt::white); - anAIS->SetColor( - Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255., - Quantity_TOC_RGB)); - anAIS->Redisplay(); - } else { - QColor aColor(Qt::red); - anAIS->SetColor( - Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255., - Quantity_TOC_RGB)); - anAIS->Redisplay(); - } - } - if (isUpdateViewer) - updateViewer(); -} - void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -428,33 +394,6 @@ void XGUI_Displayer::eraseAll(const bool isUpdateViewer) updateViewer(); } -//void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) -//{ -// Handle(AIS_InteractiveContext) aContext = AISContext(); -// if (aContext.IsNull()) -// return; -// -// QObjectPtrList aRemoved; -// foreach (ObjectPtr aFeature, myResult2AISObjectMap.keys()) { -// if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) { -// AISObjectPtr anObj = myResult2AISObjectMap[aFeature]; -// if (!anObj) -// continue; -// Handle(AIS_InteractiveObject) anAIS = anObj->impl(); -// if (!anAIS.IsNull()) { -// aContext->Remove(anAIS, false); -// aRemoved.append(aFeature); -// } -// } -// } -// foreach(ObjectPtr aObj, aRemoved) { -// myResult2AISObjectMap.remove(aObj); -// } -// -// if (isUpdateViewer) -// updateViewer(); -//} - void XGUI_Displayer::openLocalContext() { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -481,7 +420,6 @@ void XGUI_Displayer::openLocalContext() //aContext->NotUseDisplayedObjects(); //myUseExternalObjects = false; - myActiveSelectionModes.clear(); SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); for (;aIt.More(); aIt.Next()) { @@ -533,7 +471,6 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) if (isUpdateViewer) updateViewer(); //myUseExternalObjects = false; - myActiveSelectionModes.clear(); // Restore selection //AIS_ListIteratorOfListOfInteractive aIt2(aAisList); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 2cc3bd4ef..0dfb1cae1 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -56,13 +56,6 @@ class XGUI_EXPORT XGUI_Displayer /// Display the given AIS object. To hide this object use corresponde erase method void displayAIS(AISObjectPtr theAIS, bool isUpdate = true); - /// Stop the current selection and color the given features to the selection color - /// \param theFeatures a list of features to be disabled - /// \param theToStop the boolean state whether it it stopped or non stopped - /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void stopSelection(const QObjectPtrList& theFeatures, const bool isStop, - const bool isUpdateViewer); - /** * Add presentations which corresponds to the given features to current selection * \param theFeatures a list of features to be selected @@ -86,10 +79,6 @@ class XGUI_EXPORT XGUI_Displayer /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void eraseAll(const bool isUpdateViewer = true); - /// Erase AIS interactive objects, which has an empty feature in the internal map - /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - //void eraseDeletedResults(const bool isUpdateViewer = true); - /// Deactivates selection of sub-shapes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void closeLocalContexts(const bool isUpdateViewer = true); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index fa583caea..8d113e9d1 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -593,19 +593,21 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation) //****************************************************** void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) { + ModuleBase_ISelection* aSel = mySelector->selection(); + QObjectPtrList aObj = aSel->selectedPresentations(); //!< No need for property panel updateCommandStatus(); hidePropertyPanel(); myPropertyPanel->cleanContent(); // Activate objects created by current operation - FeaturePtr aFeature = theOperation->feature(); - myDisplayer->activate(aFeature); - const std::list& aResults = aFeature->results(); - std::list::const_iterator aIt; - for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { - myDisplayer->activate(*aIt); - } + //FeaturePtr aFeature = theOperation->feature(); + //myDisplayer->activate(aFeature); + //const std::list& aResults = aFeature->results(); + //std::list::const_iterator aIt; + //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { + // myDisplayer->activate(*aIt); + //} myModule->operationStopped(theOperation); }