1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #include "ModuleBase_WidgetLabelValue.h"
22 #include <Config_WidgetAPI.h>
23 #include <Config_Keywords.h>
24 #include <ModuleBase_LabelValue.h>
26 #include <ModelAPI_AttributeDouble.h>
29 #include <QVBoxLayout>
31 ModuleBase_WidgetLabelValue::ModuleBase_WidgetLabelValue(QWidget* theParent,
32 const Config_WidgetAPI* theData)
33 : ModuleBase_ModelWidget(theParent, theData)
35 QVBoxLayout* aLayout = new QVBoxLayout(this);
36 aLayout->setContentsMargins(0, 0, 0, 0);
37 aLayout->setSpacing(0);
39 QString aText = QString::fromStdString(theData->widgetLabel());
40 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
41 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
43 myLabel = new ModuleBase_LabelValue(theParent, aText, aToolTip, aLabelIcon);
45 double aDefVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
47 myLabel->setValue(aDefVal);
50 aLayout->addWidget(myLabel);
53 ModuleBase_WidgetLabelValue::~ModuleBase_WidgetLabelValue()
57 QList<QWidget*> ModuleBase_WidgetLabelValue::getControls() const
59 QList<QWidget*> aControls;
60 aControls.append(myLabel);
64 bool ModuleBase_WidgetLabelValue::restoreValueCustom()
66 DataPtr aData = myFeature->data();
67 AttributeDoublePtr anAttribute = aData->real(attributeID());
69 if (anAttribute.get() && anAttribute->isInitialized())
70 aValue = anAttribute->value();
71 myLabel->setValue(aValue);
75 bool ModuleBase_WidgetLabelValue::storeValueCustom()