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>
28 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
29 : QMainWindow(parent),
30 myObjectBrowser(NULL),
31 myPythonConsole(NULL),
32 myPropertyPanelDock(NULL)
34 setWindowTitle(tr("New Geom"));
35 myMenuBar = new XGUI_MainMenu(this);
37 QMdiArea* aMdiArea = new QMdiArea(this);
38 setCentralWidget(aMdiArea);
40 myViewer = new XGUI_Viewer(this);
45 XGUI_MainWindow::~XGUI_MainWindow(void)
49 //******************************************************
50 QMdiArea* XGUI_MainWindow::mdiArea() const
52 return static_cast<QMdiArea*>(centralWidget());
55 //******************************************************
56 void XGUI_MainWindow::showObjectBrowser()
58 myObjectBrowser->parentWidget()->show();
61 //******************************************************
62 void XGUI_MainWindow::hideObjectBrowser()
64 myObjectBrowser->parentWidget()->hide();
67 //******************************************************
68 void XGUI_MainWindow::showPythonConsole()
70 if (!myPythonConsole) {
72 QDockWidget* aDoc = new QDockWidget(this);
73 aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
74 aDoc->setMinimumHeight(0);
75 aDoc->setWindowTitle("Console");
76 myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
77 //myPythonConsole = new QTextEdit(aDoc);
78 //myPythonConsole->setGeometry(0,0,200, 50);
79 //myPythonConsole->setText(">>>");
80 aDoc->setWidget(myPythonConsole);
81 //myPythonConsole->setMinimumHeight(0);
82 addDockWidget(Qt::TopDockWidgetArea, aDoc);
83 tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
85 myPythonConsole->parentWidget()->show();
88 //******************************************************
89 void XGUI_MainWindow::hidePythonConsole()
92 myPythonConsole->parentWidget()->hide();
95 void XGUI_MainWindow::showPropertyPanel()
97 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
98 aViewAct->setEnabled(true);
99 myPropertyPanelDock->show();
100 myPropertyPanelDock->raise();
103 void XGUI_MainWindow::hidePropertyPanel()
105 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
106 aViewAct->setEnabled(false);
107 myPropertyPanelDock->hide();
111 * Creates dock widgets, places them in corresponding area
112 * and tabifies if necessary.
114 void XGUI_MainWindow::createDockWidgets()
116 QDockWidget* aObjDock = createObjectBrowser();
117 addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
118 myPropertyPanelDock = createPropertyPanel();
119 addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
120 hidePropertyPanel(); //<! Invisible by default
122 tabifyDockWidget(aObjDock, myPropertyPanelDock);
126 QDockWidget* XGUI_MainWindow::createPropertyPanel()
128 QDockWidget* aPropPanel = new QDockWidget(this);
129 aPropPanel->setWindowTitle(tr("Property Panel"));
131 QWidget* aContent = new QWidget(aPropPanel);
132 QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
133 aMainLay->setContentsMargins(3, 3, 3, 3);
134 aPropPanel->setWidget(aContent);
136 QWidget* aCustomWidget = new QWidget(aContent);
137 aCustomWidget->setObjectName("property_panel_widget");
138 aMainLay->addWidget(aCustomWidget);
139 aMainLay->addStretch(1);
141 QFrame* aFrm = new QFrame(aContent);
142 aFrm->setFrameStyle(QFrame::Sunken);
143 aFrm->setFrameShape(QFrame::Panel);
144 QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
145 aBtnLay->setContentsMargins(0, 0, 0, 0);
146 aMainLay->addWidget(aFrm);
148 QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
150 aBtnLay->addWidget(aBtn);
151 aBtnLay->addStretch(1);
152 aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
153 aBtn->setObjectName("property_panel_ok");
155 aBtnLay->addWidget(aBtn);
156 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
157 aBtn->setObjectName("property_panel_cancel");
159 aBtnLay->addWidget(aBtn);
164 QDockWidget* XGUI_MainWindow::createObjectBrowser()
166 QDockWidget* aObjDock = new QDockWidget(this);
167 aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
168 aObjDock->setWindowTitle(tr("Object browser"));
169 myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
170 //myObjectBrowser->setColumnCount(1);
171 //myObjectBrowser->setHeaderHidden(true);
172 aObjDock->setWidget(myObjectBrowser);
173 // fillObjectBrowser();