]> OCCT Git - occt-copy.git/blob
73bd67212cf02d706fc9e48993aaabd3528f36e5
[occt-copy.git] /
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
22 #include <SampleDisplayAnimationJni_SampleDisplayAnimationPackage.h>
23 #include <SampleDisplayAnimationPackage.hxx>
24 #include <jcas.hxx>
25 #include <stdlib.h>
26 #include <Standard_ErrorHandler.hxx>
27 #include <Standard_Failure.hxx>
28 #include <Standard_SStream.hxx>
29
30 #include <V3d_Viewer.hxx>
31 #include <Standard_ExtString.hxx>
32 #include <V3d_View.hxx>
33 #include <Standard_Integer.hxx>
34 #include <Standard_Boolean.hxx>
35 #include <AIS_InteractiveContext.hxx>
36 #include <Standard_CString.hxx>
37 #include <Standard_Real.hxx>
38
39
40 extern "C" {
41
42
43 JNIEXPORT jobject JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_CreateViewer (JNIEnv *env, jclass, jstring aName)
44 {
45 jobject thejret;
46
47 jcas_Locking alock(env);
48 {
49 try {
50 Standard_ExtString the_aName = jcas_ConvertToExtString(env,aName);
51 Handle(V3d_Viewer)* theret = new Handle(V3d_Viewer);
52 *theret = SampleDisplayAnimationPackage::CreateViewer(the_aName);
53 thejret = jcas_CreateObject(env,"CASCADESamplesJni/V3d_Viewer",theret);
54
55 }
56 catch (Standard_Failure) {
57   Standard_SStream Err;
58   Err <<   Standard_Failure::Caught(); 
59   Err << (char) 0;
60   jcas_ThrowException(env,Err.str().c_str());
61 }
62 }
63 alock.Release();
64 return thejret;
65 }
66
67
68
69 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetWindow (JNIEnv *env, jclass, jobject aView, jint hiwin, jint lowin)
70 {
71
72 jcas_Locking alock(env);
73 {
74 try {
75  Handle( V3d_View ) the_aView;
76  void*                ptr_aView = jcas_GetHandle(env,aView);
77  
78  if ( ptr_aView != NULL ) the_aView = *(   (  Handle( V3d_View )*  )ptr_aView   );
79
80 SampleDisplayAnimationPackage::SetWindow(the_aView,(Standard_Integer) hiwin,(Standard_Integer) lowin);
81
82 }
83 catch (Standard_Failure) {
84   Standard_SStream Err;
85   Err <<   Standard_Failure::Caught(); 
86   Err << (char) 0;
87   jcas_ThrowException(env,Err.str().c_str());
88 }
89 }
90 alock.Release();
91
92 }
93
94
95
96 JNIEXPORT jboolean JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_LoadData (JNIEnv *env, jclass, jobject aContext, jobject aPath)
97 {
98 jboolean thejret;
99
100 jcas_Locking alock(env);
101 {
102 try {
103  Handle( AIS_InteractiveContext ) the_aContext;
104  void*                ptr_aContext = jcas_GetHandle(env,aContext);
105  
106  if ( ptr_aContext != NULL ) the_aContext = *(   (  Handle( AIS_InteractiveContext )*  )ptr_aContext   );
107
108 Standard_CString the_aPath = jcas_ConvertToCString(env,aPath);
109  thejret = SampleDisplayAnimationPackage::LoadData(the_aContext,the_aPath);
110
111 }
112 catch (Standard_Failure) {
113   Standard_SStream Err;
114   Err <<   Standard_Failure::Caught(); 
115   Err << (char) 0;
116   jcas_ThrowException(env,Err.str().c_str());
117 }
118 }
119 alock.Release();
120 return thejret;
121 }
122
123
124
125 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_ChangePosition (JNIEnv *env, jclass, jobject aContext)
126 {
127
128 jcas_Locking alock(env);
129 {
130 try {
131  Handle( AIS_InteractiveContext ) the_aContext;
132  void*                ptr_aContext = jcas_GetHandle(env,aContext);
133  
134  if ( ptr_aContext != NULL ) the_aContext = *(   (  Handle( AIS_InteractiveContext )*  )ptr_aContext   );
135
136 SampleDisplayAnimationPackage::ChangePosition(the_aContext);
137
138 }
139 catch (Standard_Failure) {
140   Standard_SStream Err;
141   Err <<   Standard_Failure::Caught(); 
142   Err << (char) 0;
143   jcas_ThrowException(env,Err.str().c_str());
144 }
145 }
146 alock.Release();
147
148 }
149
150
151
152 JNIEXPORT jdouble JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_GetDeviationCoefficient (JNIEnv *env, jclass)
153 {
154 jdouble thejret;
155
156 jcas_Locking alock(env);
157 {
158 try {
159  thejret = SampleDisplayAnimationPackage::GetDeviationCoefficient();
160
161 }
162 catch (Standard_Failure) {
163   Standard_SStream Err;
164   Err <<   Standard_Failure::Caught(); 
165   Err << (char) 0;
166   jcas_ThrowException(env,Err.str().c_str());
167 }
168 }
169 alock.Release();
170 return thejret;
171 }
172
173
174
175 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetDeviationCoefficient (JNIEnv *env, jclass, jobject aContext, jdouble aValue)
176 {
177
178 jcas_Locking alock(env);
179 {
180 try {
181  Handle( AIS_InteractiveContext ) the_aContext;
182  void*                ptr_aContext = jcas_GetHandle(env,aContext);
183  
184  if ( ptr_aContext != NULL ) the_aContext = *(   (  Handle( AIS_InteractiveContext )*  )ptr_aContext   );
185
186 SampleDisplayAnimationPackage::SetDeviationCoefficient(the_aContext,(Standard_Real) aValue);
187
188 }
189 catch (Standard_Failure) {
190   Standard_SStream Err;
191   Err <<   Standard_Failure::Caught(); 
192   Err << (char) 0;
193   jcas_ThrowException(env,Err.str().c_str());
194 }
195 }
196 alock.Release();
197
198 }
199
200
201
202 JNIEXPORT jint JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_GetAngleIncrement (JNIEnv *env, jclass)
203 {
204 jint thejret;
205
206 jcas_Locking alock(env);
207 {
208 try {
209  thejret = SampleDisplayAnimationPackage::GetAngleIncrement();
210
211 }
212 catch (Standard_Failure) {
213   Standard_SStream Err;
214   Err <<   Standard_Failure::Caught(); 
215   Err << (char) 0;
216   jcas_ThrowException(env,Err.str().c_str());
217 }
218 }
219 alock.Release();
220 return thejret;
221 }
222
223
224
225 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetAngleIncrement (JNIEnv *env, jclass, jint aValue)
226 {
227
228 jcas_Locking alock(env);
229 {
230 try {
231 SampleDisplayAnimationPackage::SetAngleIncrement((Standard_Integer) aValue);
232
233 }
234 catch (Standard_Failure) {
235   Standard_SStream Err;
236   Err <<   Standard_Failure::Caught(); 
237   Err << (char) 0;
238   jcas_ThrowException(env,Err.str().c_str());
239 }
240 }
241 alock.Release();
242
243 }
244
245
246
247 JNIEXPORT jboolean JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SaveImage (JNIEnv *env, jclass, jobject aFileName, jobject aFormat, jobject aView)
248 {
249 jboolean thejret;
250
251 jcas_Locking alock(env);
252 {
253 try {
254 Standard_CString the_aFileName = jcas_ConvertToCString(env,aFileName);
255 Standard_CString the_aFormat = jcas_ConvertToCString(env,aFormat);
256  Handle( V3d_View ) the_aView;
257  void*                ptr_aView = jcas_GetHandle(env,aView);
258  
259  if ( ptr_aView != NULL ) the_aView = *(   (  Handle( V3d_View )*  )ptr_aView   );
260
261  thejret = SampleDisplayAnimationPackage::SaveImage(the_aFileName,the_aFormat,the_aView);
262
263 }
264 catch (Standard_Failure) {
265   Standard_SStream Err;
266   Err <<   Standard_Failure::Caught(); 
267   Err << (char) 0;
268   jcas_ThrowException(env,Err.str().c_str());
269 }
270 }
271 alock.Release();
272 return thejret;
273 }
274
275
276 }