1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "ModuleBase_WidgetLabelValue.h"
23 #include <Config_WidgetAPI.h>
24 #include <Config_Keywords.h>
25 #include <ModuleBase_LabelValue.h>
27 #include <ModelAPI_AttributeDouble.h>
30 #include <QVBoxLayout>
32 ModuleBase_WidgetLabelValue::ModuleBase_WidgetLabelValue(QWidget* theParent,
33 const Config_WidgetAPI* theData)
34 : ModuleBase_ModelWidget(theParent, theData)
36 QVBoxLayout* aLayout = new QVBoxLayout(this);
37 aLayout->setContentsMargins(0, 0, 0, 0);
38 aLayout->setSpacing(0);
40 QString aText = QString::fromStdString(theData->widgetLabel());
41 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
42 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
44 myLabel = new ModuleBase_LabelValue(theParent, aText, aToolTip, aLabelIcon);
46 double aDefVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
48 myLabel->setValue(aDefVal);
51 aLayout->addWidget(myLabel);
54 ModuleBase_WidgetLabelValue::~ModuleBase_WidgetLabelValue()
58 QList<QWidget*> ModuleBase_WidgetLabelValue::getControls() const
60 QList<QWidget*> aControls;
61 aControls.append(myLabel);
65 bool ModuleBase_WidgetLabelValue::restoreValueCustom()
67 DataPtr aData = myFeature->data();
68 AttributeDoublePtr anAttribute = aData->real(attributeID());
70 if (anAttribute.get() && anAttribute->isInitialized())
71 aValue = anAttribute->value();
72 myLabel->setValue(aValue);
76 bool ModuleBase_WidgetLabelValue::storeValueCustom()