]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_MainWindow.cpp
Salome HOME
Management of sub window in MDI area added
[modules/shaper.git] / src / XGUI / XGUI_MainWindow.cpp
1 #include "XGUI_MainWindow.h"
2 #include "XGUI_MainMenu.h"
3 #include "XGUI_ViewWindow.h"
4
5 #include <QMdiArea>
6 #include <QTreeWidget>
7 #include <QDockWidget>
8 #include <QTextEdit>
9 #include <QLabel>
10 #include <QToolBar>
11 #include <QToolButton>
12 #include <QTreeWidgetItem>
13 #include <QLayout>
14 #include <QLineEdit>
15 #include <QGroupBox>
16 #include <QFormLayout>
17 #include <QDoubleSpinBox>
18 #include <QPushButton>
19 #include <QScrollArea>
20 #include <QComboBox>
21
22 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) :
23     QMainWindow(parent), myObjectBrowser(0)
24 {
25     myMenuBar = new XGUI_MainMenu(this);
26
27     QDockWidget* aDoc = new QDockWidget(this);
28     aDoc->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
29     aDoc->setWindowTitle(tr("OBJECT_BROWSER_TITLE"));
30     myObjectBrowser = new QTreeWidget(aDoc);
31     myObjectBrowser->setColumnCount(1);
32     myObjectBrowser->setHeaderHidden(true);
33     aDoc->setWidget(myObjectBrowser);
34     addDockWidget(Qt::LeftDockWidgetArea, aDoc);
35     //aDoc->hide();
36
37     aDoc = new QDockWidget(this);
38     aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
39     aDoc->setMinimumHeight(0);
40     aDoc->setWindowTitle("Console");
41     QTextEdit* aTextEdt = new QTextEdit(aDoc);
42     aTextEdt->setText(">>>");
43     aDoc->setWidget(aTextEdt);
44     aTextEdt->setMinimumHeight(0);
45     addDockWidget(Qt::BottomDockWidgetArea, aDoc);
46
47     QMdiArea* aMdiArea = new QMdiArea(this);
48     setCentralWidget(aMdiArea);
49
50     aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
51     aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint);
52
53     fillObjectBrowser();
54     addPropertyPanel();
55 }
56
57 XGUI_MainWindow::~XGUI_MainWindow(void)
58 {
59 }
60
61 //******************************************************
62 void XGUI_MainWindow::showObjectBrowser()
63 {
64     myObjectBrowser->parentWidget()->show();
65 }
66
67 //******************************************************
68 void XGUI_MainWindow::hideObjectBrowser()
69 {
70     myObjectBrowser->parentWidget()->hide();
71 }
72
73 //******************************************************
74 void XGUI_MainWindow::fillObjectBrowser()
75 {
76     QStringList aNames;
77     aNames << "Parameters" << "Constructions";
78     aNames << "Part 1" << "Part 2" << "Part 3";
79     aNames << "Properties";
80
81     QStringList aIcons;
82     aIcons << ":pictures/params_folder.png";
83     aIcons << ":pictures/constr_folder.png";
84     aIcons << ":pictures/part_ico.png";
85     aIcons << ":pictures/part_ico.png";
86     aIcons << ":pictures/part_ico.png";
87     aIcons << ":pictures/properties.png";
88
89     QList<QTreeWidgetItem*> aItems;
90     foreach(QString aName, aNames) {
91         QTreeWidgetItem* aItem = new QTreeWidgetItem(myObjectBrowser);
92         aItem->setText(0, aName);
93         aItems.append(aItem);
94     }
95     for(int i = 0; i < aItems.length(); i++) {
96         aItems[i]->setIcon(0, QIcon(aIcons[i]));
97     }
98     myObjectBrowser->addTopLevelItems(aItems);
99
100     for (int i = 2; i < 5; i++) {
101         QTreeWidgetItem* aItem = new QTreeWidgetItem(aItems[i]);
102         aItem->setText(0, "Parameters");
103         aItem->setIcon(0, QIcon(":pictures/params_folder.png"));
104
105         aItem = new QTreeWidgetItem(aItems[i]);
106         aItem->setText(0, "Construction");
107         aItem->setIcon(0, QIcon(":pictures/constr_folder.png"));
108
109         aItem = new QTreeWidgetItem(aItems[i]);
110         aItem->setText(0, "Bodies");
111         aItem->setIcon(0, QIcon(":pictures/part_ico.png"));
112
113         aItem = new QTreeWidgetItem(aItems[i]);
114         aItem->setText(0, "Features");
115         aItem->setIcon(0, QIcon(":pictures/features.png"));
116     }
117 }
118
119
120 void XGUI_MainWindow::addPropertyPanel()
121 {
122     QDockWidget* aPropPanel = new QDockWidget(this);
123     aPropPanel->setWindowTitle("Point");
124
125     QWidget* aContent = new QWidget(aPropPanel);
126     QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
127     aMainLay->setContentsMargins(3,3,3,3);
128     aPropPanel->setWidget(aContent);
129
130     /*QWidget* aNameWgt = new QWidget(aContent);
131     QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt);
132     aNameLay->setContentsMargins(0,0,0,0);
133     aMainLay->addWidget(aNameWgt);
134
135     aNameLay->addWidget(new QLabel("Name", aNameWgt));
136     aNameLay->addWidget(new QLineEdit(aNameWgt));*/
137
138     QComboBox* aCombo = new QComboBox(aContent);
139     aCombo->addItem("By coordinates");
140     aMainLay->addWidget(aCombo);
141
142     QWidget* aGrpBox1 = new QWidget(aContent);
143     //aGrpBox1->setFlat(true);
144     QFormLayout* aFrmLay = new QFormLayout(aGrpBox1);
145     aFrmLay->setContentsMargins(0, 6, 0, 0);
146     aMainLay->addWidget(aGrpBox1);
147
148
149     QLabel* aLbl = new QLabel(aGrpBox1);
150     aLbl->setPixmap(QPixmap(":pictures/x_point.png"));
151     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
152
153     aLbl = new QLabel(aGrpBox1);
154     aLbl->setPixmap(QPixmap(":pictures/y_point.png"));
155     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
156
157     aLbl = new QLabel(aGrpBox1);
158     aLbl->setPixmap(QPixmap(":pictures/z_point.png"));
159     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
160     
161
162 /*    aGrpBox1 = new QGroupBox("Normal vector", aContent);
163     aGrpBox1->setFlat(true);
164     aFrmLay = new QFormLayout(aGrpBox1);
165     aFrmLay->setContentsMargins(0, 6, 0, 0);
166     aMainLay->addWidget(aGrpBox1);
167
168     aLbl = new QLabel(aGrpBox1);
169     aLbl->setPixmap(QPixmap(":pictures/x_size.png"));
170     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
171
172     aLbl = new QLabel(aGrpBox1);
173     aLbl->setPixmap(QPixmap(":pictures/y_size.png"));
174     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));
175
176     aLbl = new QLabel(aGrpBox1);
177     aLbl->setPixmap(QPixmap(":pictures/z_size.png"));
178     aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/
179     
180     aMainLay->addStretch(1);
181
182     QFrame* aFrm = new QFrame(aContent);
183     aFrm->setFrameStyle(QFrame::Sunken);
184     aFrm->setFrameShape(QFrame::Panel);
185     QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
186     aBtnLay->setContentsMargins(0, 0, 0, 0);
187     aMainLay->addWidget(aFrm);
188
189     QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
190     aBtn->setFlat(true);
191     aBtnLay->addWidget(aBtn);
192     aBtnLay->addStretch(1);
193     aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
194     aBtn->setFlat(true);
195     aBtnLay->addWidget(aBtn);
196     aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
197     aBtn->setFlat(true);
198     aBtnLay->addWidget(aBtn);
199
200     addDockWidget(Qt::RightDockWidgetArea, aPropPanel);
201 }