From: nds Date: Thu, 5 Nov 2015 10:04:27 +0000 (+0300) Subject: 1. setEditOperation should setCurrentFeature to the previous feature in the previous... X-Git-Tag: V_2.0.0_alfa1~6^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ee381bd0990d476f4f935814041cb2b5b7d40f91;p=modules%2Fshaper.git 1. setEditOperation should setCurrentFeature to the previous feature in the previous transaction. Scenario: start circle, click, click->internal edition mode[before a new create operation it should be the same current feature which was when the create of the circle is started] 2. Control by debug information setting current feature performed before starting/commit the operation. --- diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 125e7e84b..20331230c 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -54,22 +54,23 @@ void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransact if (isEditOperation()) return; - myIsEditing = true; if (theRestartTransaction) { - FeaturePtr aPrevFeature = myPreviousCurrentFeature; - + // finsh previous create operation + emit beforeCommitted(); SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_Session::get()->finishOperation(); + // start new edit operation + myIsEditing = true; QString anId = getDescription()->operationId(); if (myIsEditing) { anId = anId.append(EditSuffix()); } ModelAPI_Session::get()->startOperation(anId.toStdString()); emit beforeStarted(); - - myPreviousCurrentFeature = aPrevFeature; } + else + myIsEditing = true; propertyPanel()->setEditingMode(isEditOperation()); } diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 3834a98d8..b80724885 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -273,31 +273,8 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) { aFOperation->setEditOperation(true); - FeaturePtr anOperationFeature = aFOperation->feature(); - - CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch(); - myInternalFeature = aSketch->addFeature(anOperationFeature->getKind()); - XGUI_PropertyPanel* aPropertyPanel = dynamic_cast - (aFOperation->propertyPanel()); - myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget()); - myInternalWidget->setVisible(false); - - ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget); - - QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); - ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop); - - aFactory.createWidget(anInternalPage); - QList aWidgets = aFactory.getModelWidgets(); - - foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { - aWidget->setFeature(myInternalFeature, true); - } - ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget - (aWidgets); - if (aFirstWidget) - myInternalActiveWidget = aFirstWidget; + createInternalFeature(); myIsInternalEditOperation = true; isDone = true; @@ -336,19 +313,7 @@ void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit() disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped())); } - if (myInternalActiveWidget) { - ModuleBase_WidgetSelector* aWSelector = dynamic_cast(myInternalActiveWidget); - if (aWSelector) - aWSelector->activateSelectionAndFilters(false); - myInternalActiveWidget = 0; - } - delete myInternalWidget; - myInternalWidget = 0; - - QObjectPtrList anObjects; - anObjects.append(myInternalFeature); - workshop()->deleteFeatures(anObjects); - + deleteInternalFeature(); } void PartSet_SketcherReetntrantMgr::restartOperation() @@ -366,6 +331,57 @@ void PartSet_SketcherReetntrantMgr::restartOperation() } } +void PartSet_SketcherReetntrantMgr::createInternalFeature() +{ + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (myWorkshop->currentOperation()); + + if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) { + aFOperation->setEditOperation(true); + FeaturePtr anOperationFeature = aFOperation->feature(); + + CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch(); + myInternalFeature = aSketch->addFeature(anOperationFeature->getKind()); + XGUI_PropertyPanel* aPropertyPanel = dynamic_cast + (aFOperation->propertyPanel()); + + myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget()); + myInternalWidget->setVisible(false); + + ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget); + + QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); + ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop); + + aFactory.createWidget(anInternalPage); + QList aWidgets = aFactory.getModelWidgets(); + + foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { + aWidget->setFeature(myInternalFeature, true); + } + ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget + (aWidgets); + if (aFirstWidget) + myInternalActiveWidget = aFirstWidget; + } +} + +void PartSet_SketcherReetntrantMgr::deleteInternalFeature() +{ + if (myInternalActiveWidget) { + ModuleBase_WidgetSelector* aWSelector = dynamic_cast(myInternalActiveWidget); + if (aWSelector) + aWSelector->activateSelectionAndFilters(false); + myInternalActiveWidget = 0; + } + delete myInternalWidget; + myInternalWidget = 0; + + QObjectPtrList anObjects; + anObjects.append(myInternalFeature); + workshop()->deleteFeatures(anObjects); +} + void PartSet_SketcherReetntrantMgr::resetFlags() { if (!myIsFlagsBlocked) { diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index 8853e10dc..2d76dd637 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -130,6 +130,12 @@ private: /// Commits the current operation and launches a new with the commited operation feature index void restartOperation(); + /// Creates an internal feature and controls to process it + void createInternalFeature(); + + /// A pair method for an internal creation to remove it and clear all created controls + void deleteInternalFeature(); + /// Breaks sequense of automatically resterted operations void resetFlags(); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 05778ad7f..ace0a2749 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -17,6 +17,7 @@ #include #include "ModuleBase_OperationDescription.h" #include "ModuleBase_OperationFeature.h" +#include "ModuleBase_Tools.h" #include "ModelAPI_CompositeFeature.h" #include "ModelAPI_Session.h" @@ -25,6 +26,8 @@ #include #include +//#define DEBUG_CURRENT_FEATURE + XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop) : QObject(theParent), myIsApplyEnabled(false), myWorkshop(theWorkshop) @@ -396,9 +399,27 @@ void XGUI_OperationMgr::onBeforeOperationStarted() // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch. // As a result the sketch disappears from the viewer. However after commit it is displayed back. aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false)); + +#ifdef DEBUG_CURRENT_FEATURE + FeaturePtr aFeature = aFOperation->feature(); + QString aKind = aFeature ? aFeature->getKind().c_str() : ""; + qDebug(QString("onBeforeOperationStarted(), edit operation = %1, feature = %2") + .arg(aFOperation->isEditOperation()) + .arg(ModuleBase_Tools::objectInfo(aFeature)).toStdString().c_str()); + + qDebug(QString("\tdocument->currentFeature(false) = %1").arg( + ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif + if (aFOperation->isEditOperation()) // it should be performed by the feature edit only // in create operation, the current feature is changed by addFeature() aDoc->setCurrentFeature(aFOperation->feature(), false); + +#ifdef DEBUG_CURRENT_FEATURE + qDebug("\tdocument->setCurrentFeature"); + qDebug(QString("\tdocument->currentFeature(false) = %1").arg( + ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif } } @@ -429,6 +450,16 @@ void XGUI_OperationMgr::onBeforeOperationCommitted() /// Restore the previous current feature ModuleBase_OperationFeature* aFOperation = dynamic_cast(aCurrentOperation); if (aFOperation) { +#ifdef DEBUG_CURRENT_FEATURE + QString aKind = aFOperation->feature()->getKind().c_str(); + qDebug(QString("onBeforeOperationCommitted(), edit operation = %1, feature = %2") + .arg(aFOperation->isEditOperation()) + .arg(ModuleBase_Tools::objectInfo(aFOperation->feature())).toStdString().c_str()); + + qDebug(QString("\tdocument->currentFeature(false) = %1").arg( + ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif + if (aFOperation->isEditOperation()) { /// Restore the previous current feature setCurrentFeature(aFOperation->previousCurrentFeature()); @@ -440,6 +471,11 @@ void XGUI_OperationMgr::onBeforeOperationCommitted() if (myOperations.front() != aFOperation) setCurrentFeature(aFOperation->previousCurrentFeature()); } +#ifdef DEBUG_CURRENT_FEATURE + qDebug("\tdocument->setCurrentFeature"); + qDebug(QString("\tdocument->currentFeature(false) = %1").arg( + ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str()); +#endif } }