From 07de5d036742b1170524b3f82fbeb40973e81f3b Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 10 Jun 2015 11:57:43 +0300 Subject: [PATCH] 0023093: [CEA 1399] Perspective view in OCC view --- src/LightApp/LightApp_Application.cxx | 29 ++++ src/OCCViewer/CMakeLists.txt | 2 + src/OCCViewer/OCCViewer_Utilities.cxx | 2 + src/OCCViewer/OCCViewer_ViewFrame.cxx | 14 ++ src/OCCViewer/OCCViewer_ViewFrame.h | 3 + src/OCCViewer/OCCViewer_ViewModel.cxx | 32 ++++ src/OCCViewer/OCCViewer_ViewModel.h | 4 + src/OCCViewer/OCCViewer_ViewPort3d.cxx | 3 +- src/OCCViewer/OCCViewer_ViewWindow.cxx | 142 +++++++++++++----- src/OCCViewer/OCCViewer_ViewWindow.h | 13 +- src/OCCViewer/resources/OCCViewer_images.ts | 8 + src/OCCViewer/resources/OCCViewer_msg_en.ts | 16 ++ src/OCCViewer/resources/OCCViewer_msg_fr.ts | 17 +++ src/OCCViewer/resources/OCCViewer_msg_ja.ts | 16 ++ .../resources/occ_view_orthographic.png | Bin 0 -> 878 bytes .../resources/occ_view_perspective.png | Bin 0 -> 831 bytes 16 files changed, 258 insertions(+), 43 deletions(-) create mode 100755 src/OCCViewer/resources/occ_view_orthographic.png create mode 100755 src/OCCViewer/resources/occ_view_perspective.png diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4064fb3d2..cfd135861 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1533,6 +1533,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ), resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() )); vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) ); + vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) ); vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) ); vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) ); vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) ); @@ -2297,6 +2298,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .. "OCC viewer" group <> int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat ); + // .... -> projection mode + int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup, + LightApp_Preferences::Selector, "OCCViewer", "projection_mode" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE"); + anIndicesList << 0 << 1; + pref->setItemProperty( "strings", aValuesList, occProjMode ); + pref->setItemProperty( "indexes", anIndicesList, occProjMode ); // ... "Background" group <> int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup ); // pref->setItemProperty( "columns", 2, bgGroup ); @@ -2951,6 +2961,25 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setProjectionType( mode ); + } + } +#endif + if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) ) { int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 ); diff --git a/src/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index 4afead732..e3282c54c 100755 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -122,7 +122,9 @@ SET(_other_RESOURCES resources/occ_view_left.png resources/occ_view_maximized.png resources/occ_view_minimized.png + resources/occ_view_orthographic.png resources/occ_view_pan.png + resources/occ_view_perspective.png resources/occ_view_preselection.png resources/occ_view_presets.png resources/occ_view_reset.png diff --git a/src/OCCViewer/OCCViewer_Utilities.cxx b/src/OCCViewer/OCCViewer_Utilities.cxx index 4184c843f..2818884c3 100755 --- a/src/OCCViewer/OCCViewer_Utilities.cxx +++ b/src/OCCViewer/OCCViewer_Utilities.cxx @@ -102,6 +102,8 @@ OCCViewer_ViewWindow::Mode2dType OCCViewer_Utilities::setViewer2DMode << OCCViewer_ViewWindow::RightId << OCCViewer_ViewWindow::AntiClockWiseId << OCCViewer_ViewWindow::ClockWiseId + << OCCViewer_ViewWindow::OrthographicId + << OCCViewer_ViewWindow::PerspectiveId << OCCViewer_ViewWindow::ResetId; QtxActionToolMgr* aToolMgr = aView->toolMgr(); diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index f11cd402c..9ebb0cdf2 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -314,6 +314,20 @@ void OCCViewer_ViewFrame::setInteractionStyle( const int i ) } } +//************************************************************************************** +int OCCViewer_ViewFrame::projectionType() const +{ + return getView(MAIN_VIEW)->projectionType(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setProjectionType( int t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setProjectionType(t); + } +} + //************************************************************************************** void OCCViewer_ViewFrame::setZoomingStyle( const int i ) { diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 5dd67574b..a8ef4b2ac 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -70,6 +70,9 @@ public: virtual int interactionStyle() const { return getView(MAIN_VIEW)->interactionStyle(); } virtual void setInteractionStyle( const int i ); + virtual int projectionType() const; + virtual void setProjectionType( int ); + virtual int zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); } virtual void setZoomingStyle( const int ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index d7eae71b8..d8feb5d21 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -152,6 +152,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) mySelectionEnabled = true; myMultiSelectionEnabled = true; + // set projection type to orthographic + myProjectionType = 0; + //set clipping color and texture to standard myClippingColor = QColor( 50, 50, 50 ); myDefaultTextureUsed = true; @@ -215,6 +218,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->initLayout(); view->initSketchers(); view->setInteractionStyle( interactionStyle() ); + view->setProjectionType( projectionType() ); view->setZoomingStyle( zoomingStyle() ); view->enablePreselection( isPreselectionEnabled() ); view->enableSelection( isSelectionEnabled() ); @@ -475,6 +479,34 @@ void OCCViewer_Viewer::setInteractionStyle( const int theStyle ) } } +/*! + \return projection type +*/ +int OCCViewer_Viewer::projectionType() const +{ + return myProjectionType; +} + +/*! + Sets projection type: 0 - orthographic, 1 - perspective + \param theType - new projection type +*/ +void OCCViewer_Viewer::setProjectionType( const int theType ) +{ + myProjectionType = theType; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType ); + } +} + /*! \return zooming style */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index cf4b6cf96..6bd1e1271 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -133,6 +133,9 @@ public: int interactionStyle() const; void setInteractionStyle( const int ); + int projectionType() const; + void setProjectionType( const int ); + int zoomingStyle() const; void setZoomingStyle( const int ); @@ -208,6 +211,7 @@ protected: int myInteractionStyle; int myZoomingStyle; + int myProjectionType; bool myPreselectionEnabled; bool mySelectionEnabled; diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index a60ec0e62..7fa8797e2 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -522,7 +522,8 @@ void OCCViewer_ViewPort3d::startRotation( int x, int y, default: break; } - activeView()->DepthFitAll(); + // VSR: 10.06.2015: next line commented out - causes ugly blinking on starting rotation with Perspective projection mode + //activeView()->DepthFitAll(); } } diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 7d357e192..c7d66be64 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -236,7 +237,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myScalingDlg = 0; mySetRotationPointDlg = 0; myRectBand = 0; - + IsSketcherStyle = false; myIsKeyFree = false; @@ -251,7 +252,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myCursorIsHand = false; clearViewAspects(); - + } /*! @@ -300,7 +301,7 @@ void OCCViewer_ViewWindow::initLayout() QtxAction* anAction = dynamic_cast( toolMgr()->action( GraduatedAxesId ) ); myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" ); myCubeAxesDlg->initialize(); - + connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) ); } @@ -364,7 +365,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) case QEvent::Wheel: { QWheelEvent* aEvent = (QWheelEvent*) e; - + if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); if ( isPreselectionEnabled() && ic->HasOpenedContext() ) { @@ -426,10 +427,10 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) int anInteractionStyle = interactionStyle(); // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed), - // which are assigned for pan and rotate - these operations are activated immediately after pressing + // which are assigned for pan and rotate - these operations are activated immediately after pressing // of the first button, so it is necessary to switch to zoom when the second button is pressed bool aSwitchToZoom = false; - if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && + if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && ( myOperation == PANVIEW || myOperation == ROTATE ) ) { aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW; } @@ -870,7 +871,7 @@ bool OCCViewer_ViewWindow::setTransformRequested( OperationType op ) { bool ok = transformEnabled( op ); myOperation = ok ? op : NOTHING; - myViewPort->setMouseTracking( myOperation == NOTHING ); + myViewPort->setMouseTracking( myOperation == NOTHING ); return ok; } @@ -1106,7 +1107,7 @@ void OCCViewer_ViewWindow::drawRect() //myRectBand->setPalette(palette); } //myRectBand->hide(); - + myRectBand->setUpdatesEnabled ( false ); QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); myRectBand->initGeometry( aRect ); @@ -1146,7 +1147,7 @@ void OCCViewer_ViewWindow::createActions() { if( !toolMgr()->isEmpty() ) return; - + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QtxAction* aAction; @@ -1171,7 +1172,7 @@ void OCCViewer_ViewWindow::createActions() aAction->setStatusTip(tr("DSC_FITRECT")); connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit())); toolMgr()->registerAction( aAction, FitRectId ); - + // FitSelection aAction = new QtxAction(tr("MNU_FITSELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITSELECTION" ) ), tr( "MNU_FITSELECTION" ), 0, this); @@ -1243,7 +1244,7 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView())); this->addAction(aAction); toolMgr()->registerAction( aAction, BottomId ); - + aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ), tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view"); aAction->setStatusTip(tr("DSC_LEFT_VIEW")); @@ -1274,6 +1275,30 @@ void OCCViewer_ViewWindow::createActions() this->addAction(aAction); toolMgr()->registerAction( aAction, ClockWiseId ); + // Projection mode group + + // - orthographic projection + aAction = new QtxAction(tr("MNU_ORTHOGRAPHIC_MODE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ORTHOGRAPHIC" ) ), + tr( "MNU_ORTHOGRAPHIC_MODE" ), 0, this); + aAction->setStatusTip(tr("DSC_ORTHOGRAPHIC_MODE")); + aAction->setCheckable(true); + //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); + toolMgr()->registerAction( aAction, OrthographicId ); + + // - perspective projection + aAction = new QtxAction(tr("MNU_PERSPECTIVE_MODE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PERSPECTIVE" ) ), + tr( "MNU_PERSPECTIVE_MODE" ), 0, this); + aAction->setStatusTip(tr("DSC_PERSPECTIVE_MODE")); + aAction->setCheckable(true); + //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); + toolMgr()->registerAction( aAction, PerspectiveId ); + + // - add exclusive action group + QActionGroup* aProjectionGroup = new QActionGroup( this ); + aProjectionGroup->addAction( toolMgr()->action( OrthographicId ) ); + aProjectionGroup->addAction( toolMgr()->action( PerspectiveId ) ); + connect(aProjectionGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionType())); + // Reset aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ), tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view"); @@ -1342,7 +1367,7 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool))); toolMgr()->registerAction( aAction, SwitchSelectionId ); - // Graduated axes + // Graduated axes aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ), tr( "MNU_GRADUATED_AXES" ), 0, this); aAction->setStatusTip(tr("DSC_GRADUATED_AXES")); @@ -1388,7 +1413,7 @@ void OCCViewer_ViewWindow::createActions() toolMgr()->registerAction( aAction, ReturnTo3dViewId ); } - // Synchronize View + // Synchronize View toolMgr()->registerAction( synchronizeAction(), SynchronizeId ); } @@ -1454,6 +1479,9 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( AntiClockWiseId, tid ); toolMgr()->append( ClockWiseId, tid ); + toolMgr()->append( OrthographicId, tid ); + toolMgr()->append( PerspectiveId, tid ); + toolMgr()->append( ResetId, tid ); } @@ -1464,7 +1492,7 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( toolMgr()->separator(), tid ); toolMgr()->append( CloneId, tid ); - + toolMgr()->append( toolMgr()->separator(), tid ); toolMgr()->append( ClippingId, tid ); toolMgr()->append( AxialScaleId, tid ); @@ -1587,10 +1615,23 @@ void OCCViewer_ViewWindow::onResetView() myViewPort->getView()->Reset( false ); myViewPort->fitAll( false, true, false ); myViewPort->getView()->SetImmediateUpdate( upd ); + onProjectionType(); // needed to apply projection type properly after reset myViewPort->getView()->Update(); emit vpTransformationFinished( RESETVIEW ); } +/*! + \brief Perform "reset view" transformation. + + Sets default orientation of the viewport camera. +*/ +void OCCViewer_ViewWindow::onProjectionType() +{ + emit vpTransformationStarted( PROJECTION ); + setProjectionType( toolMgr()->action( OrthographicId )->isChecked() ? Orthographic : Perspective ); + emit vpTransformationFinished( PROJECTION ); +} + /*! \brief Perform "fit all" transformation. */ @@ -1663,7 +1704,7 @@ void OCCViewer_ViewWindow::onAxialScale() { if ( !myScalingDlg ) myScalingDlg = new OCCViewer_AxialScaleDlg( this ); - + if ( !myScalingDlg->isVisible() ) { myScalingDlg->Update(); @@ -1766,7 +1807,7 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base myModel->setTrihedronShown( anItem.isVisible ); myModel->setTrihedronSize( anItem.size ); - + // graduated trihedron bool anIsVisible = anItem.gtIsVisible; OCCViewer_AxisWidget::AxisData anAxisData[3]; @@ -1861,7 +1902,7 @@ void OCCViewer_ViewWindow::onSwitchSelection( bool on ) { mySelectionEnabled = on; myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() ); - + // update action state if method is called outside // preselection @@ -1948,13 +1989,13 @@ QImage OCCViewer_ViewWindow::dumpView() Handle(V3d_View) view = myViewPort->getView(); if ( view.IsNull() ) return QImage(); - + int aWidth = myViewPort->width(); int aHeight = myViewPort->height(); // rnv: An old approach to dump the OCCViewer content // Now used OCCT built-in procedure. - /* + /* QApplication::syncX(); view->Redraw(); // In order to reactivate GL context //view->Update(); @@ -1963,7 +2004,7 @@ QImage OCCViewer_ViewWindow::dumpView() if( aFrameBuffer.init( aWidth, aHeight ) ) { QImage anImage( aWidth, aHeight, QImage::Format_RGB32 ); - + glPushAttrib( GL_VIEWPORT_BIT ); glViewport( 0, 0, aWidth, aHeight ); aFrameBuffer.bind(); @@ -1992,7 +2033,7 @@ QImage OCCViewer_ViewWindow::dumpView() glReadPixels( p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data); */ - + Image_PixMap aPix; view->ToPixMap(aPix,aWidth, aHeight,Graphic3d_BT_RGBA); @@ -2001,8 +2042,8 @@ QImage OCCViewer_ViewWindow::dumpView() return anImage; } -bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, - const QString& fileName, +bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img, + const QString& fileName, const QString& format ) { if ( format != "PS" && format != "EPS") @@ -2052,7 +2093,7 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const doub gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz)); double a, b, c, d; pln.Coefficients(a, b, c, d); - + Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes(); if(aPlanes.Size() > 0 ) { Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes); @@ -2459,7 +2500,7 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) params.isVisible = data.count() > idx ? data[idx++].toInt() : 1; params.size = data.count() > idx ? data[idx++].toDouble() : 100.0; } - performRestoring( params ); + performRestoring( params ); setBackground( bgData ); myModel->setClipPlanes(aClipPlanes); } @@ -2703,8 +2744,8 @@ void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) QAction* anAction2 = toolMgr()->action( ReturnTo3dViewId ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); if ( toMaximize ) { - anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) ); - anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) ); + anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) ); + anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) ); anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) ); anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) ); if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId ); @@ -2713,8 +2754,8 @@ void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) } } else { - anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) ); - anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) ); + anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) ); + anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) ); anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) ); anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) ); if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId ); @@ -2730,13 +2771,13 @@ bool OCCViewer_ViewWindow::isMaximized() const } void OCCViewer_ViewWindow::setSketcherStyle( bool enable ) -{ - IsSketcherStyle = enable; +{ + IsSketcherStyle = enable; } -bool OCCViewer_ViewWindow::isSketcherStyle() const -{ - return IsSketcherStyle; +bool OCCViewer_ViewWindow::isSketcherStyle() const +{ + return IsSketcherStyle; } @@ -2745,12 +2786,37 @@ void OCCViewer_ViewWindow::set2dMode(Mode2dType theType) my2dMode = theType; } -// obsolete +void OCCViewer_ViewWindow::setProjectionType( int mode ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + aCamera->SetProjectionType( mode == Perspective ? Graphic3d_Camera::Projection_Perspective : Graphic3d_Camera::Projection_Orthographic ); + onViewFitAll(); + } + // update action state if method is called outside + QtxAction* a = dynamic_cast( toolMgr()->action( mode == Orthographic ? OrthographicId : PerspectiveId ) ); + if ( ! a->isChecked() ) + a->setChecked( true ); +} + +int OCCViewer_ViewWindow::projectionType() const +{ + int mode = Orthographic; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + mode = aCamera->ProjectionType() == Graphic3d_Camera::Projection_Perspective ? Perspective : Orthographic; + } + return mode; +} + +// obsolete QColor OCCViewer_ViewWindow::backgroundColor() const { return myViewPort ? myViewPort->backgroundColor() : Qt::black; } - + // obsolete void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor ) { @@ -2761,7 +2827,7 @@ Qtx::BackgroundData OCCViewer_ViewWindow::background() const { return myViewPort ? myViewPort->background() : Qtx::BackgroundData(); } - + void OCCViewer_ViewWindow::setBackground( const Qtx::BackgroundData& theBackground ) { if ( myViewPort ) myViewPort->setBackground( theBackground ); @@ -3063,7 +3129,7 @@ void OCCViewer_ViewWindow::onClipping (bool theIsOn) { if(!myModel) return; OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg(); - + if (theIsOn) { if (!aClippingDlg) { aClippingDlg = new OCCViewer_ClippingDlg (this, myModel); diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 088249714..c0a023771 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -151,20 +151,22 @@ public: SwitchInteractionStyleId, SwitchZoomingStyleId, SwitchPreselectionId, SwitchSelectionId, MaximizedId, SynchronizeId, ReturnTo3dViewId, + OrthographicId, PerspectiveId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW, FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW, - CLOCKWISEVIEW, ANTICLOCKWISEVIEW }; + CLOCKWISEVIEW, ANTICLOCKWISEVIEW, PROJECTION }; enum RotationPointType{ GRAVITY, SELECTED }; enum SketchingType { NoSketching, Rect, Polygon }; - enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; - + enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane }; + enum ProjectionType { Orthographic, Perspective }; + OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); @@ -206,10 +208,12 @@ public: virtual bool isSelectionEnabled() const; virtual void enableSelection( bool ); + virtual int projectionType() const; + virtual void setProjectionType( int ); + void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; - void set2dMode( Mode2dType ); Mode2dType get2dMode() const { return my2dMode; } @@ -246,6 +250,7 @@ public slots: virtual void onRightView(); virtual void onClockWiseView(); virtual void onAntiClockWiseView(); + virtual void onProjectionType(); virtual void onResetView(); virtual void onFitAll(); virtual void onFitSelection(); diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index 7e9c06f22..74b1e9f56 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -139,5 +139,13 @@ ICON_OCCVIEWER_SELECTION occ_view_selection.png + + ICON_OCCVIEWER_ORTHOGRAPHIC + occ_view_orthographic.png + + + ICON_OCCVIEWER_PERSPECTIVE + occ_view_perspective.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index e15325b09..a533aa166 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -296,6 +296,22 @@ LBL_3DTOOLBAR_LABEL 3D View Operations + + MNU_ORTHOGRAPHIC_MODE + Orthographic projection + + + DSC_ORTHOGRAPHIC_MODE + Set the orthographic projection type + + + MNU_PERSPECTIVE_MODE + Perspective projection + + + DSC_PERSPECTIVE_MODE + Set the perspective projection type + OCCViewer_CreateRestoreViewDlg diff --git a/src/OCCViewer/resources/OCCViewer_msg_fr.ts b/src/OCCViewer/resources/OCCViewer_msg_fr.ts index 9e78d01f1..250a2f447 100755 --- a/src/OCCViewer/resources/OCCViewer_msg_fr.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_fr.ts @@ -296,6 +296,23 @@ LBL_3DTOOLBAR_LABEL Opérations sur la vue 3D + + MNU_ORTHOGRAPHIC_MODE + Mode orthogonal + + + DSC_ORTHOGRAPHIC_MODE + Choisir la projection orthogonale + + + MNU_PERSPECTIVE_MODE + Mode perspective + + + DSC_PERSPECTIVE_MODE + Choisir la projection en perspective + + OCCViewer_CreateRestoreViewDlg diff --git a/src/OCCViewer/resources/OCCViewer_msg_ja.ts b/src/OCCViewer/resources/OCCViewer_msg_ja.ts index 406cb8774..f88b6b5da 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_ja.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_ja.ts @@ -296,6 +296,22 @@ LBL_3DTOOLBAR_LABEL 3D ビューの操作 + + MNU_ORTHOGRAPHIC_MODE + 直交モード + + + DSC_ORTHOGRAPHIC_MODE + 直交射影を選択します。 + + + MNU_PERSPECTIVE_MODE + 遠近法 + + + DSC_PERSPECTIVE_MODE + 透視投影を選択します。 + OCCViewer_CreateRestoreViewDlg diff --git a/src/OCCViewer/resources/occ_view_orthographic.png b/src/OCCViewer/resources/occ_view_orthographic.png new file mode 100755 index 0000000000000000000000000000000000000000..dd7a67600aba030f774e43a65346a159d32974a5 GIT binary patch literal 878 zcmV-!1CjiRP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;c4;gGW_}T2P_BU|N8Zd;rsXR3}3%~WtcHz1|v2D0RjkaAV@JtqpEWT z!#^PX=Pv`pzkiV60FfZ(Um)@O?|+7$zyC3WzJ2?D_3G7}K&ceK=FTI!+!nw&!89C&*0+X@*Sv^1KB`;0D>C` z^2!gOVmYULhGR>r7{2@f8usHa7=Ql$m*MLVgrOjHKY@lCC(UCpH8n*s6d-`$UjFjs z3&S^{OF&*y@@Zh$H7Nlc49I|ykr9kRVGHsRC|p5UUtj92SpNC_gW=E5?+m|xd}X-1xeg?)0K^Xf0toJ9P=tVzB)(J$ zjvSz2|Ns4E`1j{G!{1*ZL%)Ju2?UxzEC3KdOvo<$19TzCcCaQK2_7U0Ht_EshQEJ) z0$utOsQw>FN&pm=00G2;94Wt`2LAa6Nq1l;Gcw{a6k;&cKrjFZAh>~`FayOP#B~f{ zMgRZ*1BM$Dc0<8F_zzZt3;+TMZs6z7pMkFY1`L}&V1=NV{Pp7t&@3i!%tE3B0{;H_ z1rEF4Kfi&)5jl7O0tjy4sZ*yEfBlNMZxk~D=pA74`Td*W`=>WRV;Dj1K#47ofxm&4 z{RSEO;~OkezyKhCSdd)%z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;wMj%lRCwBA{Qv(y12q9a0I|RrjEsy#X{fBM{Qvv+ zZ-!sLelbj%Gzmi!Kmf52V@Pdn?SGI@{{8#MAY_%p@aG=`!*3vw`u+R=*|TSJ0hN4* zsRaliMwpk;U07FF_a9^cNM6J`hvDx(pn*W8Ao|Z=2>uN;_|fJ{h9yguzzqcmAQS_u ztE>OR3>LA@25SOI11X^E{=*IZ10)`Atz`gt{qNtuV7z+uYOtXI0R;DQSy|bCVW4+F z;2+SGpT8jnzzhT7$J^_{F8=f955rekUxt4`gZ};f!@zQHJxH4>5Z?v}Ah>}b?>*b! z%OGM`1lA04#oxaOLqM+hF6RefgDe2@{{s#C`{y?UBajUQdO-XZAb{Wof?`d~v7F)2 zjux;BVBUcl0&+D2I7}J9{Qv)et^?x#|Nk;TgH0HSxc~wPZs5fmjIYS`@?G+#oK876fo6Kmg$^ZIA#b)KC<|q2e%_ z0qTft00Bfyc?fdxQzXNmU@@ElD*g>1fQWG+F)oLN`8$9B0{|1GxpE literal 0 HcmV?d00001 -- 2.39.2