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 <SampleDisplayAnimationJni_SampleDisplayAnimationPackage.h>
23 #include <SampleDisplayAnimationPackage.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 <Standard_Boolean.hxx>
35 #include <AIS_InteractiveContext.hxx>
36 #include <Standard_CString.hxx>
37 #include <Standard_Real.hxx>
43 JNIEXPORT jobject JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_CreateViewer (JNIEnv *env, jclass, jstring aName)
47 jcas_Locking alock(env);
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);
56 catch (Standard_Failure) {
58 Err << Standard_Failure::Caught();
60 jcas_ThrowException(env,Err.str().c_str());
69 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetWindow (JNIEnv *env, jclass, jobject aView, jint hiwin, jint lowin)
72 jcas_Locking alock(env);
75 Handle( V3d_View ) the_aView;
76 void* ptr_aView = jcas_GetHandle(env,aView);
78 if ( ptr_aView != NULL ) the_aView = *( ( Handle( V3d_View )* )ptr_aView );
80 SampleDisplayAnimationPackage::SetWindow(the_aView,(Standard_Integer) hiwin,(Standard_Integer) lowin);
83 catch (Standard_Failure) {
85 Err << Standard_Failure::Caught();
87 jcas_ThrowException(env,Err.str().c_str());
96 JNIEXPORT jboolean JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_LoadData (JNIEnv *env, jclass, jobject aContext, jobject aPath)
100 jcas_Locking alock(env);
103 Handle( AIS_InteractiveContext ) the_aContext;
104 void* ptr_aContext = jcas_GetHandle(env,aContext);
106 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
108 Standard_CString the_aPath = jcas_ConvertToCString(env,aPath);
109 thejret = SampleDisplayAnimationPackage::LoadData(the_aContext,the_aPath);
112 catch (Standard_Failure) {
113 Standard_SStream Err;
114 Err << Standard_Failure::Caught();
116 jcas_ThrowException(env,Err.str().c_str());
125 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_ChangePosition (JNIEnv *env, jclass, jobject aContext)
128 jcas_Locking alock(env);
131 Handle( AIS_InteractiveContext ) the_aContext;
132 void* ptr_aContext = jcas_GetHandle(env,aContext);
134 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
136 SampleDisplayAnimationPackage::ChangePosition(the_aContext);
139 catch (Standard_Failure) {
140 Standard_SStream Err;
141 Err << Standard_Failure::Caught();
143 jcas_ThrowException(env,Err.str().c_str());
152 JNIEXPORT jdouble JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_GetDeviationCoefficient (JNIEnv *env, jclass)
156 jcas_Locking alock(env);
159 thejret = SampleDisplayAnimationPackage::GetDeviationCoefficient();
162 catch (Standard_Failure) {
163 Standard_SStream Err;
164 Err << Standard_Failure::Caught();
166 jcas_ThrowException(env,Err.str().c_str());
175 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetDeviationCoefficient (JNIEnv *env, jclass, jobject aContext, jdouble aValue)
178 jcas_Locking alock(env);
181 Handle( AIS_InteractiveContext ) the_aContext;
182 void* ptr_aContext = jcas_GetHandle(env,aContext);
184 if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext );
186 SampleDisplayAnimationPackage::SetDeviationCoefficient(the_aContext,(Standard_Real) aValue);
189 catch (Standard_Failure) {
190 Standard_SStream Err;
191 Err << Standard_Failure::Caught();
193 jcas_ThrowException(env,Err.str().c_str());
202 JNIEXPORT jint JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_GetAngleIncrement (JNIEnv *env, jclass)
206 jcas_Locking alock(env);
209 thejret = SampleDisplayAnimationPackage::GetAngleIncrement();
212 catch (Standard_Failure) {
213 Standard_SStream Err;
214 Err << Standard_Failure::Caught();
216 jcas_ThrowException(env,Err.str().c_str());
225 JNIEXPORT void JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SetAngleIncrement (JNIEnv *env, jclass, jint aValue)
228 jcas_Locking alock(env);
231 SampleDisplayAnimationPackage::SetAngleIncrement((Standard_Integer) aValue);
234 catch (Standard_Failure) {
235 Standard_SStream Err;
236 Err << Standard_Failure::Caught();
238 jcas_ThrowException(env,Err.str().c_str());
247 JNIEXPORT jboolean JNICALL Java_SampleDisplayAnimationJni_SampleDisplayAnimationPackage_SaveImage (JNIEnv *env, jclass, jobject aFileName, jobject aFormat, jobject aView)
251 jcas_Locking alock(env);
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);
259 if ( ptr_aView != NULL ) the_aView = *( ( Handle( V3d_View )* )ptr_aView );
261 thejret = SampleDisplayAnimationPackage::SaveImage(the_aFileName,the_aFormat,the_aView);
264 catch (Standard_Failure) {
265 Standard_SStream Err;
266 Err << Standard_Failure::Caught();
268 jcas_ThrowException(env,Err.str().c_str());