Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / drv / CASCADESamplesJni / CASCADESamplesJni_Viewer_Viewer_java.cxx
1 //
2 //                     Copyright (C) 1991 - 2000 by  
3 //                      Matra Datavision SA.  All rights reserved.
4 //  
5 //                     Copyright (C) 2001 - 2004 by
6 //                     Open CASCADE SA.  All rights reserved.
7 // 
8 // This file is part of the Open CASCADE Technology software.
9 //
10 // This software may be distributed and/or modified under the terms and
11 // conditions of the Open CASCADE Public License as defined by Open CASCADE SA
12 // and appearing in the file LICENSE included in the packaging of this file.
13 //  
14 // This software is distributed on an "AS IS" basis, without warranty of any
15 // kind, and Open CASCADE SA hereby disclaims all such warranties,
16 // including without limitation, any warranties of merchantability, fitness
17 // for a particular purpose or non-infringement. Please see the License for
18 // the specific terms and conditions governing rights and limitations under the
19 // License.
20
21 #include <CASCADESamplesJni_Viewer_Viewer.h>
22 #include <Viewer_Viewer.hxx>
23 #include <jcas.hxx>
24 #include <stdlib.h>
25 #include <Standard_ErrorHandler.hxx>
26 #include <Standard_Failure.hxx>
27 #include <Standard_SStream.hxx>
28
29 #include <Aspect_GraphicDevice.hxx>
30 #include <Standard_ExtString.hxx>
31 #include <Standard_CString.hxx>
32
33
34 extern "C" {
35
36
37 JNIEXPORT void JNICALL Java_CASCADESamplesJni_Viewer_1Viewer_Update (JNIEnv *env, jobject theobj)
38 {
39
40 jcas_Locking alock(env);
41 {
42 try {
43 Handle(Viewer_Viewer) the_this = *((Handle(Viewer_Viewer)*) jcas_GetHandle(env,theobj));
44 the_this->Update();
45
46 }
47 catch (Standard_Failure) {
48   Standard_SStream Err;
49   Err <<   Standard_Failure::Caught(); 
50   Err << (char) 0;
51   jcas_ThrowException(env,Err.str().c_str());
52 }
53 }
54 alock.Release();
55
56 }
57
58
59
60 JNIEXPORT jobject JNICALL Java_CASCADESamplesJni_Viewer_1Viewer_Device (JNIEnv *env, jobject theobj)
61 {
62 jobject thejret;
63
64 jcas_Locking alock(env);
65 {
66 try {
67 Handle(Viewer_Viewer) the_this = *((Handle(Viewer_Viewer)*) jcas_GetHandle(env,theobj));
68 Handle(Aspect_GraphicDevice)* theret = new Handle(Aspect_GraphicDevice);
69 *theret = the_this->Device();
70 thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_GraphicDevice",theret);
71
72 }
73 catch (Standard_Failure) {
74   Standard_SStream Err;
75   Err <<   Standard_Failure::Caught(); 
76   Err << (char) 0;
77   jcas_ThrowException(env,Err.str().c_str());
78 }
79 }
80 alock.Release();
81 return thejret;
82 }
83
84
85
86 JNIEXPORT jstring JNICALL Java_CASCADESamplesJni_Viewer_1Viewer_NextName (JNIEnv *env, jobject theobj)
87 {
88 jstring thejret;
89
90 jcas_Locking alock(env);
91 {
92 try {
93 Handle(Viewer_Viewer) the_this = *((Handle(Viewer_Viewer)*) jcas_GetHandle(env,theobj));
94 Standard_ExtString sret = the_this->NextName();
95 thejret = jcas_ConvertTojstring(env,sret);
96
97 }
98 catch (Standard_Failure) {
99   Standard_SStream Err;
100   Err <<   Standard_Failure::Caught(); 
101   Err << (char) 0;
102   jcas_ThrowException(env,Err.str().c_str());
103 }
104 }
105 alock.Release();
106 return thejret;
107 }
108
109
110
111 JNIEXPORT jobject JNICALL Java_CASCADESamplesJni_Viewer_1Viewer_Domain (JNIEnv *env, jobject theobj)
112 {
113 jobject thejret;
114
115 jcas_Locking alock(env);
116 {
117 try {
118 Handle(Viewer_Viewer) the_this = *((Handle(Viewer_Viewer)*) jcas_GetHandle(env,theobj));
119 Standard_CString sret = the_this->Domain();
120 jclass CLSret  = env->FindClass("jcas/Standard_CString");
121 thejret = env->AllocObject(CLSret);
122 jcas_SetCStringValue(env,thejret,sret);
123
124 }
125 catch (Standard_Failure) {
126   Standard_SStream Err;
127   Err <<   Standard_Failure::Caught(); 
128   Err << (char) 0;
129   jcas_ThrowException(env,Err.str().c_str());
130 }
131 }
132 alock.Release();
133 return thejret;
134 }
135
136
137 }