]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #24
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 15 Apr 2014 12:32:42 +0000 (16:32 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 15 Apr 2014 12:32:42 +0000 (16:32 +0400)
src/XGUI/XGUI_ViewWindow.cpp
src/XGUI/XGUI_ViewWindow.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h

index 3803cabeaaeb9876d2c1a6e6f6d7aa1833800391..4e4e54c72543aa7df34fe79c72d7d929583ab77b 100644 (file)
@@ -15,6 +15,7 @@
 #include <QPainter>
 #include <QTimer>
 #include <QFileDialog>
+#include <QStyleOptionToolBar>
 
 #include <TopoDS_Shape.hxx>
 #include <BRep_Tool.hxx>
@@ -77,9 +78,11 @@ const char* imageCrossCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c
     "................................", "................................",
     "................................", "................................" };
 
-//**************************************************************************
-void ViewerToolbar::repaintBackground()
+
+void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
 {
+  // Paint background
+  QPainter aPainter(this);
   QRect aRect = rect();
   QRect aVPRect = myVPort->rect();
   QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
@@ -87,13 +90,16 @@ void ViewerToolbar::repaintBackground()
 
   QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), 
                        aRect.width(), aRect.height()));
-  QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false));
-}
+  aPainter.drawImage(aRect, myVPort->dumpView(aImgRect, false));
 
-void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
-{
-  repaintBackground();
-  //QToolBar::paintEvent(theEvent);
+  // Paint foreground
+  QStyle *style = this->style();
+  QStyleOptionToolBar aOpt;
+  initStyleOption(&aOpt);
+
+  aOpt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &aOpt, this);
+  if (aOpt.rect.isValid())
+    style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this);
 }
 
 //**************************************************************************
@@ -248,9 +254,9 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType)
   myWindowBar->addAction(aBtn);
   connect(aBtn, SIGNAL(triggered()), SLOT(onClose()));
 
-  myViewBar->hide();
-  myWindowBar->hide();
-  myGripWgt->hide();
+  //myViewBar->hide();
+  //myWindowBar->hide();
+  //myGripWgt->hide();
 
   //Support copy of background on updating of viewer
   connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar()));
@@ -286,24 +292,43 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent)
 
   if (theEvent->type() == QEvent::WindowStateChange) {
     if (isMinimized()) {
-            myViewBar->hide();
-            myGripWgt->hide(); 
-            myWindowBar->hide();
-            myViewPort->hide();
+      myViewBar->hide();
+      myGripWgt->hide(); 
+      myWindowBar->hide();
+      myViewPort->hide();
       myPicture->show();
     } else {
       myPicture->hide();
-            myViewPort->show();
+      myViewPort->show();
       if (isMaximized()) {
         myMinimizeBtn->setIcon(MinimizeIco);
         myMaximizeBtn->setIcon(RestoreIco);
       }
+      myViewBar->setVisible(isActiveWindow());
+      myWindowBar->setVisible(isActiveWindow());
+      myGripWgt->setVisible(isActiveWindow() && (!isMaximized())); 
     }
   } else
     QWidget::changeEvent(theEvent);
 }
 
 
+
+void XGUI_ViewWindow::windowActivated()
+{
+  myViewBar->show();
+  myWindowBar->show();
+  myGripWgt->setVisible(!(isMaximized() || isMinimized())); 
+}
+
+void XGUI_ViewWindow::windowDeactivated()
+{
+  myViewBar->hide();
+  myWindowBar->hide();
+  myGripWgt->hide(); 
+}
+
+
 //****************************************************************
 void XGUI_ViewWindow::onClose()
 {
@@ -317,7 +342,7 @@ void XGUI_ViewWindow::onClose()
 }
 
 //****************************************************************
-void XGUI_ViewWindow::enterEvent(QEvent* theEvent)
+/*void XGUI_ViewWindow::enterEvent(QEvent* theEvent)
 {
   if (!isMinimized()) {
     myViewBar->show();
@@ -333,7 +358,7 @@ void XGUI_ViewWindow::leaveEvent(QEvent* theEvent)
   myViewBar->hide();
   myGripWgt->hide();
   myWindowBar->hide();
-}
+}*/
 
 //****************************************************************
 void XGUI_ViewWindow::onMinimize()
index 0c3ae8a1766f7a266634ab9cb198f90ad9750d5a..14e5ccf52a6f16deb78e86881f5dc5f38e456aab 100644 (file)
@@ -174,14 +174,17 @@ public slots:
   //! Reset point of view
   void reset();
 
+  void windowActivated();
+
+  void windowDeactivated();
 
 protected:
   virtual void resizeEvent(QResizeEvent* theEvent);
 
   virtual void changeEvent(QEvent* theEvent);
 
-  virtual void enterEvent(QEvent* theEvent);
-  virtual void leaveEvent(QEvent* theEvent);
+  //virtual void enterEvent(QEvent* theEvent);
+  //virtual void leaveEvent(QEvent* theEvent);
 
   virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
 
@@ -299,8 +302,6 @@ public:
     setAttribute(Qt::WA_PaintOnScreen);
   }
 
-  void repaintBackground();
-
 protected:
   virtual void paintEvent(QPaintEvent* theEvent);
 
index 0f6e40282c133495240260c2f86dae78ac075b07..dc5faa611bf657024289bb6c0a78c500a1974751 100644 (file)
@@ -145,6 +145,10 @@ XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron)
   }
   // set zooming style to standard
   //myZoomingStyle = 0;
+
+  QMdiArea* aMDI = myMainWindow->mdiArea();
+  connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onWindowActivated(QMdiSubWindow*)));
+
 }
 
 XGUI_Viewer::~XGUI_Viewer(void)
@@ -412,5 +416,12 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView)
 */
 void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view)
 {
+  if (view && (view != myActiveView)) {
     myActiveView = view;
+    ((XGUI_ViewWindow*)myActiveView->widget())->windowActivated();
+    QList<QMdiSubWindow*>::iterator aIt;
+    for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt)
+      if ((*aIt) != myActiveView)
+        ((XGUI_ViewWindow*)(*aIt)->widget())->windowDeactivated();
+  }
 }
index 6afdf36ec93065c94aee4c2434cc7ce554c86aff..4b29bb1f12f4b0f12859a293dceab8e5c46b7b67 100644 (file)
@@ -135,9 +135,9 @@ private:
 
   double myTrihedronSize;
   
-    QList<QMdiSubWindow*> myViews;
+  QList<QMdiSubWindow*> myViews;
 
-    QMdiSubWindow* myActiveView;
+  QMdiSubWindow* myActiveView;
 };
 
 #endif