1 #include "XGUI_MainWindow.h"
2 #include "XGUI_Constants.h"
3 #include "XGUI_MainMenu.h"
4 #include "XGUI_ViewWindow.h"
5 #include "XGUI_Viewer.h"
6 #include "XGUI_ObjectsBrowser.h"
8 #include <PyConsole_Console.h>
9 #include <PyConsole_EnhInterp.h>
12 #include <QTreeWidget>
13 #include <QDockWidget>
17 #include <QToolButton>
18 #include <QTreeWidgetItem>
22 #include <QFormLayout>
23 #include <QDoubleSpinBox>
24 #include <QPushButton>
25 #include <QScrollArea>
29 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
30 : QMainWindow(parent),
33 myPropertyPanelDock(0)
35 setWindowTitle(tr("New Geom"));
36 myMenuBar = new XGUI_MainMenu(this);
38 QMdiArea* aMdiArea = new QMdiArea(this);
39 setCentralWidget(aMdiArea);
41 myViewer = new XGUI_Viewer(this);
43 //createDockWidgets();
46 XGUI_MainWindow::~XGUI_MainWindow(void)
50 //******************************************************
51 QMdiArea* XGUI_MainWindow::mdiArea() const
53 return static_cast<QMdiArea*>(centralWidget());
56 //******************************************************
57 void XGUI_MainWindow::showObjectBrowser()
59 myObjectBrowser->parentWidget()->show();
62 //******************************************************
63 void XGUI_MainWindow::hideObjectBrowser()
65 myObjectBrowser->parentWidget()->hide();
68 //******************************************************
69 void XGUI_MainWindow::showPythonConsole()
71 if (!myPythonConsole) {
73 QDockWidget* aDoc = new QDockWidget(this);
74 aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
75 aDoc->setMinimumHeight(0);
76 aDoc->setWindowTitle("Console");
77 myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
78 aDoc->setWidget(myPythonConsole);
79 addDockWidget(Qt::TopDockWidgetArea, aDoc);
80 tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
82 myPythonConsole->parentWidget()->show();
85 //******************************************************
86 void XGUI_MainWindow::hidePythonConsole()
89 myPythonConsole->parentWidget()->hide();
92 void XGUI_MainWindow::showPropertyPanel()
94 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
95 //<! Restore ability to close panel from the window's menu
96 aViewAct->setEnabled(true);
97 myPropertyPanelDock->show();
98 myPropertyPanelDock->raise();
101 void XGUI_MainWindow::hidePropertyPanel()
103 QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
104 //<! Do not allow to show empty property panel
105 aViewAct->setEnabled(false);
106 myPropertyPanelDock->hide();
110 * Creates dock widgets, places them in corresponding area
111 * and tabifies if necessary.
113 void XGUI_MainWindow::createDockWidgets()
115 QDockWidget* aObjDock = createObjectBrowser();
116 addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
117 myPropertyPanelDock = createPropertyPanel();
118 addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
119 hidePropertyPanel(); //<! Invisible by default
121 tabifyDockWidget(aObjDock, myPropertyPanelDock);
125 QDockWidget* XGUI_MainWindow::createPropertyPanel()
127 QDockWidget* aPropPanel = new QDockWidget(this);
128 aPropPanel->setWindowTitle(tr("Property Panel"));
129 aPropPanel->setObjectName(XGUI::PROP_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(XGUI::PROP_PANEL_WDG);
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(XGUI::PROP_PANEL_OK);
155 aBtnLay->addWidget(aBtn);
156 aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
157 aBtn->setObjectName(XGUI::PROP_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 aObjDock->setWidget(myObjectBrowser);