From: vsv Date: Fri, 18 Apr 2014 06:52:01 +0000 (+0400) Subject: Improve Viewer on Linux X-Git-Tag: V_0.2~149^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a70c55f532ad40650954c68b776cc7caff0b9936;p=modules%2Fshaper.git Improve Viewer on Linux --- diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index f7edd5d5e..9dcb2f914 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -295,8 +296,8 @@ bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView) if (!mapped(theView)) { theView->SetWindow(myWindow); - if (theView != activeView()) - theView->View()->Deactivate(); + //if (theView != activeView()) + //theView->View()->Deactivate(); } /* create static trihedron (16551: EDF PAL 501) */ @@ -480,7 +481,7 @@ void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent) mapView( activeView() ); #endif if (!myWindow.IsNull()) { - //QGuiApplication::sync(); + QApplication::syncX(); QRect rc = theEvent->rect(); //if ( !myPaintersRedrawing ) { //activeView()->Redraw(); @@ -496,16 +497,17 @@ void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent) } //*********************************************** -void XGUI_ViewPort::resizeEvent(QResizeEvent*) +void XGUI_ViewPort::resizeEvent(QResizeEvent* theEvent) { #ifdef WIN32 /* Win32 : map before first show to avoid flicker */ if (!mapped(activeView())) mapView(activeView()); #endif - //QGuiApplication::sync(); - if (!activeView().IsNull()) + QApplication::syncX(); + if (!activeView().IsNull()) { activeView()->MustBeResized(); + } } //*********************************************** @@ -524,7 +526,7 @@ QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate) aWidth = theRect.width(); aHeight = theRect.height(); } - //QApplication::syncX(); + QApplication::syncX(); OpenGLUtils_FrameBuffer aFrameBuffer; if (aFrameBuffer.init(aWidth, aHeight)) { diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h index 0f62915b6..cb8327d26 100644 --- a/src/XGUI/XGUI_ViewPort.h +++ b/src/XGUI/XGUI_ViewPort.h @@ -41,7 +41,7 @@ public: void fitRect(const QRect& rect); void startZoomAtPoint(int x, int y); void zoom(int x0, int y0, int x, int y); - void fitAll(bool theKeepScale = false, bool theWithZ = true, bool theUpd = true); + void fitAll(bool theKeepScale = false, bool theWithZ = true, bool theUpd = true); void setAdvancedZoomingEnabled(const bool theState) { diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index 4e4e54c72..ff03a737d 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -81,6 +81,9 @@ const char* imageCrossCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c void ViewerToolbar::paintEvent(QPaintEvent* theEvent) { + QApplication::syncX(); + printf("### ViewerToolbar::paintEvent\n"); + //QToolBar::paintEvent(theEvent); // Paint background QPainter aPainter(this); QRect aRect = rect(); @@ -88,7 +91,7 @@ void ViewerToolbar::paintEvent(QPaintEvent* theEvent) QPoint aGlobPnt = mapToGlobal(aRect.topLeft()); QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt); - QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), + QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height())); aPainter.drawImage(aRect, myVPort->dumpView(aImgRect, false)); @@ -142,6 +145,7 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) myClosable(true), myStartX(0), myStartY(0), myCurrX(0), myCurrY(0), myCurScale(0.0), myCurSketch(0), myDrawRect(false), myEnableDrawMode(false), myCursorIsHand(false), myEventStarted(false), + myIsActive(false), myLastState(WindowNormalState), myOperation(NOTHING) { mySelectedPoint = gp_Pnt(0., 0., 0.); @@ -278,8 +282,8 @@ void XGUI_ViewWindow::resizeEvent(QResizeEvent* theEvent) QSize aWndBarSize = myWindowBar->sizeHint(); QSize myViewBarSize = myViewBar->sizeHint(); - myWindowBar->move(aSize.width() - aWndBarSize.width() - BORDER_SIZE - 4, - BORDER_SIZE + 2); + myWindowBar->setGeometry(aSize.width() - aWndBarSize.width() - BORDER_SIZE - 4, BORDER_SIZE + 2, + aWndBarSize.width(), aWndBarSize.height()); int aViewBarWidth = aSize.width() - aWndBarSize.width() - myGripWgt->width() - 8; if (aViewBarWidth > myViewBarSize.width()) aViewBarWidth = myViewBarSize.width(); @@ -291,7 +295,7 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) { if (theEvent->type() == QEvent::WindowStateChange) { - if (isMinimized()) { + if (parentWidget()->isMinimized()) { myViewBar->hide(); myGripWgt->hide(); myWindowBar->hide(); @@ -300,13 +304,13 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) } else { myPicture->hide(); myViewPort->show(); - if (isMaximized()) { + if (parentWidget()->isMaximized()) { myMinimizeBtn->setIcon(MinimizeIco); myMaximizeBtn->setIcon(RestoreIco); } - myViewBar->setVisible(isActiveWindow()); - myWindowBar->setVisible(isActiveWindow()); - myGripWgt->setVisible(isActiveWindow() && (!isMaximized())); + myViewBar->setVisible(myIsActive); + myWindowBar->setVisible(myIsActive); + myGripWgt->setVisible(myIsActive && (!parentWidget()->isMaximized())); } } else QWidget::changeEvent(theEvent); @@ -314,15 +318,19 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) +//**************************************************************** void XGUI_ViewWindow::windowActivated() { + myIsActive = true; myViewBar->show(); myWindowBar->show(); - myGripWgt->setVisible(!(isMaximized() || isMinimized())); + myGripWgt->setVisible(!(parentWidget()->isMaximized() || parentWidget()->isMinimized())); } +//**************************************************************** void XGUI_ViewWindow::windowDeactivated() { + myIsActive = false; myViewBar->hide(); myWindowBar->hide(); myGripWgt->hide(); @@ -370,23 +378,22 @@ void XGUI_ViewWindow::onMinimize() int aNewH = int(aH / aR); myPicture->setPixmap(aPMap.scaled(100, aNewH)); - myLastState = isMaximized() ? MaximizedState : WindowNormalState; - showMinimized(); - parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), - 100, aNewH); + myLastState = parentWidget()->isMaximized() ? MaximizedState : WindowNormalState; + parentWidget()->showMinimized(); + parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), 100, aNewH); } //**************************************************************** void XGUI_ViewWindow::onMaximize() { - if (isMaximized()) { + if (parentWidget()->isMaximized()) { myMaximizeBtn->setIcon(MaximizeIco); myGripWgt->show(); - showNormal(); + parentWidget()->showNormal(); } else { myMaximizeBtn->setIcon(RestoreIco); myGripWgt->hide(); - showMaximized(); + parentWidget()->showMaximized(); } myMinimizeBtn->setIcon(MinimizeIco); } diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 01fd18ddf..77a127e5e 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -269,6 +269,7 @@ private: bool myIsKeyFree; bool myEventStarted; // set when transformation is in process bool myClosable; + bool myIsActive; QCursor myCursor; @@ -323,7 +324,9 @@ public: ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort) : QLabel(theParent), myVPort(thePort) { + setBackgroundRole(QPalette::NoRole); setAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_PaintOnScreen); } void repaintBackground();