Back to index

salome-gui  6.5.0
SOCC_ViewWindow.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "SOCC_ViewWindow.h"
00024 
00025 #include "OCCViewer_ViewPort3d.h"
00026 
00027 #include "SUIT_Accel.h"
00028 
00032 SOCC_ViewWindow
00033 ::SOCC_ViewWindow( SUIT_Desktop* theDesktop, 
00034                    OCCViewer_Viewer* theModel)
00035   : OCCViewer_ViewWindow( theDesktop, theModel )
00036 {
00037 }
00038 
00042 SOCC_ViewWindow
00043 ::~SOCC_ViewWindow()
00044 {
00045 }
00046 
00051 bool 
00052 SOCC_ViewWindow
00053 ::action( const int theAction  )
00054 {
00055   const int inc = 10;
00056   int cx, cy;
00057   if ( theAction == SUIT_Accel::ZoomIn || theAction == SUIT_Accel::ZoomOut ||
00058        theAction == SUIT_Accel::RotateLeft || theAction == SUIT_Accel::RotateRight ||
00059        theAction == SUIT_Accel::RotateUp || theAction == SUIT_Accel::RotateDown ) {
00060     cx = myViewPort->width() / 2;
00061     cy = myViewPort->height() / 2;
00062   }
00063   switch ( theAction ) {
00064   case SUIT_Accel::PanLeft     : 
00065     myViewPort->pan( -inc, 0 );   
00066     break;
00067   case SUIT_Accel::PanRight    : 
00068     myViewPort->pan(  inc, 0 );   
00069     break;
00070   case SUIT_Accel::PanUp       : 
00071     myViewPort->pan( 0, inc );   
00072     break;
00073   case SUIT_Accel::PanDown     : 
00074     myViewPort->pan( 0, -inc );   
00075     break;
00076   case SUIT_Accel::ZoomIn      : 
00077     myViewPort->zoom( cx, cy, cx + inc, cy + inc );
00078     break;
00079   case SUIT_Accel::ZoomOut     : 
00080     myViewPort->zoom( cx, cy, cx - inc, cy - inc );
00081     break;
00082   case SUIT_Accel::ZoomFit     :
00083     myViewPort->fitAll();
00084     break;
00085   case SUIT_Accel::RotateLeft  : 
00086     myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
00087     myViewPort->rotate( cx - inc, cy, myCurrPointType, mySelectedPoint );
00088     myViewPort->endRotation();
00089     break;
00090   case SUIT_Accel::RotateRight :  
00091     myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
00092     myViewPort->rotate( cx + inc, cy, myCurrPointType, mySelectedPoint );
00093     myViewPort->endRotation();
00094     break;
00095   case SUIT_Accel::RotateUp    :  
00096     myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
00097     myViewPort->rotate( cx, cy - inc, myCurrPointType, mySelectedPoint );
00098     myViewPort->endRotation();
00099     break;
00100   case SUIT_Accel::RotateDown  :  
00101     myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
00102     myViewPort->rotate( cx, cy + inc, myCurrPointType, mySelectedPoint );
00103     myViewPort->endRotation();
00104     break;
00105   }
00106   return true;
00107 }