]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix repaint and resize for MDI
authorvsv <vsv@opencascade.com>
Thu, 2 Apr 2009 10:43:22 +0000 (10:43 +0000)
committervsv <vsv@opencascade.com>
Thu, 2 Apr 2009 10:43:22 +0000 (10:43 +0000)
src/OCCViewer/OCCViewer_ViewPort.cxx
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index a975fe049a0c651d32b558e906e76dc4833fa8a9..19608ea1fa8aa16dfff213de877ccc46002c9fd4 100755 (executable)
@@ -209,8 +209,6 @@ void OCCViewer_ViewPort::initialize()
   setBackgroundRole( QPalette::NoRole );//NoBackground );
   // set focus policy to threat QContextMenuEvent from keyboard  
   setFocusPolicy( Qt::StrongFocus );
-  setAttribute( Qt::WA_PaintOnScreen );
-  setAttribute( Qt::WA_NoSystemBackground );
 }
 
 /*!
@@ -424,7 +422,7 @@ void OCCViewer_ViewPort::keyReleaseEvent( QKeyEvent *e )
 /*!
     Repaints the viewport. [ virtual protected ]
 */
-void OCCViewer_ViewPort::paintEvent( QPaintEvent* )
+void OCCViewer_ViewPort::paintEvent( QPaintEvent* e)
 {
        if ( myPaintersRedrawing )
        {
index 7fc204ddd3a1e489df889386d10da86c93c4ac02..2828b0d850e89d0cc8f20eb343033e1c5692b9da 100755 (executable)
@@ -32,6 +32,7 @@
 #include <QPaintEvent>
 #include <QResizeEvent>
 #include <QApplication>
+#include <QPainter>
 
 #include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
@@ -58,8 +59,14 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
 myScale( 1.0 ),
 myDegenerated( true ),
 myAnimate( false ),
-myBusy( true )
+myBusy( true ),
+mySizeChanged(false)
 {
+  setAttribute( Qt::WA_PaintOnScreen );
+  setAttribute( Qt::WA_NoSystemBackground );
+  setAttribute( Qt::WA_OpaquePaintEvent );
+  setAutoFillBackground(false);
+
   selectVisualId();
 
   if ( type == V3d_ORTHOGRAPHIC ) {
@@ -435,13 +442,23 @@ void OCCViewer_ViewPort3d::endRotation()
     {
       if (myAnimate) activeView()->SetAnimationModeOff();
       if ( !myDegenerated )
-       activeView()->SetDegenerateModeOff();
+             activeView()->SetDegenerateModeOff();
       activeView()->ZFitAll(1.);
       activeView()->SetZSize(0.);
       activeView()->Update();
     }
 }
 
+/*bool OCCViewer_ViewPort3d::event( QEvent* e)
+{
+  if (e->type() == QEvent::Paint) {
+    paintEvent((QPaintEvent*)e);
+    return true;
+  } 
+  return QWidget::event(e);
+}*/
+
+
 /*!
     Repaints the viewport. [ virtual protected ]
 */
@@ -456,11 +473,16 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
        {
                QApplication::syncX();
                QRect rc = e->rect();
-               if ( !myPaintersRedrawing )
+    if (mySizeChanged) {
+      activeView()->MustBeResized();
+      mySizeChanged = false;
+    }
+    if ( !myPaintersRedrawing )
                    activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() );
        }
        OCCViewer_ViewPort::paintEvent( e );
        myBusy = false;
+  e->accept();
 }
 
 /*!
@@ -473,9 +495,14 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
        if ( !mapped( activeView() ) )
            mapView( activeView() );
 #endif
+  //bool aRes = testAttribute(Qt::WA_Resized);
        QApplication::syncX();
-    if ( !activeView().IsNull() )
-        activeView()->MustBeResized();
+  mySizeChanged = true;
+  //if ( !activeView().IsNull() ) {
+    //activeView()->MustBeResized();
+    e->accept();
+  //}
+  //OCCViewer_ViewPort::resizeEvent(e);
 }
 
 /*!
index efa011d4b5e408dcfd24ddf2ec86fbf17719213c..3dbf7e7ccc4ededb285002c89045f80785dd1f26 100755 (executable)
@@ -76,8 +76,13 @@ public:
   void                 endRotation();
   bool                  isBusy() {return myBusy;} // check that View Port is fully initialized
 
+
+  virtual QPaintEngine* paintEngine () const { return 0; }
+
 protected:
     // EVENTS
+  //virtual bool               event( QEvent* );
+
   virtual void         paintEvent( QPaintEvent* );
   virtual void          resizeEvent( QResizeEvent* );
 
@@ -96,6 +101,7 @@ private:
   bool                  myAnimate;
   bool                  myBusy;
   double               myScale;
+  bool mySizeChanged;
 };
 
 #ifdef WIN32
index a366dfbb5e52ba24cb8b1adf1ef6942e9c8e9be0..2634b7c9c39a1b119d9e91c4df4473215995b92d 100755 (executable)
@@ -309,7 +309,6 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
           emit contextMenuRequested( aEvent );
       }
       return true;
-
     default:
       break;
     }
@@ -317,6 +316,15 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
   return SUIT_ViewWindow::eventFilter(watched, e);
 }
 
+/*void OCCViewer_ViewWindow::resizeEvent( QResizeEvent* e )
+{
+  bool aRes = testAttribute(Qt::WA_Resized);
+  resize(e->size());
+  SUIT_ViewWindow::resizeEvent(e);
+  e->accept();
+}*/
+
+
 /*!
   \brief Update state of enable draw mode state.
 */
index 180e66c1975e09fb4274cb9846579ba7093bf07e..1f5a2a7920dccf8150db38a946998ac05262aa06 100755 (executable)
@@ -127,6 +127,8 @@ signals:
   void Hide( QHideEvent * );
 
 protected:
+  //virtual void          resizeEvent( QResizeEvent* );
+
   virtual QImage dumpView();
   virtual bool   dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
   virtual QString  filter() const;