2 // Copyright (C) 1991 - 2000 by
3 // Matra Datavision SA. All rights reserved.
5 // Copyright (C) 2001 - 2004 by
6 // Open CASCADE SA. All rights reserved.
8 // This file is part of the Open CASCADE Technology software.
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.
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
22 #include <SampleAISBasicJni_SampleAISBasicPackage.h>
23 #include <SampleAISBasicPackage.hxx>
26 #include <Standard_ErrorHandler.hxx>
27 #include <Standard_Failure.hxx>
28 #include <Standard_SStream.hxx>
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>
41 JNIEXPORT jobject JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_CreateViewer (JNIEnv *env, jclass, jstring aName)
45 jcas_Locking alock(env);
48 Standard_ExtString the_aName = jcas_ConvertToExtString(env,aName);
49 Handle(V3d_Viewer)* theret = new Handle(V3d_Viewer);
50 *theret = SampleAISBasicPackage::CreateViewer(the_aName);
51 thejret = jcas_CreateObject(env,"CASCADESamplesJni/V3d_Viewer",theret);
54 catch (Standard_Failure) {
56 Err << Standard_Failure::Caught();
58 jcas_ThrowException(env,Err.str().c_str());
67 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_SetWindow (JNIEnv *env, jclass, jobject aView, jint hiwin, jint lowin)
70 jcas_Locking alock(env);
73 Handle( V3d_View ) the_aView;
74 void* ptr_aView = jcas_GetHandle(env,aView);
76 if ( ptr_aView != NULL ) the_aView = *( ( Handle( V3d_View )* )ptr_aView );
78 SampleAISBasicPackage::SetWindow(the_aView,(Standard_Integer) hiwin,(Standard_Integer) lowin);
81 catch (Standard_Failure) {
83 Err << Standard_Failure::Caught();
85 jcas_ThrowException(env,Err.str().c_str());
94 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayTrihedron (JNIEnv *env, jclass, jobject aContext)
97 jcas_Locking alock(env);
100 Handle( AIS_InteractiveContext ) the_aContext;
101 void* ptr_aContext = jcas_GetHandle(env,aContext);
103 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
105 SampleAISBasicPackage::DisplayTrihedron(the_aContext);
108 catch (Standard_Failure) {
109 Standard_SStream Err;
110 Err << Standard_Failure::Caught();
112 jcas_ThrowException(env,Err.str().c_str());
121 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayCircle (JNIEnv *env, jclass, jobject aContext, jobject Message)
124 jcas_Locking alock(env);
127 Handle( AIS_InteractiveContext ) the_aContext;
128 void* ptr_aContext = jcas_GetHandle(env,aContext);
130 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
132 TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
133 if ( the_Message == NULL ) {
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");
143 SampleAISBasicPackage::DisplayCircle(the_aContext,*the_Message);
146 catch (Standard_Failure) {
147 Standard_SStream Err;
148 Err << Standard_Failure::Caught();
150 jcas_ThrowException(env,Err.str().c_str());
159 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayLine (JNIEnv *env, jclass, jobject aContext, jobject Message)
162 jcas_Locking alock(env);
165 Handle( AIS_InteractiveContext ) the_aContext;
166 void* ptr_aContext = jcas_GetHandle(env,aContext);
168 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
170 TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
171 if ( the_Message == NULL ) {
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");
181 SampleAISBasicPackage::DisplayLine(the_aContext,*the_Message);
184 catch (Standard_Failure) {
185 Standard_SStream Err;
186 Err << Standard_Failure::Caught();
188 jcas_ThrowException(env,Err.str().c_str());
197 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplaySphere (JNIEnv *env, jclass, jobject aContext, jobject Message)
200 jcas_Locking alock(env);
203 Handle( AIS_InteractiveContext ) the_aContext;
204 void* ptr_aContext = jcas_GetHandle(env,aContext);
206 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
208 TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
209 if ( the_Message == NULL ) {
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");
219 SampleAISBasicPackage::DisplaySphere(the_aContext,*the_Message);
222 catch (Standard_Failure) {
223 Standard_SStream Err;
224 Err << Standard_Failure::Caught();
226 jcas_ThrowException(env,Err.str().c_str());
235 JNIEXPORT void JNICALL Java_SampleAISBasicJni_SampleAISBasicPackage_DisplayCylinder (JNIEnv *env, jclass, jobject aContext, jobject Message)
238 jcas_Locking alock(env);
241 Handle( AIS_InteractiveContext ) the_aContext;
242 void* ptr_aContext = jcas_GetHandle(env,aContext);
244 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
246 TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message);
247 if ( the_Message == NULL ) {
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");
257 SampleAISBasicPackage::DisplayCylinder(the_aContext,*the_Message);
260 catch (Standard_Failure) {
261 Standard_SStream Err;
262 Err << Standard_Failure::Caught();
264 jcas_ThrowException(env,Err.str().c_str());