From d7838f22206b74391743d67a0af723196f55213f Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 14 Mar 2014 16:22:47 +0400 Subject: [PATCH] Management of sub window --- src/GeomModule/GeomModule.cpp | 7 +- src/XGUI/CMakeLists.txt | 2 + src/XGUI/XGUI_MainWindow.cpp | 75 +++++-------------- src/XGUI/XGUI_MainWindow.h | 2 +- src/XGUI/XGUI_ViewWindow.cpp | 137 ++++++++++++++++++++++++++++++++++ src/XGUI/XGUI_ViewWindow.h | 36 +++++++++ src/XGUI/XGUI_Workshop.cpp | 35 ++++----- src/XGUI/XGUI_msg_en.ts | 4 +- 8 files changed, 216 insertions(+), 82 deletions(-) create mode 100644 src/XGUI/XGUI_ViewWindow.cpp create mode 100644 src/XGUI/XGUI_ViewWindow.h diff --git a/src/GeomModule/GeomModule.cpp b/src/GeomModule/GeomModule.cpp index 5bac10336..6bddce9b1 100644 --- a/src/GeomModule/GeomModule.cpp +++ b/src/GeomModule/GeomModule.cpp @@ -25,7 +25,7 @@ GeomModule::~GeomModule() void GeomModule::createFeatures() { - IWorkbench* aPage = myWorkshop->addWorkbench("Primitives"); + IWorkbench* aPage = myWorkshop->addWorkbench("Home"); IMenuGroup* aGroup = aPage->addGroup(); IFeatureMenu* aCommand = aGroup->addFeature("new_part", "Part", "Creates a new part", QIcon(":pictures/part_ico.png")); @@ -41,11 +41,14 @@ void GeomModule::createFeatures() aGroup = aPage->addGroup(); aCommand = aGroup->addFeature("extrusion", "Extrusion", "Make extrusion", QIcon(":icons/extrusion.png")); + aCommand = aGroup->addFeature("revolution", "Revolution", "Make revolution", QIcon(":icons/revol.png")); aCommand = aGroup->addFeature("cut", "Cut", "Make cut", QIcon(":icons/cut.png")); aCommand = aGroup->addFeature("fusion", "Fusion", "Make fusion", QIcon(":icons/fusion.png")); - aCommand = aGroup->addFeature("revolution", "Revolution", "Make revolution", QIcon(":icons/revol.png")); aCommand = aGroup->addFeature("common", "Common", "Make common", QIcon(":icons/common.png")); //aGroup = aPage->addGroup(); aCommand = aGroup->addFeature("import", "Import", "Make import", QIcon(":icons/import.png")); + + aPage = myWorkshop->addWorkbench("Sketch"); + aPage = myWorkshop->addWorkbench("Properties"); } \ No newline at end of file diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index edc7d7e25..e4521a148 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -11,6 +11,7 @@ SET(PROJECT_HEADERS XGUI_Tools.h XGUI_Workbench.h XGUI_Workshop.h + XGUI_ViewWindow.h ) SET(PROJECT_AUTOMOC @@ -26,6 +27,7 @@ SET(PROJECT_SOURCES XGUI_Tools.cpp XGUI_Workbench.cpp XGUI_Workshop.cpp + XGUI_ViewWindow.cpp ) SET(PROJECT_RESOURCES diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index f5c82a4bc..2a88182d2 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -1,15 +1,14 @@ #include "XGUI_MainWindow.h" #include "XGUI_MainMenu.h" +#include "XGUI_ViewWindow.h" #include #include #include #include -#include #include #include #include -#include #include #include #include @@ -18,11 +17,11 @@ #include #include #include +#include XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : QMainWindow(parent), myObjectBrowser(0) { - //menuBar(); myMenuBar = new XGUI_MainMenu(this); QDockWidget* aDoc = new QDockWidget(this); @@ -48,57 +47,12 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : QMdiArea* aMdiArea = new QMdiArea(this); setCentralWidget(aMdiArea); - aMdiArea->addSubWindow(getSubWindow(), Qt::FramelessWindowHint); + aMdiArea->addSubWindow(new XGUI_ViewWindow(), Qt::FramelessWindowHint); fillObjectBrowser(); addPropertyPanel(); } - -QWidget* XGUI_MainWindow::getSubWindow() -{ - QMdiSubWindow* aSub = new QMdiSubWindow(this); - QLabel* aLbl = new QLabel(aSub); - aLbl->setFrameStyle(QFrame::Sunken); - aLbl->setFrameShape(QFrame::Panel); - aLbl->setPixmap(QPixmap(":pictures/ViewPort.png")); - aLbl->setScaledContents(true); - aSub->setWidget(aLbl); - - QStringList aPictures; - aPictures<<":pictures/occ_view_camera_dump.png"<<":pictures/occ_view_style_switch.png"; - aPictures<<":pictures/occ_view_triedre.png"<<":pictures/occ_view_fitall.png"; - aPictures<<":pictures/occ_view_fitarea.png"<<":pictures/occ_view_zoom.png"; - aPictures<<":pictures/occ_view_pan.png"<<":pictures/occ_view_glpan.png"; - aPictures<<":pictures/occ_view_rotate.png"<<":pictures/occ_view_front.png"; - aPictures<<":pictures/occ_view_back.png"<<":pictures/occ_view_left.png"; - aPictures<<":pictures/occ_view_right.png"<<":pictures/occ_view_top.png"; - aPictures<<":pictures/occ_view_bottom.png"<<":pictures/occ_view_clone.png"; - - QToolBar* aBar = new QToolBar(aSub); - aBar->setGeometry(0,0,500,30); - - QAction* aBtn; - foreach(QString aName, aPictures) { - aBtn = new QAction(aBar); - aBtn->setIcon(QIcon(aName)); - aBar->addAction(aBtn); - } - - aBar = new QToolBar(aSub); - aBar->setGeometry(615,0,100,25); - QStringList aWndIcons; - aWndIcons<<":pictures/wnd_minimize.png"<<":pictures/wnd_maximize.png"<<":pictures/wnd_close.png"; - foreach(QString aName, aWndIcons) { - aBtn = new QAction(aBar); - aBtn->setIcon(QIcon(aName)); - aBar->addAction(aBtn); - } - - return aSub; -} - - XGUI_MainWindow::~XGUI_MainWindow(void) { } @@ -165,27 +119,32 @@ void XGUI_MainWindow::fillObjectBrowser() void XGUI_MainWindow::addPropertyPanel() { QDockWidget* aPropPanel = new QDockWidget(this); - aPropPanel->setWindowTitle("Property panel"); + aPropPanel->setWindowTitle("Point"); QWidget* aContent = new QWidget(aPropPanel); QVBoxLayout* aMainLay = new QVBoxLayout(aContent); aMainLay->setContentsMargins(3,3,3,3); aPropPanel->setWidget(aContent); - QWidget* aNameWgt = new QWidget(aContent); + /*QWidget* aNameWgt = new QWidget(aContent); QHBoxLayout* aNameLay = new QHBoxLayout(aNameWgt); aNameLay->setContentsMargins(0,0,0,0); aMainLay->addWidget(aNameWgt); aNameLay->addWidget(new QLabel("Name", aNameWgt)); - aNameLay->addWidget(new QLineEdit(aNameWgt)); + aNameLay->addWidget(new QLineEdit(aNameWgt));*/ - QGroupBox* aGrpBox1 = new QGroupBox("Point", aContent); - aGrpBox1->setFlat(true); + QComboBox* aCombo = new QComboBox(aContent); + aCombo->addItem("By coordinates"); + aMainLay->addWidget(aCombo); + + QWidget* aGrpBox1 = new QWidget(aContent); + //aGrpBox1->setFlat(true); QFormLayout* aFrmLay = new QFormLayout(aGrpBox1); aFrmLay->setContentsMargins(0, 6, 0, 0); aMainLay->addWidget(aGrpBox1); + QLabel* aLbl = new QLabel(aGrpBox1); aLbl->setPixmap(QPixmap(":pictures/x_point.png")); aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1)); @@ -199,7 +158,7 @@ void XGUI_MainWindow::addPropertyPanel() aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1)); - aGrpBox1 = new QGroupBox("Normal vector", aContent); +/* aGrpBox1 = new QGroupBox("Normal vector", aContent); aGrpBox1->setFlat(true); aFrmLay = new QFormLayout(aGrpBox1); aFrmLay->setContentsMargins(0, 6, 0, 0); @@ -215,7 +174,7 @@ void XGUI_MainWindow::addPropertyPanel() aLbl = new QLabel(aGrpBox1); aLbl->setPixmap(QPixmap(":pictures/z_size.png")); - aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1)); + aFrmLay->addRow(aLbl, new QDoubleSpinBox(aGrpBox1));*/ aMainLay->addStretch(1); @@ -230,10 +189,10 @@ void XGUI_MainWindow::addPropertyPanel() aBtn->setFlat(true); aBtnLay->addWidget(aBtn); aBtnLay->addStretch(1); - aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm); + aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm); aBtn->setFlat(true); aBtnLay->addWidget(aBtn); - aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm); + aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm); aBtn->setFlat(true); aBtnLay->addWidget(aBtn); diff --git a/src/XGUI/XGUI_MainWindow.h b/src/XGUI/XGUI_MainWindow.h index d6590d44a..dc9e34fee 100644 --- a/src/XGUI/XGUI_MainWindow.h +++ b/src/XGUI/XGUI_MainWindow.h @@ -22,7 +22,7 @@ public: private: //!! For test purposes only - QWidget* getSubWindow(); + //QWidget* getSubWindow(); void fillObjectBrowser(); void addPropertyPanel(); diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp new file mode 100644 index 000000000..2ca380116 --- /dev/null +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -0,0 +1,137 @@ +#include "XGUI_ViewWindow.h" + + +#include +#include +#include +#include +#include +#include + +#define BORDER_SIZE 2 + +XGUI_ViewWindow::XGUI_ViewWindow() +{ + setMouseTracking(true); + QVBoxLayout* aLay = new QVBoxLayout(this); + aLay->setContentsMargins(BORDER_SIZE,BORDER_SIZE,BORDER_SIZE,BORDER_SIZE); + myViewPort = new QLabel(this); + aLay->addWidget(myViewPort); + myViewPort->setFrameStyle(QFrame::Raised); + myViewPort->setCursor(Qt::ArrowCursor); + myViewPort->setFrameShape(QFrame::Panel); + myViewPort->setPixmap(QPixmap(":pictures/ViewPort.png")); + myViewPort->setScaledContents(true); + + myPicture = new QLabel(this); + aLay->addWidget(myPicture); + myPicture->hide(); + + QStringList aPictures; + aPictures<<":pictures/occ_view_camera_dump.png"<<":pictures/occ_view_style_switch.png"; + aPictures<<":pictures/occ_view_triedre.png"<<":pictures/occ_view_fitall.png"; + aPictures<<":pictures/occ_view_fitarea.png"<<":pictures/occ_view_zoom.png"; + aPictures<<":pictures/occ_view_pan.png"<<":pictures/occ_view_glpan.png"; + aPictures<<":pictures/occ_view_rotate.png"<<":pictures/occ_view_front.png"; + aPictures<<":pictures/occ_view_back.png"<<":pictures/occ_view_left.png"; + aPictures<<":pictures/occ_view_right.png"<<":pictures/occ_view_top.png"; + aPictures<<":pictures/occ_view_bottom.png"<<":pictures/occ_view_clone.png"; + + QStringList aTitles; + aTitles << "Dump view" << "Mouse style switch" << "Show trihedron" << "Fit all"; + aTitles << "Fit area" << "Zoom" << "Panning" << "Global panning" << "Rotate"; + aTitles << "Front" << "Back" << "Left" << "Right" << "Top" << "Bottom" << "Clone view"; + + aViewBar = new QToolBar(this); + //aViewBar->move(BORDER_SIZE, BORDER_SIZE); + + QAction* aBtn; + for (int i = 0; i < aTitles.length(); i++) { + aBtn = new QAction(QIcon(aPictures.at(i)), aTitles.at(i), aViewBar); + aViewBar->addAction(aBtn); + } + + aWindowBar = new QToolBar(this); + //aWindowBar->move(615,0); + + aBtn = new QAction(aWindowBar); + aBtn->setIcon(QIcon(":pictures/wnd_minimize.png")); + aWindowBar->addAction(aBtn); + connect(aBtn, SIGNAL(triggered()), SLOT(onMinimize())); + connect(aBtn, SIGNAL(triggered()), SLOT(showMinimized())); + + aBtn = new QAction(aWindowBar); + aBtn->setIcon(QIcon(":pictures/wnd_maximize.png")); + aWindowBar->addAction(aBtn); + connect(aBtn, SIGNAL(triggered()), SLOT(showMaximized())); + + aBtn = new QAction(aWindowBar); + aBtn->setIcon(QIcon(":pictures/wnd_close.png")); + aWindowBar->addAction(aBtn); + connect(aBtn, SIGNAL(triggered()), SLOT(onClose())); + + aViewBar->hide(); + aWindowBar->hide(); +} + + +XGUI_ViewWindow::~XGUI_ViewWindow() +{ +} + + +void XGUI_ViewWindow::resizeEvent(QResizeEvent* theEvent) +{ + QSize aSize = theEvent->size(); + QSize aWndBarSize = aWindowBar->sizeHint(); + QSize aViewBarSize = aViewBar->sizeHint(); + + aWindowBar->move(aSize.width() - aWndBarSize.width() - BORDER_SIZE, BORDER_SIZE); + aViewBar->setGeometry(BORDER_SIZE, BORDER_SIZE, aSize.width() - aWndBarSize.width(), aViewBarSize.height()); +} + + +void XGUI_ViewWindow::changeEvent(QEvent* theEvent) +{ + + if (theEvent->type() == QEvent::WindowStateChange) { + if (isMinimized()) { + parentWidget()->setGeometry(0, 0, 110, 80); + myViewPort->hide(); + aViewBar->hide(); + aWindowBar->hide(); + myPicture->show(); + } else { + myViewPort->show(); + myPicture->hide(); + } + } else + QWidget::changeEvent(theEvent); +} + +void XGUI_ViewWindow::onClose() +{ + if (parentWidget()) + parentWidget()->close(); + +} + +void XGUI_ViewWindow::enterEvent(QEvent* theEvent) +{ + if (!isMinimized()) + aViewBar->show(); + aWindowBar->show(); +} + +void XGUI_ViewWindow::leaveEvent(QEvent* theEvent) +{ + aViewBar->hide(); + aWindowBar->hide(); +} + + +void XGUI_ViewWindow::onMinimize() +{ + QPixmap aPMap = grab(); + myPicture->setPixmap(aPMap.scaled(110, 80)); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h new file mode 100644 index 000000000..e4daab713 --- /dev/null +++ b/src/XGUI/XGUI_ViewWindow.h @@ -0,0 +1,36 @@ +#ifndef XGUI_ViewWindow_H +#define XGUI_ViewWindow_H + +#include + +class QLabel; +class QToolBar; + +class XGUI_ViewWindow : public QWidget +{ + Q_OBJECT +public: + XGUI_ViewWindow(); + virtual ~XGUI_ViewWindow(); + +protected: + virtual void resizeEvent(QResizeEvent* theEvent); + + virtual void changeEvent(QEvent* theEvent); + + virtual void enterEvent(QEvent* theEvent); + virtual void leaveEvent(QEvent* theEvent); + +private slots: + void onClose(); + void onMinimize(); + +private: + + QLabel* myPicture; + QLabel* myViewPort; + QToolBar* aViewBar; + QToolBar* aWindowBar; +}; + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 191e960a0..b7db81cb1 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -37,34 +37,17 @@ void XGUI_Workshop::startApplication() //****************************************************** void XGUI_Workshop::initMenu() { - IWorkbench* aPage = addWorkbench(tr("HOME_MENU_TITLE")); + IWorkbench* aPage = addWorkbench(tr("GEN_MENU_TITLE")); // File commands group IMenuGroup* aGroup = aPage->addGroup(); IFeatureMenu* aCommand; - aCommand = aGroup->addFeature("NEW_CMD", tr("NEW_MENU"), tr("NEW_MENU_TIP"), - QIcon(":pictures/new.png"), QKeySequence::New); - aCommand->connectTo(this, SLOT(onNew())); - - aCommand = aGroup->addFeature("OPEN_CMD", tr("OPEN_MENU"), tr("OPEN_MENU_TIP"), - QIcon(":pictures/open.png"), QKeySequence::Open); - aCommand->connectTo(this, SLOT(onOpen())); - aCommand = aGroup->addFeature("SAVE_CMD", tr("SAVE_MENU"), tr("SAVE_MENU_TIP"), QIcon(":pictures/save.png"), QKeySequence::Save); aCommand->connectTo(this, SLOT(onSave())); - aCommand->disable(); - - - aCommand = aGroup->addFeature("SAVEAS_CMD", tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"), - QIcon(":pictures/save.png")); - aCommand->connectTo(this, SLOT(onSaveAs())); - aCommand->disable(); - - // Edit commands group - //aGroup = aPage->addGroup(); + //aCommand->disable(); aCommand = aGroup->addFeature("UNDO_CMD", tr("UNDO_MENU"), tr("UNDO_MENU_TIP"), QIcon(":pictures/undo.png"), QKeySequence::Undo); @@ -75,6 +58,20 @@ void XGUI_Workshop::initMenu() aCommand = aGroup->addFeature("REBUILD_CMD", tr("REBUILD_MENU"), tr("REBUILD_MENU_TIP"), QIcon(":pictures/rebuild.png")); + aCommand = aGroup->addFeature("SAVEAS_CMD", tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"), + QIcon(":pictures/save.png")); + aCommand->connectTo(this, SLOT(onSaveAs())); + //aCommand->disable(); + + aCommand = aGroup->addFeature("OPEN_CMD", tr("OPEN_MENU"), tr("OPEN_MENU_TIP"), + QIcon(":pictures/open.png"), QKeySequence::Open); + aCommand->connectTo(this, SLOT(onOpen())); + + + aCommand = aGroup->addFeature("NEW_CMD", tr("NEW_MENU"), tr("NEW_MENU_TIP"), + QIcon(":pictures/new.png"), QKeySequence::New); + aCommand->connectTo(this, SLOT(onNew())); + aCommand = aGroup->addFeature("EXIT_CMD", tr("EXIT_MENU"), tr("EXIT_MENU_TIP"), QIcon(":pictures/close.png"), QKeySequence::Close); aCommand->connectTo(this, SLOT(onExit())); diff --git a/src/XGUI/XGUI_msg_en.ts b/src/XGUI/XGUI_msg_en.ts index 4f72790d6..6f94461a3 100644 --- a/src/XGUI/XGUI_msg_en.ts +++ b/src/XGUI/XGUI_msg_en.ts @@ -7,8 +7,8 @@ XGUI_Workshop - HOME_MENU_TITLE - Home + GEN_MENU_TITLE + General NEW_MENU -- 2.39.2