Salome HOME
0023093: [CEA 1399] Perspective view in OCC view
authorvsr <vsr@opencascade.com>
Wed, 10 Jun 2015 08:57:43 +0000 (11:57 +0300)
committervsr <vsr@opencascade.com>
Wed, 10 Jun 2015 08:57:43 +0000 (11:57 +0300)
16 files changed:
src/LightApp/LightApp_Application.cxx
src/OCCViewer/CMakeLists.txt
src/OCCViewer/OCCViewer_Utilities.cxx
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/OCCViewer_msg_fr.ts
src/OCCViewer/resources/OCCViewer_msg_ja.ts
src/OCCViewer/resources/occ_view_orthographic.png [new file with mode: 0755]
src/OCCViewer/resources/occ_view_perspective.png [new file with mode: 0755]

index 4064fb3d27aa89c876a7d5460aeb8af764f80199..cfd1358618c56132330a2186cd08dd3bdba31c45 100644 (file)
@@ -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 <<start>>
   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 <<start>>
   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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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 );
index 4afead732a202cc8e4a7aec8526ebf8d3c222e05..e3282c54c6150b7602d1a7b1fff9b1c96548843b 100755 (executable)
@@ -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
index 4184c843f71359593866bc7412170790fb990d5c..2818884c390688c02d33a285450d2a4f21c6545c 100755 (executable)
@@ -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();
index f11cd402cbf716ada2eecc81d460514f1e39bda9..9ebb0cdf228f9e3e3eb4aa78ab9fedaf0c30c7dc 100644 (file)
@@ -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 ) 
 { 
index 5dd67574bc898892988abefbf6f3fa82d226daa2..a8ef4b2ac5910ed269b2a8c59eafa54ef3034d13 100644 (file)
@@ -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 );
 
index d7eae71b8e218e1880be08f8efc94bb9277f26d6..d8feb5d21ce801209b9433800713d830b96dbe42 100755 (executable)
@@ -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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win )
+      win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
+  }
+}
+
 /*!
   \return zooming style
 */
index cf4b6cf9694b1a4ffcd1a8feb3a1e86693c262ce..6bd1e12710244969e234ca0d420434f9386713b0 100755 (executable)
@@ -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;
index a60ec0e62b6b08bdb13168552d42cb723fc5b471..7fa8797e2038e772e9f2b2e32e3679889da4b9f5 100755 (executable)
@@ -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();
   }
 }
 
index 7d357e1927336db0bbba59fc5ca8ce5f87dc91e4..c7d66be64b2ee124868822988a175c4e788cd844 100755 (executable)
@@ -57,6 +57,7 @@
 #include <QKeyEvent>
 #include <QMouseEvent>
 #include <QApplication>
+#include <QActionGroup>
 #include <QMenu>
 
 #include <AIS_ListOfInteractive.hxx>
@@ -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<QtxAction*>( 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<QtxAction*>( 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);
index 088249714aaa3d344fc6d20120fd50ff800ef7f9..c0a0237715f49cdcf90942aff477cc060bc035ba 100755 (executable)
@@ -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();
index 7e9c06f22a342c242e87680ab8444c422675621d..74b1e9f567721636aeb62018a9857232a07b8fcd 100644 (file)
         <source>ICON_OCCVIEWER_SELECTION</source>
         <translation>occ_view_selection.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_ORTHOGRAPHIC</source>
+        <translation>occ_view_orthographic.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_PERSPECTIVE</source>
+        <translation>occ_view_perspective.png</translation>
+    </message>
 </context>
 </TS>
index e15325b09011a08f7fd159ab8345ec323bf1dbe4..a533aa166029cf35c03e76e106e559c03cf414ef 100644 (file)
         <source>LBL_3DTOOLBAR_LABEL</source>
         <translation>3D View Operations</translation>
     </message>
+    <message>
+        <source>MNU_ORTHOGRAPHIC_MODE</source>
+        <translation>Orthographic projection</translation>
+    </message>
+    <message>
+        <source>DSC_ORTHOGRAPHIC_MODE</source>
+        <translation>Set the orthographic projection type</translation>
+    </message>
+    <message>
+        <source>MNU_PERSPECTIVE_MODE</source>
+        <translation>Perspective projection</translation>
+    </message>
+    <message>
+        <source>DSC_PERSPECTIVE_MODE</source>
+        <translation>Set the perspective projection type</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
index 9e78d01f1cedb42ccccace109b7447a7847a8b05..250a2f447d37f1808ccec10f27b48a43fbe933a7 100755 (executable)
         <source>LBL_3DTOOLBAR_LABEL</source>
         <translation>Opérations sur la vue 3D</translation>
     </message>
+    <message>
+        <source>MNU_ORTHOGRAPHIC_MODE</source>
+        <translation>Mode orthogonal</translation>
+    </message>
+    <message>
+        <source>DSC_ORTHOGRAPHIC_MODE</source>
+        <translation>Choisir la projection orthogonale</translation>
+    </message>
+    <message>
+        <source>MNU_PERSPECTIVE_MODE</source>
+        <translation>Mode perspective</translation>
+    </message>
+    <message>
+        <source>DSC_PERSPECTIVE_MODE</source>
+        <translation>Choisir la projection en perspective</translation>
+    </message>
+</context>
 </context>
 <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
index 406cb87748bfe89d9e2d6e832d6ecfd5581f02b5..f88b6b5dabe018025239abd7c8366faca1e72258 100644 (file)
       <source>LBL_3DTOOLBAR_LABEL</source>
       <translation>3D ビューの操作</translation>
     </message>
+    <message>
+      <source>MNU_ORTHOGRAPHIC_MODE</source>
+      <translation>直交モード</translation>
+    </message>
+    <message>
+      <source>DSC_ORTHOGRAPHIC_MODE</source>
+      <translation>直交射影を選択します。</translation>
+    </message>
+    <message>
+      <source>MNU_PERSPECTIVE_MODE</source>
+      <translation>遠近法</translation>
+    </message>
+    <message>
+      <source>DSC_PERSPECTIVE_MODE</source>
+      <translation>透視投影を選択します。</translation>
+    </message>
   </context>
   <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
diff --git a/src/OCCViewer/resources/occ_view_orthographic.png b/src/OCCViewer/resources/occ_view_orthographic.png
new file mode 100755 (executable)
index 0000000..dd7a676
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_orthographic.png differ
diff --git a/src/OCCViewer/resources/occ_view_perspective.png b/src/OCCViewer/resources/occ_view_perspective.png
new file mode 100755 (executable)
index 0000000..36cdd4c
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_perspective.png differ