1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SamplePanelPlugin_PageGroupBox.h
4 // Created: 29 Mar 2015
5 // Author: Natalia ERMOLAEVA
7 #include <SamplePanelPlugin_ModelWidget.h>
8 #include <SamplePanelPlugin_Feature.h>
10 #include <ModelAPI_AttributeInteger.h>
11 #include <ModelAPI_Events.h>
13 #include <Config_WidgetAPI.h>
14 #include <Events_Loop.h>
16 #include <QVBoxLayout>
17 #include <QGridLayout>
21 SamplePanelPlugin_ModelWidget::SamplePanelPlugin_ModelWidget(QWidget* theParent,
22 const Config_WidgetAPI* theData)
23 : ModuleBase_ModelWidget(theParent, theData), myDefaultValue(0)
25 QVBoxLayout* aLay = new QVBoxLayout(this);
26 aLay->setContentsMargins(0, 0, 0, 0);
28 myMainWidget = new QWidget(this);
29 aLay->addWidget(myMainWidget);
31 QGridLayout* aLayout = new QGridLayout(myMainWidget);
32 aLayout->addWidget(new QLabel(tr("Values:")), 0, 0);
34 myComboBox = new QComboBox(myMainWidget);
35 myComboBox->addItem("Value_1");
36 myComboBox->addItem("Value_2");
37 myComboBox->addItem("Value_3");
39 connect(myComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(valuesChanged()));
40 aLayout->addWidget(myComboBox, 0, 1);
43 QList<QWidget*> SamplePanelPlugin_ModelWidget::getControls() const
45 QList<QWidget*> aControls;
46 // this control will accept focus and will be highlighted in the Property Panel
47 aControls.push_back(myComboBox);
51 bool SamplePanelPlugin_ModelWidget::storeValueCustom()
53 AttributePtr anAttribute = myFeature->attribute(SamplePanelPlugin_Feature::VALUE_ID());
54 AttributeIntegerPtr aValueAttribute =
55 std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttribute);
56 aValueAttribute->setValue(myComboBox->currentIndex());
57 updateObject(myFeature);
61 bool SamplePanelPlugin_ModelWidget::restoreValueCustom()
63 AttributePtr anAttribute = myFeature->attribute(SamplePanelPlugin_Feature::VALUE_ID());
64 AttributeIntegerPtr aValueAttribute =
65 std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttribute);
67 bool isBlocked = myComboBox->blockSignals(true);
68 myComboBox->setCurrentIndex(aValueAttribute->value());
69 myComboBox->blockSignals(isBlocked);