X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_OperationFeature.cpp;h=450e52399e20a9af5b0c8a22471538df6adeb997;hb=26d86199535820c6080ad582470b04e1bbff6152;hp=f331ed72fda1f511a3f7db7a7f711dd8a069813d;hpb=af73a3e00de48eeff2610b25e2d5f851df7a5075;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index f331ed72f..450e52399 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -42,6 +42,8 @@ #include #endif +//#define DEBUG_OPERATION_START + #ifdef _DEBUG #include #endif @@ -100,6 +102,7 @@ bool ModuleBase_OperationFeature::isValid() const return true; std::string anError = ModelAPI_Tools::getFeatureError(myFeature); + ModuleBase_Tools::translate(myFeature->getKind(), anError); return anError.empty(); } @@ -114,7 +117,8 @@ void ModuleBase_OperationFeature::startOperation() myVisualizedObjects.clear(); // store hidden result features - std::list aResults = aFeature->results(); + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); std::list::const_iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { ObjectPtr anObject = *aIt; @@ -137,7 +141,8 @@ void ModuleBase_OperationFeature::stopOperation() return; // store hidden result features - std::list aResults = aFeature->results(); + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); std::list::const_iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { ObjectPtr anObject = *aIt; @@ -172,8 +177,10 @@ FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage }*/ } - if (theFlushMessage) + if (theFlushMessage) { Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + } return myFeature; } @@ -189,11 +196,13 @@ bool ModuleBase_OperationFeature::hasObject(ObjectPtr theObj) const if (aFeature) { if (aFeature == theObj) return true; - std::list aResults = aFeature->results(); + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); std::list::const_iterator aIt; for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { - if (theObj == (*aIt)) - return true; + ResultPtr aResult = *aIt; + if (theObj == aResult) + return true; } #ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE if (aFeature->isMacro()) { @@ -229,6 +238,9 @@ bool ModuleBase_OperationFeature::isDisplayedOnStart(ObjectPtr theObject) bool ModuleBase_OperationFeature::start() { +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::start -- begin"); +#endif setIsModified(false); QString anId = getDescription()->operationId(); if (myIsEditing) { @@ -247,16 +259,26 @@ bool ModuleBase_OperationFeature::start() // in order to update commands status in the workshop, to be exact the feature action // to be unchecked abort(); +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::start -- end : IMPOSSIBLE to start"); +#endif return false; } } //Already called startOperation(); emit started(); +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::start -- end"); +#endif return true; } void ModuleBase_OperationFeature::abort() { +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::abort -- begin"); +#endif + emit beforeAborted(); // the viewer update should be blocked in order to avoid the features blinking before they are @@ -291,10 +313,16 @@ void ModuleBase_OperationFeature::abort() Events_Loop::loop()->send(aMsg); emit aborted(); +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::abort -- end"); +#endif } bool ModuleBase_OperationFeature::commit() { +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::commit -- begin"); +#endif ModuleBase_IPropertyPanel* aPanel = propertyPanel(); if (aPanel) { ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget(); @@ -326,8 +354,14 @@ bool ModuleBase_OperationFeature::commit() emit committed(); afterCommitOperation(); +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::commit -- end : IMPOSSIBLE to commit"); +#endif return true; } +#ifdef DEBUG_OPERATION_START + qDebug("ModuleBase_OperationFeature::commit -- end"); +#endif return false; } @@ -337,8 +371,6 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( ModuleBase_ModelWidget* aWidget = 0; if (myPreSelection.empty()) return aWidget; - // equal vertices should not be used here - ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection); ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel(); ModuleBase_ModelWidget* aFilledWgt = 0; @@ -347,16 +379,23 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( QList::const_iterator aWIt; ModuleBase_ModelWidget* aWgt = 0; if (!aWidgets.empty()) { + // equal vertices should not be used here + ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection); + if (!theGreedAttributeId.empty()) { // set preselection to greed widget for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { aWgt = (*aWIt); if (aWgt->attributeID() == theGreedAttributeId) { aPropertyPanel->setPreselectionWidget(aWgt); - aWgt->setSelection(myPreSelection, true); - aPropertyPanel->setPreselectionWidget(NULL); - aFilledWgt = aWgt; - break; + if (aWgt->setSelection(myPreSelection, true)) { + aPropertyPanel->setPreselectionWidget(NULL); + aFilledWgt = aWgt; + break; + } + else { // do not process invalid for greed widget selection + break; + } } } } @@ -368,7 +407,7 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( if (!aWgt->canAcceptFocus()) continue; aPropertyPanel->setPreselectionWidget(aWgt); - if (!aWgt->setSelection(myPreSelection, true)) { + if (myPreSelection.empty() || !aWgt->setSelection(myPreSelection, true)) { isSet = false; break; } else { @@ -381,7 +420,7 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( // in order to redisplay object in the viewer, the update/redisplay signals should be flushed // it is better to perform it not in setSelection of each widget, but do it here, // after the preselection is processed - ModuleBase_ModelWidget::updateObject(myFeature); + ModuleBase_Tools::flushUpdated(myFeature); } } clearPreselection(); @@ -409,31 +448,36 @@ FeaturePtr ModuleBase_OperationFeature::previousCurrentFeature() return myPreviousCurrentFeature; } -void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelection, - ModuleBase_IViewer* theViewer) +void ModuleBase_OperationFeature::initSelection(const QList& thePreSelected) { - clearPreselection(); + QObjectPtrList aCurrentFeatureResults; - QList aPreSelected; // Check that the selected result are not results of operation feature FeaturePtr aFeature = feature(); if (aFeature) { - QList aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls); - - std::list aResults = aFeature->results(); - QObjectPtrList aResList; + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); std::list::const_iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) - aResList.append(*aIt); - - foreach (ModuleBase_ViewerPrs aPrs, aSelected) { - if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature)) + aCurrentFeatureResults.append(*aIt); + } + + if (aCurrentFeatureResults.empty()) /// filtering of selection is not necessary + setPreselection(thePreSelected); + else { // create preselection list without results of current feature + QList aPreSelected; + foreach (ModuleBase_ViewerPrsPtr aPrs, thePreSelected) { + if ((!aCurrentFeatureResults.contains(aPrs->object())) && (aPrs->object() != aFeature)) aPreSelected.append(aPrs); } - } else - aPreSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls); + setPreselection(aPreSelected); + } +} - myPreSelection = aPreSelected; +void ModuleBase_OperationFeature::setPreselection(const QList& theValues) +{ + clearPreselection(); + myPreSelection = theValues; } void ModuleBase_OperationFeature::clearPreselection() @@ -453,6 +497,7 @@ void ModuleBase_OperationFeature::setPropertyPanel(ModuleBase_IPropertyPanel* th for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { ModuleBase_ModelWidget* aWgt = (*aWIt); connect(aWgt, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged())); + connect(aWgt, SIGNAL(valueStateChanged(int)), this, SLOT(onValueStateChanged(int))); } }