BackTrihedronDrawerGL.cpp

Go to the documentation of this file.
00001 #include "BackTrihedronDrawerGL.hxx"
00002 /* Generated by GIWS (version 0.9.9.4) */
00003 /*
00004 
00005 Copyright 2007-2008 INRIA
00006 
00007 Author : Sylvestre Ledru & others
00008 
00009 This software is a computer program whose purpose is to hide the complexity
00010 of accessing Java objects/methods from C++ code.
00011 
00012 This software is governed by the CeCILL-B license under French law and
00013 abiding by the rules of distribution of free software.  You can  use, 
00014 modify and/ or redistribute the software under the terms of the CeCILL-B
00015 license as circulated by CEA, CNRS and INRIA at the following URL
00016 "http://www.cecill.info". 
00017 
00018 As a counterpart to the access to the source code and  rights to copy,
00019 modify and redistribute granted by the license, users are provided only
00020 with a limited warranty  and the software's author,  the holder of the
00021 economic rights,  and the successive licensors  have only  limited
00022 liability. 
00023 
00024 In this respect, the user's attention is drawn to the risks associated
00025 with loading,  using,  modifying and/or developing or reproducing the
00026 software by the user in light of its specific status of free software,
00027 that may mean  that it is complicated to manipulate,  and  that  also
00028 therefore means  that it is reserved for developers  and  experienced
00029 professionals having in-depth computer knowledge. Users are therefore
00030 encouraged to load and test the software's suitability as regards their
00031 requirements in conditions enabling the security of their systems and/or 
00032 data to be ensured and,  more generally, to use and operate it in the 
00033 same conditions as regards security. 
00034 
00035 The fact that you are presently reading this means that you have had
00036 knowledge of the CeCILL-B license and that you accept its terms.
00037 */
00038 
00039 namespace org_scilab_modules_renderer_subwinDrawing {
00040 
00041 // Returns the current env
00042 
00043 JNIEnv * BackTrihedronDrawerGL::getCurrentEnv() {
00044 JNIEnv * curEnv = NULL;
00045 this->jvm->AttachCurrentThread((void **) &curEnv, NULL);
00046 return curEnv;
00047 }
00048 // Destructor
00049 
00050 BackTrihedronDrawerGL::~BackTrihedronDrawerGL() {
00051 JNIEnv * curEnv = NULL;
00052 this->jvm->AttachCurrentThread((void **) &curEnv, NULL);
00053 
00054 curEnv->DeleteGlobalRef(this->instance);
00055 curEnv->DeleteGlobalRef(this->instanceClass);
00056 }
00057 // Constructors
00058 
00059 BackTrihedronDrawerGL::BackTrihedronDrawerGL(JavaVM * jvm_) {
00060 jmethodID constructObject = NULL ;
00061 jobject localInstance ;
00062 jclass localClass ;
00063 const std::string construct="<init>";
00064 const std::string param="()V";
00065 jvm=jvm_;
00066 
00067 JNIEnv * curEnv = getCurrentEnv();
00068 
00069 localClass = curEnv->FindClass( this->className().c_str() ) ;
00070 if (localClass == NULL) {
00071   throw GiwsException::JniClassNotFoundException(curEnv, this->className());
00072 }
00073 
00074 this->instanceClass = (jclass) curEnv->NewGlobalRef(localClass) ;
00075 
00076 /* localClass is not needed anymore */
00077 curEnv->DeleteLocalRef(localClass);
00078 
00079 if (this->instanceClass == NULL) {
00080 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00081 }
00082 
00083 
00084 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
00085 if(constructObject == NULL){
00086 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00087 }
00088 
00089 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
00090 if(localInstance == NULL){
00091 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00092 }
00093  
00094 this->instance = curEnv->NewGlobalRef(localInstance) ;
00095 if(this->instance == NULL){
00096 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00097 }
00098 /* localInstance not needed anymore */
00099 curEnv->DeleteLocalRef(localInstance);
00100 
00101                 /* Methods ID set to NULL */
00102 voiddisplayID=NULL; 
00103 voidinitializeDrawingjintID=NULL; 
00104 voidendDrawingID=NULL; 
00105 voidshowjintID=NULL; 
00106 voiddestroyjintID=NULL; 
00107 voidsetFigureIndexjintID=NULL; 
00108 voidsetBoxParametersjintjfloatID=NULL; 
00109 voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID=NULL; 
00110 
00111 
00112 }
00113 
00114 BackTrihedronDrawerGL::BackTrihedronDrawerGL(JavaVM * jvm_, jobject JObj) {
00115         jvm=jvm_;
00116 
00117         JNIEnv * curEnv = getCurrentEnv();
00118 
00119 jclass localClass = curEnv->GetObjectClass(JObj);
00120         this->instanceClass = (jclass) curEnv->NewGlobalRef(localClass);
00121         curEnv->DeleteLocalRef(localClass);
00122 
00123         if (this->instanceClass == NULL) {
00124 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00125         }
00126 
00127         this->instance = curEnv->NewGlobalRef(JObj) ;
00128         if(this->instance == NULL){
00129 throw GiwsException::JniObjectCreationException(curEnv, this->className());
00130         }
00131         /* Methods ID set to NULL */
00132         voiddisplayID=NULL; 
00133 voidinitializeDrawingjintID=NULL; 
00134 voidendDrawingID=NULL; 
00135 voidshowjintID=NULL; 
00136 voiddestroyjintID=NULL; 
00137 voidsetFigureIndexjintID=NULL; 
00138 voidsetBoxParametersjintjfloatID=NULL; 
00139 voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID=NULL; 
00140 
00141 
00142 }
00143 
00144 // Generic methods
00145 
00146 
00147 void BackTrihedronDrawerGL::synchronize() {
00148 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
00149 std::cerr << "Fail to enter monitor." << std::endl;
00150 exit(EXIT_FAILURE);
00151 }
00152 }
00153 
00154 
00155 void BackTrihedronDrawerGL::endSynchronize() {
00156 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
00157 std::cerr << "Fail to exit monitor." << std::endl;
00158 exit(EXIT_FAILURE);
00159 }
00160 }
00161 
00162 // Method(s)
00163 
00164 void BackTrihedronDrawerGL::display (){
00165 
00166 JNIEnv * curEnv = getCurrentEnv();
00167 
00168 if (voiddisplayID==NULL) { /* Use the cache Luke */ voiddisplayID = curEnv->GetMethodID(this->instanceClass, "display", "()V" ) ;
00169 if (voiddisplayID == NULL) {
00170 throw GiwsException::JniMethodNotFoundException(curEnv, "display");
00171 }
00172 }
00173                          curEnv->CallVoidMethod( this->instance, voiddisplayID );
00174                         if (curEnv->ExceptionCheck()) {
00175 throw GiwsException::JniCallMethodException(curEnv);
00176 }
00177 }
00178 
00179 void BackTrihedronDrawerGL::initializeDrawing (int figureIndex){
00180 
00181 JNIEnv * curEnv = getCurrentEnv();
00182 
00183 if (voidinitializeDrawingjintID==NULL) { /* Use the cache Luke */ voidinitializeDrawingjintID = curEnv->GetMethodID(this->instanceClass, "initializeDrawing", "(I)V" ) ;
00184 if (voidinitializeDrawingjintID == NULL) {
00185 throw GiwsException::JniMethodNotFoundException(curEnv, "initializeDrawing");
00186 }
00187 }
00188                          curEnv->CallVoidMethod( this->instance, voidinitializeDrawingjintID ,figureIndex);
00189                         if (curEnv->ExceptionCheck()) {
00190 throw GiwsException::JniCallMethodException(curEnv);
00191 }
00192 }
00193 
00194 void BackTrihedronDrawerGL::endDrawing (){
00195 
00196 JNIEnv * curEnv = getCurrentEnv();
00197 
00198 if (voidendDrawingID==NULL) { /* Use the cache Luke */ voidendDrawingID = curEnv->GetMethodID(this->instanceClass, "endDrawing", "()V" ) ;
00199 if (voidendDrawingID == NULL) {
00200 throw GiwsException::JniMethodNotFoundException(curEnv, "endDrawing");
00201 }
00202 }
00203                          curEnv->CallVoidMethod( this->instance, voidendDrawingID );
00204                         if (curEnv->ExceptionCheck()) {
00205 throw GiwsException::JniCallMethodException(curEnv);
00206 }
00207 }
00208 
00209 void BackTrihedronDrawerGL::show (int figureIndex){
00210 
00211 JNIEnv * curEnv = getCurrentEnv();
00212 
00213 if (voidshowjintID==NULL) { /* Use the cache Luke */ voidshowjintID = curEnv->GetMethodID(this->instanceClass, "show", "(I)V" ) ;
00214 if (voidshowjintID == NULL) {
00215 throw GiwsException::JniMethodNotFoundException(curEnv, "show");
00216 }
00217 }
00218                          curEnv->CallVoidMethod( this->instance, voidshowjintID ,figureIndex);
00219                         if (curEnv->ExceptionCheck()) {
00220 throw GiwsException::JniCallMethodException(curEnv);
00221 }
00222 }
00223 
00224 void BackTrihedronDrawerGL::destroy (int figureIndex){
00225 
00226 JNIEnv * curEnv = getCurrentEnv();
00227 
00228 if (voiddestroyjintID==NULL) { /* Use the cache Luke */ voiddestroyjintID = curEnv->GetMethodID(this->instanceClass, "destroy", "(I)V" ) ;
00229 if (voiddestroyjintID == NULL) {
00230 throw GiwsException::JniMethodNotFoundException(curEnv, "destroy");
00231 }
00232 }
00233                          curEnv->CallVoidMethod( this->instance, voiddestroyjintID ,figureIndex);
00234                         if (curEnv->ExceptionCheck()) {
00235 throw GiwsException::JniCallMethodException(curEnv);
00236 }
00237 }
00238 
00239 void BackTrihedronDrawerGL::setFigureIndex (int figureIndex){
00240 
00241 JNIEnv * curEnv = getCurrentEnv();
00242 
00243 if (voidsetFigureIndexjintID==NULL) { /* Use the cache Luke */ voidsetFigureIndexjintID = curEnv->GetMethodID(this->instanceClass, "setFigureIndex", "(I)V" ) ;
00244 if (voidsetFigureIndexjintID == NULL) {
00245 throw GiwsException::JniMethodNotFoundException(curEnv, "setFigureIndex");
00246 }
00247 }
00248                          curEnv->CallVoidMethod( this->instance, voidsetFigureIndexjintID ,figureIndex);
00249                         if (curEnv->ExceptionCheck()) {
00250 throw GiwsException::JniCallMethodException(curEnv);
00251 }
00252 }
00253 
00254 void BackTrihedronDrawerGL::setBoxParameters (int hiddenAxisColor, float thickness){
00255 
00256 JNIEnv * curEnv = getCurrentEnv();
00257 
00258 if (voidsetBoxParametersjintjfloatID==NULL) { /* Use the cache Luke */ voidsetBoxParametersjintjfloatID = curEnv->GetMethodID(this->instanceClass, "setBoxParameters", "(IF)V" ) ;
00259 if (voidsetBoxParametersjintjfloatID == NULL) {
00260 throw GiwsException::JniMethodNotFoundException(curEnv, "setBoxParameters");
00261 }
00262 }
00263                          curEnv->CallVoidMethod( this->instance, voidsetBoxParametersjintjfloatID ,hiddenAxisColor, thickness);
00264                         if (curEnv->ExceptionCheck()) {
00265 throw GiwsException::JniCallMethodException(curEnv);
00266 }
00267 }
00268 
00269 void BackTrihedronDrawerGL::drawBox (double xMin, double xMax, double yMin, double yMax, double zMin, double zMax, int concealedCornerIndex){
00270 
00271 JNIEnv * curEnv = getCurrentEnv();
00272 
00273 if (voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID==NULL) { /* Use the cache Luke */ voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID = curEnv->GetMethodID(this->instanceClass, "drawBox", "(DDDDDDI)V" ) ;
00274 if (voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID == NULL) {
00275 throw GiwsException::JniMethodNotFoundException(curEnv, "drawBox");
00276 }
00277 }
00278                          curEnv->CallVoidMethod( this->instance, voiddrawBoxjdoublejdoublejdoublejdoublejdoublejdoublejintID ,xMin, xMax, yMin, yMax, zMin, zMax, concealedCornerIndex);
00279                         if (curEnv->ExceptionCheck()) {
00280 throw GiwsException::JniCallMethodException(curEnv);
00281 }
00282 }
00283 
00284 }

Generated on Tue Sep 9 17:48:31 2008 for Scilab [trunk] by  doxygen 1.5.5