X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ModelWidget.cpp;h=a21cf4517902ce714da983ed57c2d26c2c22e4a2;hb=90a04fa2943fd985a9dbabc839313a8744d898fc;hp=097f5175d31c949ea1e2ff15f800066dd53179be;hpb=b394e9c094d25b01f1d7b9b59b218807c5be087b;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 097f5175d..a21cf4517 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "ModuleBase_ModelWidget.h" @@ -51,13 +50,13 @@ //************************************************************** ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, - const Config_WidgetAPI* theData) - : QWidget(theParent), - myIsEditing(false), - myState(Stored), - myIsValueStateBlocked(false), - myFlushUpdateBlocked(false), - myWidgetValidator(0) + const Config_WidgetAPI* theData) + : QWidget(theParent), + myWidgetValidator(0), + myState(Stored), + myIsEditing(false), + myIsValueStateBlocked(false), + myFlushUpdateBlocked(false) { #ifdef DEBUG_WIDGET_INSTANCE qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget"); @@ -66,9 +65,12 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, myFeatureId = theData->featureId(); myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false); + myUseExternalParts = theData->getBooleanAttribute("allow_parts_content", false); myIsModifiedInEdit = theData->getProperty(ATTR_MODIFIED_IN_EDIT); + myUpdateVisualAttributes = theData->getBooleanAttribute(ATTR_VISUAL_CHANGED, false); + myDefaultValue = theData->getProperty(ATTR_DEFAULT); myUseReset = theData->getBooleanAttribute(ATTR_USE_RESET, true); myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED; @@ -119,10 +121,9 @@ void ModuleBase_ModelWidget::selectionModes(int& theModuleSelectionModes, QIntLi } //************************************************************** -void ModuleBase_ModelWidget::selectionFilters(int& theModuleSelectionFilters, +void ModuleBase_ModelWidget::selectionFilters(QIntList& theModuleSelectionFilters, SelectMgr_ListOfFilter& theSelectionFilters) { - theModuleSelectionFilters = -1; if (myWidgetValidator) myWidgetValidator->selectionFilters(theModuleSelectionFilters, theSelectionFilters); } @@ -157,6 +158,7 @@ void ModuleBase_ModelWidget::processValueState() Events_InfoMessage ModuleBase_ModelWidget::getValueStateError() const { Events_InfoMessage aMessage; + aMessage.setContext(context()); ModuleBase_ModelWidget::ValueState aState = getValueState(); if (aState != ModuleBase_ModelWidget::Stored) { @@ -189,7 +191,6 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const if (!feature().get()) return anError; - std::string aFeatureID = feature()->getKind(); std::string anAttributeID = attributeID(); AttributePtr anAttribute = feature()->attribute(anAttributeID); if (!anAttribute.get()) @@ -204,7 +205,7 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const anErrorMsg = "Unknown error."; if (anErrorMsg.context().empty()) { - anErrorMsg.setContext(aFeatureID + ":" + anAttributeID + ":" + aValidatorID); + anErrorMsg.setContext(context() + ":" + aValidatorID); } } @@ -424,6 +425,12 @@ bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked) //************************************************************** bool ModuleBase_ModelWidget::restoreValue() { + if (!isEnabled()) { + // This code works in inspection panel + ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators(); + if (!aValidators->isCase(myFeature, attributeID())) + return false; // if it is not an active case for the widget + } emit beforeValuesRestored(); bool isDone = restoreValueCustom(); emit afterValuesRestored(); @@ -438,6 +445,10 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject) #ifdef DEBUG_WIDGET_INSTANCE qDebug("ModuleBase_ModelWidget::updateObject"); #endif + if (myFeature.get() && myUpdateVisualAttributes) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_VISUAL_ATTRIBUTES); + ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent); + } ModuleBase_Tools::flushUpdated(theObject); emit objectUpdated(); }