Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
Common/vtkJavaAwt.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "jawt_md.h"
00018
00019 #define VTK_JAVA_DEBUG
00020
00021 extern "C" JNIEXPORT jint JNICALL
00022 Java_vtk_vtkPanel_RenderCreate(JNIEnv *env, jobject canvas, jobject id0)
00023 {
00024 JAWT awt;
00025 JAWT_DrawingSurface* ds;
00026 JAWT_DrawingSurfaceInfo* dsi;
00027 jint lock;
00028
00029
00030 vtkRenderWindow *temp0;
00031 temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0,(char *) "vtkRenderWindow"));
00032
00033
00034 awt.version = JAWT_VERSION_1_3;
00035 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00036 {
00037 #ifndef VTK_JAVA_DEBUG
00038 printf("AWT Not found\n");
00039 #endif
00040 return 1;
00041 }
00042
00043
00044 ds = awt.GetDrawingSurface(env, canvas);
00045 if (ds == NULL)
00046 {
00047 #ifndef VTK_JAVA_DEBUG
00048 printf("NULL drawing surface\n");
00049 #endif
00050 return 1;
00051 }
00052
00053
00054 lock = ds->Lock(ds);
00055 if((lock & JAWT_LOCK_ERROR) != 0)
00056 {
00057 #ifndef VTK_JAVA_DEBUG
00058 printf("Error locking surface\n");
00059 #endif
00060 awt.FreeDrawingSurface(ds);
00061 return 1;
00062 }
00063
00064
00065 dsi = ds->GetDrawingSurfaceInfo(ds);
00066 if (dsi == NULL)
00067 {
00068 printf("Error getting surface info\n");
00069 ds->Unlock(ds);
00070 awt.FreeDrawingSurface(ds);
00071 return 1;
00072 }
00073
00074
00075 #if defined(_WIN32) || defined(WIN32)
00076 JAWT_Win32DrawingSurfaceInfo* dsi_win;
00077 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
00078 temp0->SetWindowId((void *)dsi_win->hwnd);
00079 temp0->SetDisplayId((void *)dsi_win->hdc);
00080
00081 temp0->SetParentId((void *)dsi_win->hdc);
00082
00083 #elif defined(VTK_USE_CARBON) || defined(VTK_USE_COCOA)
00084 JAWT_MacDrawingSurfaceInfo* dsi_mac;
00085 dsi_mac = (JAWT_MacDrawingSurfaceInfo*)dsi->platformInfo;
00086 temp0->SetWindowId((void *)dsi_mac->fQDWindow);
00087
00088 #else
00089 JAWT_X11DrawingSurfaceInfo* dsi_x11;
00090 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
00091 temp0->SetDisplayId((void *)dsi_x11->display);
00092 temp0->SetWindowId((void *)dsi_x11->drawable);
00093 temp0->SetParentId((void *)dsi_x11->display);
00094 #endif
00095
00096
00097 ds->FreeDrawingSurfaceInfo(dsi);
00098
00099
00100 ds->Unlock(ds);
00101
00102
00103 awt.FreeDrawingSurface(ds);
00104
00105 return 0;
00106
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 extern "C" JNIEXPORT jint JNICALL
00118 Java_vtk_vtkPanel_Lock(JNIEnv *env,
00119 jobject canvas)
00120 {
00121 JAWT awt;
00122 JAWT_DrawingSurface* ds;
00123 jint lock;
00124
00125
00126 awt.version = JAWT_VERSION_1_3;
00127 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00128 {
00129 #ifndef VTK_JAVA_DEBUG
00130 printf("AWT Not found\n");
00131 #endif
00132 return 1;
00133 }
00134
00135
00136 ds = awt.GetDrawingSurface(env, canvas);
00137 if (ds == NULL)
00138 {
00139 #ifndef VTK_JAVA_DEBUG
00140 printf("NULL drawing surface\n");
00141 #endif
00142 return 1;
00143 }
00144
00145
00146 lock = ds->Lock(ds);
00147 if((lock & JAWT_LOCK_ERROR) != 0)
00148 {
00149 #ifndef VTK_JAVA_DEBUG
00150 printf("Error locking surface\n");
00151 #endif
00152 awt.FreeDrawingSurface(ds);
00153 return 1;
00154 }
00155
00156 return 0;
00157
00158 }
00159
00160
00161
00162 extern "C" JNIEXPORT jint JNICALL
00163 Java_vtk_vtkPanel_UnLock(JNIEnv *env,
00164 jobject canvas)
00165 {
00166 JAWT awt;
00167 JAWT_DrawingSurface* ds;
00168
00169
00170 awt.version = JAWT_VERSION_1_3;
00171 if (JAWT_GetAWT(env, &awt) == JNI_FALSE)
00172 {
00173 #ifndef VTK_JAVA_DEBUG
00174 printf("AWT Not found\n");
00175 #endif
00176 return 1;
00177 }
00178
00179
00180 ds = awt.GetDrawingSurface(env, canvas);
00181 if (ds == NULL)
00182 {
00183 #ifndef VTK_JAVA_DEBUG
00184 printf("NULL drawing surface\n");
00185 #endif
00186 return 1;
00187 }
00188
00189
00190 ds->Unlock(ds);
00191
00192
00193 awt.FreeDrawingSurface(ds);
00194
00195 return 0;
00196 }