1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetLabelValue.cpp
4 // Created: 30 Nov 2016
5 // Author: Natalia ERMOLAEVA
7 #include "ModuleBase_WidgetLabelValue.h"
9 #include <Config_WidgetAPI.h>
10 #include <Config_Keywords.h>
11 #include <ModuleBase_LabelValue.h>
13 #include <ModelAPI_AttributeDouble.h>
16 #include <QVBoxLayout>
18 ModuleBase_WidgetLabelValue::ModuleBase_WidgetLabelValue(QWidget* theParent,
19 const Config_WidgetAPI* theData)
20 : ModuleBase_ModelWidget(theParent, theData)
22 QVBoxLayout* aLayout = new QVBoxLayout(this);
23 aLayout->setContentsMargins(0, 0, 0, 0);
24 aLayout->setSpacing(0);
26 QString aText = QString::fromStdString(theData->widgetLabel());
27 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
28 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
30 myLabel = new ModuleBase_LabelValue(theParent, aText, aToolTip, aLabelIcon);
32 double aDefVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
34 myLabel->setValue(aDefVal);
37 aLayout->addWidget(myLabel);
40 ModuleBase_WidgetLabelValue::~ModuleBase_WidgetLabelValue()
44 QList<QWidget*> ModuleBase_WidgetLabelValue::getControls() const
46 QList<QWidget*> aControls;
47 aControls.append(myLabel);
51 bool ModuleBase_WidgetLabelValue::restoreValueCustom()
53 DataPtr aData = myFeature->data();
54 AttributeDoublePtr anAttribute = aData->real(attributeID());
56 if (anAttribute.get() && anAttribute->isInitialized())
57 aValue = anAttribute->value();
58 myLabel->setValue(aValue);
62 bool ModuleBase_WidgetLabelValue::storeValueCustom()