ede055081485f206c679ea9fac05da3f0c48243c
[scilab.git] / scilab / modules / renderer / src / cpp / DrawableObjectJoGL.cpp
1 /*------------------------------------------------------------------------*/
2 /* file: DrawableObjectJoGL.cpp                                           */
3 /* Copyright INRIA 2007                                                   */
4 /* Authors : Jean-Baptiste Silvy                                          */
5 /* desc : Objects which can be drawn using JoGL                           */
6 /*------------------------------------------------------------------------*/
7
8 #include "DrawableObjectJoGL.h"
9 #include "DrawableObject.h"
10 extern "C"
11 {
12 #include "JniUtils.h"
13 #include "GetProperty.h"
14 }
15
16 namespace sciGraphics
17 {
18 /*------------------------------------------------------------------------------------------*/
19 DrawableObjectJoGL::DrawableObjectJoGL( DrawableObject * drawer, const char * className ) : DrawableObjectImp(drawer)
20 {
21   m_oDrawableClass  = NULL ;
22   m_oDrawableObject = NULL ;
23   jniCreateDefaultInstanceSafe( className, &m_oDrawableClass, &m_oDrawableObject ) ;
24   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "setFigureIndex", "(I)V", sciGetNum(sciGetParentFigure(m_pDrawer->getDrawedObject())) ) ;
25 }
26 /*------------------------------------------------------------------------------------------*/
27 DrawableObjectJoGL::~DrawableObjectJoGL( void )
28 {
29   destroy() ;
30 }
31 /*------------------------------------------------------------------------------------------*/
32 void DrawableObjectJoGL::initializeDrawing( void )
33 {
34   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "initializeDrawing", "(I)V", sciGetNum(sciGetParentFigure(m_pDrawer->getDrawedObject())) ) ;
35 }
36 /*------------------------------------------------------------------------------------------*/
37 void DrawableObjectJoGL::endDrawing( void )
38 {   
39   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "endDrawing", "()V" ) ;
40 }
41 /*------------------------------------------------------------------------------------------*/
42 void DrawableObjectJoGL::initializeShowing( void )
43 {
44   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "initializeShowing", "(I)V", sciGetNum(sciGetParentFigure(m_pDrawer->getDrawedObject())) ) ;
45 }
46 /*------------------------------------------------------------------------------------------*/
47 void DrawableObjectJoGL::endShowing( void )
48 {   
49   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "endShowing", "()V" ) ;
50 }
51 /*------------------------------------------------------------------------------------------*/
52 void DrawableObjectJoGL::show( void )
53 {
54   jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "show", "(I)V", sciGetNum(sciGetParentFigure(m_pDrawer->getDrawedObject())) ) ;
55 }
56 /*------------------------------------------------------------------------------------------*/
57 void DrawableObjectJoGL::destroy( void )
58 {
59   if ( m_oDrawableObject != NULL )
60   {
61     jniCallMemberFunctionSafe( m_oDrawableObject, NULL, "destroy", "(I)V", sciGetNum(sciGetParentFigure(m_pDrawer->getDrawedObject())) ) ;
62     jniDeleteGlobalEntity( m_oDrawableObject ) ;
63     jniDeleteGlobalEntity(m_oDrawableClass) ;
64   }
65   m_oDrawableObject = NULL ;
66   m_oDrawableClass  = NULL ;
67 }
68 /*------------------------------------------------------------------------------------------*/
69 }