1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4 #include "XGUI_Viewer.h"
12 #include <QToolButton>
13 #include <QTreeWidgetItem>
17 #include <QFormLayout>
18 #include <QDoubleSpinBox>
19 #include <QPushButton>
20 #include <QScrollArea>
23 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) :
24 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 myViewer = new XGUI_Viewer(this);
52 //aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
53 //aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
59 XGUI_MainWindow::~XGUI_MainWindow(void)
63 //******************************************************
64 QMdiArea* XGUI_MainWindow::mdiArea() const
66 return static_cast<QMdiArea*>(centralWidget());
70 //******************************************************
71 void XGUI_MainWindow::showObjectBrowser()
73 myObjectBrowser->parentWidget()->show();
76 //******************************************************
77 void XGUI_MainWindow::hideObjectBrowser()
79 myObjectBrowser->parentWidget()->hide();
82 //******************************************************
83 void XGUI_MainWindow::fillObjectBrowser()
86 aNames << "Parameters" << "Constructions";
87 aNames << "Part 1" << "Part 2" << "Part 3";
88 aNames << "Properties";
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";
98 QList<QTreeWidgetItem*> aItems;
99 foreach(QString aName, aNames) {
100 QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
101 aItem->setText(0, aName);
102 aItems.append(aItem);
104 for(int i = 0; i < aItems.length(); i++) {
105 aItems[i]->setIcon(0, QIcon(aIcons[i]));
107 myObjectBrowser->addTopLevelItems(aItems);
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"));
114 aItem = new QTreeWidgetItem(aItems[i]);
115 aItem->setText(0, "Construction");
116 aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
118 aItem = new QTreeWidgetItem(aItems[i]);
119 aItem->setText(0, "Bodies");
120 aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
122 aItem = new QTreeWidgetItem(aItems[i]);
123 aItem->setText(0, "Features");
124 aItem->setIcon(0, QIcon(":pictures/features.png"));
129 void XGUI_MainWindow::addPropertyPanel()
131 QDockWidget* aPropPanel = new QDockWidget(this);
132 aPropPanel->setWindowTitle("Point");
134 QWidget* aContent = new QWidget(aPropPanel);
135 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
136 aMainLay->setContentsMargins(3,3,3,3);
137 aPropPanel->setWidget(aContent);
139 /*QWidget* aNameWgt = new QWidget(aContent);
140 QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
141 aNameLay->setContentsMargins(0,0,0,0);
142 aMainLay->addWidget(aNameWgt);
144 aNameLay->addWidget(new QLabel("Name", aNameWgt));
145 aNameLay->addWidget(new QLineEdit(aNameWgt));*/
147 QComboBox* aCombo = new QComboBox(aContent);
148 aCombo->addItem("By coordinates");
149 aMainLay->addWidget(aCombo);
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);
158 QLabel* aLbl = new QLabel(aGrpBox1);
159 aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
160 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
162 aLbl = new QLabel(aGrpBox1);
163 aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
164 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
166 aLbl = new QLabel(aGrpBox1);
167 aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
168 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
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);
177 aLbl = new QLabel(aGrpBox1);
178 aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
179 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
181 aLbl = new QLabel(aGrpBox1);
182 aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
183 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
185 aLbl = new QLabel(aGrpBox1);
186 aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
187 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/
189 aMainLay->addStretch(1);
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);
198 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
200 aBtnLay->addWidget(aBtn);
201 aBtnLay->addStretch(1);
202 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
204 aBtnLay->addWidget(aBtn);
205 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
207 aBtnLay->addWidget(aBtn);
209 addDockWidget(Qt::RightDockWidgetArea, aPropPanel);