]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Management of sub window
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 14 Mar 2014 12:22:47 +0000 (16:22 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 14 Mar 2014 12:22:47 +0000 (16:22 +0400)
src/GeomModule/GeomModule.cpp
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MainWindow.h
src/XGUI/XGUI_ViewWindow.cpp [new file with mode: 0644]
src/XGUI/XGUI_ViewWindow.h [new file with mode: 0644]
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_msg_en.ts

index 5bac1033695d82076e4d01072982f094c46d5236..6bddce9b101628566db1ce41374d26b906d85d34 100644 (file)
@@ -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
index edc7d7e2568fc22d38a21244480def233b742053..e4521a14864a2890f02424e1a2502b9ef029857d 100644 (file)
@@ -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 
index f5c82a4bc76f1c38652cdc1a73e306d736ebea8d..2a88182d297b691cdbf4d21b0c754fdd53be60a2 100644 (file)
@@ -1,15 +1,14 @@
 #include "XGUI_MainWindow.h"
 #include "XGUI_MainMenu.h"
+#include "XGUI_ViewWindow.h"
 
 #include <QMdiArea>
 #include <QTreeWidget>
 #include <QDockWidget>
 #include <QTextEdit>
-#include <QMdiSubWindow>
 #include <QLabel>
 #include <QToolBar>
 #include <QToolButton>
-#include <QAction>
 #include <QTreeWidgetItem>
 #include <QLayout>
 #include <QLineEdit>
 #include <QDoubleSpinBox>
 #include <QPushButton>
 #include <QScrollArea>
+#include <QComboBox>
 
 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);
 
index d6590d44a1e95d6f24ec5c71982a1a62d5b22b6f..dc9e34fee27bc1a34b9330acce82857068974117 100644 (file)
@@ -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 (file)
index 0000000..2ca3801
--- /dev/null
@@ -0,0 +1,137 @@
+#include "XGUI_ViewWindow.h"
+
+
+#include <QLayout>
+#include <QLabel>
+#include <QToolBar>
+#include <QAction>
+#include <QResizeEvent>
+#include <QApplication>
+
+#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 (file)
index 0000000..e4daab7
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef XGUI_ViewWindow_H
+#define XGUI_ViewWindow_H
+
+#include <QWidget>
+
+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
index 191e960a0c87daa56c4964a1bba81bd5c6b3938b..b7db81cb10a0b24d529a94e91ab2f609c3eed2ce 100644 (file)
@@ -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()));
index 4f72790d63ab7cb11d1050b08c8aa3a04a9f6efd..6f94461a36ee71480205de8ded07ed7f979ce545 100644 (file)
@@ -7,8 +7,8 @@
 <context>
     <name>XGUI_Workshop</name>
     <message>
-        <source>HOME_MENU_TITLE</source>
-        <translation>Home</translation>
+        <source>GEN_MENU_TITLE</source>
+        <translation>General</translation>
     </message>
     <message>
         <source>NEW_MENU</source>