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 <SampleHLRJni_Aspect_ColorCubeColorMap.h> |
22 | #include <Aspect_ColorCubeColorMap.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 <Standard_Integer.hxx> |
30 | #include <Aspect_ColorMapEntry.hxx> |
31 | #include <Quantity_Color.hxx> |
32 | |
33 | |
34 | extern "C" { |
35 | |
36 | |
37 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_Aspect_1ColorCubeColorMap_1Create_10 (JNIEnv *env, jobject theobj, jint base_pixel, jint redmax, jint redmult, jint greenmax, jint greenmult, jint bluemax, jint bluemult) |
38 | { |
39 | |
40 | jcas_Locking alock(env); |
41 | { |
42 | try { |
43 | Handle(Aspect_ColorCubeColorMap)* theret = new Handle(Aspect_ColorCubeColorMap); |
44 | *theret = new Aspect_ColorCubeColorMap((Standard_Integer) base_pixel,(Standard_Integer) redmax,(Standard_Integer) redmult,(Standard_Integer) greenmax,(Standard_Integer) greenmult,(Standard_Integer) bluemax,(Standard_Integer) bluemult); |
45 | jcas_SetHandle(env,theobj,theret); |
46 | |
47 | } |
48 | catch (Standard_Failure) { |
49 | Standard_SStream Err; |
50 | Err << Standard_Failure::Caught(); |
51 | Err << (char) 0; |
52 | jcas_ThrowException(env,Err.str().c_str()); |
53 | } |
54 | } |
55 | alock.Release(); |
56 | |
57 | } |
58 | |
59 | |
60 | |
61 | JNIEXPORT void JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_ColorCubeDefinition (JNIEnv *env, jobject theobj, jobject base_pixel, jobject redmax, jobject redmult, jobject greenmax, jobject greenmult, jobject bluemax, jobject bluemult) |
62 | { |
63 | |
64 | jcas_Locking alock(env); |
65 | { |
66 | try { |
67 | Standard_Integer the_base_pixel = jcas_GetInteger(env,base_pixel); |
68 | Standard_Integer the_redmax = jcas_GetInteger(env,redmax); |
69 | Standard_Integer the_redmult = jcas_GetInteger(env,redmult); |
70 | Standard_Integer the_greenmax = jcas_GetInteger(env,greenmax); |
71 | Standard_Integer the_greenmult = jcas_GetInteger(env,greenmult); |
72 | Standard_Integer the_bluemax = jcas_GetInteger(env,bluemax); |
73 | Standard_Integer the_bluemult = jcas_GetInteger(env,bluemult); |
74 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
75 | the_this->ColorCubeDefinition(the_base_pixel,the_redmax,the_redmult,the_greenmax,the_greenmult,the_bluemax,the_bluemult); |
76 | jcas_SetInteger(env,base_pixel,the_base_pixel); |
77 | jcas_SetInteger(env,redmax,the_redmax); |
78 | jcas_SetInteger(env,redmult,the_redmult); |
79 | jcas_SetInteger(env,greenmax,the_greenmax); |
80 | jcas_SetInteger(env,greenmult,the_greenmult); |
81 | jcas_SetInteger(env,bluemax,the_bluemax); |
82 | jcas_SetInteger(env,bluemult,the_bluemult); |
83 | |
84 | } |
85 | catch (Standard_Failure) { |
86 | Standard_SStream Err; |
87 | Err << Standard_Failure::Caught(); |
88 | Err << (char) 0; |
89 | jcas_ThrowException(env,Err.str().c_str()); |
90 | } |
91 | } |
92 | alock.Release(); |
93 | |
94 | } |
95 | |
96 | |
97 | |
98 | JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_FindColorMapIndex (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex) |
99 | { |
100 | jint thejret; |
101 | |
102 | jcas_Locking alock(env); |
103 | { |
104 | try { |
105 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
106 | thejret = the_this->FindColorMapIndex((Standard_Integer) AColorMapEntryIndex); |
107 | |
108 | } |
109 | catch (Standard_Failure) { |
110 | Standard_SStream Err; |
111 | Err << Standard_Failure::Caught(); |
112 | Err << (char) 0; |
113 | jcas_ThrowException(env,Err.str().c_str()); |
114 | } |
115 | } |
116 | alock.Release(); |
117 | return thejret; |
118 | } |
119 | |
120 | |
121 | |
122 | JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_FindEntry (JNIEnv *env, jobject theobj, jint AColorMapEntryIndex) |
123 | { |
124 | jobject thejret; |
125 | |
126 | jcas_Locking alock(env); |
127 | { |
128 | try { |
129 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
130 | const Aspect_ColorMapEntry& theret = the_this->FindEntry((Standard_Integer) AColorMapEntryIndex); |
131 | thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0); |
132 | |
133 | } |
134 | catch (Standard_Failure) { |
135 | Standard_SStream Err; |
136 | Err << Standard_Failure::Caught(); |
137 | Err << (char) 0; |
138 | jcas_ThrowException(env,Err.str().c_str()); |
139 | } |
140 | } |
141 | alock.Release(); |
142 | return thejret; |
143 | } |
144 | |
145 | |
146 | |
147 | JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_NearestColorMapIndex (JNIEnv *env, jobject theobj, jobject aColor) |
148 | { |
149 | jint thejret; |
150 | |
151 | jcas_Locking alock(env); |
152 | { |
153 | try { |
154 | Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor); |
155 | if ( the_aColor == NULL ) { |
156 | |
157 | // The following assumes availability of the default constructor (what may not |
158 | // always be the case). Therefore explicit exception is thrown if the null |
159 | // object has been passed. |
160 | // the_aColor = new Quantity_Color (); |
161 | // jcas_SetHandle ( env, aColor, the_aColor ); |
162 | jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); |
163 | |
164 | } // end if |
165 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
166 | thejret = the_this->NearestColorMapIndex(*the_aColor); |
167 | |
168 | } |
169 | catch (Standard_Failure) { |
170 | Standard_SStream Err; |
171 | Err << Standard_Failure::Caught(); |
172 | Err << (char) 0; |
173 | jcas_ThrowException(env,Err.str().c_str()); |
174 | } |
175 | } |
176 | alock.Release(); |
177 | return thejret; |
178 | } |
179 | |
180 | |
181 | |
182 | JNIEXPORT jobject JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_NearestEntry (JNIEnv *env, jobject theobj, jobject aColor) |
183 | { |
184 | jobject thejret; |
185 | |
186 | jcas_Locking alock(env); |
187 | { |
188 | try { |
189 | Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor); |
190 | if ( the_aColor == NULL ) { |
191 | |
192 | // The following assumes availability of the default constructor (what may not |
193 | // always be the case). Therefore explicit exception is thrown if the null |
194 | // object has been passed. |
195 | // the_aColor = new Quantity_Color (); |
196 | // jcas_SetHandle ( env, aColor, the_aColor ); |
197 | jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); |
198 | |
199 | } // end if |
200 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
201 | const Aspect_ColorMapEntry& theret = the_this->NearestEntry(*the_aColor); |
202 | thejret = jcas_CreateObject(env,"CASCADESamplesJni/Aspect_ColorMapEntry",&theret,0); |
203 | |
204 | } |
205 | catch (Standard_Failure) { |
206 | Standard_SStream Err; |
207 | Err << Standard_Failure::Caught(); |
208 | Err << (char) 0; |
209 | jcas_ThrowException(env,Err.str().c_str()); |
210 | } |
211 | } |
212 | alock.Release(); |
213 | return thejret; |
214 | } |
215 | |
216 | |
217 | |
218 | JNIEXPORT jint JNICALL Java_SampleHLRJni_Aspect_1ColorCubeColorMap_AddEntry (JNIEnv *env, jobject theobj, jobject aColor) |
219 | { |
220 | jint thejret; |
221 | |
222 | jcas_Locking alock(env); |
223 | { |
224 | try { |
225 | Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor); |
226 | if ( the_aColor == NULL ) { |
227 | |
228 | // The following assumes availability of the default constructor (what may not |
229 | // always be the case). Therefore explicit exception is thrown if the null |
230 | // object has been passed. |
231 | // the_aColor = new Quantity_Color (); |
232 | // jcas_SetHandle ( env, aColor, the_aColor ); |
233 | jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); |
234 | |
235 | } // end if |
236 | Handle(Aspect_ColorCubeColorMap) the_this = *((Handle(Aspect_ColorCubeColorMap)*) jcas_GetHandle(env,theobj)); |
237 | thejret = the_this->AddEntry(*the_aColor); |
238 | |
239 | } |
240 | catch (Standard_Failure) { |
241 | Standard_SStream Err; |
242 | Err << Standard_Failure::Caught(); |
243 | Err << (char) 0; |
244 | jcas_ThrowException(env,Err.str().c_str()); |
245 | } |
246 | } |
247 | alock.Release(); |
248 | return thejret; |
249 | } |
250 | |
251 | |
252 | } |