1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
8 #include <QMdiSubWindow>
11 #include <QToolButton>
13 #include <QTreeWidgetItem>
17 #include <QFormLayout>
18 #include <QDoubleSpinBox>
19 #include <QPushButton>
20 #include <QScrollArea>
22 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) :
23 QMainWindow(parent), myObjectBrowser(0)
26 myMenuBar = new XGUI_MainMenu(this);
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);
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);
48 QMdiArea* aMdiArea = new QMdiArea(this);
49 setCentralWidget(aMdiArea);
51 aMdiArea->addSubWindow(getSubWindow(), Qt::FramelessWindowHint);
58 QWidget* XGUI_MainWindow::getSubWindow()
60 QMdiSubWindow* aSub = new QMdiSubWindow(this);
61 QLabel* aLbl = new QLabel(aSub);
62 aLbl->setFrameStyle(QFrame::Sunken);
63 aLbl->setFrameShape(QFrame::Panel);
64 aLbl->setPixmap(QPixmap(":pictures/ViewPort.png"));
65 aLbl->setScaledContents(true);
66 aSub->setWidget(aLbl);
68 QStringList aPictures;
69 aPictures<<":pictures/occ_view_camera_dump.png"<<":pictures/occ_view_style_switch.png";
70 aPictures<<":pictures/occ_view_triedre.png"<<":pictures/occ_view_fitall.png";
71 aPictures<<":pictures/occ_view_fitarea.png"<<":pictures/occ_view_zoom.png";
72 aPictures<<":pictures/occ_view_pan.png"<<":pictures/occ_view_glpan.png";
73 aPictures<<":pictures/occ_view_rotate.png"<<":pictures/occ_view_front.png";
74 aPictures<<":pictures/occ_view_back.png"<<":pictures/occ_view_left.png";
75 aPictures<<":pictures/occ_view_right.png"<<":pictures/occ_view_top.png";
76 aPictures<<":pictures/occ_view_bottom.png"<<":pictures/occ_view_clone.png";
78 QToolBar* aBar = new QToolBar(aSub);
79 aBar->setGeometry(0,0,500,30);
82 foreach(QString aName, aPictures) {
83 aBtn = new QAction(aBar);
84 aBtn->setIcon(QIcon(aName));
85 aBar->addAction(aBtn);
88 aBar = new QToolBar(aSub);
89 aBar->setGeometry(615,0,100,25);
90 QStringList aWndIcons;
91 aWndIcons<<":pictures/wnd_minimize.png"<<":pictures/wnd_maximize.png"<<":pictures/wnd_close.png";
92 foreach(QString aName, aWndIcons) {
93 aBtn = new QAction(aBar);
94 aBtn->setIcon(QIcon(aName));
95 aBar->addAction(aBtn);
102 XGUI_MainWindow::~XGUI_MainWindow(void)
106 //******************************************************
107 void XGUI_MainWindow::showObjectBrowser()
109 myObjectBrowser->parentWidget()->show();
112 //******************************************************
113 void XGUI_MainWindow::hideObjectBrowser()
115 myObjectBrowser->parentWidget()->hide();
118 //******************************************************
119 void XGUI_MainWindow::fillObjectBrowser()
122 aNames << "Parameters" << "Constructions";
123 aNames << "Part 1" << "Part 2" << "Part 3";
124 aNames << "Properties";
127 aIcons << ":pictures/params_folder.png";
128 aIcons << ":pictures/constr_folder.png";
129 aIcons << ":pictures/part_ico.png";
130 aIcons << ":pictures/part_ico.png";
131 aIcons << ":pictures/part_ico.png";
132 aIcons << ":pictures/properties.png";
134 QList<QTreeWidgetItem*> aItems;
135 foreach(QString aName, aNames) {
136 QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
137 aItem->setText(0, aName);
138 aItems.append(aItem);
140 for(int i = 0; i < aItems.length(); i++) {
141 aItems[i]->setIcon(0, QIcon(aIcons[i]));
143 myObjectBrowser->addTopLevelItems(aItems);
145 for (int i = 2; i < 5; i++) {
146 QTreeWidgetItem* aItem = new QTreeWidgetItem(aItems[i]);
147 aItem->setText(0, "Parameters");
148 aItem->setIcon(0, QIcon(":pictures/params_folder.png"));
150 aItem = new QTreeWidgetItem(aItems[i]);
151 aItem->setText(0, "Construction");
152 aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
154 aItem = new QTreeWidgetItem(aItems[i]);
155 aItem->setText(0, "Bodies");
156 aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
158 aItem = new QTreeWidgetItem(aItems[i]);
159 aItem->setText(0, "Features");
160 aItem->setIcon(0, QIcon(":pictures/features.png"));
165 void XGUI_MainWindow::addPropertyPanel()
167 QDockWidget* aPropPanel = new QDockWidget(this);
168 aPropPanel->setWindowTitle("Property panel");
170 QWidget* aContent = new QWidget(aPropPanel);
171 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
172 aMainLay->setContentsMargins(3,3,3,3);
173 aPropPanel->setWidget(aContent);
175 QWidget* aNameWgt = new QWidget(aContent);
176 QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
177 aNameLay->setContentsMargins(0,0,0,0);
178 aMainLay->addWidget(aNameWgt);
180 aNameLay->addWidget(new QLabel("Name", aNameWgt));
181 aNameLay->addWidget(new QLineEdit(aNameWgt));
183 QGroupBox* aGrpBox1 = new QGroupBox("Point", aContent);
184 aGrpBox1->setFlat(true);
185 QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
186 aFrmLay->setContentsMargins(0, 6, 0, 0);
187 aMainLay->addWidget(aGrpBox1);
189 QLabel* aLbl = new QLabel(aGrpBox1);
190 aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
191 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
193 aLbl = new QLabel(aGrpBox1);
194 aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
195 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
197 aLbl = new QLabel(aGrpBox1);
198 aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
199 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
202 aGrpBox1 = new QGroupBox("Normal vector", aContent);
203 aGrpBox1->setFlat(true);
204 aFrmLay = new QFormLayout(aGrpBox1);
205 aFrmLay->setContentsMargins(0, 6, 0, 0);
206 aMainLay->addWidget(aGrpBox1);
208 aLbl = new QLabel(aGrpBox1);
209 aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
210 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
212 aLbl = new QLabel(aGrpBox1);
213 aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
214 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
216 aLbl = new QLabel(aGrpBox1);
217 aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
218 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
220 aMainLay->addStretch(1);
222 QFrame* aFrm = new QFrame(aContent);
223 aFrm->setFrameStyle(QFrame::Sunken);
224 aFrm->setFrameShape(QFrame::Panel);
225 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
226 aBtnLay->setContentsMargins(0, 0, 0, 0);
227 aMainLay->addWidget(aFrm);
229 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
231 aBtnLay->addWidget(aBtn);
232 aBtnLay->addStretch(1);
233 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
235 aBtnLay->addWidget(aBtn);
236 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
238 aBtnLay->addWidget(aBtn);
240 addDockWidget(Qt::RightDockWidgetArea, aPropPanel);