2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 1998-2000 - ENPC - Jean-Philippe Chancelier
4 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
5 * Copyright (C) 2010-2012 - DIGITEO - Manuel Juliachs
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
19 /*------------------------------------------------------------------------
21 --------------------------------------------------------------------------*/
22 /*------------------------------------------------------------------------
23 * Axis drawing for 2d plots
24 *--------------------------------------------------------------------------*/
28 #include "DestroyObjects.h"
29 #include "InitObjects.h"
30 #include "SetProperty.h"
31 #include "axesScale.h"
32 #include "CurrentSubwin.h"
34 #include "GetProperty.h"
35 #include "HandleManagement.h"
37 #include "getGraphicObjectProperty.h"
38 #include "setGraphicObjectProperty.h"
39 #include "graphicObjectProperties.h"
40 #include "AxesModel.h"
41 #include "CurrentSubwin.h"
43 #include "deleteGraphicObject.h"
44 /*--------------------------------------------------------------------------------*/
45 static void initSubWinAngles(int iSubWinUID);
46 static void initSubWinBounds(int iSubWinUID);
47 /*--------------------------------------------------------------------------------*/
48 /* reinit a subwindow (but don't change position) */
49 static void reinitSubWin(int iSubWinUID)
55 int iChildrenCount = 0;
56 int *piChildrenCount = &iChildrenCount;
58 int* piChildrenUID = NULL;
60 /* Deletes the Axes' children */
61 getGraphicObjectProperty(iSubWinUID, __GO_CHILDREN_COUNT__, jni_int, (void **) &piChildrenCount);
63 if (iChildrenCount != 0)
65 getGraphicObjectProperty(iSubWinUID, __GO_CHILDREN__, jni_int_vector, (void **) &piChildrenUID);
67 for (i = 0 ; i < iChildrenCount ; ++i)
69 deleteGraphicObject(piChildrenUID[i]);
73 initSubWinBounds(iSubWinUID);
75 iLabelUID = initLabel(iSubWinUID, __GO_TITLE__);
76 setGraphicObjectProperty(iSubWinUID, __GO_TITLE__, &iLabelUID, jni_int, 1);
78 iLabelUID = initLabel(iSubWinUID, __GO_X_AXIS_LABEL__);
79 setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1);
81 iLabelUID = initLabel(iSubWinUID, __GO_Y_AXIS_LABEL__);
82 setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1);
84 iLabelUID = initLabel(iSubWinUID, __GO_Z_AXIS_LABEL__);
85 setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1);
89 setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LOCATION__, &axisLocation, jni_int, 1);
92 setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LOCATION__, &axisLocation, jni_int, 1);
95 setGraphicObjectProperty(iSubWinUID, __GO_VISIBLE__, &visible, jni_bool, 1);
97 setGraphicObjectProperty(iSubWinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1);
99 initSubWinAngles(iSubWinUID);
101 /*--------------------------------------------------------------------------------*/
102 /* reinit the viewing angles of a subwindow */
103 static void initSubWinAngles(int iSubWinUID)
106 int* piViewType = &iViewType;
107 double* rotationAngles = NULL;
108 int iAxesModelUID = getAxesModel();
110 getGraphicObjectProperty(iAxesModelUID, __GO_VIEW__, jni_int, (void **) &piViewType);
111 setGraphicObjectProperty(iSubWinUID, __GO_VIEW__, &iViewType, jni_int, 1);
113 getGraphicObjectProperty(iAxesModelUID, __GO_ROTATION_ANGLES__, jni_double_vector, (void **) &rotationAngles);
114 setGraphicObjectProperty(iSubWinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2);
116 getGraphicObjectProperty(iAxesModelUID, __GO_ROTATION_ANGLES_3D__, jni_double_vector, (void **) &rotationAngles);
117 setGraphicObjectProperty(iSubWinUID, __GO_ROTATION_ANGLES_3D__, rotationAngles, jni_double_vector, 2);
120 /*--------------------------------------------------------------------------------*/
121 /* set the data_bounds of the axes to the default value */
122 static void initSubWinBounds(int iSubWinUID)
124 double* dataBounds = NULL;
125 double* realDataBounds = NULL;
126 int iAxesModelUID = getAxesModel();
129 setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1);
130 setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1);
131 setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1);
133 getGraphicObjectProperty(iAxesModelUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&dataBounds);
134 setGraphicObjectProperty(iSubWinUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
136 getGraphicObjectProperty(iAxesModelUID, __GO_REAL_DATA_BOUNDS__, jni_double_vector, (void **)&realDataBounds);
137 setGraphicObjectProperty(iSubWinUID, __GO_REAL_DATA_BOUNDS__, realDataBounds, jni_double_vector, 6);
139 /*--------------------------------------------------------------------------------*/
140 /* reinit the selected subwindow if the auto_clear property is set to on */
141 /* return TRUE if the window has been redrawn */
142 BOOL checkRedrawing(void)
145 int* piAutoClear = &iAutoClear;
148 // fprintf(stderr, "[DEBUG] checkRedrawing : %d\n", nbCheckRedraw);
149 int iSubWinID = getCurrentSubWin();
151 getGraphicObjectProperty(iSubWinID, __GO_AUTO_CLEAR__, jni_bool, (void **)&piAutoClear);
155 reinitSubWin(iSubWinID);
161 /*--------------------------------------------------------------------------------*/
162 sciLegendPlace propertyNameToLegendPlace(const char * string)
164 if (strcmp(string, "in_upper_right") == 0)
166 return SCI_LEGEND_IN_UPPER_RIGHT;
168 else if (strcmp(string, "in_upper_left") == 0)
170 return SCI_LEGEND_IN_UPPER_LEFT;
172 else if (strcmp(string, "in_lower_right") == 0)
174 return SCI_LEGEND_IN_LOWER_RIGHT;
176 else if (strcmp(string, "in_lower_left") == 0)
178 return SCI_LEGEND_IN_LOWER_LEFT;
180 else if (strcmp(string, "out_upper_right") == 0)
182 return SCI_LEGEND_OUT_UPPER_RIGHT;
184 else if (strcmp(string, "out_upper_left") == 0)
186 return SCI_LEGEND_OUT_UPPER_LEFT;
188 else if (strcmp(string, "out_lower_right") == 0)
190 return SCI_LEGEND_OUT_LOWER_RIGHT;
192 else if (strcmp(string, "out_lower_left") == 0)
194 return SCI_LEGEND_OUT_LOWER_LEFT;
196 else if (strcmp(string, "upper_caption") == 0)
198 return SCI_LEGEND_UPPER_CAPTION;
200 else if (strcmp(string, "lower_caption") == 0)
202 return SCI_LEGEND_LOWER_CAPTION;
204 else if (strcmp(string, "by_coordinates") == 0)
206 return SCI_LEGEND_BY_COORDINATES;
210 return SCI_LEGEND_POSITION_UNSPECIFIED;
213 /*--------------------------------------------------------------------------------*/
215 * Converts a boolean log flag to the character format
217 char getTextLogFlag(int logFlag)
228 /*--------------------------------------------------------------------------------*/
230 * Converts a character log flag to the equivalent boolean
232 int getBooleanLogFlag(char logFlag)
243 /*--------------------------------------------------------------------------------*/