1 // File: ModuleBase_WidgetPoint2D.cpp
2 // Created: 25 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <ModuleBase_WidgetPoint2D.h>
7 #include <Config_Keywords.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
11 #include <GeomDataAPI_Point2D.h>
14 #include <QGridLayout>
15 #include <QDoubleSpinBox>
21 ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
22 const std::string& theFeatureAttributeID)
23 : ModuleBase_WidgetCustom(theParent), myFeatureAttributeID(theFeatureAttributeID)
25 myGroupBox = new QGroupBox(theTitle, theParent);
26 QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
27 aGroupLay->setContentsMargins(0, 0, 0, 0);
28 aGroupLay->setColumnStretch(1, 1);
30 QLabel* aLabel = new QLabel(myGroupBox);
32 aLabel->setPixmap(QPixmap(":pictures/x_point.png"));
33 aGroupLay->addWidget(aLabel, 0, 0);
35 myXSpin = new QDoubleSpinBox(myGroupBox);
36 myXSpin->setMinimum(-DBL_MAX);
37 myXSpin->setMaximum(DBL_MAX);
38 myXSpin->setToolTip("X");
39 aGroupLay->addWidget(myXSpin, 0, 1);
41 connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
44 QLabel* aLabel = new QLabel(myGroupBox);
46 aLabel->setPixmap(QPixmap(":pictures/y_point.png"));
47 aGroupLay->addWidget(aLabel, 1, 0);
49 myYSpin = new QDoubleSpinBox(myGroupBox);
50 myYSpin->setMinimum(-DBL_MAX);
51 myYSpin->setMaximum(DBL_MAX);
52 myYSpin->setToolTip("X");
53 aGroupLay->addWidget(myYSpin, 1, 1);
55 connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
59 ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
63 void ModuleBase_WidgetPoint2D::store(boost::shared_ptr<ModelAPI_Feature> theFeature)
65 boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
66 boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
67 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myFeatureAttributeID));
69 aPoint->setValue(myXSpin->value(), myYSpin->value());
72 QWidget* ModuleBase_WidgetPoint2D::getControl() const