From: vsv Date: Fri, 18 Apr 2014 14:30:36 +0000 (+0400) Subject: Intermediate debug for Issue #32 X-Git-Tag: V_0.2~147^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6aeb748cc6eeb2bb86d34e9669ca6ceb8e4d0a55;p=modules%2Fshaper.git Intermediate debug for Issue #32 --- diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index 9dcb2f914..d0cfa2d55 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -179,7 +179,7 @@ bool OpenGLUtils_FrameBuffer::init(const GLsizei& xSize, const GLsizei& ySize) { char* ext = (char*) glGetString(GL_EXTENSIONS); if (!IsEXTInitialized || strstr(ext, "GL_EXT_framebuffer_object") == NULL) { - qDebug( "Initializing OpenGL FrameBuffer extension failed"); + //qDebug( "Initializing OpenGL FrameBuffer extension failed"); return false; } @@ -271,6 +271,7 @@ XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, setFocusPolicy(Qt::StrongFocus); setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); + setAutoFillBackground(false); if (theType == V3d_ORTHOGRAPHIC) { myOrthoView = new V3d_OrthographicView(theViewer); diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index 000e4b4ae..b8b90d696 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -81,9 +81,7 @@ 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); + //qDebug("### ViewerToolbar::paintEvent %i\n", AA++); // Paint background QPainter aPainter(this); QRect aRect = rect(); @@ -144,7 +142,7 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) myRotationPointSelection(false), myClosable(true), myStartX(0), myStartY(0), myCurrX(0), myCurrY(0), myCurScale(0.0), myCurSketch(0), - myDrawRect(false), myEnableDrawMode(false), myCursorIsHand(false), myEventStarted(false), + myDrawRect(false), myEnableDrawMode(true), myCursorIsHand(false), myEventStarted(false), myIsActive(false), myLastState(WindowNormalState), myOperation(NOTHING) { @@ -158,6 +156,7 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) aLay->setContentsMargins(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE); myViewPort = new XGUI_ViewPort(this, myViewer->v3dViewer(), theType); myViewPort->installEventFilter(this); + myViewPort->setCursor(Qt::ArrowCursor); aLay->addWidget(myViewPort); myPicture = new QLabel(this); @@ -168,14 +167,30 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) aLay->addWidget(myPicture); myPicture->hide(); + QVBoxLayout* aVPLay = new QVBoxLayout(myViewPort); + aVPLay->setMargin(0); + aVPLay->setSpacing(0); + aVPLay->setContentsMargins(0,0,0,0); + + QHBoxLayout* aToolLay = new QHBoxLayout(); + aToolLay->setMargin(0); + aToolLay->setSpacing(0); + aVPLay->setContentsMargins(0,0,0,0); + aVPLay->addLayout(aToolLay); + aVPLay->addStretch(); + myGripWgt = new ViewerLabel(this, myViewPort); myGripWgt->setPixmap(QPixmap(":pictures/wnd_grip.png")); - myGripWgt->setGeometry(BORDER_SIZE + 2, BORDER_SIZE + 2, 19, 32); myGripWgt->setMouseTracking(true); myGripWgt->installEventFilter(this); + myGripWgt->setCursor(Qt::OpenHandCursor); + aToolLay->addWidget(myGripWgt); // Create Viewer management buttons myViewBar = new ViewerToolbar(this, myViewPort); + myViewBar->setCursor(Qt::PointingHandCursor); + aToolLay->addWidget(myViewBar); + aToolLay->addStretch(); QAction* aBtn; @@ -242,6 +257,9 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) // Create Window management buttons myWindowBar = new ViewerToolbar(this, myViewPort); + myWindowBar->setCursor(Qt::PointingHandCursor); + aToolLay->addWidget(myWindowBar); + myWindowBar->setFixedWidth(100); myMinimizeBtn = new QAction(myWindowBar); myMinimizeBtn->setIcon(MinimizeIco); @@ -258,10 +276,6 @@ 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(); - //Support copy of background on updating of viewer connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar())); connect(myViewPort, SIGNAL(vpUpdated()), this, SLOT(updateToolBar())); @@ -275,21 +289,6 @@ XGUI_ViewWindow::~XGUI_ViewWindow() { } -//**************************************************************** -void XGUI_ViewWindow::resizeEvent(QResizeEvent* theEvent) -{ - QSize aSize = theEvent->size(); - QSize aWndBarSize = myWindowBar->sizeHint(); - QSize myViewBarSize = myViewBar->sizeHint(); - - 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(); - myViewBar->setGeometry(BORDER_SIZE + 18, BORDER_SIZE + 2, aViewBarWidth, myViewBarSize.height()); -} - //**************************************************************** void XGUI_ViewWindow::changeEvent(QEvent* theEvent) { @@ -325,32 +324,33 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) //**************************************************************** void XGUI_ViewWindow::windowActivated() { - myIsActive = true; - if (!isMinimized()) { - myViewBar->show(); - myWindowBar->show(); - myGripWgt->setVisible(!(isMaximized() || isMinimized())); - if (isMaximized()) { + if (!(isMinimized() || parentWidget()->isMinimized())) { + myIsActive = true; + if (isMaximized() || parentWidget()->isMaximized()) { myMaximizeBtn->setIcon(RestoreIco); } else { myMaximizeBtn->setIcon(MaximizeIco); } - } + myViewBar->show(); + myWindowBar->show(); + myGripWgt->setVisible(!(isMaximized() || isMinimized())); + } else + myIsActive = false; } //**************************************************************** void XGUI_ViewWindow::windowDeactivated() { myIsActive = false; - if (!isMinimized()) { - myViewBar->hide(); - myWindowBar->hide(); - myGripWgt->hide(); - if (isMaximized()) { + if (!(isMinimized() || parentWidget()->isMinimized())) { + if (isMaximized() || parentWidget()->isMaximized()) { myMaximizeBtn->setIcon(RestoreIco); } else { myMaximizeBtn->setIcon(MaximizeIco); } + myViewBar->hide(); + myWindowBar->hide(); + myGripWgt->hide(); } } @@ -367,25 +367,6 @@ void XGUI_ViewWindow::onClose() } } -//**************************************************************** -/*void XGUI_ViewWindow::enterEvent(QEvent* theEvent) -{ - if (!isMinimized()) { - myViewBar->show(); - myWindowBar->show(); - if (!isMaximized()) - myGripWgt->show(); - } -} - -//**************************************************************** -void XGUI_ViewWindow::leaveEvent(QEvent* theEvent) -{ - myViewBar->hide(); - myGripWgt->hide(); - myWindowBar->hide(); -}*/ - //**************************************************************** void XGUI_ViewWindow::onMinimize() { @@ -397,9 +378,12 @@ void XGUI_ViewWindow::onMinimize() myPicture->setPixmap(aPMap.scaled(100, aNewH)); myLastState = (isMaximized() || parentWidget()->isMaximized()) ? MaximizedState : WindowNormalState; - //parentWidget()->showMinimized(); showMinimized(); + parentWidget()->showMinimized(); parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), 100, aNewH); + parentWidget()->lower(); + windowDeactivated(); + myViewer->onWindowMinimized((QMdiSubWindow*)parentWidget()); } //**************************************************************** @@ -414,7 +398,9 @@ void XGUI_ViewWindow::onMaximize() myMaximizeBtn->setIcon(RestoreIco); myGripWgt->hide(); showMaximized(); + parentWidget()->showMaximized(); } + parentWidget()->activateWindow(); myMinimizeBtn->setIcon(MinimizeIco); } @@ -460,10 +446,13 @@ bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent) case QEvent::MouseButtonDblClick: if (theObj == myPicture) { myMoving = false; - if (myLastState == MaximizedState) + if (myLastState == MaximizedState) { showMaximized(); - else + } else { showNormal(); + } + raise(); + myViewer->onWindowActivated((QMdiSubWindow*)parentWidget()); return true; } } diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 77a127e5e..0af119b37 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -87,6 +87,12 @@ public: //! Sets the current view window closable or not void setClosable( const bool isClosable ) { myClosable = isClosable; } + //! Enable/Disable drawing of ribbon line + void enableDrawMode(bool toEnable) { myEnableDrawMode = toEnable; } + + //! Returns true if ribbon line drawing enabled + bool isDrawModeEnabled() const { return myEnableDrawMode; } + signals: //! Emited whien view transformation operation is started void vpTransformationStarted(XGUI_ViewWindow::OperationType type); @@ -180,13 +186,8 @@ public slots: void windowDeactivated(); protected: - virtual void resizeEvent(QResizeEvent* theEvent); - virtual void changeEvent(QEvent* theEvent); - //virtual void enterEvent(QEvent* theEvent); - //virtual void leaveEvent(QEvent* theEvent); - virtual bool eventFilter(QObject *theObj, QEvent *theEvent); private slots: @@ -302,6 +303,7 @@ public: setBackgroundRole(QPalette::NoRole); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_PaintOnScreen); + setAutoFillBackground(false); } protected: @@ -327,6 +329,7 @@ public: setBackgroundRole(QPalette::NoRole); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_PaintOnScreen); + setAutoFillBackground(false); } void repaintBackground(); diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 6d207e991..30ac2e1d3 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -414,14 +415,34 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView) /*! Emit activated for view \a view. */ +static int AA = 0; void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view) { + qDebug("### windowActivated %i\n", AA++); if (view && (view != myActiveView)) { myActiveView = view; ((XGUI_ViewWindow*)myActiveView->widget())->windowActivated(); QList::iterator aIt; - for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) - if ((*aIt) != myActiveView) + for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) { + if ((*aIt) != myActiveView) { ((XGUI_ViewWindow*)(*aIt)->widget())->windowDeactivated(); + } + } + } +} + + +void XGUI_Viewer::onWindowMinimized(QMdiSubWindow* theWnd) +{ + if (myActiveView == theWnd) { + myActiveView = 0; + QList::iterator aIt; + for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) { + if (!(*aIt)->widget()->isMinimized()) { + (*aIt)->raise(); + onWindowActivated(*aIt); + break; + } + } } } diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index fc0476cbb..b68f9accb 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -111,10 +111,12 @@ signals: void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent); void activated(XGUI_ViewWindow* theWindow); +public slots: + void onWindowMinimized(QMdiSubWindow*); + void onWindowActivated(QMdiSubWindow*); + private slots: void onViewClosed(QMdiSubWindow*); - //void onViewMapped(); - void onWindowActivated(QMdiSubWindow*); private: void addView(QMdiSubWindow* theView);