]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetLabelValue.cpp
Salome HOME
aafbb4ba2e07ac20d164aef0e290c9f460e2ce67
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetLabelValue.cpp
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetLabelValue.cpp
4 // Created:     30 Nov 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #include "ModuleBase_WidgetLabelValue.h"
8
9 #include <Config_WidgetAPI.h>
10 #include <Config_Keywords.h>
11 #include <ModuleBase_LabelValue.h>
12
13 #include <ModelAPI_AttributeDouble.h>
14
15 #include <QLabel>
16 #include <QVBoxLayout>
17
18 ModuleBase_WidgetLabelValue::ModuleBase_WidgetLabelValue(QWidget* theParent,
19                                                const Config_WidgetAPI* theData)
20 : ModuleBase_ModelWidget(theParent, theData)
21 {
22   QVBoxLayout* aLayout = new QVBoxLayout(this);
23   aLayout->setContentsMargins(0, 0, 0, 0);
24   aLayout->setSpacing(0);
25
26   QString aText = QString::fromStdString(theData->widgetLabel());
27   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
28   QString aToolTip = QString::fromStdString(theData->widgetTooltip());
29
30   myLabel = new ModuleBase_LabelValue(theParent, aText, aToolTip, aLabelIcon);
31   aLayout->addWidget(myLabel);
32 }
33
34 ModuleBase_WidgetLabelValue::~ModuleBase_WidgetLabelValue()
35 {
36 }
37
38 QList<QWidget*> ModuleBase_WidgetLabelValue::getControls() const
39 {
40   return QList<QWidget*>();
41 }
42
43 bool ModuleBase_WidgetLabelValue::restoreValueCustom()
44 {
45   DataPtr aData = myFeature->data();
46   AttributeDoublePtr anAttribute = aData->real(attributeID());
47   double aValue = 0;
48   if (anAttribute.get() && anAttribute->isInitialized())
49     aValue = anAttribute->value();
50   myLabel->setValue(aValue);
51   return true;
52 }
53
54 bool ModuleBase_WidgetLabelValue::storeValueCustom()
55 {
56   return true;
57 }