]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_MainWindow.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_MainWindow.cpp
1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4 #include "XGUI_Viewer.h"
5
6 #include <PyConsole_Console.h>
7 #include <PyConsole_EnhInterp.h>
8
9 #include <QMdiArea>
10 #include <QTreeWidget>
11 #include <QDockWidget>
12 #include <QTextEdit>
13 #include <QLabel>
14 #include <QToolBar>
15 #include <QToolButton>
16 #include <QTreeWidgetItem>
17 #include <QLayout>
18 #include <QLineEdit>
19 #include <QGroupBox>
20 #include <QFormLayout>
21 #include <QDoubleSpinBox>
22 #include <QPushButton>
23 #include <QScrollArea>
24 #include <QComboBox>
25
26 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
27     : QMainWindow(parent), 
28     myObjectBrowser(0), 
29     myPythonConsole(0)
30 {
31   setWindowTitle(tr("WINDOW_TITLE"));
32   myMenuBar = new XGUI_MainMenu(this);
33
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);
42   //aDoc->hide();
43
44   QMdiArea* aMdiArea = new QMdiArea(this);
45   setCentralWidget(aMdiArea);
46
47   myViewer = new XGUI_Viewer(this);
48
49   //fillObjectBrowser();
50   //addPropertyPanel();
51 }
52
53 XGUI_MainWindow::~XGUI_MainWindow(void)
54 {
55 }
56
57 //******************************************************
58 QMdiArea* XGUI_MainWindow::mdiArea() const
59 {
60   return static_cast<QMdiArea*>(centralWidget());
61 }
62
63 //******************************************************
64 void XGUI_MainWindow::showObjectBrowser()
65 {
66   myObjectBrowser->parentWidget()->show();
67 }
68
69 //******************************************************
70 void XGUI_MainWindow::hideObjectBrowser()
71 {
72   myObjectBrowser->parentWidget()->hide();
73 }
74
75 //******************************************************
76 void XGUI_MainWindow::showPythonConsole()
77 {
78   if (!myPythonConsole) {
79
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);
92   }
93   myPythonConsole->parentWidget()->show();
94 }
95
96 //******************************************************
97 void XGUI_MainWindow::hidePythonConsole()
98 {
99   if (myPythonConsole)
100     myPythonConsole->parentWidget()->hide();
101 }
102
103
104
105 //******************************************************
106
107 // TEST FUNCTIONS
108
109 //******************************************************
110 void XGUI_MainWindow::fillObjectBrowser()
111 {
112   QStringList aNames;
113   aNames << "Parameters" << "Constructions";
114   aNames << "Part 1" << "Part 2" << "Part 3";
115   aNames << "Properties";
116
117   QStringList aIcons;
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";
124
125   QList<QTreeWidgetItem*> aItems;
126   foreach(QString aName, aNames)
127   {
128     QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
129     aItem->setText(0, aName);
130     aItems.append(aItem);
131   }
132   for(int i = 0; i < aItems.length(); i++) {
133     aItems[i]->setIcon(0, QIcon(aIcons[i]));
134   }
135   myObjectBrowser->addTopLevelItems(aItems);
136
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"));
141
142     aItem = new QTreeWidgetItem(aItems[i]);
143     aItem->setText(0, "Construction");
144     aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
145
146     aItem = new QTreeWidgetItem(aItems[i]);
147     aItem->setText(0, "Bodies");
148     aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
149
150     aItem = new QTreeWidgetItem(aItems[i]);
151     aItem->setText(0, "Features");
152     aItem->setIcon(0, QIcon(":pictures/features.png"));
153   }
154 }
155
156 void XGUI_MainWindow::addPropertyPanel()
157 {
158   QDockWidget* aPropPanel = new QDockWidget(this);
159   aPropPanel->setWindowTitle("Property Panel");
160
161   QWidget* aContent = new QWidget(aPropPanel);
162   QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
163   aMainLay->setContentsMargins(3, 3, 3, 3);
164   aPropPanel->setWidget(aContent);
165
166   QWidget* aCustomWidget = new QWidget(aContent);
167   aCustomWidget->setObjectName("PropertyPanelWidget");
168   aMainLay->addWidget(aCustomWidget);
169
170   /*
171   QWidget* aNameWgt = new QWidget(aContent);
172   QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
173   aNameLay->setContentsMargins(0,0,0,0);
174   aMainLay->addWidget(aNameWgt);
175
176   aNameLay->addWidget(new QLabel("Name", aNameWgt));
177   aNameLay->addWidget(new QLineEdit(aNameWgt));
178   */
179
180 /* Moved into PartSetModule by sbh
181   QComboBox* aCombo = new QComboBox(aContent);
182   aCombo->addItem("By coordinates");
183   aMainLay->addWidget(aCombo);
184
185   QWidget* aGrpBox1 = new QWidget(aContent);
186   QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
187   aFrmLay->setContentsMargins(0, 6, 0, 0);
188   aMainLay->addWidget(aGrpBox1);
189
190   QLabel* aLbl = new QLabel(aGrpBox1);
191   aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
192   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
193
194   aLbl = new QLabel(aGrpBox1);
195   aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
196   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
197
198   aLbl = new QLabel(aGrpBox1);
199   aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
200   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
201   */
202
203   /*
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);
209
210   aLbl = new QLabel(aGrpBox1);
211   aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
212   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
213
214   aLbl = new QLabel(aGrpBox1);
215   aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
216   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
217
218   aLbl = new QLabel(aGrpBox1);
219   aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
220   aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
221   */
222
223   aMainLay->addStretch(1);
224
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);
231
232   QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
233   aBtn->setFlat(true);
234   aBtnLay->addWidget(aBtn);
235   aBtnLay->addStretch(1);
236   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
237   aBtn->setFlat(true);
238   aBtnLay->addWidget(aBtn);
239   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
240   aBtn->setFlat(true);
241   aBtnLay->addWidget(aBtn);
242
243   addDockWidget(Qt::RightDockWidgetArea, aPropPanel);
244 }