1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4 #include "XGUI_Viewer.h"
5 #include "XGUI_ObjectsBrowser.h"
7 #include <PyConsole_Console.h>
8 #include <PyConsole_EnhInterp.h>
11 #include <QTreeWidget>
12 #include <QDockWidget>
16 #include <QToolButton>
17 #include <QTreeWidgetItem>
21 #include <QFormLayout>
22 #include <QDoubleSpinBox>
23 #include <QPushButton>
24 #include <QScrollArea>
27 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
28 : QMainWindow(parent),
32 setWindowTitle(tr("WINDOW_TITLE"));
33 myMenuBar = new XGUI_MainMenu(this);
35 QDockWidget* aDoc = new QDockWidget(this);
36 aDoc->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
37 aDoc->setWindowTitle(tr("OBJECT_BROWSER_TITLE"));
39 myObjectBrowser = new XGUI_ObjectsBrowser(aDoc);
40 //myObjectBrowser->setColumnCount(1);
41 //myObjectBrowser->setHeaderHidden(true);
42 aDoc->setWidget(myObjectBrowser);
43 addDockWidget(Qt::LeftDockWidgetArea, aDoc);
46 QMdiArea* aMdiArea = new QMdiArea(this);
47 setCentralWidget(aMdiArea);
49 myViewer = new XGUI_Viewer(this);
51 //fillObjectBrowser();
55 XGUI_MainWindow::~XGUI_MainWindow(void)
59 //******************************************************
60 QMdiArea* XGUI_MainWindow::mdiArea() const
62 return static_cast<QMdiArea*>(centralWidget());
65 //******************************************************
66 void XGUI_MainWindow::showObjectBrowser()
68 myObjectBrowser->parentWidget()->show();
71 //******************************************************
72 void XGUI_MainWindow::hideObjectBrowser()
74 myObjectBrowser->parentWidget()->hide();
77 //******************************************************
78 void XGUI_MainWindow::showPythonConsole()
80 if (!myPythonConsole) {
82 QDockWidget* aDoc = new QDockWidget(this);
83 aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
84 aDoc->setMinimumHeight(0);
85 aDoc->setWindowTitle("Console");
86 myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
87 //myPythonConsole = new QTextEdit(aDoc);
88 //myPythonConsole->setGeometry(0,0,200, 50);
89 //myPythonConsole->setText(">>>");
90 aDoc->setWidget(myPythonConsole);
91 //myPythonConsole->setMinimumHeight(0);
92 addDockWidget(Qt::TopDockWidgetArea, aDoc);
93 tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
95 myPythonConsole->parentWidget()->show();
98 //******************************************************
99 void XGUI_MainWindow::hidePythonConsole()
102 myPythonConsole->parentWidget()->hide();
107 //******************************************************
111 //******************************************************
112 /*void XGUI_MainWindow::fillObjectBrowser()
115 aNames << "Parameters" << "Constructions";
116 aNames << "Part 1" << "Part 2" << "Part 3";
117 aNames << "Properties";
120 aIcons << ":pictures/params_folder.png";
121 aIcons << ":pictures/constr_folder.png";
122 aIcons << ":pictures/part_ico.png";
123 aIcons << ":pictures/part_ico.png";
124 aIcons << ":pictures/part_ico.png";
125 aIcons << ":pictures/properties.png";
127 QList<QTreeWidgetItem*> aItems;
128 foreach(QString aName, aNames)
130 QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
131 aItem->setText(0, aName);
132 aItems.append(aItem);
134 for(int i = 0; i < aItems.length(); i++) {
135 aItems[i]->setIcon(0, QIcon(aIcons[i]));
137 myObjectBrowser->addTopLevelItems(aItems);
139 for(int i = 2; i < 5; i++) {
140 QTreeWidgetItem* aItem = new QTreeWidgetItem(aItems[i]);
141 aItem->setText(0, "Parameters");
142 aItem->setIcon(0, QIcon(":pictures/params_folder.png"));
144 aItem = new QTreeWidgetItem(aItems[i]);
145 aItem->setText(0, "Construction");
146 aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
148 aItem = new QTreeWidgetItem(aItems[i]);
149 aItem->setText(0, "Bodies");
150 aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
152 aItem = new QTreeWidgetItem(aItems[i]);
153 aItem->setText(0, "Features");
154 aItem->setIcon(0, QIcon(":pictures/features.png"));
158 void XGUI_MainWindow::addPropertyPanel()
160 QDockWidget* aPropPanel = new QDockWidget(this);
161 aPropPanel->setWindowTitle("Point");
163 QWidget* aContent = new QWidget(aPropPanel);
164 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
165 aMainLay->setContentsMargins(3, 3, 3, 3);
166 aPropPanel->setWidget(aContent);
168 /*QWidget* aNameWgt = new QWidget(aContent);
169 QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
170 aNameLay->setContentsMargins(0,0,0,0);
171 aMainLay->addWidget(aNameWgt);
173 aNameLay->addWidget(new QLabel("Name", aNameWgt));
174 aNameLay->addWidget(new QLineEdit(aNameWgt));*/
176 QComboBox* aCombo = new QComboBox(aContent);
177 aCombo->addItem("By coordinates");
178 aMainLay->addWidget(aCombo);
180 QWidget* aGrpBox1 = new QWidget(aContent);
181 //aGrpBox1->setFlat(true);
182 QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
183 aFrmLay->setContentsMargins(0, 6, 0, 0);
184 aMainLay->addWidget(aGrpBox1);
186 QLabel* aLbl = new QLabel(aGrpBox1);
187 aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
188 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
190 aLbl = new QLabel(aGrpBox1);
191 aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
192 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
194 aLbl = new QLabel(aGrpBox1);
195 aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
196 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
198 /* aGrpBox1 = new QGroupBox("Normal vector", aContent);
199 aGrpBox1->setFlat(true);
200 aFrmLay = new QFormLayout(aGrpBox1);
201 aFrmLay->setContentsMargins(0, 6, 0, 0);
202 aMainLay->addWidget(aGrpBox1);
204 aLbl = new QLabel(aGrpBox1);
205 aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
206 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
208 aLbl = new QLabel(aGrpBox1);
209 aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
210 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
212 aLbl = new QLabel(aGrpBox1);
213 aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
214 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/
216 aMainLay->addStretch(1);
218 QFrame* aFrm = new QFrame(aContent);
219 aFrm->setFrameStyle(QFrame::Sunken);
220 aFrm->setFrameShape(QFrame::Panel);
221 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
222 aBtnLay->setContentsMargins(0, 0, 0, 0);
223 aMainLay->addWidget(aFrm);
225 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
227 aBtnLay->addWidget(aBtn);
228 aBtnLay->addStretch(1);
229 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
231 aBtnLay->addWidget(aBtn);
232 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
234 aBtnLay->addWidget(aBtn);
236 addDockWidget(Qt::RightDockWidgetArea, aPropPanel);