Fix direct-casting BOOL / int or BOOL / bool
[scilab.git] / scilab / modules / renderer / src / cpp / GetJavaProperty.cpp
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2007 - INRIA - Jean-Baptiste Silvy
4  * Copyright (C) 2010 - Paul Griffiths
5  * desc : Interface functions between between GetProperty functions and the C++/Java part of module 
6  * 
7  * This file must be used under the terms of the CeCILL.
8  * This source file is licensed as described in the file COPYING, which
9  * you should have received as part of this distribution.  The terms
10  * are also available at    
11  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12  *
13  */
14
15 #include "GetJavaProperty.h"
16 #include "getHandleDrawer.h"
17 #include "figureDrawing/DrawableFigure.h"
18 #include "BasicAlgos.hxx"
19
20 extern "C"
21 {
22 #include "BasicAlgos.h"
23 }
24
25 using namespace sciGraphics;
26
27 /*---------------------------------------------------------------------------------*/
28 void sciGetJavaColormap(sciPointObj * pFigure, double rgbMat[])
29 {
30     getFigureDrawer(pFigure)->getColorMap(rgbMat);
31 }
32
33 /*---------------------------------------------------------------------------------*/
34 void sciGetJavaFigureSize(sciPointObj * pFigure, int size[2])
35 {
36     getFigureDrawer(pFigure)->getSize(size);
37 }
38
39 /*---------------------------------------------------------------------------------*/
40 void sciGetJavaWindowSize(sciPointObj * pFigure, int size[2])
41 {
42     getFigureDrawer(pFigure)->getWindowSize(size);
43 }
44
45 /*---------------------------------------------------------------------------------*/
46 void sciGetJavaWindowPosition(sciPointObj * pFigure, int pos[2])
47 {
48     getFigureDrawer(pFigure)->getWindowPosition(pos);
49 }
50
51 /*---------------------------------------------------------------------------------*/
52 void sciGetJavaInfoMessage(sciPointObj * pFigure, char *infoMessage)
53 {
54     getFigureDrawer(pFigure)->getInfoMessage(infoMessage);
55 }
56
57 /*---------------------------------------------------------------------------------*/
58 int sciGetJavaInfoMessageLength(sciPointObj * pFigure)
59 {
60     return getFigureDrawer(pFigure)->getInfoMessageLength();
61 }
62
63 /*---------------------------------------------------------------------------------*/
64 int sciGetJavaAntialiasingQuality(sciPointObj * pFigure)
65 {
66     return getFigureDrawer(pFigure)->getAntialiasingQuality();
67 }
68
69 /*---------------------------------------------------------------------------------*/
70 void sciGetJavaPixelCoordinates(sciPointObj * pSubwin, const double userCoord[3], int pixCoord[2])
71 {
72     getSubwinDrawer(pSubwin)->getCamera()->getPixelCoordinates(userCoord, pixCoord);
73 }
74
75 /*---------------------------------------------------------------------------------*/
76 void sciGetJava2dViewPixelCoordinates(sciPointObj * pSubwin, const double userCoord[3], int pixCoord[2])
77 {
78     getSubwinDrawer(pSubwin)->getCamera()->get2dViewPixelCoordinates(userCoord, pixCoord);
79 }
80
81 /*---------------------------------------------------------------------------------*/
82 void sciGetJava2dViewCoordinates(sciPointObj * pSubwin, const double userCoords3D[3], double userCoords2D[2])
83 {
84     getSubwinDrawer(pSubwin)->getCamera()->get2dViewCoordinates(userCoords3D, userCoords2D);
85 }
86
87 /*---------------------------------------------------------------------------------*/
88 void sciGetJava2dViewCoordFromPixel(sciPointObj * pSubwin, const int pixCoords[2], double userCoords2D[2])
89 {
90     getSubwinDrawer(pSubwin)->getCamera()->get2dViewCoordinates(pixCoords, userCoords2D);
91 }
92
93 /*---------------------------------------------------------------------------------*/
94 void sciGetJavaBoundingBox(sciPointObj * pText, double corner1[3], double corner2[3], double corner3[3], double corner4[3])
95 {
96     getTextDrawer(pText)->getBoundingRectangle(corner1, corner2, corner3, corner4);
97 }
98
99 /*---------------------------------------------------------------------------------*/
100 void sciGetJavaPixelBoundingBox(sciPointObj * pText, int corner1[2], int corner2[2], int corner3[2], int corner4[2])
101 {
102     getTextDrawer(pText)->getScreenBoundingBox(corner1, corner2, corner3, corner4);
103 }
104
105 /*---------------------------------------------------------------------------------*/
106 void sciGetJavaViewingArea(sciPointObj * pSubwin, int *xPos, int *yPos, int *width, int *height)
107 {
108     getSubwinDrawer(pSubwin)->getCamera()->getViewingArea(xPos, yPos, width, height);
109 }
110
111 /*---------------------------------------------------------------------------------*/
112 void sciGetJavaSegsBoundingBox(sciPointObj * pSegs, double bounds[6])
113 {
114     getSegsDrawer(pSegs)->getBoundingBox(bounds);
115 }
116
117 /*---------------------------------------------------------------------------------*/
118 BOOL sciGetJavaAutoResizeMode(sciPointObj * pFigure)
119 {
120     if (getFigureDrawer(pFigure)->getAutoResizeMode())
121     {
122         return TRUE;
123     }
124     else
125     {
126         return FALSE;
127     }
128 }
129
130 /*---------------------------------------------------------------------------------*/
131 void sciGetJavaViewport(sciPointObj * pFigure, int viewport[4])
132 {
133     getFigureDrawer(pFigure)->getViewport(viewport);
134 }
135
136 /*---------------------------------------------------------------------------------*/
137 void sciGetJavaNbSubticks(sciPointObj * pSubwin, double nbsubtics[3])
138 {
139     getSubwinDrawer(pSubwin)->getNbSubticksPerGrad(nbsubtics);
140 }
141
142 /*---------------------------------------------------------------------------------*/
143 int sciGetJavaNbXTicks(sciPointObj * pSubwin)
144 {
145     return getSubwinDrawer(pSubwin)->getNbXTicks();
146 }
147
148 /*---------------------------------------------------------------------------------*/
149 void sciGetJavaXTicksPos(sciPointObj * pSubwin, double ticksPos[], char **ticksLabels)
150 {
151     // ticksLabels comes from graphics so is allocated with MALLOC
152     // however getTicksPos will use new to allocate
153     int nbTicks = sciGetJavaNbXTicks(pSubwin);
154     char **javaLabels = BasicAlgos::createStringArray(nbTicks);
155
156     getSubwinDrawer(pSubwin)->getXTicksPos(ticksPos, javaLabels);
157
158     // copy it into ticksLabels
159     stringArrayCopy(ticksLabels, javaLabels, nbTicks);
160
161     BasicAlgos::destroyStringArray(javaLabels, nbTicks);
162 }
163
164 /*---------------------------------------------------------------------------------*/
165 int sciGetJavaNbYTicks(sciPointObj * pSubwin)
166 {
167     return getSubwinDrawer(pSubwin)->getNbYTicks();
168 }
169
170 /*---------------------------------------------------------------------------------*/
171 void sciGetJavaYTicksPos(sciPointObj * pSubwin, double ticksPos[], char **ticksLabels)
172 {
173     // ticksLabels comes from graphics so is allocated with MALLOC
174     // however getTicksPos will use new to allocate
175     int nbTicks = sciGetJavaNbYTicks(pSubwin);
176     char **javaLabels = BasicAlgos::createStringArray(nbTicks);
177
178     getSubwinDrawer(pSubwin)->getYTicksPos(ticksPos, javaLabels);
179
180     // copy it into ticksLabels
181     stringArrayCopy(ticksLabels, javaLabels, nbTicks);
182
183     BasicAlgos::destroyStringArray(javaLabels, nbTicks);
184 }
185
186 /*---------------------------------------------------------------------------------*/
187 int sciGetJavaNbZTicks(sciPointObj * pSubwin)
188 {
189     return getSubwinDrawer(pSubwin)->getNbZTicks();
190 }
191
192 /*---------------------------------------------------------------------------------*/
193 void sciGetJavaZTicksPos(sciPointObj * pSubwin, double ticksPos[], char **ticksLabels)
194 {
195     // ticksLabels comes from graphics so is allocated with MALLOC
196     // however getTicksPos will use new to allocate
197     int nbTicks = sciGetJavaNbZTicks(pSubwin);
198     char **javaLabels = BasicAlgos::createStringArray(nbTicks);
199
200     getSubwinDrawer(pSubwin)->getZTicksPos(ticksPos, javaLabels);
201
202     // copy it into ticksLabels
203     stringArrayCopy(ticksLabels, javaLabels, nbTicks);
204
205     BasicAlgos::destroyStringArray(javaLabels, nbTicks);
206 }
207
208 /*---------------------------------------------------------------------------------*/
209 BOOL sciGetJavaIsAbleToCreateWindow(void)
210 {
211     if (DrawableFigure::isAbleToCreateFigure())
212     {
213         return booltoBOOL(true);
214     }
215     else
216     {
217         return booltoBOOL(false);
218     }
219 }
220
221 /*---------------------------------------------------------------------------------*/