1143db10b821df4b23efe1b82d3b51cda8bd38a1
[scilab.git] / scilab / modules / renderer / src / cpp / subwinDrawing / Camera.cpp
1 /*------------------------------------------------------------------------*/
2 /* file: Camera.cpp                                                       */
3 /* Copyright INRIA 2007                                                   */
4 /* Authors : Jean-Baptiste Silvy                                          */
5 /* desc : File used to position viewpoint and rendering zone in the       */
6 /*        canvas.                                                         */
7 /*------------------------------------------------------------------------*/
8
9 #include "Camera.h"
10 #include "MALLOC.h"
11
12 namespace sciGraphics
13 {
14
15 /*-----------------------------------------------------------------------------------*/
16 Camera::Camera( void )
17 {
18   m_pImp = NULL;
19 }
20 /*-----------------------------------------------------------------------------------*/
21 Camera::~Camera( void )
22 {
23   if ( m_pImp != NULL )
24   {
25     delete m_pImp;
26   }
27   m_pImp = NULL;
28 }
29 /*-----------------------------------------------------------------------------------*/
30 void Camera::setViewingArea( double axesBounds[4], double margins[4] )
31 {
32   double translation[2] ;
33   // T = Taxes + SizeAxes * [marginLeft, marginTop}.
34   translation[0] = axesBounds[0] + axesBounds[2] * margins[0] ;
35   translation[1] = axesBounds[1] + axesBounds[3] * margins[2] ;
36
37   // S = Saxes - margin.Saxes
38   // where Saxes = [w,h] and margin = [margin_left+margin_right, margin_top+margin_bottom].
39   double scale[2] ;
40   scale[0] = (1.0 - margins[0] - margins[1]) * axesBounds[2] ;
41   scale[1] = (1.0 - margins[2] - margins[3]) * axesBounds[3] ;
42   m_pImp->setViewingArea(translation, scale);
43 }
44 /*-----------------------------------------------------------------------------------*/
45 void Camera::setRotationAngles( double alpha, double theta )
46 {
47   m_pImp->setRotationAngles(alpha, theta);
48 }
49 /*-----------------------------------------------------------------------------------*/
50 void Camera::setSubWinBox( double box[6] )
51 {
52   m_pImp->setSubWinBox(box);
53 }
54 /*-----------------------------------------------------------------------------------*/
55 void Camera::setFarthestDistance( double maxDist )
56 {
57   m_pImp->setFarthestDistance(maxDist);
58 }
59 /*-----------------------------------------------------------------------------------*/
60 void Camera::renderPosition( void )
61 {
62   m_pImp->renderPosition();
63 }
64 /*-----------------------------------------------------------------------------------*/
65
66 }