From: vsv Date: Tue, 1 Apr 2014 05:57:09 +0000 (+0400) Subject: Connection of view management buttons to operations X-Git-Tag: V_0.1~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9c985b359361fc2eb4a1b746dcb27031bc2c3c06;p=modules%2Fshaper.git Connection of view management buttons to operations --- diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index b8ec91582..abcb6a3dd 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -716,3 +716,17 @@ void XGUI_ViewPort::setBackground( const XGUI_ViewBackground& bgData ) emit vpChangeBackground( myBackground ); } } + +void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd) +{ + if ( activeView().IsNull() ) + return; + + if ( theKeepScale ) + myScale = activeView()->Scale(); + + Standard_Real aMargin = 0.01; + activeView()->FitAll( aMargin, theWithZ, theUpd ); + activeView()->SetZSize(0.); + emit vpTransformed( ); +} diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h index cd79d564e..10dd2356a 100644 --- a/src/XGUI/XGUI_ViewPort.h +++ b/src/XGUI/XGUI_ViewPort.h @@ -36,6 +36,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 setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; } bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; } diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index eb851c800..8370775d9 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -13,11 +13,13 @@ #include #include #include -#include +//#include +#include #include #include #include +#include #define BORDER_SIZE 2 @@ -183,7 +185,8 @@ QFrame(), my2dMode(XGUI::No2dMode), myCurrPointType(XGUI::GRAVITY), myPrevPointType(XGUI::GRAVITY), - myRotationPointSelection(false) + myRotationPointSelection(false), + myClosable(false) { mySelectedPoint = gp_Pnt(0.,0.,0.); setFrameStyle(QFrame::Raised); @@ -197,28 +200,14 @@ QFrame(), myViewPort->installEventFilter(this); aLay->addWidget(myViewPort); - myPicture = new QLabel(); + myPicture = new QLabel(this); myPicture->setFrameStyle(QFrame::Sunken); myPicture->setFrameShape(QFrame::Panel); myPicture->setMouseTracking(true); myPicture->installEventFilter(this); + aLay->addWidget(myPicture); myPicture->hide(); - QStringList aPictures; - aPictures<<":pictures/occ_view_camera_dump.png"<<":pictures/occ_view_style_switch.png"; - aPictures<<":pictures/occ_view_triedre.png"<<":pictures/occ_view_fitall.png"; - aPictures<<":pictures/occ_view_fitarea.png"<<":pictures/occ_view_zoom.png"; - aPictures<<":pictures/occ_view_pan.png"<<":pictures/occ_view_glpan.png"; - aPictures<<":pictures/occ_view_rotate.png"<<":pictures/occ_view_front.png"; - aPictures<<":pictures/occ_view_back.png"<<":pictures/occ_view_left.png"; - aPictures<<":pictures/occ_view_right.png"<<":pictures/occ_view_top.png"; - aPictures<<":pictures/occ_view_bottom.png"<<":pictures/occ_view_clone.png"; - - QStringList aTitles; - aTitles << "Dump view" << "Mouse style switch" << "Show trihedron" << "Fit all"; - aTitles << "Fit area" << "Zoom" << "Panning" << "Global panning" << "Rotate"; - aTitles << "Front" << "Back" << "Left" << "Right" << "Top" << "Bottom" << "Clone view"; - myGripWgt = new ViewerLabel(this, myViewPort); myGripWgt->setPixmap(QPixmap(":pictures/wnd_grip.png")); myGripWgt->setGeometry(BORDER_SIZE + 2, BORDER_SIZE + 2, 19, 32); @@ -227,16 +216,73 @@ QFrame(), connect(myViewPort, SIGNAL(vpTransformed()), myGripWgt, SLOT(update())); connect(myViewPort, SIGNAL(vpUpdated()), myGripWgt, SLOT(update())); + // Create Viewer management buttons myViewBar = new ViewerToolbar(this, myViewPort); QAction* aBtn; - for (int i = 0; i < aTitles.length(); i++) { - aBtn = new QAction(QIcon(aPictures.at(i)), aTitles.at(i), myViewBar); - myViewBar->addAction(aBtn); - } + + // Dump view + aBtn = new QAction(QIcon(":pictures/occ_view_camera_dump.png"), tr("DUMP_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(dumpView())); + myViewBar->addAction(aBtn); + // Fit all + aBtn = new QAction(QIcon(":pictures/occ_view_fitall.png"), tr("FIT_ALL"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(fitAll())); + myViewBar->addAction(aBtn); + // Fit area + aBtn = new QAction(QIcon(":pictures/occ_view_fitarea.png"), tr("FIT_AREA"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(activateWindowFit())); + myViewBar->addAction(aBtn); + // Zoom + aBtn = new QAction(QIcon(":pictures/occ_view_zoom.png"), tr("ZOOM_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(activateZoom())); + myViewBar->addAction(aBtn); + // Pan + aBtn = new QAction(QIcon(":pictures/occ_view_pan.png"), tr("PAN_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(activatePanning())); + myViewBar->addAction(aBtn); + // Global Panning + aBtn = new QAction(QIcon(":pictures/occ_view_glpan.png"), tr("GLOB_PAN_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(activateGlobalPanning())); + myViewBar->addAction(aBtn); + // Rotation + aBtn = new QAction(QIcon(":pictures/occ_view_rotate.png"), tr("ROTATE_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(activateRotation())); + myViewBar->addAction(aBtn); + // Front view + aBtn = new QAction(QIcon(":pictures/occ_view_front.png"), tr("FRONT_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(frontView())); + myViewBar->addAction(aBtn); + // Back view + aBtn = new QAction(QIcon(":pictures/occ_view_back.png"), tr("BACK_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(backView())); + myViewBar->addAction(aBtn); + // Top view + aBtn = new QAction(QIcon(":pictures/occ_view_top.png"), tr("TOP_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(topView())); + myViewBar->addAction(aBtn); + // Bottom view + aBtn = new QAction(QIcon(":pictures/occ_view_bottom.png"), tr("BOTTOM_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(bottomView())); + myViewBar->addAction(aBtn); + // Left view + aBtn = new QAction(QIcon(":pictures/occ_view_left.png"), tr("LEFT_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(leftView())); + myViewBar->addAction(aBtn); + // Right view + aBtn = new QAction(QIcon(":pictures/occ_view_right.png"), tr("RIGHT_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(rightView())); + myViewBar->addAction(aBtn); + // Clone view + aBtn = new QAction(QIcon(":pictures/occ_view_clone.png"), tr("CLONE_VIEW"), myViewBar); + connect(aBtn, SIGNAL(triggered()), SLOT(cloneView())); + myViewBar->addAction(aBtn); + + //Support copy of background on updating of viewer connect(myViewPort, SIGNAL(vpTransformed()), myViewBar, SLOT(update())); connect(myViewPort, SIGNAL(vpUpdated()), myViewBar, SLOT(update())); + // Create Window management buttons myWindowBar = new ViewerToolbar(this, myViewPort); connect(myViewPort, SIGNAL(vpTransformed()), myWindowBar, SLOT(update())); connect(myViewPort, SIGNAL(vpUpdated()), myWindowBar, SLOT(update())); @@ -286,15 +332,14 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) if (theEvent->type() == QEvent::WindowStateChange) { if (isMinimized()) { - if (!myPicture->parentWidget()) { - QMdiSubWindow* aParent = static_cast(parentWidget()); - QMdiArea* aMDIArea = aParent->mdiArea(); - myPicture->setParent(aMDIArea); - } - myPicture->move(parentWidget()->x(), parentWidget()->y()); + myViewBar->hide(); + myGripWgt->hide(); + myWindowBar->hide(); + myViewPort->hide(); myPicture->show(); } else { myPicture->hide(); + myViewPort->show(); if (isMaximized()) { myMinimizeBtn->setIcon(MinimizeIco); myMaximizeBtn->setIcon(RestoreIco); @@ -304,12 +349,17 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) QWidget::changeEvent(theEvent); } + //**************************************************************** void XGUI_ViewWindow::onClose() { - if (parentWidget()) - parentWidget()->close(); - + if (parentWidget()) { + emit tryClosing(this); + if (closable()) { + emit closed(static_cast(parentWidget())); + parentWidget()->close(); + } + } } //**************************************************************** @@ -317,10 +367,10 @@ void XGUI_ViewWindow::enterEvent(QEvent* theEvent) { if (!isMinimized()) { myViewBar->show(); + myWindowBar->show(); if (!isMaximized()) myGripWgt->show(); } - myWindowBar->show(); } //**************************************************************** @@ -338,10 +388,13 @@ void XGUI_ViewWindow::onMinimize() int aW = width(); int aH = height(); double aR = aW / 100.; - myPicture->setPixmap(aPMap.scaled(100, int(aH / aR))); + int aNewH = int(aH / aR); + myPicture->setPixmap(aPMap.scaled(100, aNewH)); myLastState = isMaximized()? MaximizedState : NormalState; showMinimized(); + parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), + 100, aNewH); } //**************************************************************** @@ -362,7 +415,6 @@ void XGUI_ViewWindow::onMaximize() //**************************************************************** bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent) { - QWidget* aWgt = (theObj == myPicture)? myPicture : static_cast(parentWidget()); switch (theEvent->type()) { case QEvent::MouseButtonPress: { @@ -393,9 +445,9 @@ bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent) QPoint aPnt = aEvent->globalPos(); QPoint aMDIPnt = aMDIArea->mapFromGlobal(aPnt); if (aMDIArea->rect().contains(aMDIPnt)) { - int aX = aWgt->x() + (aPnt.x() - myMousePnt.x()); - int aY = aWgt->y() + (aPnt.y() - myMousePnt.y()); - aWgt->move(aX, aY); + int aX = aParent->x() + (aPnt.x() - myMousePnt.x()); + int aY = aParent->y() + (aPnt.y() - myMousePnt.y()); + aParent->move(aX, aY); myMousePnt = aPnt; } return true; @@ -434,6 +486,18 @@ bool XGUI_ViewWindow::processViewPort(QEvent *theEvent) case QEvent::MouseButtonDblClick: emit mouseDoubleClicked(this, (QMouseEvent*)theEvent); return true; + case QEvent::Wheel: + { + QWheelEvent* aEvent = (QWheelEvent*) theEvent; + myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); + double aDelta = (double)( aEvent->delta() ) / ( 15 * 8 ); + int x = aEvent->x(); + int y = aEvent->y(); + int x1 = (int)( aEvent->x() + width()*aDelta/100 ); + int y1 = (int)( aEvent->y() + height()*aDelta/100 ); + myViewPort->zoom( x, y, x1, y1 ); + } + return true; } return false; } @@ -849,6 +913,26 @@ void XGUI_ViewWindow::activatePanning() } } +/*! + \brief Start global panning operation + + Sets the corresponding cursor for the widget. +*/ +void XGUI_ViewWindow::activateGlobalPanning() +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + QPixmap globalPanPixmap (imageCrossCursor); + QCursor glPanCursor (globalPanPixmap); + myCurScale = aView3d->Scale(); + aView3d->FitAll(0.01, false); + myCursor = cursor(); // save old cursor + myViewPort->fitAll(); // fits view before selecting a new scene center + if( setTransformRequested( PANGLOBAL ) ) + myViewPort->setCursor( glPanCursor ); + } +} + /*! \brief Start rotation operation @@ -900,3 +984,139 @@ void XGUI_ViewWindow::setBackground( const XGUI_ViewBackground& theBackground ) { if ( myViewPort ) myViewPort->setBackground( theBackground ); } + +/*! + \brief Create one more window with same content. +*/ +void XGUI_ViewWindow::cloneView() +{ + QMdiSubWindow* vw = myViewer->createView(); + //vw->show(); + emit viewCloned( vw ); +} + +void XGUI_ViewWindow::dumpView() +{ + QString aFilter(tr("OCC_IMAGE_FILES")); + QString aSelectedFilter; + QString aFileName = QFileDialog::getSaveFileName(this, "Save picture", QString(), aFilter, &aSelectedFilter); + if (!aFileName.isNull()) { + QApplication::setOverrideCursor( Qt::WaitCursor ); + QImage aPicture = myViewPort->dumpView(); + + QString aFmt = extension(aFileName).toUpper(); + if( aFmt.isEmpty() ) + aFmt = QString( "BMP" ); // default format + else if( aFmt == "JPG" ) + aFmt = "JPEG"; + + Handle(Visual3d_View) a3dView = myViewPort->getView()->View(); + if (aFmt == "PS") + a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript); + else if (aFmt == "EPS") + a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript); + else + aPicture.save( aFileName, aFmt.toLatin1() ); + QApplication::restoreOverrideCursor(); + } +} + +void XGUI_ViewWindow::fitAll() +{ + emit vpTransformationStarted( FITALLVIEW ); + myViewPort->fitAll(); + emit vpTransformationFinished( FITALLVIEW ); +} + +/*! + \brief Starts fit operation. + + Sets the corresponding cursor for the widget. +*/ +void XGUI_ViewWindow::activateWindowFit() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != WINDOWFIT ) { + QCursor handCursor (Qt::PointingHandCursor); + if( setTransformRequested ( WINDOWFIT ) ) + { + myViewPort->setCursor ( handCursor ); + myCursorIsHand = true; + } + } +} + + +/*! + \brief Perform "front view" transformation. +*/ +void XGUI_ViewWindow::frontView() +{ + emit vpTransformationStarted ( FRONTVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos); + myViewPort->fitAll(); + emit vpTransformationFinished ( FRONTVIEW ); +} + +/*! + \brief Perform "back view" transformation. +*/ +void XGUI_ViewWindow::backView() +{ + emit vpTransformationStarted ( BACKVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg); + myViewPort->fitAll(); + emit vpTransformationFinished ( BACKVIEW ); +} + +/*! + \brief Perform "top view" transformation. +*/ +void XGUI_ViewWindow::topView() +{ + emit vpTransformationStarted ( TOPVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos); + myViewPort->fitAll(); + emit vpTransformationFinished ( TOPVIEW ); +} + +/*! + \brief Perform "bottom view" transformation. +*/ +void XGUI_ViewWindow::bottomView() +{ + emit vpTransformationStarted ( BOTTOMVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg); + myViewPort->fitAll(); + emit vpTransformationFinished ( BOTTOMVIEW ); +} + +/*! + \brief Perform "left view" transformation. +*/ +void XGUI_ViewWindow::leftView() +{ + emit vpTransformationStarted ( LEFTVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg); + myViewPort->fitAll(); + emit vpTransformationFinished ( LEFTVIEW ); +} + +/*! + \brief Perform "right view" transformation. +*/ +void XGUI_ViewWindow::rightView() +{ + emit vpTransformationStarted ( RIGHTVIEW ); + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos); + myViewPort->fitAll(); + emit vpTransformationFinished ( RIGHTVIEW ); +} diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 1d794e94d..0938e1b97 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -18,6 +18,7 @@ class XGUI_Viewer; class ViewerToolbar; class ViewerLabel; class XGUI_RectRubberBand; +class QMdiSubWindow; class XGUI_ViewWindow : public QFrame { @@ -44,10 +45,12 @@ public: XGUI_ViewBackground background() const; void setBackground( const XGUI_ViewBackground& theBackground ); + bool closable() const { return myClosable; } + void setClosable( const bool isClosable ) { myClosable = isClosable; } + signals: void vpTransformationStarted(XGUI_ViewWindow::OperationType type); void vpTransformationFinished(XGUI_ViewWindow::OperationType type); - //void viewCloned( XGUI_ViewWindow* ); void Show( QShowEvent * ); void Hide( QHideEvent * ); @@ -56,21 +59,35 @@ signals: void tryClosing( XGUI_ViewWindow* ); - void closing( XGUI_ViewWindow* ); + void closed( QMdiSubWindow* ); void mousePressed( XGUI_ViewWindow*, QMouseEvent* ); void mouseReleased( XGUI_ViewWindow*, QMouseEvent* ); void mouseDoubleClicked( XGUI_ViewWindow*, QMouseEvent* ); void mouseMoving( XGUI_ViewWindow*, QMouseEvent* ); - void wheeling( XGUI_ViewWindow*, QWheelEvent* ); void keyPressed( XGUI_ViewWindow*, QKeyEvent* ); void keyReleased( XGUI_ViewWindow*, QKeyEvent* ); void contextMenuRequested( QContextMenuEvent *e ); + void viewModified( XGUI_ViewWindow* ); + void viewCloned( QMdiSubWindow* theView ); public slots: void activateZoom(); void activateRotation(); void activatePanning(); + void activateWindowFit(); + void activateGlobalPanning(); + + void cloneView(); + void dumpView(); + void fitAll(); + + void frontView(); + void backView(); + void topView(); + void bottomView(); + void leftView(); + void rightView(); protected: virtual void resizeEvent(QResizeEvent* theEvent); @@ -147,6 +164,7 @@ private: bool myCursorIsHand; bool myIsKeyFree; bool myEventStarted; // set when transformation is in process + bool myClosable; QCursor myCursor; diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 77b61acca..c8cd002b9 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -90,7 +90,8 @@ QObject(theParent), myMultiSelectionEnabled(true), myIsRelative(true), myInteractionStyle(XGUI::STANDARD), - myTrihedronSize(100) + myTrihedronSize(100), + myActiveView(0) { if ( !isInitialized ) { isInitialized = true; @@ -173,13 +174,16 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType) // set default background for view window //vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here) //// connect signal from viewport - connect(view->viewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed())); - connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped())); + //connect(view->viewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed())); + //connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped())); + if (myViews.size() == 0) + setTrihedronShown(true); view->setBackground(XGUI_ViewBackground(XGUI::VerticalGradient, Qt::green, Qt::blue)); QMdiArea* aMDI = myMainWindow->mdiArea(); QMdiSubWindow* aWnd = aMDI->addSubWindow(view, Qt::FramelessWindowHint); + addView(aWnd); aWnd->setGeometry(0,0, aMDI->width() / 2, aMDI->height() / 2); aWnd->show(); return aWnd; @@ -333,19 +337,86 @@ bool XGUI_Viewer::computeTrihedronSize( double& theNewSize, double& theSize ) } -void XGUI_Viewer::onViewClosed() +void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView) { - Standard_Integer aViewsNb = 0; - for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews()) - ++aViewsNb; - if ( aViewsNb < 2 ) { - //clean up presentations before last view is closed - myAISContext->RemoveAll(Standard_False); - } + if ( !theView ) + return; + + emit deleteView( static_cast(theView->widget()) ); + removeView( theView ); + + // if this is last view + if (myViews.size() == 0) { + Standard_Integer aViewsNb = 0; + for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews()) + ++aViewsNb; + if ( aViewsNb < 2 ) { + //clean up presentations before last view is closed + myAISContext->RemoveAll(Standard_False); + } + } +} + +/*!Remove view window \a theView from view manager. + *And close the last view, if it has \a theView. +*/ +void XGUI_Viewer::removeView( QMdiSubWindow* theView ) +{ + XGUI_ViewWindow* aWindow = static_cast(theView->widget()); + + aWindow->disconnect( this ); + myViews.removeAt( myViews.indexOf( theView ) ); + if ( myActiveView == theView ) + myActiveView = 0; + if ( myViews.size() == 0 ) + emit lastViewClosed(); } -void XGUI_Viewer::onViewMapped() + +/*void XGUI_Viewer::onViewMapped() { setTrihedronShown( true ); +}*/ + + +void XGUI_Viewer::addView(QMdiSubWindow* theView) +{ + XGUI_ViewWindow* aWindow = dynamic_cast(theView->widget()); + + connect(aWindow, SIGNAL(closed(QMdiSubWindow*)), + this, SLOT(onViewClosed(QMdiSubWindow*))); + + connect(aWindow, SIGNAL(tryClosing(XGUI_ViewWindow*)), + this, SIGNAL(tryCloseView(XGUI_ViewWindow*))); + + connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*))); + + connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)), + this, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*))); + + connect(aWindow, SIGNAL(mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*)), + this, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*))); + + connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), + this, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*))); + + connect(aWindow, SIGNAL(keyPressed(XGUI_ViewWindow*, QKeyEvent*)), + this, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*))); + + connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)), + this, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*))); + + connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )), + this, SLOT (onContextMenuRequested( QContextMenuEvent* ))); + + myViews.append(theView); } +/*! + Emit activated for view \a view. +*/ +void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view) +{ + myActiveView = view; +} diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 78cfe55a5..92bc53192 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -13,6 +14,9 @@ class XGUI_MainWindow; class QMdiSubWindow; +class XGUI_ViewWindow; +class QMouseEvent; +class QKeyEvent; class XGUI_Viewer : public QObject { @@ -58,9 +62,29 @@ public: static InteractionStyle2StatesMap myStateMap; static InteractionStyle2ButtonsMap myButtonMap; +signals: + void lastViewClosed(); + void tryCloseView(XGUI_ViewWindow* theWindow); + void deleteView(XGUI_ViewWindow* theWindow); + void viewCreated(XGUI_ViewWindow* theWindow); + void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); + void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); + void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); + void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); + void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent); + void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent); + void activated(XGUI_ViewWindow* theWindow); + private slots: - void onViewClosed(); - void onViewMapped(); + void onViewClosed(QMdiSubWindow*); + //void onViewMapped(); + void onWindowActivated(QMdiSubWindow*); + +private: + void addView(QMdiSubWindow* theView); + + /*! Removes the View from internal Views list.*/ + void removeView(QMdiSubWindow* theView); private: XGUI_MainWindow* myMainWindow; @@ -77,6 +101,10 @@ private: bool myIsRelative; double myTrihedronSize; + + QList myViews; + + QMdiSubWindow* myActiveView; }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_msg_en.ts b/src/XGUI/XGUI_msg_en.ts index 55984e580..f9090d15d 100644 --- a/src/XGUI/XGUI_msg_en.ts +++ b/src/XGUI/XGUI_msg_en.ts @@ -156,4 +156,67 @@ Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs) + + XGUI_ViewWindow + + OCC_IMAGE_FILES + Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps) + + + DUMP_VIEW + Dump view + + + FIT_ALL + Fit all + + + FIT_AREA + Fit area + + + CLONE_VIEW + Clone view + + + ZOOM_VIEW + Zoom + + + PAN_VIEW + Panning + + + GLOB_PAN_VIEW + Global panning + + + ROTATE_VIEW + Rotate + + + FRONT_VIEW + Front + + + BACK_VIEW + Back + + + TOP_VIEW + Top + + + BOTTOM_VIEW + Bottom + + + LEFT_VIEW + Left + + + RIGHT_VIEW + Right + +