#include </home/scilab/compilation_chain/sci_checkOut/scilab/modules/renderer/src/cpp/subwinDrawing/CameraJoGL.h>


Public Member Functions | |
| CameraJoGL (Camera *camera) | |
| virtual | ~CameraJoGL (void) |
| virtual void | renderPosition (void) |
| virtual void | show (void) |
| virtual void | redraw (void) |
| virtual void | replaceCamera (void) |
| virtual void | getPixelCoordinates (const double userCoord[3], int pixCoord[2]) |
| virtual void | getPixelCoordinates (const double userCoords[3], double pixCoords[3]) |
| virtual void | getPixelCoordinatesRaw (const double userCoords[3], double pixCoords[3]) |
| virtual void | get2dViewPixelCoordinates (const double userCoord[3], int pixCoord[2]) |
| virtual void | get2dViewPixelCoordinates (const double userCoord[3], double pixCoord[3]) |
| virtual void | getSceneCoordinates (const double pixCoords[3], double userCoords[3]) |
| virtual void | getSceneCoordinatesRaw (const double pixCoords[3], double userCoords[3]) |
| virtual void | get2dViewCoordinates (const int pixCoords[2], double userCoord2D[2]) |
| virtual void | getViewingArea (int *xPos, int *yPos, int *width, int *height) |
| virtual void | getViewport (int viewport[4]) |
Protected Member Functions | |
| void | project (const double projMatrix[4][4], const double viewPort[4], const double sceneCoordinate[3], double pixCoordinate[3]) |
| void | unProject (double unProjMatrix[4][4], double viewPort[4], const double pixCoordinates[3], double sceneCoordinates[3]) |
| CameraJavaMapper * | getCameraJavaMapper (void) |
Protected Attributes | |
| double | m_aProjMatrix3D [4][4] |
| double | m_aUnprojMatrix3D [4][4] |
| double | m_aProjMatrix2D [4][4] |
| double | m_aUnprojMatrix2D [4][4] |
| double | m_aViewPort [4] |
| double | m_aViewingArea [4] |
Definition at line 27 of file CameraJoGL.h.
| sciGraphics::CameraJoGL::CameraJoGL | ( | Camera * | camera | ) |
Default constructor
| camera | corresponding camera |
Definition at line 27 of file CameraJoGL.cpp.
References m_aProjMatrix2D, m_aProjMatrix3D, m_aUnprojMatrix2D, m_aUnprojMatrix3D, m_aViewPort, and setToIdentity().
00028 : CameraBridge(), DrawableObjectJoGL(camera) 00029 { 00030 setToIdentity(m_aProjMatrix2D); 00031 setToIdentity(m_aProjMatrix3D); 00032 setToIdentity(m_aUnprojMatrix2D); 00033 setToIdentity(m_aUnprojMatrix3D); 00034 00035 m_aViewPort[0] = 0.0; 00036 m_aViewPort[1] = 0.0; 00037 m_aViewPort[2] = 0.0; 00038 m_aViewPort[3] = 0.0; 00039 }

