-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModuleBase_ModelWidget.h"
//**************************************************************
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");
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;
Events_InfoMessage ModuleBase_ModelWidget::getValueStateError() const
{
Events_InfoMessage aMessage;
+ aMessage.setContext(context());
ModuleBase_ModelWidget::ValueState aState = getValueState();
if (aState != ModuleBase_ModelWidget::Stored) {
if (!feature().get())
return anError;
- std::string aFeatureID = feature()->getKind();
std::string anAttributeID = attributeID();
AttributePtr anAttribute = feature()->attribute(anAttributeID);
if (!anAttribute.get())
anErrorMsg = "Unknown error.";
if (anErrorMsg.context().empty()) {
- anErrorMsg.setContext(aFeatureID + ":" + anAttributeID + ":" + aValidatorID);
+ anErrorMsg.setContext(context() + ":" + aValidatorID);
}
}
//**************************************************************
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();
#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();
}