From 9881d34dc9d179eab03442d822b4428608b07949 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 2 Apr 2009 10:43:22 +0000 Subject: [PATCH] Fix repaint and resize for MDI --- src/OCCViewer/OCCViewer_ViewPort.cxx | 4 +-- src/OCCViewer/OCCViewer_ViewPort3d.cxx | 37 ++++++++++++++++++++++---- src/OCCViewer/OCCViewer_ViewPort3d.h | 6 +++++ src/OCCViewer/OCCViewer_ViewWindow.cxx | 10 ++++++- src/OCCViewer/OCCViewer_ViewWindow.h | 2 ++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index a975fe049..19608ea1f 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -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 ) { diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 7fc204ddd..2828b0d85 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -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); } /*! diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index efa011d4b..3dbf7e7cc 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -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 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index a366dfbb5..2634b7c9c 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -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. */ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 180e66c19..1f5a2a792 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -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; -- 2.39.2