Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / drv / SampleAISBasicJni / SampleAISBasicJni_SampleAISBasicPackage_java.cxx
CommitLineData
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
22#include <SampleAISBasicJni_SampleAISBasicPackage.h>
23#include <SampleAISBasicPackage.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 <AIS_InteractiveContext.hxx>
35#include <TCollection_AsciiString.hxx>
36
37
38extern "C" {
39
40
41JNIEXPORT jobject JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_CreateViewer (JNIEnv *env, jclass, jstring aName)
42{
43jobject thejret;
44
45jcas_Locking alock(env);
46{
47try {
48Standard_ExtString the_aName = jcas_ConvertToExtString(env,aName);
49Handle(V3d_Viewer)* theret = new Handle(V3d_Viewer);
50*theret = SampleAISBasicPackage::CreateViewer(the_aName);
51thejret = jcas_CreateObject(env,"CASCADESamplesJni/V3d_Viewer",theret);
52
53}
54catch (Standard_Failure) {
55 Standard_SStream Err;
56 Err << Standard_Failure::Caught();
57 Err << (char) 0;
58 jcas_ThrowException(env,Err.str().c_str());
59}
60}
61alock.Release();
62return thejret;
63}
64
65
66
67JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_SetWindow (JNIEnv *env, jclass, jobject aView, jint hiwin, jint lowin)
68{
69
70jcas_Locking alock(env);
71{
72try {
73 Handle( V3d_View ) the_aView;
74 void* ptr_aView = jcas_GetHandle(env,aView);
75
76 if ( ptr_aView != NULL ) the_aView = *( ( Handle( V3d_View )* )ptr_aView );
77
78SampleAISBasicPackage::SetWindow(the_aView,(Standard_Integer) hiwin,(Standard_Integer) lowin);
79
80}
81catch (Standard_Failure) {
82 Standard_SStream Err;
83 Err << Standard_Failure::Caught();
84 Err << (char) 0;
85 jcas_ThrowException(env,Err.str().c_str());
86}
87}
88alock.Release();
89
90}
91
92
93
94JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayTrihedron (JNIEnv *env, jclass, jobject aContext)
95{
96
97jcas_Locking alock(env);
98{
99try {
100 Handle( AIS_InteractiveContext ) the_aContext;
101 void* ptr_aContext = jcas_GetHandle(env,aContext);
102
103 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
104
105SampleAISBasicPackage::DisplayTrihedron(the_aContext);
106
107}
108catch (Standard_Failure) {
109 Standard_SStream Err;
110 Err << Standard_Failure::Caught();
111 Err << (char) 0;
112 jcas_ThrowException(env,Err.str().c_str());
113}
114}
115alock.Release();
116
117}
118
119
120
121JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayCircle (JNIEnv *env, jclass, jobject aContext, jobject Message)
122{
123
124jcas_Locking alock(env);
125{
126try {
127 Handle( AIS_InteractiveContext ) the_aContext;
128 void* ptr_aContext = jcas_GetHandle(env,aContext);
129
130 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
131
132TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
133if ( the_Message == NULL ) {
134
135 // The following assumes availability of the default constructor (what may not
136 // always be the case). Therefore explicit exception is thrown if the null
137 // object has been passed.
138 // the_Message = new TCollection_AsciiString ();
139 // jcas_SetHandle ( env, Message, the_Message );
140 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
141
142} // end if
143SampleAISBasicPackage::DisplayCircle(the_aContext,*the_Message);
144
145}
146catch (Standard_Failure) {
147 Standard_SStream Err;
148 Err << Standard_Failure::Caught();
149 Err << (char) 0;
150 jcas_ThrowException(env,Err.str().c_str());
151}
152}
153alock.Release();
154
155}
156
157
158
159JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayLine (JNIEnv *env, jclass, jobject aContext, jobject Message)
160{
161
162jcas_Locking alock(env);
163{
164try {
165 Handle( AIS_InteractiveContext ) the_aContext;
166 void* ptr_aContext = jcas_GetHandle(env,aContext);
167
168 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
169
170TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
171if ( the_Message == NULL ) {
172
173 // The following assumes availability of the default constructor (what may not
174 // always be the case). Therefore explicit exception is thrown if the null
175 // object has been passed.
176 // the_Message = new TCollection_AsciiString ();
177 // jcas_SetHandle ( env, Message, the_Message );
178 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
179
180} // end if
181SampleAISBasicPackage::DisplayLine(the_aContext,*the_Message);
182
183}
184catch (Standard_Failure) {
185 Standard_SStream Err;
186 Err << Standard_Failure::Caught();
187 Err << (char) 0;
188 jcas_ThrowException(env,Err.str().c_str());
189}
190}
191alock.Release();
192
193}
194
195
196
197JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplaySphere (JNIEnv *env, jclass, jobject aContext, jobject Message)
198{
199
200jcas_Locking alock(env);
201{
202try {
203 Handle( AIS_InteractiveContext ) the_aContext;
204 void* ptr_aContext = jcas_GetHandle(env,aContext);
205
206 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
207
208TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
209if ( the_Message == NULL ) {
210
211 // The following assumes availability of the default constructor (what may not
212 // always be the case). Therefore explicit exception is thrown if the null
213 // object has been passed.
214 // the_Message = new TCollection_AsciiString ();
215 // jcas_SetHandle ( env, Message, the_Message );
216 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
217
218} // end if
219SampleAISBasicPackage::DisplaySphere(the_aContext,*the_Message);
220
221}
222catch (Standard_Failure) {
223 Standard_SStream Err;
224 Err << Standard_Failure::Caught();
225 Err << (char) 0;
226 jcas_ThrowException(env,Err.str().c_str());
227}
228}
229alock.Release();
230
231}
232
233
234
235JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayCylinder (JNIEnv *env, jclass, jobject aContext, jobject Message)
236{
237
238jcas_Locking alock(env);
239{
240try {
241 Handle( AIS_InteractiveContext ) the_aContext;
242 void* ptr_aContext = jcas_GetHandle(env,aContext);
243
244 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
245
246TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
247if ( the_Message == NULL ) {
248
249 // The following assumes availability of the default constructor (what may not
250 // always be the case). Therefore explicit exception is thrown if the null
251 // object has been passed.
252 // the_Message = new TCollection_AsciiString ();
253 // jcas_SetHandle ( env, Message, the_Message );
254 jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value");
255
256} // end if
257SampleAISBasicPackage::DisplayCylinder(the_aContext,*the_Message);
258
259}
260catch (Standard_Failure) {
261 Standard_SStream Err;
262 Err << Standard_Failure::Caught();
263 Err << (char) 0;
264 jcas_ThrowException(env,Err.str().c_str());
265}
266}
267alock.Release();
268
269}
270
271
272}