7fd59977 |
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_ISession2D_InteractiveContext.h> |
22 | #include <ISession2D_InteractiveContext.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 <V2d_Viewer.hxx> |
30 | #include <AIS_InteractiveObject.hxx> |
31 | #include <Standard_Boolean.hxx> |
32 | #include <Standard_Integer.hxx> |
33 | #include <V2d_View.hxx> |
34 | |
35 | |
36 | extern "C" { |
37 | |
38 | |
39 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Create_11 (JNIEnv *env, jobject theobj) |
40 | { |
41 | |
42 | jcas_Locking alock(env); |
43 | { |
44 | try { |
45 | Handle(ISession2D_InteractiveContext)* theret = new Handle(ISession2D_InteractiveContext); |
46 | *theret = new ISession2D_InteractiveContext(); |
47 | jcas_SetHandle(env,theobj,theret); |
48 | |
49 | } |
50 | catch (Standard_Failure) { |
51 | Standard_SStream Err; |
52 | Err << Standard_Failure::Caught(); |
53 | Err << (char) 0; |
54 | jcas_ThrowException(env,Err.str().c_str()); |
55 | } |
56 | } |
57 | alock.Release(); |
58 | |
59 | } |
60 | |
61 | |
62 | |
63 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Create_12 (JNIEnv *env, jobject theobj, jobject aViewer) |
64 | { |
65 | |
66 | jcas_Locking alock(env); |
67 | { |
68 | try { |
69 | Handle( V2d_Viewer ) the_aViewer; |
70 | void* ptr_aViewer = jcas_GetHandle(env,aViewer); |
71 | |
72 | if ( ptr_aViewer != NULL ) the_aViewer = *( ( Handle( V2d_Viewer )* )ptr_aViewer ); |
73 | |
74 | Handle(ISession2D_InteractiveContext)* theret = new Handle(ISession2D_InteractiveContext); |
75 | *theret = new ISession2D_InteractiveContext(the_aViewer); |
76 | jcas_SetHandle(env,theobj,theret); |
77 | |
78 | } |
79 | catch (Standard_Failure) { |
80 | Standard_SStream Err; |
81 | Err << Standard_Failure::Caught(); |
82 | Err << (char) 0; |
83 | jcas_ThrowException(env,Err.str().c_str()); |
84 | } |
85 | } |
86 | alock.Release(); |
87 | |
88 | } |
89 | |
90 | |
91 | |
92 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Initialize (JNIEnv *env, jobject theobj, jobject aViewer) |
93 | { |
94 | |
95 | jcas_Locking alock(env); |
96 | { |
97 | try { |
98 | Handle( V2d_Viewer ) the_aViewer; |
99 | void* ptr_aViewer = jcas_GetHandle(env,aViewer); |
100 | |
101 | if ( ptr_aViewer != NULL ) the_aViewer = *( ( Handle( V2d_Viewer )* )ptr_aViewer ); |
102 | |
103 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
104 | the_this->Initialize(the_aViewer); |
105 | |
106 | } |
107 | catch (Standard_Failure) { |
108 | Standard_SStream Err; |
109 | Err << Standard_Failure::Caught(); |
110 | Err << (char) 0; |
111 | jcas_ThrowException(env,Err.str().c_str()); |
112 | } |
113 | } |
114 | alock.Release(); |
115 | |
116 | } |
117 | |
118 | |
119 | |
120 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Display_11 (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
121 | { |
122 | |
123 | jcas_Locking alock(env); |
124 | { |
125 | try { |
126 | Handle( AIS_InteractiveObject ) the_anObject; |
127 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
128 | |
129 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
130 | |
131 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
132 | the_this->Display(the_anObject,(Standard_Boolean) Redraw); |
133 | |
134 | } |
135 | catch (Standard_Failure) { |
136 | Standard_SStream Err; |
137 | Err << Standard_Failure::Caught(); |
138 | Err << (char) 0; |
139 | jcas_ThrowException(env,Err.str().c_str()); |
140 | } |
141 | } |
142 | alock.Release(); |
143 | |
144 | } |
145 | |
146 | |
147 | |
148 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Display_12 (JNIEnv *env, jobject theobj, jobject anObject, jint aDisplayMode, jint aSelectionMode, jboolean Redraw) |
149 | { |
150 | |
151 | jcas_Locking alock(env); |
152 | { |
153 | try { |
154 | Handle( AIS_InteractiveObject ) the_anObject; |
155 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
156 | |
157 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
158 | |
159 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
160 | the_this->Display(the_anObject,(Standard_Integer) aDisplayMode,(Standard_Integer) aSelectionMode,(Standard_Boolean) Redraw); |
161 | |
162 | } |
163 | catch (Standard_Failure) { |
164 | Standard_SStream Err; |
165 | Err << Standard_Failure::Caught(); |
166 | Err << (char) 0; |
167 | jcas_ThrowException(env,Err.str().c_str()); |
168 | } |
169 | } |
170 | alock.Release(); |
171 | |
172 | } |
173 | |
174 | |
175 | |
176 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Erase (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
177 | { |
178 | |
179 | jcas_Locking alock(env); |
180 | { |
181 | try { |
182 | Handle( AIS_InteractiveObject ) the_anObject; |
183 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
184 | |
185 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
186 | |
187 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
188 | the_this->Erase(the_anObject,(Standard_Boolean) Redraw); |
189 | |
190 | } |
191 | catch (Standard_Failure) { |
192 | Standard_SStream Err; |
193 | Err << Standard_Failure::Caught(); |
194 | Err << (char) 0; |
195 | jcas_ThrowException(env,Err.str().c_str()); |
196 | } |
197 | } |
198 | alock.Release(); |
199 | |
200 | } |
201 | |
202 | |
203 | |
204 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_DisplayAll (JNIEnv *env, jobject theobj, jboolean Redraw) |
205 | { |
206 | |
207 | jcas_Locking alock(env); |
208 | { |
209 | try { |
210 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
211 | the_this->DisplayAll((Standard_Boolean) Redraw); |
212 | |
213 | } |
214 | catch (Standard_Failure) { |
215 | Standard_SStream Err; |
216 | Err << Standard_Failure::Caught(); |
217 | Err << (char) 0; |
218 | jcas_ThrowException(env,Err.str().c_str()); |
219 | } |
220 | } |
221 | alock.Release(); |
222 | |
223 | } |
224 | |
225 | |
226 | |
227 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_EraseAll (JNIEnv *env, jobject theobj, jboolean Redraw) |
228 | { |
229 | |
230 | jcas_Locking alock(env); |
231 | { |
232 | try { |
233 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
234 | the_this->EraseAll((Standard_Boolean) Redraw); |
235 | |
236 | } |
237 | catch (Standard_Failure) { |
238 | Standard_SStream Err; |
239 | Err << Standard_Failure::Caught(); |
240 | Err << (char) 0; |
241 | jcas_ThrowException(env,Err.str().c_str()); |
242 | } |
243 | } |
244 | alock.Release(); |
245 | |
246 | } |
247 | |
248 | |
249 | |
250 | JNIEXPORT jboolean JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_IsDisplayed (JNIEnv *env, jobject theobj, jobject anObject, jint aMode) |
251 | { |
252 | jboolean thejret; |
253 | |
254 | jcas_Locking alock(env); |
255 | { |
256 | try { |
257 | Handle( AIS_InteractiveObject ) the_anObject; |
258 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
259 | |
260 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
261 | |
262 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
263 | thejret = the_this->IsDisplayed(the_anObject,(Standard_Integer) aMode); |
264 | |
265 | } |
266 | catch (Standard_Failure) { |
267 | Standard_SStream Err; |
268 | Err << Standard_Failure::Caught(); |
269 | Err << (char) 0; |
270 | jcas_ThrowException(env,Err.str().c_str()); |
271 | } |
272 | } |
273 | alock.Release(); |
274 | return thejret; |
275 | } |
276 | |
277 | |
278 | |
279 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Redisplay (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw, jboolean allmodes) |
280 | { |
281 | |
282 | jcas_Locking alock(env); |
283 | { |
284 | try { |
285 | Handle( AIS_InteractiveObject ) the_anObject; |
286 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
287 | |
288 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
289 | |
290 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
291 | the_this->Redisplay(the_anObject,(Standard_Boolean) Redraw,(Standard_Boolean) allmodes); |
292 | |
293 | } |
294 | catch (Standard_Failure) { |
295 | Standard_SStream Err; |
296 | Err << Standard_Failure::Caught(); |
297 | Err << (char) 0; |
298 | jcas_ThrowException(env,Err.str().c_str()); |
299 | } |
300 | } |
301 | alock.Release(); |
302 | |
303 | } |
304 | |
305 | |
306 | |
307 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Clear (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
308 | { |
309 | |
310 | jcas_Locking alock(env); |
311 | { |
312 | try { |
313 | Handle( AIS_InteractiveObject ) the_anObject; |
314 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
315 | |
316 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
317 | |
318 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
319 | the_this->Clear(the_anObject,(Standard_Boolean) Redraw); |
320 | |
321 | } |
322 | catch (Standard_Failure) { |
323 | Standard_SStream Err; |
324 | Err << Standard_Failure::Caught(); |
325 | Err << (char) 0; |
326 | jcas_ThrowException(env,Err.str().c_str()); |
327 | } |
328 | } |
329 | alock.Release(); |
330 | |
331 | } |
332 | |
333 | |
334 | |
335 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Remove (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
336 | { |
337 | |
338 | jcas_Locking alock(env); |
339 | { |
340 | try { |
341 | Handle( AIS_InteractiveObject ) the_anObject; |
342 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
343 | |
344 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
345 | |
346 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
347 | the_this->Remove(the_anObject,(Standard_Boolean) Redraw); |
348 | |
349 | } |
350 | catch (Standard_Failure) { |
351 | Standard_SStream Err; |
352 | Err << Standard_Failure::Caught(); |
353 | Err << (char) 0; |
354 | jcas_ThrowException(env,Err.str().c_str()); |
355 | } |
356 | } |
357 | alock.Release(); |
358 | |
359 | } |
360 | |
361 | |
362 | |
363 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Highlight (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
364 | { |
365 | |
366 | jcas_Locking alock(env); |
367 | { |
368 | try { |
369 | Handle( AIS_InteractiveObject ) the_anObject; |
370 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
371 | |
372 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
373 | |
374 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
375 | the_this->Highlight(the_anObject,(Standard_Boolean) Redraw); |
376 | |
377 | } |
378 | catch (Standard_Failure) { |
379 | Standard_SStream Err; |
380 | Err << Standard_Failure::Caught(); |
381 | Err << (char) 0; |
382 | jcas_ThrowException(env,Err.str().c_str()); |
383 | } |
384 | } |
385 | alock.Release(); |
386 | |
387 | } |
388 | |
389 | |
390 | |
391 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Unhighlight (JNIEnv *env, jobject theobj, jobject anObject, jboolean Redraw) |
392 | { |
393 | |
394 | jcas_Locking alock(env); |
395 | { |
396 | try { |
397 | Handle( AIS_InteractiveObject ) the_anObject; |
398 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
399 | |
400 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
401 | |
402 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
403 | the_this->Unhighlight(the_anObject,(Standard_Boolean) Redraw); |
404 | |
405 | } |
406 | catch (Standard_Failure) { |
407 | Standard_SStream Err; |
408 | Err << Standard_Failure::Caught(); |
409 | Err << (char) 0; |
410 | jcas_ThrowException(env,Err.str().c_str()); |
411 | } |
412 | } |
413 | alock.Release(); |
414 | |
415 | } |
416 | |
417 | |
418 | |
419 | JNIEXPORT jboolean JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_IsHilighted (JNIEnv *env, jobject theobj, jobject anObject) |
420 | { |
421 | jboolean thejret; |
422 | |
423 | jcas_Locking alock(env); |
424 | { |
425 | try { |
426 | Handle( AIS_InteractiveObject ) the_anObject; |
427 | void* ptr_anObject = jcas_GetHandle(env,anObject); |
428 | |
429 | if ( ptr_anObject != NULL ) the_anObject = *( ( Handle( AIS_InteractiveObject )* )ptr_anObject ); |
430 | |
431 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
432 | thejret = the_this->IsHilighted(the_anObject); |
433 | |
434 | } |
435 | catch (Standard_Failure) { |
436 | Standard_SStream Err; |
437 | Err << Standard_Failure::Caught(); |
438 | Err << (char) 0; |
439 | jcas_ThrowException(env,Err.str().c_str()); |
440 | } |
441 | } |
442 | alock.Release(); |
443 | return thejret; |
444 | } |
445 | |
446 | |
447 | |
448 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Move_11 (JNIEnv *env, jobject theobj, jint x1, jint y1, jobject aView) |
449 | { |
450 | |
451 | jcas_Locking alock(env); |
452 | { |
453 | try { |
454 | Handle( V2d_View ) the_aView; |
455 | void* ptr_aView = jcas_GetHandle(env,aView); |
456 | |
457 | if ( ptr_aView != NULL ) the_aView = *( ( Handle( V2d_View )* )ptr_aView ); |
458 | |
459 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
460 | the_this->Move((Standard_Integer) x1,(Standard_Integer) y1,the_aView); |
461 | |
462 | } |
463 | catch (Standard_Failure) { |
464 | Standard_SStream Err; |
465 | Err << Standard_Failure::Caught(); |
466 | Err << (char) 0; |
467 | jcas_ThrowException(env,Err.str().c_str()); |
468 | } |
469 | } |
470 | alock.Release(); |
471 | |
472 | } |
473 | |
474 | |
475 | |
476 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ISession2D_1InteractiveContext_1Move_12 (JNIEnv *env, jobject theobj, jint x1, jint y1, jint x2, jint y2, jobject aView) |
477 | { |
478 | |
479 | jcas_Locking alock(env); |
480 | { |
481 | try { |
482 | Handle( V2d_View ) the_aView; |
483 | void* ptr_aView = jcas_GetHandle(env,aView); |
484 | |
485 | if ( ptr_aView != NULL ) the_aView = *( ( Handle( V2d_View )* )ptr_aView ); |
486 | |
487 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
488 | the_this->Move((Standard_Integer) x1,(Standard_Integer) y1,(Standard_Integer) x2,(Standard_Integer) y2,the_aView); |
489 | |
490 | } |
491 | catch (Standard_Failure) { |
492 | Standard_SStream Err; |
493 | Err << Standard_Failure::Caught(); |
494 | Err << (char) 0; |
495 | jcas_ThrowException(env,Err.str().c_str()); |
496 | } |
497 | } |
498 | alock.Release(); |
499 | |
500 | } |
501 | |
502 | |
503 | |
504 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_Pick (JNIEnv *env, jobject theobj, jboolean MultiSelection) |
505 | { |
506 | |
507 | jcas_Locking alock(env); |
508 | { |
509 | try { |
510 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
511 | the_this->Pick((Standard_Boolean) MultiSelection); |
512 | |
513 | } |
514 | catch (Standard_Failure) { |
515 | Standard_SStream Err; |
516 | Err << Standard_Failure::Caught(); |
517 | Err << (char) 0; |
518 | jcas_ThrowException(env,Err.str().c_str()); |
519 | } |
520 | } |
521 | alock.Release(); |
522 | |
523 | } |
524 | |
525 | |
526 | |
527 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_DisplayAreas (JNIEnv *env, jobject theobj) |
528 | { |
529 | |
530 | jcas_Locking alock(env); |
531 | { |
532 | try { |
533 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
534 | the_this->DisplayAreas(); |
535 | |
536 | } |
537 | catch (Standard_Failure) { |
538 | Standard_SStream Err; |
539 | Err << Standard_Failure::Caught(); |
540 | Err << (char) 0; |
541 | jcas_ThrowException(env,Err.str().c_str()); |
542 | } |
543 | } |
544 | alock.Release(); |
545 | |
546 | } |
547 | |
548 | |
549 | |
550 | JNIEXPORT void JNICALL Java_CASCADESamplesJni_ISession2D_1InteractiveContext_ClearAreas (JNIEnv *env, jobject theobj) |
551 | { |
552 | |
553 | jcas_Locking alock(env); |
554 | { |
555 | try { |
556 | Handle(ISession2D_InteractiveContext) the_this = *((Handle(ISession2D_InteractiveContext)*) jcas_GetHandle(env,theobj)); |
557 | the_this->ClearAreas(); |
558 | |
559 | } |
560 | catch (Standard_Failure) { |
561 | Standard_SStream Err; |
562 | Err << Standard_Failure::Caught(); |
563 | Err << (char) 0; |
564 | jcas_ThrowException(env,Err.str().c_str()); |
565 | } |
566 | } |
567 | alock.Release(); |
568 | |
569 | } |
570 | |
571 | |
572 | } |