Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 /*
2  * XGUI_PropertyPanel.cpp
3  *
4  *  Created on: Apr 29, 2014
5  *      Author: sbh
6  */
7
8 #include <XGUI_Constants.h>
9 #include <XGUI_PropertyPanel.h>
10
11 #include <QWidget>
12 #include <QVBoxLayout>
13 #include <QFrame>
14 #include <QPushButton>
15 #include <QIcon>
16 #include <QVBoxLayout>
17
18 #ifdef _DEBUG
19 #include <iostream>
20 #endif
21
22 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
23 {
24   this->setWindowTitle(tr("Property Panel"));
25   QAction* aViewAct = this->toggleViewAction();
26   this->setObjectName(XGUI::PROP_PANEL);
27
28   QWidget* aContent = new QWidget(this);
29   QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
30   aMainLay->setContentsMargins(3, 3, 3, 3);
31   this->setWidget(aContent);
32
33   QFrame* aFrm = new QFrame(aContent);
34   aFrm->setFrameStyle(QFrame::Sunken);
35   aFrm->setFrameShape(QFrame::Panel);
36   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
37   aBtnLay->setContentsMargins(0, 0, 0, 0);
38   aMainLay->addWidget(aFrm);
39
40   QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
41   aBtn->setFlat(true);
42   aBtnLay->addWidget(aBtn);
43   aBtnLay->addStretch(1);
44   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
45   aBtn->setObjectName(XGUI::PROP_PANEL_OK);
46   aBtn->setFlat(true);
47   aBtnLay->addWidget(aBtn);
48   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
49   aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
50   aBtn->setFlat(true);
51   aBtnLay->addWidget(aBtn);
52
53   myCustomWidget = new QWidget(aContent);
54   aMainLay->addWidget(myCustomWidget);
55   aMainLay->addStretch(1);
56 }
57
58 XGUI_PropertyPanel::~XGUI_PropertyPanel()
59 {
60 }
61
62 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
63 {
64   myWidgets = theWidgets;
65 }
66
67 QWidget* XGUI_PropertyPanel::contentWidget()
68 {
69   return myCustomWidget;
70 }
71
72 void XGUI_PropertyPanel::updateContentWidget(boost::shared_ptr<ModelAPI_Feature> theFeature)
73 {
74   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
75     eachWidget->restoreValue(theFeature);
76   }
77   // the repaint is used here to immediatelly react in GUI to the values change.
78   repaint();
79 }