| sciGraphics::CameraJoGL::~CameraJoGL | ( | void | ) | [virtual] |
| void sciGraphics::CameraJoGL::renderPosition | ( | void | ) | [virtual] |
Position the view and view area accordingly to previous calls.
Implements sciGraphics::CameraBridge.
Definition at line 46 of file CameraJoGL.cpp.
References sciGraphics::CameraJavaMapper::get2dViewProjectionMatrix(), sciGraphics::CameraJavaMapper::get2dViewUnprojectMatrix(), getCameraJavaMapper(), sciGraphics::DrawableObject::getDrawedObject(), sciGraphics::CameraJavaMapper::getProjectionMatrix(), sciGraphics::CameraJavaMapper::getUnprojectMatrix(), sciGraphics::CameraJavaMapper::getViewPort(), sciGraphics::CameraBridge::m_aAxesFittingScale, sciGraphics::CameraBridge::m_aAxesNormalizationScale, sciGraphics::CameraBridge::m_aAxesReverse, sciGraphics::CameraBridge::m_aAxesTranslation, sciGraphics::CameraBridge::m_aBoxCenter, m_aProjMatrix2D, m_aProjMatrix3D, m_aUnprojMatrix2D, m_aUnprojMatrix3D, sciGraphics::CameraBridge::m_aViewingScale, sciGraphics::CameraBridge::m_aViewingTranslation, m_aViewPort, sciGraphics::CameraBridge::m_dAlpha, sciGraphics::CameraBridge::m_dTheta, sciGraphics::DrawableObjectJoGL::m_pDrawer, sciGraphics::CameraJavaMapper::placeCamera(), sciGetRealDataBounds(), sciGraphics::CameraJavaMapper::setAxesBounds(), sciGraphics::CameraJavaMapper::setAxesReverse(), sciGraphics::CameraJavaMapper::setAxesRotationParameters(), sciGraphics::CameraJavaMapper::setFittingScale(), sciGraphics::CameraJavaMapper::setNormalizationParameters(), and sciGraphics::CameraJavaMapper::setViewingArea().
00047 { 00048 getCameraJavaMapper()->setViewingArea(m_aViewingTranslation[0], m_aViewingTranslation[1], 00049 m_aViewingScale[0], m_aViewingScale[1]) ; 00050 getCameraJavaMapper()->setNormalizationParameters(m_aAxesNormalizationScale[0], m_aAxesNormalizationScale[1], m_aAxesNormalizationScale[2], 00051 m_aAxesTranslation[0], m_aAxesTranslation[1], m_aAxesTranslation[2] ) ; 00052 00053 00054 getCameraJavaMapper()->setAxesRotationParameters(m_aBoxCenter[0], m_aBoxCenter[1], m_aBoxCenter[2], 00055 m_dAlpha, m_dTheta); 00056 00057 getCameraJavaMapper()->setFittingScale(m_aAxesFittingScale[0], m_aAxesFittingScale[1], m_aAxesFittingScale[2]); 00058 00059 getCameraJavaMapper()->setAxesReverse(m_aAxesReverse[0], m_aAxesReverse[1], m_aAxesReverse[2]); 00060 00061 double bounds[6]; 00062 sciGetRealDataBounds(m_pDrawer->getDrawedObject(), bounds); 00063 getCameraJavaMapper()->setAxesBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]); 00064 00065 getCameraJavaMapper()->placeCamera(); 00066 00067 // save camera viewing settings 00068 getCameraJavaMapper()->getProjectionMatrix(m_aProjMatrix3D); 00069 getCameraJavaMapper()->getUnprojectMatrix(m_aUnprojMatrix3D); 00070 getCameraJavaMapper()->get2dViewProjectionMatrix(m_aProjMatrix2D); 00071 getCameraJavaMapper()->get2dViewUnprojectMatrix(m_aUnprojMatrix2D); 00072 getCameraJavaMapper()->getViewPort(m_aViewPort); 00073 00074 }

| void sciGraphics::CameraJoGL::show | ( | void | ) | [virtual] |
Display an object which whose representation has been already saved (ie dl created).
Reimplemented from sciGraphics::DrawableObjectJoGL.
Definition at line 76 of file CameraJoGL.cpp.
References sciGraphics::DrawableObjectJoGL::show().
00077 { 00078 DrawableObjectJoGL::show(); 00079 00080 }

| void sciGraphics::CameraJoGL::redraw | ( | void | ) | [virtual] |
Display the camera using precomputed data
Implements sciGraphics::CameraBridge.
Definition at line 82 of file CameraJoGL.cpp.
References getCameraJavaMapper(), and sciGraphics::CameraJavaMapper::redrawCamera().
00083 { 00084 getCameraJavaMapper()->redrawCamera(); 00085 }

