Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / SOCC / SOCC_ViewWindow.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "SOCC_ViewWindow.h"
20
21 #include "OCCViewer_ViewPort3d.h"
22
23 #include "SUIT_Accel.h"
24
25 /*!
26   Constructor
27 */
28 SOCC_ViewWindow
29 ::SOCC_ViewWindow( SUIT_Desktop* theDesktop, 
30                    OCCViewer_Viewer* theModel)
31   : OCCViewer_ViewWindow( theDesktop, theModel )
32 {
33 }
34
35 /*!
36   Destructor
37 */
38 SOCC_ViewWindow
39 ::~SOCC_ViewWindow()
40 {
41 }
42
43 /*!
44   Performs action
45   \param theAction - type of action
46 */
47 bool 
48 SOCC_ViewWindow
49 ::action( const int theAction  )
50 {
51   const int inc = 10;
52   int cx, cy;
53   if ( theAction == SUIT_Accel::ZoomIn || theAction == SUIT_Accel::ZoomOut ||
54        theAction == SUIT_Accel::RotateLeft || theAction == SUIT_Accel::RotateRight ||
55        theAction == SUIT_Accel::RotateUp || theAction == SUIT_Accel::RotateDown ) {
56     cx = myViewPort->width() / 2;
57     cy = myViewPort->height() / 2;
58   }
59   switch ( theAction ) {
60   case SUIT_Accel::PanLeft     : 
61     myViewPort->pan( -inc, 0 );   
62     break;
63   case SUIT_Accel::PanRight    : 
64     myViewPort->pan(  inc, 0 );   
65     break;
66   case SUIT_Accel::PanUp       : 
67     myViewPort->pan( 0, inc );   
68     break;
69   case SUIT_Accel::PanDown     : 
70     myViewPort->pan( 0, -inc );   
71     break;
72   case SUIT_Accel::ZoomIn      : 
73     myViewPort->zoom( cx, cy, cx + inc, cy + inc );
74     break;
75   case SUIT_Accel::ZoomOut     : 
76     myViewPort->zoom( cx, cy, cx - inc, cy - inc );
77     break;
78   case SUIT_Accel::ZoomFit     :
79     myViewPort->fitAll();
80     break;
81   case SUIT_Accel::RotateLeft  : 
82     myViewPort->startRotation( cx, cy );
83     myViewPort->rotate( cx - inc, cy );
84     myViewPort->endRotation();
85     break;
86   case SUIT_Accel::RotateRight :  
87     myViewPort->startRotation( cx, cy );
88     myViewPort->rotate( cx + inc, cy );
89     myViewPort->endRotation();
90     break;
91   case SUIT_Accel::RotateUp    :  
92     myViewPort->startRotation( cx, cy );
93     myViewPort->rotate( cx, cy - inc );
94     myViewPort->endRotation();
95     break;
96   case SUIT_Accel::RotateDown  :  
97     myViewPort->startRotation( cx, cy );
98     myViewPort->rotate( cx, cy + inc );
99     myViewPort->endRotation();
100     break;
101   }
102   return true;
103 }