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("Property Panel");
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* aCustomWidget = new QWidget(aContent);
167 aCustomWidget->setObjectName("PropertyPanelWidget");
168 aMainLay->addWidget(aCustomWidget);
171 QWidget* aNameWgt = new QWidget(aContent);
172 QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
173 aNameLay->setContentsMargins(0,0,0,0);
174 aMainLay->addWidget(aNameWgt);
176 aNameLay->addWidget(new QLabel("Name", aNameWgt));
177 aNameLay->addWidget(new QLineEdit(aNameWgt));
180 /* Moved into PartSetModule by sbh
181 QComboBox* aCombo = new QComboBox(aContent);
182 aCombo->addItem("By coordinates");
183 aMainLay->addWidget(aCombo);
185 QWidget* aGrpBox1 = new QWidget(aContent);
186 QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
187 aFrmLay->setContentsMargins(0, 6, 0, 0);
188 aMainLay->addWidget(aGrpBox1);
190 QLabel* aLbl = new QLabel(aGrpBox1);
191 aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
192 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
194 aLbl = new QLabel(aGrpBox1);
195 aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
196 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
198 aLbl = new QLabel(aGrpBox1);
199 aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
200 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
204 aGrpBox1 = new QGroupBox("Normal vector", aContent);
205 aGrpBox1->setFlat(true);
206 aFrmLay = new QFormLayout(aGrpBox1);
207 aFrmLay->setContentsMargins(0, 6, 0, 0);
208 aMainLay->addWidget(aGrpBox1);
210 aLbl = new QLabel(aGrpBox1);
211 aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
212 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
214 aLbl = new QLabel(aGrpBox1);
215 aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
216 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
218 aLbl = new QLabel(aGrpBox1);
219 aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
220 aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
223 aMainLay->addStretch(1);
225 QFrame* aFrm = new QFrame(aContent);
226 aFrm->setFrameStyle(QFrame::Sunken);
227 aFrm->setFrameShape(QFrame::Panel);
228 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
229 aBtnLay->setContentsMargins(0, 0, 0, 0);
230 aMainLay->addWidget(aFrm);
232 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
234 aBtnLay->addWidget(aBtn);
235 aBtnLay->addStretch(1);
236 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
238 aBtnLay->addWidget(aBtn);
239 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
241 aBtnLay->addWidget(aBtn);
243 addDockWidget(Qt::RightDockWidgetArea, aPropPanel);