1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4 #include "XGUI_Viewer.h"
6 #include <PyConsole_Console.h>
7 #include <PyConsole_EnhInterp.h>
10 #include <QTreeWidget>
11 #include <QDockWidget>
15 #include <QToolButton>
16 #include <QTreeWidgetItem>
20 #include <QFormLayout>
21 #include <QDoubleSpinBox>
22 #include <QPushButton>
23 #include <QScrollArea>
26 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
27 : QMainWindow(parent),
31 setWindowTitle(tr("WINDOW_TITLE"));
32 myMenuBar = new XGUI_MainMenu(this);
34 QDockWidget* aDoc = new QDockWidget(this);
35 aDoc->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
36 aDoc->setWindowTitle(tr("OBJECT_BROWSER_TITLE"));
37 myObjectBrowser = new QTreeWidget(aDoc);
38 myObjectBrowser->setColumnCount(1);
39 myObjectBrowser->setHeaderHidden(true);
40 aDoc->setWidget(myObjectBrowser);
41 addDockWidget(Qt::LeftDockWidgetArea, aDoc);
44 QMdiArea* aMdiArea = new QMdiArea(this);
45 setCentralWidget(aMdiArea);
47 myViewer = new XGUI_Viewer(this);
49 //fillObjectBrowser();
53 XGUI_MainWindow::~XGUI_MainWindow(void)
57 //******************************************************
58 QMdiArea* XGUI_MainWindow::mdiArea() const
60 return static_cast<QMdiArea*>(centralWidget());
63 //******************************************************
64 void XGUI_MainWindow::showObjectBrowser()
66 myObjectBrowser->parentWidget()->show();
69 //******************************************************
70 void XGUI_MainWindow::hideObjectBrowser()
72 myObjectBrowser->parentWidget()->hide();
75 //******************************************************
76 void XGUI_MainWindow::showPythonConsole()
78 if (!myPythonConsole) {
80 QDockWidget* aDoc = new QDockWidget(this);
81 aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
82 aDoc->setMinimumHeight(0);
83 aDoc->setWindowTitle("Console");
84 myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
85 //myPythonConsole = new QTextEdit(aDoc);
86 //myPythonConsole->setGeometry(0,0,200, 50);
87 //myPythonConsole->setText(">>>");
88 aDoc->setWidget(myPythonConsole);
89 //myPythonConsole->setMinimumHeight(0);
90 addDockWidget(Qt::TopDockWidgetArea, aDoc);
91 tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
93 myPythonConsole->parentWidget()->show();
96 //******************************************************
97 void XGUI_MainWindow::hidePythonConsole()
100 myPythonConsole->parentWidget()->hide();
105 //******************************************************
109 //******************************************************
110 void XGUI_MainWindow::fillObjectBrowser()
113 aNames << "Parameters" << "Constructions";
114 aNames << "Part 1" << "Part 2" << "Part 3";
115 aNames << "Properties";
118 aIcons << ":pictures/params_folder.png";
119 aIcons << ":pictures/constr_folder.png";
120 aIcons << ":pictures/part_ico.png";
121 aIcons << ":pictures/part_ico.png";
122 aIcons << ":pictures/part_ico.png";
123 aIcons << ":pictures/properties.png";
125 QList<QTreeWidgetItem*> aItems;
126 foreach(QString aName, aNames)
128 QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
129 aItem->setText(0, aName);
130 aItems.append(aItem);
132 for(int i = 0; i < aItems.length(); i++) {
133 aItems[i]->setIcon(0, QIcon(aIcons[i]));
135 myObjectBrowser->addTopLevelItems(aItems);
137 for(int i = 2; i < 5; i++) {
138 QTreeWidgetItem* aItem = new QTreeWidgetItem(aItems[i]);
139 aItem->setText(0, "Parameters");
140 aItem->setIcon(0, QIcon(":pictures/params_folder.png"));
142 aItem = new QTreeWidgetItem(aItems[i]);
143 aItem->setText(0, "Construction");
144 aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
146 aItem = new QTreeWidgetItem(aItems[i]);
147 aItem->setText(0, "Bodies");
148 aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
150 aItem = new QTreeWidgetItem(aItems[i]);
151 aItem->setText(0, "Features");
152 aItem->setIcon(0, QIcon(":pictures/features.png"));
156 void XGUI_MainWindow::addPropertyPanel()
158 QDockWidget* aPropPanel = new QDockWidget(this);
159 aPropPanel->setWindowTitle("Point");
161 QWidget* aContent = new QWidget(aPropPanel);
162 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
163 aMainLay->setContentsMargins(3, 3, 3, 3);
164 aPropPanel->setWidget(aContent);
166 /*QWidget* aNameWgt = new QWidget(aContent);
167 QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
168 aNameLay->setContentsMargins(0,0,0,0);
169 aMainLay->addWidget(aNameWgt);
171 aNameLay->addWidget(new QLabel("Name", aNameWgt));
172 aNameLay->addWidget(new QLineEdit(aNameWgt));*/
174 QComboBox* aCombo = new QComboBox(aContent);
175 aCombo->addItem("By coordinates");
176 aMainLay->addWidget(aCombo);
178 QWidget* aGrpBox1 = new QWidget(aContent);
179 //aGrpBox1->setFlat(true);
180 QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
181 aFrmLay->setContentsMargins(0, 6, 0, 0);
182 aMainLay->addWidget(aGrpBox1);
184 QLabel* aLbl = new QLabel(aGrpBox1);
185 aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
186 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
188 aLbl = new QLabel(aGrpBox1);
189 aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
190 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
192 aLbl = new QLabel(aGrpBox1);
193 aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
194 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
196 /* aGrpBox1 = new QGroupBox("Normal vector", aContent);
197 aGrpBox1->setFlat(true);
198 aFrmLay = new QFormLayout(aGrpBox1);
199 aFrmLay->setContentsMargins(0, 6, 0, 0);
200 aMainLay->addWidget(aGrpBox1);
202 aLbl = new QLabel(aGrpBox1);
203 aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
204 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
206 aLbl = new QLabel(aGrpBox1);
207 aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
208 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
210 aLbl = new QLabel(aGrpBox1);
211 aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
212 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/
214 aMainLay->addStretch(1);
216 QFrame* aFrm = new QFrame(aContent);
217 aFrm->setFrameStyle(QFrame::Sunken);
218 aFrm->setFrameShape(QFrame::Panel);
219 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
220 aBtnLay->setContentsMargins(0, 0, 0, 0);
221 aMainLay->addWidget(aFrm);
223 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
225 aBtnLay->addWidget(aBtn);
226 aBtnLay->addStretch(1);
227 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
229 aBtnLay->addWidget(aBtn);
230 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
232 aBtnLay->addWidget(aBtn);
234 addDockWidget(Qt::RightDockWidgetArea, aPropPanel);