]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_MainWindow.cpp
Salome HOME
9f2f85b8c988383ee088b3e77538213ce19335f2
[modules/shaper.git] / src / XGUI / XGUI_MainWindow.cpp
1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4 #include "XGUI_Viewer.h"
5
6 #include <QMdiArea>
7 #include <QTreeWidget>
8 #include <QDockWidget>
9 #include <QTextEdit>
10 #include <QLabel>
11 #include <QToolBar>
12 #include <QToolButton>
13 #include <QTreeWidgetItem>
14 #include <QLayout>
15 #include <QLineEdit>
16 #include <QGroupBox>
17 #include <QFormLayout>
18 #include <QDoubleSpinBox>
19 #include <QPushButton>
20 #include <QScrollArea>
21 #include <QComboBox>
22
23 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) :
24     QMainWindow(parent), myObjectBrowser(0)
25 {
26     myMenuBar = new XGUI_MainMenu(this);
27
28     QDockWidget* aDoc = new QDockWidget(this);
29     aDoc->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
30     aDoc->setWindowTitle(tr("OBJECT_BROWSER_TITLE"));
31     myObjectBrowser = new QTreeWidget(aDoc);
32     myObjectBrowser->setColumnCount(1);
33     myObjectBrowser->setHeaderHidden(true);
34     aDoc->setWidget(myObjectBrowser);
35     addDockWidget(Qt::LeftDockWidgetArea, aDoc);
36     //aDoc->hide();
37
38     aDoc = new QDockWidget(this);
39     aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
40     aDoc->setMinimumHeight(0);
41     aDoc->setWindowTitle("Console");
42     QTextEdit* aTextEdt = new QTextEdit(aDoc);
43     aTextEdt->setText(">>>");
44     aDoc->setWidget(aTextEdt);
45     aTextEdt->setMinimumHeight(0);
46     addDockWidget(Qt::BottomDockWidgetArea, aDoc);
47
48     QMdiArea* aMdiArea = new QMdiArea(this);
49     setCentralWidget(aMdiArea);
50
51     myViewer = new XGUI_Viewer(this);
52     //aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
53     //aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
54
55     fillObjectBrowser();
56     addPropertyPanel();
57 }
58
59 XGUI_MainWindow::~XGUI_MainWindow(void)
60 {
61 }
62
63 //******************************************************
64 QMdiArea* XGUI_MainWindow::mdiArea() const
65 {
66     return static_cast<QMdiArea*>(centralWidget());
67 }
68
69
70 //******************************************************
71 void XGUI_MainWindow::showObjectBrowser()
72 {
73     myObjectBrowser->parentWidget()->show();
74 }
75
76 //******************************************************
77 void XGUI_MainWindow::hideObjectBrowser()
78 {
79     myObjectBrowser->parentWidget()->hide();
80 }
81
82 //******************************************************
83 void XGUI_MainWindow::fillObjectBrowser()
84 {
85     QStringList aNames;
86     aNames << "Parameters" << "Constructions";
87     aNames << "Part 1" << "Part 2" << "Part 3";
88     aNames << "Properties";
89
90     QStringList aIcons;
91     aIcons << ":pictures/params_folder.png";
92     aIcons << ":pictures/constr_folder.png";
93     aIcons << ":pictures/part_ico.png";
94     aIcons << ":pictures/part_ico.png";
95     aIcons << ":pictures/part_ico.png";
96     aIcons << ":pictures/properties.png";
97
98     QList<QTreeWidgetItem*> aItems;
99     foreach(QString aName, aNames) {
100         QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
101         aItem->setText(0, aName);
102         aItems.append(aItem);
103     }
104     for(int i = 0; i < aItems.length(); i++) {
105         aItems[i]->setIcon(0, QIcon(aIcons[i]));
106     }
107     myObjectBrowser->addTopLevelItems(aItems);
108
109     for (int i = 2; i < 5; i++) {
110         QTreeWidgetItem* aItem = new QTreeWidgetItem(aItems[i]);
111         aItem->setText(0, "Parameters");
112         aItem->setIcon(0, QIcon(":pictures/params_folder.png"));
113
114         aItem = new QTreeWidgetItem(aItems[i]);
115         aItem->setText(0, "Construction");
116         aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
117
118         aItem = new QTreeWidgetItem(aItems[i]);
119         aItem->setText(0, "Bodies");
120         aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
121
122         aItem = new QTreeWidgetItem(aItems[i]);
123         aItem->setText(0, "Features");
124         aItem->setIcon(0, QIcon(":pictures/features.png"));
125     }
126 }
127
128
129 void XGUI_MainWindow::addPropertyPanel()
130 {
131     QDockWidget* aPropPanel = new QDockWidget(this);
132     aPropPanel->setWindowTitle("Point");
133
134     QWidget* aContent = new QWidget(aPropPanel);
135     QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
136     aMainLay->setContentsMargins(3,3,3,3);
137     aPropPanel->setWidget(aContent);
138
139     /*QWidget* aNameWgt = new QWidget(aContent);
140     QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
141     aNameLay->setContentsMargins(0,0,0,0);
142     aMainLay->addWidget(aNameWgt);
143
144     aNameLay->addWidget(new QLabel("Name", aNameWgt));
145     aNameLay->addWidget(new QLineEdit(aNameWgt));*/
146
147     QComboBox* aCombo = new QComboBox(aContent);
148     aCombo->addItem("By coordinates");
149     aMainLay->addWidget(aCombo);
150
151     QWidget* aGrpBox1 = new QWidget(aContent);
152     //aGrpBox1->setFlat(true);
153     QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
154     aFrmLay->setContentsMargins(0, 6, 0, 0);
155     aMainLay->addWidget(aGrpBox1);
156
157
158     QLabel* aLbl = new QLabel(aGrpBox1);
159     aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
160     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
161
162     aLbl = new QLabel(aGrpBox1);
163     aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
164     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
165
166     aLbl = new QLabel(aGrpBox1);
167     aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
168     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
169     
170
171 /*    aGrpBox1 = new QGroupBox("Normal vector", aContent);
172     aGrpBox1->setFlat(true);
173     aFrmLay = new QFormLayout(aGrpBox1);
174     aFrmLay->setContentsMargins(0, 6, 0, 0);
175     aMainLay->addWidget(aGrpBox1);
176
177     aLbl = new QLabel(aGrpBox1);
178     aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
179     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
180
181     aLbl = new QLabel(aGrpBox1);
182     aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
183     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
184
185     aLbl = new QLabel(aGrpBox1);
186     aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
187     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/
188     
189     aMainLay->addStretch(1);
190
191     QFrame* aFrm = new QFrame(aContent);
192     aFrm->setFrameStyle(QFrame::Sunken);
193     aFrm->setFrameShape(QFrame::Panel);
194     QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
195     aBtnLay->setContentsMargins(0, 0, 0, 0);
196     aMainLay->addWidget(aFrm);
197
198     QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
199     aBtn->setFlat(true);
200     aBtnLay->addWidget(aBtn);
201     aBtnLay->addStretch(1);
202     aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
203     aBtn->setFlat(true);
204     aBtnLay->addWidget(aBtn);
205     aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
206     aBtn->setFlat(true);
207     aBtnLay->addWidget(aBtn);
208
209     addDockWidget(Qt::RightDockWidgetArea, aPropPanel);
210 }