| void sciGraphics::CameraJoGL::replaceCamera | ( | void | ) | [virtual] |
Put back camera to default position.
Implements sciGraphics::CameraBridge.
Definition at line 87 of file CameraJoGL.cpp.
References getCameraJavaMapper(), and sciGraphics::CameraJavaMapper::replaceCamera().
00088 { 00089 getCameraJavaMapper()->replaceCamera(); 00090 // save camera viewing settings 00091 /*getCameraJavaMapper()->getProjectionMatrix(m_aProjMatrix3D); 00092 getCameraJavaMapper()->getUnprojectMatrix(m_aUnprojMatrix3D); 00093 getCameraJavaMapper()->get2dViewProjectionMatrix(m_aProjMatrix2D); 00094 getCameraJavaMapper()->get2dViewUnprojectMatrix(m_aUnprojMatrix2D); 00095 getCameraJavaMapper()->getViewPort(m_aViewPort);*/ 00096 }

| void sciGraphics::CameraJoGL::getPixelCoordinates | ( | const double | userCoord[3], | |
| int | pixCoord[2] | |||
| ) | [virtual] |
Convert user coordinates to pixel coordinates.
Implements sciGraphics::CameraBridge.
Definition at line 124 of file CameraJoGL.cpp.
00125 { 00126 // project point on the screen 00127 double pixCoords3D[3]; 00128 getPixelCoordinates(userCoord, pixCoords3D); 00129 00130 // get the two pixels coordinates 00131 pixCoord[0] = (int) pixCoords3D[0]; 00132 00133 pixCoord[1] = (int) pixCoords3D[1]; 00134 }
| void sciGraphics::CameraJoGL::getPixelCoordinates | ( | const double | userCoords[3], | |
| double | pixCoords[3] | |||
| ) | [virtual] |
Convert user coordinates to pixel coordinates including depth value
Implements sciGraphics::CameraBridge.
Definition at line 136 of file CameraJoGL.cpp.
References getPixelCoordinatesRaw(), sciGraphics::DrawableObjectJoGL::m_pDrawer, and sciGraphics::DrawableObject::pointScale().
00137 { 00138 double finalUserCoord[3]; 00139 // convert user coordinates to log scale if needed 00140 m_pDrawer->pointScale(userCoords[0], userCoords[1], userCoords[2], 00141 &(finalUserCoord[0]), &(finalUserCoord[1]), (&finalUserCoord[2])); 00142 00143 getPixelCoordinatesRaw(finalUserCoord, pixCoords); 00144 }

| void sciGraphics::CameraJoGL::getPixelCoordinatesRaw | ( | const double | userCoords[3], | |
| double | pixCoords[3] | |||
| ) | [virtual] |
Convert user coordinates to pixel coordinates including depth value. Does not take pixel coordinates into account.
Implements sciGraphics::CameraBridge.
Definition at line 146 of file CameraJoGL.cpp.
References m_aProjMatrix3D, m_aViewPort, and project().
Referenced by getPixelCoordinates().
00147 { 00148 // project point on the screen 00149 project(m_aProjMatrix3D, m_aViewPort, userCoords, pixCoords); 00150 00151 // in OpenGL, pixel coordinates are taken from the bottom left point 00152 // of the window, however, in Scilab it is from the top left 00153 // so we have to invert Y coordinate 00154 pixCoords[1] = m_aViewPort[3] - pixCoords[1]; 00155 }


| void sciGraphics::CameraJoGL::get2dViewPixelCoordinates | ( | const double | userCoord[3], | |
| int | pixCoord[2] | |||
| ) | [virtual] |
Convert user coordinates to pixel coordinated using the 2d view.
Implements sciGraphics::CameraBridge.
Definition at line 157 of file CameraJoGL.cpp.
00158 { 00159 double pixCoord3D[3]; 00160 get2dViewPixelCoordinates(userCoord, pixCoord3D); 00161 00162 // get it in pixel coordinates 00163 pixCoord[0] = (int) pixCoord3D[0]; 00164 pixCoord[1] = (int) pixCoord3D[1]; 00165 }
| void sciGraphics::CameraJoGL::get2dViewPixelCoordinates | ( | const double | userCoord[3], | |
| double | pixCoord[3] | |||
| ) | [virtual] |
Convert user coordinates to pixel coordinated using the 2d view.
Implements sciGraphics::CameraBridge.
Definition at line 167 of file CameraJoGL.cpp.
References m_aProjMatrix2D, m_aViewPort, sciGraphics::DrawableObjectJoGL::m_pDrawer, sciGraphics::DrawableObject::pointScale(), and project().
00168 { 00169 double finalUserCoord[3]; 00170 // convert user coordinates to log scale if needed 00171 m_pDrawer->pointScale(userCoord[0], userCoord[1], userCoord[2], 00172 &(finalUserCoord[0]), &(finalUserCoord[1]), (&finalUserCoord[2])); 00173 00174 // project point on the screen 00175 project(m_aProjMatrix2D, m_aViewPort, finalUserCoord, pixCoord); 00176 00177 // get the two pixels coordinates 00178 //pixCoord[0] = pixCoordsD[0]; 00179 // in OpenGL, pixel coordinates are taken from the bottom left point 00180 // of the window, however, in Scilab it is from the top left 00181 // so we have to invert Y coordinate 00182 pixCoord[1] = (m_aViewPort[3] - pixCoord[1]); 00183 }

| void sciGraphics::CameraJoGL::getSceneCoordinates | ( | const double | pixCoords[3], | |
| double | userCoords[3] | |||
| ) | [virtual] |
Unproject a 3 position in pixels into the standard scene coordinates
Implements sciGraphics::CameraBridge.
Definition at line 185 of file CameraJoGL.cpp.
References getSceneCoordinatesRaw(), sciGraphics::DrawableObject::inversePointScale(), and sciGraphics::DrawableObjectJoGL::m_pDrawer.
00186 { 00187 00188 getSceneCoordinatesRaw(pixCoords, userCoords); 00189 00190 // convert user coordinates to log scale if needed 00191 m_pDrawer->inversePointScale(userCoords[0], userCoords[1], userCoords[2], 00192 &(userCoords[0]), &(userCoords[1]), &(userCoords[2])); 00193 }

| void sciGraphics::CameraJoGL::getSceneCoordinatesRaw | ( | const double | pixCoords[3], | |
| double | userCoords[3] | |||
| ) | [virtual] |
Unproject a 3 position in pixels into the standard scene coordinates Does not take logarithmic sclae into account.
Implements sciGraphics::CameraBridge.
Definition at line 195 of file CameraJoGL.cpp.
References m_aUnprojMatrix3D, m_aViewPort, and unProject().
Referenced by getSceneCoordinates().
00196 { 00197 // in OpenGL, pixel coordinates are taken from the bottom left point 00198 // of the window, however, in Scilab it is from the top left 00199 // so we have to invert Y coordinate 00200 double pixCoords3D[3] = {pixCoords[0], m_aViewPort[3] - pixCoords[1], pixCoords[2]}; 00201 unProject(m_aUnprojMatrix3D, m_aViewPort, pixCoords3D, userCoords); 00202 }


| void sciGraphics::CameraJoGL::get2dViewCoordinates | ( | const int | pixCoords[2], | |
| double | userCoord2D[2] | |||
| ) | [virtual] |
Find coordinates in 2D view from pixel ones
Implements sciGraphics::CameraBridge.
Definition at line 204 of file CameraJoGL.cpp.
References sciGraphics::DrawableObject::inversePointScale(), m_aUnprojMatrix2D, m_aViewPort, sciGraphics::DrawableObjectJoGL::m_pDrawer, NULL, and unProject().
00205 { 00206 // in OpenGL, pixel coordinates are taken from the bottom left point 00207 // of the window, however, in Scilab it is from the top left 00208 // so we have to invert Y coordinate 00209 double pixCoordsD[3] = {pixCoords[0], m_aViewPort[3] - pixCoords[1], 0.0}; 00210 double sceneCoords[3]; 00211 unProject(m_aUnprojMatrix2D, m_aViewPort, pixCoordsD, sceneCoords); 00212 00213 // convert user coordinates to log scale if needed 00214 m_pDrawer->inversePointScale(sceneCoords[0], sceneCoords[1], sceneCoords[2], 00215 &(userCoord2D[0]), &(userCoord2D[1]), NULL); 00216 }

| void sciGraphics::CameraJoGL::getViewingArea | ( | int * | xPos, | |
| int * | yPos, | |||
| int * | width, | |||
| int * | height | |||
| ) | [virtual] |
Get the position and size of the rectangle in which the axes box must fit
Implements sciGraphics::CameraBridge.
Definition at line 218 of file CameraJoGL.cpp.
References sciGraphics::CameraBridge::m_aViewingScale, sciGraphics::CameraBridge::m_aViewingTranslation, and m_aViewPort.
00219 { 00220 *xPos = (int)(m_aViewPort[0] + m_aViewingTranslation[0] * m_aViewPort[2]); 00221 //*yPos =(int)(m_aViewPort[1] + m_aViewingTranslation[1] * m_aViewPort[3]); 00222 00223 00224 00225 *width = (int)(m_aViewPort[2] * m_aViewingScale[0]); 00226 *height = (int)(m_aViewPort[3] * m_aViewingScale[1]); 00227 00228 // invert on y axis 00229 *yPos = (int) (m_aViewPort[1] + m_aViewPort[3] * (1.0 - m_aViewingTranslation[1])) - *height; 00230 }
| void sciGraphics::CameraJoGL::getViewport | ( | int | viewport[4] | ) | [virtual] |
Get viewport of the canvas
Implements sciGraphics::CameraBridge.
Definition at line 232 of file CameraJoGL.cpp.
References i, and m_aViewPort.
00233 { 00234 for (int i = 0; i < 4; i++) 00235 { 00236 viewport[i] = (int)m_aViewPort[i]; 00237 } 00238 }
| void sciGraphics::CameraJoGL::project | ( | const double | projMatrix[4][4], | |
| const double | viewPort[4], | |||
| const double | sceneCoordinate[3], | |||
| double | pixCoordinate[3] | |||
| ) | [protected] |
Get the projection of a point on the canvas.
Definition at line 98 of file CameraJoGL.cpp.
References mat4DMult().
Referenced by get2dViewPixelCoordinates(), and getPixelCoordinatesRaw().
00100 { 00101 00102 mat4DMult(projMatrix, sceneCoordinates, pixCoordinates); 00103 pixCoordinates[0] = viewPort[0] + viewPort[2] * (pixCoordinates[0] + 1.0) / 2.0; 00104 pixCoordinates[1] = viewPort[1] + viewPort[3] * (pixCoordinates[1] + 1.0) / 2.0; 00105 pixCoordinates[2] = (pixCoordinates[2] + 1.0) / 2.0; 00106 }


| void sciGraphics::CameraJoGL::unProject | ( | double | unProjMatrix[4][4], | |
| double | viewPort[4], | |||
| const double | pixCoordinates[3], | |||
| double | sceneCoordinates[3] | |||
| ) | [protected] |
Retrieve the position of a point from its coordinates on the canvas.
Definition at line 108 of file CameraJoGL.cpp.
References mat4DMult().
Referenced by get2dViewCoordinates(), and getSceneCoordinatesRaw().
00110 { 00111 double viewPix[3]; 00112 viewPix[0] = 2.0 * (pixCoordinates[0] - viewPort[0]) / viewPort[2] - 1.0; 00113 viewPix[1] = 2.0 * (pixCoordinates[1] - viewPort[1]) / viewPort[3] - 1.0; 00114 viewPix[2] = 2.0 * pixCoordinates[2] - 1.0; 00115 00116 mat4DMult(unProjMatrix, viewPix, sceneCoordinates); 00117 }


| CameraJavaMapper * sciGraphics::CameraJoGL::getCameraJavaMapper | ( | void | ) | [protected] |
Get the object performing mapping with Java class.
Definition at line 119 of file CameraJoGL.cpp.
References sciGraphics::DrawableObjectJoGL::getJavaMapper().
Referenced by redraw(), renderPosition(), and replaceCamera().
00120 { 00121 return dynamic_cast<CameraJavaMapper *>(getJavaMapper()); 00122 }


double sciGraphics::CameraJoGL::m_aProjMatrix3D[4][4] [protected] |
Projection matrix in current coordinates frame
Definition at line 134 of file CameraJoGL.h.
Referenced by CameraJoGL(), getPixelCoordinatesRaw(), and renderPosition().
double sciGraphics::CameraJoGL::m_aUnprojMatrix3D[4][4] [protected] |
inverse of projection matrix in current coordinates frame
Definition at line 136 of file CameraJoGL.h.
Referenced by CameraJoGL(), getSceneCoordinatesRaw(), and renderPosition().
double sciGraphics::CameraJoGL::m_aProjMatrix2D[4][4] [protected] |
Projection matrix fro 2D projection
Definition at line 139 of file CameraJoGL.h.
Referenced by CameraJoGL(), get2dViewPixelCoordinates(), and renderPosition().
double sciGraphics::CameraJoGL::m_aUnprojMatrix2D[4][4] [protected] |
Inverse of projMatrix2D
Definition at line 141 of file CameraJoGL.h.
Referenced by CameraJoGL(), get2dViewCoordinates(), and renderPosition().
double sciGraphics::CameraJoGL::m_aViewPort[4] [protected] |
Current viewPort
Definition at line 144 of file CameraJoGL.h.
Referenced by CameraJoGL(), get2dViewCoordinates(), get2dViewPixelCoordinates(), getPixelCoordinatesRaw(), getSceneCoordinatesRaw(), getViewingArea(), getViewport(), and renderPosition().
double sciGraphics::CameraJoGL::m_aViewingArea[4] [protected] |
Current size of the viewing area used by the plot, this a vector [x,y,w,h]
Definition at line 147 of file CameraJoGL.h.
1.5.5