00001
00002 #include "jawt_md.h"
00003
00004 extern "C" JNIEXPORT void JNICALL
00005 Java_vtkPanel_RenderCreate(JNIEnv *env, jobject canvas, jobject id0)
00006 {
00007 JAWT awt;
00008 JAWT_DrawingSurface* ds;
00009 JAWT_DrawingSurfaceInfo* dsi;
00010 jint lock;
00011
00012
00013 vtkRenderWindow *temp0;
00014 temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0,(char *) "vtkRenderWindow"));
00015
00016
00017 awt.version = JAWT_VERSION_1_3;
00018 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00019 {
00020 printf("AWT Not found\n");
00021 return;
00022 }
00023
00024
00025 ds = awt.GetDrawingSurface(env, canvas);
00026 if (ds == NULL)
00027 {
00028 printf("NULL drawing surface\n");
00029 return;
00030 }
00031
00032
00033 lock = ds->Lock(ds);
00034 if((lock & JAWT_LOCK_ERROR) != 0)
00035 {
00036 printf("Error locking surface\n");
00037 awt.FreeDrawingSurface(ds);
00038 return;
00039 }
00040
00041
00042 dsi = ds->GetDrawingSurfaceInfo(ds);
00043 if (dsi == NULL)
00044 {
00045 printf("Error getting surface info\n");
00046 ds->Unlock(ds);
00047 awt.FreeDrawingSurface(ds);
00048 return;
00049 }
00050
00051
00052 #if defined(_WIN32) || defined(WIN32)
00053 JAWT_Win32DrawingSurfaceInfo* dsi_win;
00054 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
00055 temp0->SetWindowId((void *)dsi_win->hwnd);
00056
00057
00058 #else
00059 JAWT_X11DrawingSurfaceInfo* dsi_x11;
00060 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
00061 temp0->SetDisplayId((void *)dsi_x11->display);
00062 temp0->SetWindowId((void *)dsi_x11->drawable);
00063 #endif
00064
00065 temp0->Render();
00066
00067
00068 ds->FreeDrawingSurfaceInfo(dsi);
00069
00070
00071 ds->Unlock(ds);
00072
00073
00074 awt.FreeDrawingSurface(ds);
00075 }
00076
00077 extern "C" JNIEXPORT void JNICALL
00078 Java_vtkPanel_RenderInternal(JNIEnv *env, jobject canvas, jobject id0)
00079 {
00080 JAWT awt;
00081 JAWT_DrawingSurface* ds;
00082 jint lock;
00083
00084
00085 vtkRenderWindow *temp0;
00086 temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0,(char *) "vtkRenderWindow"));
00087
00088
00089 awt.version = JAWT_VERSION_1_3;
00090 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00091 {
00092 printf("AWT Not found\n");
00093 return;
00094 }
00095
00096
00097 ds = awt.GetDrawingSurface(env, canvas);
00098 if (ds == NULL)
00099 {
00100 printf("NULL drawing surface\n");
00101 return;
00102 }
00103
00104
00105 lock = ds->Lock(ds);
00106 if((lock & JAWT_LOCK_ERROR) != 0)
00107 {
00108 printf("Error locking surface\n");
00109 awt.FreeDrawingSurface(ds);
00110 return;
00111 }
00112
00113 temp0->Render();
00114
00115
00116 ds->Unlock(ds);
00117
00118
00119 awt.FreeDrawingSurface(ds);
00120 }
00121
00122 extern "C" JNIEXPORT void JNICALL
00123 Java_vtkPanel_SetSizeInternal(JNIEnv *env,
00124 jobject canvas,
00125 jobject id0, jint id1,jint id2)
00126 {
00127 JAWT awt;
00128 JAWT_DrawingSurface* ds;
00129 jint lock;
00130
00131
00132 vtkRenderWindow *temp0;
00133 temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0,(char *) "vtkRenderWindow"));
00134
00135
00136 awt.version = JAWT_VERSION_1_3;
00137 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00138 {
00139 printf("AWT Not found\n");
00140 return;
00141 }
00142
00143
00144 ds = awt.GetDrawingSurface(env, canvas);
00145 if (ds == NULL)
00146 {
00147 printf("NULL drawing surface\n");
00148 return;
00149 }
00150
00151
00152 lock = ds->Lock(ds);
00153 if((lock & JAWT_LOCK_ERROR) != 0)
00154 {
00155 printf("Error locking surface\n");
00156 awt.FreeDrawingSurface(ds);
00157 return;
00158 }
00159
00160 int temp1;
00161 int temp2;
00162 temp1 = id1;
00163 temp2 = id2;
00164
00165 temp0->SetSize(temp1,temp2);
00166
00167
00168 ds->Unlock(ds);
00169
00170
00171 awt.FreeDrawingSurface(ds);
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181 extern "C" JNIEXPORT void JNICALL
00182 Java_vtkPanel_LockAndExecuteVoidMethod(JNIEnv *env,
00183 jobject canvas,
00184 jobject renderWindow,
00185 jobject anObject,
00186 jstring methodString)
00187 {
00188 JAWT awt;
00189 JAWT_DrawingSurface* ds;
00190 jint lock;
00191
00192 jclass clazz;
00193 jmethodID mid;
00194 jboolean isCopy;
00195
00196
00197 vtkRenderWindow *temp0;
00198 temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,renderWindow,(char *) "vtkRenderWindow"));
00199
00200
00201
00202 const char* utf_string = env->GetStringUTFChars(methodString, &isCopy);
00203
00204
00205 awt.version = JAWT_VERSION_1_3;
00206 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00207 {
00208 printf("AWT Not found\n");
00209 return;
00210 }
00211
00212
00213 ds = awt.GetDrawingSurface(env, canvas);
00214 if (ds == NULL)
00215 {
00216 printf("NULL drawing surface\n");
00217 return;
00218 }
00219
00220
00221 lock = ds->Lock(ds);
00222 if((lock & JAWT_LOCK_ERROR) != 0)
00223 {
00224 printf("Error locking surface\n");
00225 awt.FreeDrawingSurface(ds);
00226 return;
00227 }
00228
00229
00230 clazz = env->GetObjectClass(anObject);
00231
00232
00233 mid = env->GetMethodID(clazz, utf_string, "()V");
00234 if (mid == 0)
00235 {
00236 printf("Can't get void methodID %s for object\n", utf_string);
00237 ds->Unlock(ds);
00238 awt.FreeDrawingSurface(ds);
00239 return;
00240 }
00241
00242 env->CallVoidMethod(anObject, mid);
00243
00244 temp0->Render();
00245
00246
00247 ds->Unlock(ds);
00248
00249
00250 awt.FreeDrawingSurface(ds);
00251 }
00252
00253