2014-06-20 1 views
0

Java 및 JavaFX와 함께 vtk를 사용해야하는 프로젝트에 있습니다. 그리고 VTK에게 그릴 수있는 올바른 캔버스를 주려면 GetDrawingSurface() 함수가 아래 코드에서 무엇을하는지 궁금합니다. awt는 jawt 라이브러리의 jawt.h에 설명 된 JAWT 객체입니다.AWT.GetDrawingSurface의 기능은 무엇입니까?

Java 클래스를 다시 작성하여 C++에 올바른 캔버스를 제공하기 위해서입니다.

extern "C" JNIEXPORT jint JNICALL 
Java_vtk_vtkPanel_RenderCreate(JNIEnv *env, jobject canvas, jobject id0) 
{ 
#if defined(WIN32_JAWT_LOCK_HACK) 
    int hash; 
    WJLH_HASH_FUNC(env, canvas, hash); 
    WJLH_lock_map[hash] = 0; 
#endif 

    JAWT awt; 
    JAWT_DrawingSurface* ds; 
    JAWT_DrawingSurfaceInfo* dsi; 
    jint lock; 

    // get the render window pointer 
    vtkRenderWindow *temp0; 
    temp0 = (vtkRenderWindow *)(vtkJavaGetPointerFromObject(env,id0)); 

    /* Get the AWT */ 
    awt.version = JAWT_VERSION_1_3; 
    if (JAWT_GetAWT(env, &awt) == JNI_FALSE) 
    { 
#ifndef VTK_JAVA_DEBUG 
    printf("AWT Not found\n"); 
#endif 
    return 1; 
    } 

    /* Get the drawing surface */ 
    ds = awt.GetDrawingSurface(env, canvas); 
    if (ds == NULL) 
    { 
#ifndef VTK_JAVA_DEBUG 
    printf("NULL drawing surface\n"); 
#endif 
    return 1; 
    } 

    /* Lock the drawing surface */ 
    lock = ds->Lock(ds); 
    if((lock & JAWT_LOCK_ERROR) != 0) 
    { 
#ifndef VTK_JAVA_DEBUG 
    printf("Error locking surface\n"); 
#endif 
    awt.FreeDrawingSurface(ds); 
    return 1; 
    } 

    /* Get the drawing surface info */ 
    dsi = ds->GetDrawingSurfaceInfo(ds); 
    if (dsi == NULL) 
    { 
    printf("Error getting surface info\n"); 
    ds->Unlock(ds); 
    awt.FreeDrawingSurface(ds); 
    return 1; 
    } 

// Here is the win32 drawing code 
#if defined(_WIN32) || defined(WIN32) 
    temp0->Finalize(); 
    JAWT_Win32DrawingSurfaceInfo* dsi_win; 
    dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; 
    temp0->SetWindowId((void *)dsi_win->hwnd); 
    temp0->SetDisplayId((void *)dsi_win->hdc); 
    // also set parent id to avoid border sizes being added 
    temp0->SetParentId((void *)dsi_win->hdc); 
// use mac code 
#elif defined(__APPLE__) 
    JAWT_MacOSXDrawingSurfaceInfo* dsi_mac; 
    dsi_mac = (JAWT_MacOSXDrawingSurfaceInfo*)dsi->platformInfo; 
    temp0->SetWindowId(dsi_mac->cocoaViewRef); 
// otherwise use X11 code 
#else 
    JAWT_X11DrawingSurfaceInfo* dsi_x11; 
    dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; 
    temp0->SetDisplayId((void *)dsi_x11->display); 
    temp0->SetWindowId((void *)dsi_x11->drawable); 
    temp0->SetParentId((void *)dsi_x11->display); 
#endif 

    /* Free the drawing surface info */ 
    ds->FreeDrawingSurfaceInfo(dsi); 

    /* Unlock the drawing surface */ 
    ds->Unlock(ds); 

    /* Free the drawing surface */ 
    awt.FreeDrawingSurface(ds); 

#if defined(WIN32_JAWT_LOCK_HACK) 
    if (WJLH_init_check == 0) 
    { 
    WJLH_init_check = 1; 
    } 
    WJLH_lock_map[hash] = 1; 
#endif 
    return 0; 
} 

답변

0

글쎄, 나는 그것이 시스템에서 윈도우 관리자 사용에 대한 정보를 반환하고 있다고 생각했다.

Java의 getPeer 기능을 사용하여 올바른 정보를 얻고이를 C 코드에 제공합니다. 그래서 javadoc이 컴퓨터에 특정 적이며 재 작성 될 수 없다는 것을 분명하게 알려주기 때문에 어디에서 그려야 할 것인지 알려줄 수는 없습니다.

마지막 VTK ​​버전 (6.1.0)은 vtkJoGLPanelComponent을 사용하여 JavaFX에서 VTK를 갖는 새로운 옵션을 제공합니다. 다른 옵션 인 vtkJoGLCanvasComponent이 전혀 작동하지 않기 때문에 가볍습니다.