2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
16 #include "handle_properties.hxx"
21 #include "h5_fileManagement.h"
22 #include "h5_writeDataToFile.h"
23 #include "h5_readDataFromFile.h"
24 #include "h5_attributeConstants.h"
26 #include "setGraphicObjectProperty.h"
27 #include "getGraphicObjectProperty.h"
28 #include "graphicObjectProperties.h"
29 #include "createGraphicObject.h"
30 #include "FigureList.h"
31 #include "CurrentFigure.h"
32 #include "BuildObjects.h"
34 #include "HandleManagement.h"
37 extern types::InternalType* import_data(int dataset);
38 extern int export_data(int parent, const std::string& name, types::InternalType* data);
40 static int getHandleInt(int dataset, const char* prop, int* val)
43 node = getDataSetIdFromName(dataset, prop);
49 readInteger32Matrix(node, val);
53 static int getHandleIntVector(int dataset, const char* prop, int* row, int* col, int** vals)
56 node = getDataSetIdFromName(dataset, prop);
64 int ret = getDatasetInfo(node, &complex, &dims, NULL);
67 closeDataSet(dataset);
72 std::vector<int> d(dims);
73 int size = getDatasetInfo(node, &complex, &dims, d.data());
75 if (dims == 0 || size <= 0)
83 *vals = new int[size];
84 readInteger32Matrix(node, *vals);
88 static int getHandleBool(int dataset, const char* prop, int* val)
91 node = getDataSetIdFromName(dataset, prop);
97 readBooleanMatrix(node, val);
101 static int getHandleBoolVector(int dataset, const char* prop, int* row, int* col, int** vals)
104 node = getDataSetIdFromName(dataset, prop);
112 int ret = getDatasetInfo(node, &complex, &dims, NULL);
115 closeDataSet(dataset);
120 std::vector<int> d(dims);
121 int size = getDatasetInfo(node, &complex, &dims, d.data());
123 if (dims == 0 || size <= 0)
132 *vals = new int[size];
133 readBooleanMatrix(node, *vals);
137 static double getHandleDouble(int dataset, const char* prop, double* val)
140 node = getDataSetIdFromName(dataset, prop);
146 readDoubleMatrix(node, val);
150 static int getHandleDoubleVector(int dataset, const char* prop, int* row, int* col, double** vals)
153 node = getDataSetIdFromName(dataset, prop);
161 int ret = getDatasetInfo(node, &complex, &dims, NULL);
164 closeDataSet(dataset);
169 std::vector<int> d(dims);
170 int size = getDatasetInfo(node, &complex, &dims, d.data());
172 if (dims == 0 || size <= 0)
181 *vals = new double[size];
182 readDoubleMatrix(node, *vals);
186 static int getHandleString(int dataset, const char* prop, char** val)
189 node = getDataSetIdFromName(dataset, prop);
197 int ret = getDatasetInfo(node, &complex, &dims, NULL);
200 closeDataSet(dataset);
205 std::vector<int> d(dims);
206 int size = getDatasetInfo(node, &complex, &dims, d.data());
208 if (dims == 0 || size <= 0)
214 readStringMatrix(node, val);
218 static int getHandleStringVector(int dataset, const char* prop, int* row, int* col, char*** vals)
221 node = getDataSetIdFromName(dataset, prop);
229 int ret = getDatasetInfo(node, &complex, &dims, NULL);
232 closeDataSet(dataset);
237 std::vector<int> d(dims);
238 int size = getDatasetInfo(node, &complex, &dims, d.data());
240 if (dims == 0 || size <= 0)
249 *vals = new char*[size];
250 readStringMatrix(node, *vals);
254 static int import_handle_generic(int dataset, int uid, int parent, const HandleProp& props, bool childrenFirst);
256 static void import_userdata(int dataset, int uid)
258 types::InternalType* ud = nullptr;
260 node = getDataSetIdFromName(dataset, "userdata");
264 //assign an empty matrix
265 ud = types::Double::Empty();
269 ud = import_data(node);
272 //increase ref before trying to delete old value to avoid double free
280 getGraphicObjectProperty(uid, __GO_USER_DATA_SIZE__, jni_int, (void **)&psize);
281 getGraphicObjectProperty(uid, __GO_USER_DATA__, jni_int_vector, (void **)&data);
285 types::InternalType* previous = nullptr;
290 previous = ((types::InternalType*) * p);
295 long long* p = (long long*)data;
296 previous = ((types::InternalType*) * p);
299 previous->DecreaseRef();
304 size = sizeof(void*) / sizeof(int);
305 setGraphicObjectProperty(uid, __GO_USER_DATA__, &ud, jni_int_vector, size);
308 static void import_handle_tag(int dataset, int uid)
311 int node = getHandleString(dataset, "tag", &tag);
312 setGraphicObjectProperty(uid, __GO_TAG__, tag, jni_string, 1);
313 freeStringMatrix(node, &tag);
316 static int import_handle_children(int dataset, int parent)
319 int children = getDataSetIdFromName(dataset, "children");
321 getListDims6(children, &childcount);
324 for (int i = childcount - 1; i >= 0; --i)
326 int c = getDataSetIdFromName(children, std::to_string(i).data());
327 int newChild = import_handle(c, parent);
330 closeList6(children);
334 static int import_handle_generic(int dataset, int uid, int parent, const HandleProp& props, bool childrenFirst)
336 //link current handle with its parent
339 setGraphicObjectRelationship(parent, uid);
341 //restore children before other property in case of properties has an
347 import_handle_children(dataset, uid);
350 for (auto & prop : props)
352 const char* name = prop.first.data();
353 std::vector<int> info(prop.second);
355 if (info[0] == SAVE_ONLY)
370 getHandleBool(dataset, name, &val);
371 setGraphicObjectProperty(uid, go, &val, jni_bool, 1);
377 getHandleInt(dataset, name, &val);
378 setGraphicObjectProperty(uid, go, &val, jni_int, 1);
384 getHandleDouble(dataset, name, &val);
385 setGraphicObjectProperty(uid, go, &val, jni_double, 1);
390 char* data = nullptr;
391 int node = getHandleString(dataset, name, &data);
392 setGraphicObjectProperty(uid, go, data, jni_string, 1);
393 freeStringMatrix(node, &data);
396 case jni_bool_vector:
399 getHandleBoolVector(dataset, name, &row, &col, &vals);
402 setGraphicObjectProperty(uid, go, vals, jni_bool_vector, row * col);
410 getHandleIntVector(dataset, name, &row, &col, &vals);
413 setGraphicObjectProperty(uid, go, vals, jni_int_vector, row * col);
418 case jni_double_vector:
420 double* vals = nullptr;
421 getHandleDoubleVector(dataset, name, &row, &col, &vals);
424 setGraphicObjectProperty(uid, go, vals, jni_double_vector, row * col);
429 case jni_string_vector:
431 char** vals = nullptr;
432 int node = getHandleStringVector(dataset, name, &row, &col, &vals);
435 setGraphicObjectProperty(uid, go, vals, jni_string_vector, row * col);
438 freeStringMatrix(node, vals);
446 import_userdata(dataset, uid);
449 import_handle_tag(dataset, uid);
452 if (childrenFirst == false)
454 import_handle_children(dataset, uid);
460 static int import_handle_border(int dataset);
462 static int import_handle_border_none(int dataset, int border)
468 static int import_handle_border_line(int dataset, int border)
472 char* color = nullptr;
473 int nc = getHandleString(dataset, "color", &color);
474 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_COLOR__, color, jni_string, 1);
475 freeStringMatrix(nc, &color);
479 status = getHandleInt(dataset, "thickness", &thickness);
482 setGraphicObjectProperty(border, __GO_LINE_THICKNESS__, &thickness, jni_int, 1);
487 status = getHandleBool(dataset, "rounded", &rounded);
490 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_ROUNDED__, &rounded, jni_bool, 1);
497 static int import_handle_border_bevel(int dataset, int border)
499 char* data = nullptr;
503 getHandleInt(dataset, "type", &type);
504 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_TYPE__, &type, jni_int, 1);
507 node = getHandleString(dataset, "highlight_out", &data);
510 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
513 freeStringMatrix(node, &data);
517 node = getHandleString(dataset, "highlight_in", &data);
520 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, data, jni_string, 1);
523 freeStringMatrix(node, &data);
527 node = getHandleString(dataset, "shadow_out", &data);
530 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
533 freeStringMatrix(node, &data);
537 node = getHandleString(dataset, "shadow_in", &data);
540 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_SHADOW_IN__, data, jni_string, 1);
543 freeStringMatrix(node, &data);
550 static int import_handle_border_soft_bevel(int dataset, int border)
552 return import_handle_border_bevel(dataset, border);
555 static int import_handle_border_etched(int dataset, int border)
558 char* data = nullptr;
563 status = getHandleInt(dataset, "type", &type);
566 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_TYPE__, &type, jni_int, 1);
570 node = getHandleString(dataset, "highlight_out", &data);
573 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
576 freeStringMatrix(node, &data);
580 node = getHandleString(dataset, "shadow_out", &data);
583 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
586 freeStringMatrix(node, &data);
593 static int import_handle_border_titled(int dataset, int border)
595 char* data = nullptr;
600 int title_border = getDataSetIdFromName(dataset, "title_border");
601 if (title_border != -1)
604 int uiborder = import_handle_border(title_border);
605 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_TITLE__, &uiborder, jni_int, 1);
606 //force new border to be hide in scilab view
607 setGraphicObjectProperty(uiborder, __GO_HIDDEN__, &hidden, jni_bool, 1);
611 node = getHandleString(dataset, "title", &data);
614 setGraphicObjectProperty(border, __GO_TITLE__, data, jni_string, 1);
617 freeStringMatrix(node, &data);
621 int justification = 0;
622 status = getHandleInt(dataset, "justification", &justification);
625 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_JUSTIFICATION__, &justification, jni_int, 1);
629 node = getHandleString(dataset, "fontname", &data);
632 setGraphicObjectProperty(border, __GO_UI_FONTNAME__, data, jni_string, 1);
635 freeStringMatrix(node, &data);
639 node = getHandleString(dataset, "fontangle", &data);
642 setGraphicObjectProperty(border, __GO_UI_FONTANGLE__, data, jni_string, 1);
645 freeStringMatrix(node, &data);
650 status = getHandleInt(dataset, "fontsize", &fontsize);
653 setGraphicObjectProperty(border, __GO_UI_FONTSIZE__, &fontsize, jni_int, 1);
657 node = getHandleString(dataset, "fontweight", &data);
660 setGraphicObjectProperty(border, __GO_UI_FONTWEIGHT__, data, jni_string, 1);
663 freeStringMatrix(node, &data);
668 status = getHandleInt(dataset, "position", &position);
671 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_POSITION__, &position, jni_int, 1);
675 node = getHandleString(dataset, "color", &data);
678 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
681 freeStringMatrix(node, &data);
688 static int import_handle_border_empty(int dataset, int border)
692 double* pos = nullptr;
694 getHandleDoubleVector(dataset, "position", &row, &col, &pos);
695 if (pos && row * col == 4)
697 setGraphicObjectProperty(border, __GO_POSITION__, pos, jni_double_vector, row * col);
705 static int import_handle_border_compound(int dataset, int border)
708 int out_border = getDataSetIdFromName(dataset, "out_border");
709 if (out_border != -1)
712 int uiborder = import_handle_border(out_border);
713 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_OUT_BORDER__, &uiborder, jni_int, 1);
714 //force new border to be hide in scilab view
715 setGraphicObjectProperty(uiborder, __GO_HIDDEN__, &hidden, jni_bool, 1);
719 int in_border = getDataSetIdFromName(dataset, "in_border");
723 int uiborder = import_handle_border(in_border);
724 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_IN_BORDER__, &uiborder, jni_int, 1);
725 //force new border to be hide in scilab view
726 setGraphicObjectProperty(uiborder, __GO_HIDDEN__, &hidden, jni_bool, 1);
733 static int import_handle_border_matte(int dataset, int border)
737 double* pos = nullptr;
739 getHandleDoubleVector(dataset, "position", &row, &col, &pos);
740 setGraphicObjectProperty(border, __GO_POSITION__, pos, jni_double_vector, row * col);
744 char* data = nullptr;
745 int nc = getHandleString(dataset, "color", &data);
746 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
747 freeStringMatrix(nc, &data);
753 static int import_handle_border(int dataset)
755 int border = createGraphicObject(__GO_UI_FRAME_BORDER__);
757 getHandleInt(dataset, "style", &style);
759 setGraphicObjectProperty(border, __GO_UI_FRAME_BORDER_STYLE__, &style, jni_int, 1);
765 return import_handle_border_none(dataset, border);
767 return import_handle_border_line(dataset, border);
769 return import_handle_border_bevel(dataset, border);
771 return import_handle_border_soft_bevel(dataset, border);
773 return import_handle_border_etched(dataset, border);
775 return import_handle_border_titled(dataset, border);
777 return import_handle_border_empty(dataset, border);
779 return import_handle_border_compound(dataset, border);
781 return import_handle_border_matte(dataset, border);
785 static int import_handle_uicontrol(int dataset, int parent)
788 getHandleInt(dataset, "style", &style);
789 //uicontrol was created by their style instead of type like others graphic objects.
790 int uic = createGraphicObject(style);
792 //some properties must be set before parent ( in import_handle_generic )
796 getHandleBool(dataset, "scrollable", &scrollable);
797 setGraphicObjectProperty(uic, __GO_UI_SCROLLABLE__, &scrollable, jni_bool, 1);
803 double* margins = nullptr;
804 getHandleDoubleVector(dataset, "margins", &row, &col, &margins);
805 setGraphicObjectProperty(uic, __GO_MARGINS__, margins, jni_double_vector, row * col);
811 int border_position = 0;
812 getHandleInt(dataset, "border_position", &border_position);
813 setGraphicObjectProperty(uic, __GO_UI_BORDER_POSITION__, &border_position, jni_int, 1);
816 int* border_size = nullptr;
817 getHandleIntVector(dataset, "border_size", &row, &col, &border_size);
818 setGraphicObjectProperty(uic, __GO_UI_BORDER_PREFERREDSIZE__, border_size, jni_int_vector, row * col);
819 delete[] border_size;
822 int* gridbad_grid = nullptr;
823 getHandleIntVector(dataset, "gridbad_grid", &row, &col, &gridbad_grid);
824 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_GRID__, gridbad_grid, jni_int_vector, row * col);
825 delete[] gridbad_grid;
828 double* gridbad_weight = nullptr;
829 getHandleDoubleVector(dataset, "gridbad_weight", &row, &col, &gridbad_weight);
830 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_WEIGHT__, gridbad_weight, jni_double_vector, row * col);
831 delete[] gridbad_weight;
834 int gridbad_fill = 0;
835 getHandleInt(dataset, "gridbad_fill", &gridbad_fill);
836 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_FILL__, &gridbad_fill, jni_int, 1);
839 int gridbad_anchor = 0;
840 getHandleInt(dataset, "gridbad_anchor", &gridbad_anchor);
841 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_ANCHOR__, &gridbad_anchor, jni_int, 1);
844 int* gridbad_padding = nullptr;
845 getHandleIntVector(dataset, "gridbad_padding", &row, &col, &gridbad_padding);
846 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_PADDING__, gridbad_padding, jni_int_vector, row * col);
847 delete[] gridbad_padding;
850 int* gridbad_size = nullptr;
851 getHandleIntVector(dataset, "gridbad_size", &row, &col, &gridbad_size);
852 setGraphicObjectProperty(uic, __GO_UI_GRIDBAG_PREFERREDSIZE__, gridbad_size, jni_int_vector, row * col);
853 delete[] gridbad_size;
855 //import "standards" properties
856 import_handle_generic(dataset, uic, parent, UicontrolHandle::getPropertyList(), false);
859 char** string = nullptr;
860 int node = getHandleStringVector(dataset, "string", &row, &col, &string);
861 setGraphicObjectProperty(uic, __GO_UI_STRING_COLNB__, &col, jni_int, 1);
862 setGraphicObjectProperty(uic, __GO_UI_STRING__, string, jni_string_vector, row * col);
863 freeStringMatrix(node, string);
867 int dborder = getDataSetIdFromName(dataset, "border");
868 int border = import_handle_border(dborder);
869 setGraphicObjectProperty(uic, __GO_UI_FRAME_BORDER__, &border, jni_int, 1);
873 double* value = nullptr;
874 getHandleDoubleVector(dataset, "value", &row, &col, &value);
877 setGraphicObjectProperty(uic, __GO_UI_VALUE__, value, jni_double_vector, row * col);
885 static int import_handle_uicontextmenu(int dataset, int parent)
887 int menu = createGraphicObject(__GO_UICONTEXTMENU__);
889 //import "standards" properties
890 import_handle_generic(dataset, menu, parent, UicontextmenuHandle::getPropertyList(), false);
896 static int import_handle_uimenu(int dataset, int parent)
898 int menu = createGraphicObject(__GO_UIMENU__);
900 //import "standards" properties
901 import_handle_generic(dataset, menu, parent, UimenuHandle::getPropertyList(), false);
907 static int import_handle_light(int dataset, int parent)
909 int light = createGraphicObject(__GO_LIGHT__);
911 //import "standards" properties
912 import_handle_generic(dataset, light, parent, LightHandle::getPropertyList(), true);
918 static int import_handle_axis(int dataset, int parent)
920 int axis = createGraphicObject(__GO_AXIS__);
922 //import "standards" properties
923 import_handle_generic(dataset, axis, parent, AxisHandle::getPropertyList(), true);
929 static int import_handle_text(int dataset, int parent)
931 int t = createGraphicObject(__GO_TEXT__);
933 //import "standards" properties
934 import_handle_generic(dataset, t, parent, TextHandle::getPropertyList(), true);
939 char** text = nullptr;
940 int textnode = getHandleStringVector(dataset, "text", &dims[0], &dims[1], &text);
941 setGraphicObjectProperty(t, __GO_TEXT_ARRAY_DIMENSIONS__, dims, jni_int_vector, 2);
942 setGraphicObjectProperty(t, __GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
943 freeStringMatrix(textnode, text);
949 static int import_handle_legend(int dataset, int parent)
951 int legend = createGraphicObject(__GO_LEGEND__);
953 //import "standards" properties
954 import_handle_generic(dataset, legend, parent, LegendHandle::getPropertyList(), true);
959 char** text = nullptr;
960 int textnode = getHandleStringVector(dataset, "text", &dims[0], &dims[1], &text);
961 setGraphicObjectProperty(legend, __GO_TEXT_ARRAY_DIMENSIONS__, dims, jni_int_vector, 2);
962 setGraphicObjectProperty(legend, __GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
963 freeStringMatrix(textnode, text);
967 //to retore links we need to have the entire hierarchie loaded.
968 //store links information in a "global" variable and update variable at the end of process.
969 int node = getDataSetIdFromName(dataset, "links");
971 getListDims6(node, &count);
973 Links::PathList paths;
975 for (int i = 0; i < count; ++i)
980 getHandleIntVector(node, std::to_string(i).data(), &row, &col, &path);
981 std::vector<int> res(row * col);
982 for (int j = 0; j < row * col; ++j)
989 paths.push_back(res);
992 Links::add(legend, paths);
999 static int import_handle_fec(int dataset, int parent)
1001 int fec = createGraphicObject(__GO_FEC__);
1002 createDataObject(fec, __GO_FEC__);
1004 //import "standards" properties
1005 import_handle_generic(dataset, fec, parent, FecHandle::getPropertyList(), true);
1015 double* coords = nullptr;
1016 getHandleDoubleVector(dataset, "coords", &coordR, &coordC, &coords);
1017 double* values = nullptr;
1018 getHandleDoubleVector(dataset, "values", &valuesR, &valuesC, &values);
1019 double* triangles = nullptr;
1020 getHandleDoubleVector(dataset, "triangles", &trianglesR, &trianglesC, &triangles);
1021 int realcol = trianglesC - 2;
1023 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_NUM_VERTICES__, &valuesC, jni_int, 1);
1024 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_NUM_VERTICES_BY_ELEM__, &realcol, jni_int, 1);
1025 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_NUM_INDICES__, &trianglesR, jni_int, 1);
1026 //setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_X__, coords, jni_double_vector, coordR);
1027 //setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_Y__, coords + coordR, jni_double_vector, coordR);
1028 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_COORDINATES__, coords, jni_double_vector, coordC);
1029 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_FEC_ELEMENTS__, triangles, jni_double_vector, trianglesR);
1030 setGraphicObjectPropertyAndNoWarn(fec, __GO_DATA_MODEL_VALUES__, values, jni_double_vector, valuesC);
1036 closeList6(dataset);
1040 static int import_handle_matplot(int dataset, int parent)
1042 int plot = createGraphicObject(__GO_MATPLOT__);
1043 createDataObject(plot, __GO_MATPLOT__);
1045 //import "standards" properties
1046 import_handle_generic(dataset, plot, parent, MatplotHandle::getPropertyList(), true);
1051 double* rect = nullptr;
1052 getHandleDoubleVector(dataset, "rect", &row, &col, &rect);
1053 double tmp = rect[1];
1058 getHandleInt(dataset, "num_x", &row);
1059 getHandleInt(dataset, "num_y", &col);
1060 double* data = nullptr;
1063 getHandleDoubleVector(dataset, "data", &data_x, &data_y, &data);
1071 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_GRID_SIZE__, grid, jni_int_vector, 4);
1074 setGraphicObjectProperty(plot, __GO_MATPLOT_TRANSLATE__, rect, jni_double_vector, 2);
1075 scale[0] = (rect[2] - rect[0]) / (col - 1.0);
1076 scale[1] = (rect[3] - rect[1]) / (row - 1.0);
1077 setGraphicObjectProperty(plot, __GO_MATPLOT_SCALE__, scale, jni_double_vector, 2);
1079 setGraphicObjectProperty(plot, __GO_DATA_MODEL_MATPLOT_BOUNDS__, rect, jni_double_vector, 4);
1081 setGraphicObjectProperty(plot, __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__, data, jni_double_vector, data_x * data_y);
1086 closeList6(dataset);
1090 static int import_handle_grayplot(int dataset, int parent)
1092 int plot = createGraphicObject(__GO_GRAYPLOT__);
1093 createDataObject(plot, __GO_GRAYPLOT__);
1095 //import "standards" properties
1096 import_handle_generic(dataset, plot, parent, GrayplotHandle::getPropertyList(), true);
1100 double* dataX = nullptr;
1101 double* dataY = nullptr;
1102 double* dataZ = nullptr;
1103 getHandleDoubleVector(dataset, "data_x", &row, &col, &dataX);
1104 getHandleDoubleVector(dataset, "data_y", &row, &col, &dataY);
1105 getHandleDoubleVector(dataset, "data_z", &row, &col, &dataZ);
1114 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_GRID_SIZE__, grid, jni_int_vector, 4);
1117 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_X__, dataX, jni_double_vector, row);
1118 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, col);
1119 setGraphicObjectProperty(plot, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, row * col);
1121 closeList6(dataset);
1125 static int import_handle_segs(int dataset, int parent)
1127 int segs = createGraphicObject(__GO_SEGS__);
1129 //import "standards" properties
1130 import_handle_generic(dataset, segs, parent, SegsHandle::getPropertyList(), true);
1132 closeList6(dataset);
1136 static int import_handle_arc(int dataset, int parent)
1138 int arc = createGraphicObject(__GO_ARC__);
1140 //import "standards" properties
1141 import_handle_generic(dataset, arc, parent, ArcHandle::getPropertyList(), true);
1143 closeList6(dataset);
1147 static int import_handle_rectangle(int dataset, int parent)
1149 int rect = createGraphicObject(__GO_RECTANGLE__);
1151 //import "standards" properties
1152 import_handle_generic(dataset, rect, parent, RectangleHandle::getPropertyList(), true);
1154 closeList6(dataset);
1158 static int import_handle_compound(int dataset, int parent)
1160 int compound = createGraphicObject(__GO_COMPOUND__);
1162 //import "standards" properties
1163 import_handle_generic(dataset, compound, parent, CompoundHandle::getPropertyList(), true);
1165 closeList6(dataset);
1169 static int import_handle_datatip(int dataset, int parent)
1171 int datatip = createGraphicObject(__GO_DATATIP__);
1172 //set parent manually, these no real releationship between datatip and parent
1173 setGraphicObjectProperty(datatip, __GO_PARENT__, &parent, jni_int, 1);
1177 getHandleInt(dataset, "data_index", &index);
1182 setGraphicObjectProperty(datatip, __GO_DATATIP_INDEXES__, indexes, jni_double_vector, 2);
1184 //import "standards" properties
1185 import_handle_generic(dataset, datatip, -1, DatatipHandle::getPropertyList(), true);
1187 closeList6(dataset);
1191 static int import_handle_datatips(int dataset, int uid)
1193 int datatip = getDataSetIdFromName(dataset, "datatips");
1195 getListDims6(datatip, &count);
1197 std::vector<int> datatips(count);
1198 for (int i = 0; i < count; ++i)
1200 int d = getDataSetIdFromName(datatip, std::to_string(i).data());
1201 datatips[i] = import_handle_datatip(d, uid);
1204 setGraphicObjectProperty(uid, __GO_DATATIPS__, datatips.data(), jni_int_vector, count);
1206 closeList6(datatip);
1210 static int import_polyline_shift(int dataset, int uid, const std::string& name, int go_set, int go_data)
1215 double* data = nullptr;
1217 getHandleDoubleVector(dataset, name.data(), &row, &col, &data);
1221 setGraphicObjectProperty(uid, go_data, data, jni_double_vector, row * col);
1229 setGraphicObjectProperty(uid, go_set, &set, jni_int, 1);
1233 static void updateXYDataBounds(double rect[6], int axes = -1)
1236 int * piFirstPlot = &firstPlot;
1239 axes = getOrCreateDefaultSubwin();
1242 getGraphicObjectProperty(axes, __GO_FIRST_PLOT__, jni_bool, (void **)&piFirstPlot);
1250 double * dataBounds = NULL;
1251 getGraphicObjectProperty(axes, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&dataBounds);
1253 rect[0] = Min(rect[0], dataBounds[0]);
1254 rect[1] = Max(rect[1], dataBounds[1]);
1255 rect[2] = Min(rect[2], dataBounds[2]);
1256 rect[3] = Max(rect[3], dataBounds[3]);
1257 rect[4] = dataBounds[4];
1258 rect[5] = dataBounds[5];
1261 setGraphicObjectProperty(axes, __GO_DATA_BOUNDS__, rect, jni_double_vector, 6);
1264 static int mustUpdate(int axes = -1)
1267 int * piTmp = &iTmp;
1270 axes = getOrCreateDefaultSubwin();
1273 getGraphicObjectProperty(axes, __GO_AUTO_SCALE__, jni_bool, (void **)&piTmp);
1277 void MiniMaxi(const double vect[], int n, double * const min, double * const max)
1280 double _min = DBL_MAX;
1281 double _max = -DBL_MAX;
1284 /* if ( isinf(vect[i])== 0 && isnan(vect[i])==0 && vect[i] < vmin) */
1285 if (finite(vect[i]) == 1)
1303 static int import_handle_polyline(int dataset, int parent)
1305 int polyline = createGraphicObject(__GO_POLYLINE__);
1306 createDataObject(polyline, __GO_POLYLINE__);
1308 //import "standards" properties
1309 import_handle_generic(dataset, polyline, parent, PolylineHandle::getPropertyList(), true);
1312 import_polyline_shift(dataset, polyline, "x_shift", __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_X_COORDINATES_SHIFT__);
1314 import_polyline_shift(dataset, polyline, "y_shift", __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Y_COORDINATES_SHIFT__);
1316 import_polyline_shift(dataset, polyline, "z_shift", __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Z_COORDINATES_SHIFT__);
1319 //interp_color_vector
1324 int* data = nullptr;
1326 getHandleIntVector(dataset, "interp_color_vector", &row, &col, &data);
1330 setGraphicObjectProperty(polyline, __GO_INTERP_COLOR_VECTOR__, data, jni_double_vector, row * col);
1338 setGraphicObjectProperty(polyline, __GO_INTERP_COLOR_VECTOR_SET__, &set, jni_bool, 1);
1343 int numElementsArray[2];
1345 double* dataX = nullptr;
1346 double* dataY = nullptr;
1347 double* dataZ = nullptr;
1348 getHandleDoubleVector(dataset, "data_x", &numElementsArray[0], &numElementsArray[1], &dataX);
1349 size = numElementsArray[0] * numElementsArray[1];
1350 getHandleDoubleVector(dataset, "data_y", &numElementsArray[0], &numElementsArray[1], &dataY);
1352 if (numElementsArray[0] * numElementsArray[1] != size)
1354 std::cout << "size trouble !!!" << std::endl;
1357 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, numElementsArray, jni_int_vector, 2);
1358 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_X__, dataX, jni_double_vector, size);
1359 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, size);
1363 numElementsArray[0] = 0;
1364 numElementsArray[1] = 0;
1365 getHandleDoubleVector(dataset, "data_z", &numElementsArray[0], &numElementsArray[1], &dataZ);
1366 if (numElementsArray[0] * numElementsArray[1] != 0)
1368 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, size);
1372 setGraphicObjectProperty(polyline, __GO_DATA_MODEL_Z_COORDINATES_SET__, &zSet, jni_int, 1);
1374 //update parent axes data_bounds
1379 MiniMaxi(dataX, size, rect, rect + 1);
1380 MiniMaxi(dataY, size, rect + 2, rect + 3);
1382 updateXYDataBounds(rect);
1391 import_handle_datatips(dataset, polyline);
1393 closeList6(dataset);
1397 static int import_handle_surface(int dataset, int uid, int parent)
1399 //import "standards" properties
1400 import_handle_generic(dataset, uid, parent, SurfaceHandle::getPropertyList(), true);
1404 static int import_handle_plot3d(int dataset, int parent)
1406 int plot = createGraphicObject(__GO_PLOT3D__);
1407 createDataObject(plot, __GO_PLOT3D__);
1408 import_handle_surface(dataset, plot, parent);
1412 double* dataX = nullptr;
1414 double* dataY = nullptr;
1416 double* dataZ = nullptr;
1418 getHandleDoubleVector(dataset, "data_x", &xR, &xC, &dataX);
1419 getHandleDoubleVector(dataset, "data_y", &yR, &yC, &dataY);
1420 getHandleDoubleVector(dataset, "data_z", &zR, &zC, &dataZ);
1430 result = setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_GRID_SIZE__, gridSize, jni_int_vector, 4);
1432 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_X__, dataX, jni_double_vector, xR * xC);
1433 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, yR * yC);
1434 setGraphicObjectProperty(plot, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, zR * zC);
1441 closeList6(dataset);
1445 static int import_handle_fac3d(int dataset, int parent)
1447 int fac = createGraphicObject(__GO_FAC3D__);
1448 createDataObject(fac, __GO_FAC3D__);
1450 import_handle_surface(dataset, fac, parent);
1454 double* dataX = nullptr;
1456 double* dataY = nullptr;
1458 double* dataZ = nullptr;
1460 getHandleDoubleVector(dataset, "data_x", &xR, &xC, &dataX);
1461 getHandleDoubleVector(dataset, "data_y", &yR, &yC, &dataY);
1462 getHandleDoubleVector(dataset, "data_z", &zR, &zC, &dataZ);
1466 double* colors = nullptr;
1467 getHandleDoubleVector(dataset, "colors", &cR, &cC, &colors);
1468 int cSize = cR * cC;
1470 int numElementsArray[3];
1472 numElementsArray[0] = xC;
1473 numElementsArray[1] = xR;
1474 numElementsArray[2] = cSize;
1476 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, numElementsArray, jni_int_vector, 3);
1478 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_X__, dataX, jni_double_vector, xR * xC);
1479 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, yR * yC);
1480 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, zR * zC);
1481 setGraphicObjectProperty(fac, __GO_DATA_MODEL_COLORS__, colors, jni_double_vector, cSize);
1491 getHandleInt(dataset, "cdata_mapping", &cdata);
1492 setGraphicObjectProperty(fac, __GO_DATA_MAPPING__, &cdata, jni_int, 1);
1495 closeList6(dataset);
1500 static int import_handle_champ(int dataset, int parent)
1502 //need to get properties and call a "creator" :x
1504 int champ = createGraphicObject(__GO_CHAMP__);
1511 double* baseX = nullptr;
1512 getHandleDoubleVector(dataset, "base_x", &row, &col, &baseX);
1515 double* baseY = nullptr;
1516 getHandleDoubleVector(dataset, "base_y", &row, &col, &baseY);
1518 num = dims[0] * dims[1];
1520 double* directionX = nullptr;
1521 getHandleDoubleVector(dataset, "direction_x", &row, &col, &directionX);
1523 double* directionY = nullptr;
1524 getHandleDoubleVector(dataset, "direction_y", &row, &col, &directionY);
1526 setGraphicObjectProperty(champ, __GO_NUMBER_ARROWS__, &num, jni_int, 1);
1527 setGraphicObjectProperty(champ, __GO_CHAMP_DIMENSIONS__, dims, jni_int_vector, 2);
1528 setGraphicObjectProperty(champ, __GO_BASE_X__, baseX, jni_double_vector, dims[0]);
1529 setGraphicObjectProperty(champ, __GO_BASE_Y__, baseY, jni_double_vector, dims[1]);
1530 setGraphicObjectProperty(champ, __GO_DIRECTION_X__, directionX, jni_double_vector, dims[0] * dims[1]);
1531 setGraphicObjectProperty(champ, __GO_DIRECTION_Y__, directionY, jni_double_vector, dims[0] * dims[1]);
1535 delete[] directionX;
1536 delete[] directionY;
1538 //import "standards" properties
1539 import_handle_generic(dataset, champ, parent, ChampHandle::getPropertyList(), true);
1541 closeList6(dataset);
1544 static int import_handle_label(int dataset, int uid)
1546 //import "standards" properties
1547 //do not create releationship between parent
1548 import_handle_generic(dataset, uid, -1, LabelHandle::getPropertyList(), true);
1551 std::vector<int> dims(2);
1552 char** data = nullptr;
1553 int node = getHandleStringVector(dataset, "text", &dims[0], &dims[1], &data);
1555 setGraphicObjectProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, dims.data(), jni_int_vector, 2);
1556 setGraphicObjectProperty(uid, __GO_TEXT_STRINGS__, data, jni_string_vector, dims[0] * dims[1]);
1557 freeStringMatrix(node, data);
1560 closeList6(dataset);
1564 static int import_handle_axes(int dataset, int parent)
1566 //how to manage call by %h_copy ?
1568 int axes = createSubWin(parent);
1572 setGraphicObjectProperty(axes, __GO_VISIBLE__, &visible, jni_bool, 1);
1574 //import "standards" properties
1575 import_handle_generic(dataset, axes, parent, AxesHandle::getPropertyList(), true);
1579 int *ptitle = &title;
1580 int nodeTitle = getDataSetIdFromName(dataset, "title");
1581 getGraphicObjectProperty(axes, __GO_TITLE__, jni_int, (void **)&ptitle);
1582 import_handle_label(nodeTitle, title);
1586 int *px_label = &x_label;
1587 int nodeX = getDataSetIdFromName(dataset, "x_label");
1588 getGraphicObjectProperty(axes, __GO_X_AXIS_LABEL__, jni_int, (void **)&px_label);
1589 import_handle_label(nodeX, x_label);
1593 int *py_label = &y_label;
1594 int nodeY = getDataSetIdFromName(dataset, "y_label");
1595 getGraphicObjectProperty(axes, __GO_Y_AXIS_LABEL__, jni_int, (void **)&py_label);
1596 import_handle_label(nodeY, y_label);
1600 int *pz_label = &z_label;
1601 int nodeZ = getDataSetIdFromName(dataset, "z_label");
1602 getGraphicObjectProperty(axes, __GO_Z_AXIS_LABEL__, jni_int, (void **)&pz_label);
1603 import_handle_label(nodeZ, z_label);
1605 //set real visible state
1606 getHandleInt(dataset, "visible", &visible);
1607 setGraphicObjectProperty(axes, __GO_VISIBLE__, &visible, jni_bool, 1);
1609 closeList6(dataset);
1613 static int import_handle_layout_options(int dataset, int frame)
1615 int layout_type = 0;
1616 getHandleInt(dataset, "layout", &layout_type);
1619 int* data = nullptr;
1621 switch (layout_type)
1625 int node = getDataSetIdFromName(dataset, "layout_options");
1626 getHandleIntVector(node, "grid", &row, &col, &data);
1627 if (data && row * col == 2)
1629 setGraphicObjectProperty(frame, __GO_GRID_OPT_GRID__, data, jni_int_vector, 2);
1635 getHandleIntVector(node, "padding", &row, &col, &data);
1636 if (data && row * col == 2)
1638 setGraphicObjectProperty(frame, __GO_GRID_OPT_PADDING__, data, jni_int_vector, 2);
1649 int node = getDataSetIdFromName(dataset, "layout_options");
1650 getHandleIntVector(node, "padding", &row, &col, &data);
1651 if (data && row * col == 2)
1653 setGraphicObjectProperty(frame, __GO_BORDER_OPT_PADDING__, data, jni_int_vector, 2);
1667 static int import_handle_figure(int dataset, int parent)
1669 //some properties must be set @ creation time
1671 getHandleInt(dataset, "menubar", &menubar);
1673 getHandleInt(dataset, "toolbar", &toolbar);
1675 getHandleBool(dataset, "dockable", &dockable);
1676 int default_axes = 0;
1677 getHandleBool(dataset, "default_axes", &default_axes);
1679 //force visible true FOR DEBUG ONLY
1682 //create a new hidden figure
1683 int fig = createFigure(dockable, menubar, toolbar, default_axes, visible);
1684 int id = getValidDefaultFigureId();
1685 setGraphicObjectProperty(fig, __GO_ID__, &id, jni_int, 1);
1688 getHandleBool(dataset, "menubar_visible", &menu);
1689 int notmenu = !menu;
1691 getHandleBool(dataset, "infobar_visible", &info);
1692 int notinfo = !info;
1694 getHandleBool(dataset, "toolbar_visible", &tool);
1695 int nottool = !tool;
1697 //force inverse flag
1698 setGraphicObjectProperty(fig, __GO_MENUBAR_VISIBLE__, ¬menu, jni_bool, 1);
1699 setGraphicObjectProperty(fig, __GO_INFOBAR_VISIBLE__, ¬info, jni_bool, 1);
1700 setGraphicObjectProperty(fig, __GO_TOOLBAR_VISIBLE__, ¬tool, jni_bool, 1);
1703 setGraphicObjectProperty(fig, __GO_MENUBAR_VISIBLE__, &menu, jni_bool, 1);
1704 setGraphicObjectProperty(fig, __GO_INFOBAR_VISIBLE__, &info, jni_bool, 1);
1705 setGraphicObjectProperty(fig, __GO_TOOLBAR_VISIBLE__, &tool, jni_bool, 1);
1707 //import "standards" properties
1708 import_handle_generic(dataset, fig, -1, FigureHandle::getPropertyList(), true);
1710 import_handle_layout_options(dataset, fig);
1711 closeList6(dataset);
1715 int import_handle(int dataset, int parent)
1719 getHandleInt(dataset, "type", &type);
1724 return import_handle_figure(dataset, parent);
1728 return import_handle_axes(dataset, parent);
1732 return import_handle_champ(dataset, parent);
1736 return import_handle_fac3d(dataset, parent);
1740 return import_handle_plot3d(dataset, parent);
1742 case __GO_COMPOUND__:
1744 return import_handle_compound(dataset, parent);
1746 case __GO_POLYLINE__:
1748 return import_handle_polyline(dataset, parent);
1750 case __GO_RECTANGLE__:
1752 return import_handle_rectangle(dataset, parent);
1756 return import_handle_arc(dataset, parent);
1760 return import_handle_segs(dataset, parent);
1762 case __GO_GRAYPLOT__:
1764 return import_handle_grayplot(dataset, parent);
1766 case __GO_MATPLOT__:
1768 return import_handle_matplot(dataset, parent);
1772 return import_handle_fec(dataset, parent);
1776 return import_handle_legend(dataset, parent);
1780 return import_handle_text(dataset, parent);
1784 return import_handle_axis(dataset, parent);
1788 return import_handle_light(dataset, parent);
1792 return import_handle_uimenu(dataset, parent);
1794 case __GO_UICONTEXTMENU__:
1796 return import_handle_uicontextmenu(dataset, parent);
1798 case __GO_UICONTROL__:
1800 return import_handle_uicontrol(dataset, parent);
1806 void update_link_path(int legend, Links::PathList& paths)
1808 //find legend parent axes ( origin of path items )
1811 int axes = legend; //start point
1813 getGraphicObjectProperty(legend, __GO_PARENT_AXES__, jni_int, (void**)&paxes);
1814 std::vector<int> links;
1815 //loop on child following path index
1816 for (auto & path : paths)
1819 for (int j = 0; j < path.size(); ++j)
1821 int index = path[path.size() - 1 - j];
1823 int* pcount = &count;
1824 getGraphicObjectProperty(current, __GO_CHILDREN_COUNT__, jni_int, (void**)&pcount);
1825 if (count == 0 || index >= count)
1827 getGraphicObjectProperty(current, __GO_TYPE__, jni_int, (void**)&ptype);
1831 int* children = nullptr;
1832 getGraphicObjectProperty(current, __GO_CHILDREN__, jni_int_vector, (void**)&children);
1834 current = children[index];
1836 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
1839 links.push_back(current);
1842 setGraphicObjectProperty(legend, __GO_LINKS__, links.data(), jni_int_vector, static_cast<int>(links.size()));
1845 static bool getHandleBoolProperty(int uid, int prop, int* data)
1849 getGraphicObjectProperty(uid, prop, jni_bool, (void **)&pVal);
1850 if (pVal == nullptr)
1859 static bool getHandleIntProperty(int uid, int prop, int* data)
1863 getGraphicObjectProperty(uid, prop, jni_int, (void **)&pVal);
1864 if (pVal == nullptr)
1873 static bool getHandleDoubleProperty(int uid, int prop, double* data)
1876 double* pVal = &val;
1877 getGraphicObjectProperty(uid, prop, jni_double, (void **)&pVal);
1878 if (pVal == nullptr)
1887 static void getHandleStringProperty(int uid, int prop, char** str)
1889 getGraphicObjectProperty(uid, prop, jni_string, (void **)str);
1893 static void getHandleBoolVectorProperty(int uid, int prop, int** vals)
1895 getGraphicObjectProperty(uid, prop, jni_bool_vector, (void **)vals);
1898 static void getHandleIntVectorProperty(int uid, int prop, int** vals)
1900 getGraphicObjectProperty(uid, prop, jni_int_vector, (void **)vals);
1903 static void getHandleDoubleVectorProperty(int uid, int prop, double** vals)
1905 getGraphicObjectProperty(uid, prop, jni_double_vector, (void **)vals);
1908 static void getHandleStringVectorProperty(int uid, int prop, char*** vals)
1910 getGraphicObjectProperty(uid, prop, jni_string_vector, (void **)vals);
1913 static bool export_handle_generic(int parent, int uid, const HandleProp& props);
1914 static bool export_handle_layout_options(int parent, int uid);
1915 static bool export_handle_userdata(int parent, int uid);
1916 static bool export_handle_tag(int parent, int uid);
1917 static bool export_handle_figure(int parent, int uid);
1918 static bool export_handle_axes(int parent, int uid);
1919 static bool export_handle_label(int parent, int uid);
1920 static bool export_handle_champ(int parent, int uid);
1921 static bool export_handle_children(int parent, int uid);
1923 static bool export_handle_generic(int parent, int uid, const HandleProp& props)
1925 for (auto & prop : props)
1927 const char* name = prop.first.data();
1928 std::vector<int> info(prop.second);
1931 if (info.size() == 3)
1940 std::vector<int> dims = {1, 1};
1942 getHandleBoolProperty(uid, go, &val);
1943 writeBooleanMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1948 std::vector<int> dims = {1, 1};
1950 getHandleDoubleProperty(uid, go, &val);
1951 writeDoubleMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1956 std::vector<int> dims = {1, 1};
1958 getHandleIntProperty(uid, go, &val);
1959 writeIntegerMatrix6(parent, name, H5T_NATIVE_INT32, "32", static_cast<int>(dims.size()), dims.data(), &val);
1964 std::vector<int> dims = {1, 1};
1966 getHandleStringProperty(uid, go, &val);
1967 writeStringMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1968 releaseGraphicObjectProperty(go, val, jni_string, 1);
1973 else //vector variable
1978 int col = info.size() > 3 ? info[4] : -1;
1986 getHandleIntProperty(uid, row, &row);
1995 getHandleIntProperty(uid, col, &col);
2000 case jni_bool_vector:
2002 std::vector<int> dims = {row, col};
2004 getHandleBoolVectorProperty(uid, go, &vals);
2005 writeBooleanMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
2006 releaseGraphicObjectProperty(go, vals, jni_bool_vector, row * col);
2009 case jni_double_vector:
2011 std::vector<int> dims = {row, col};
2013 getHandleDoubleVectorProperty(uid, go, &vals);
2014 writeDoubleMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
2015 releaseGraphicObjectProperty(go, vals, jni_double_vector, row * col);
2018 case jni_int_vector:
2020 std::vector<int> dims = {row, col};
2022 getHandleIntVectorProperty(uid, go, &vals);
2023 writeIntegerMatrix6(parent, name, H5T_NATIVE_INT32, "32", static_cast<int>(dims.size()), dims.data(), vals);
2024 releaseGraphicObjectProperty(go, vals, jni_int_vector, row * col);
2027 case jni_string_vector:
2029 std::vector<int> dims = {row, col};
2031 getHandleStringVectorProperty(uid, go, &vals);
2032 writeStringMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
2033 releaseGraphicObjectProperty(go, vals, jni_string_vector, row * col);
2045 export_handle_userdata(parent, uid);
2047 export_handle_tag(parent, uid);
2049 export_handle_children(parent, uid);
2053 static bool export_handle_layout_options(int parent, int uid)
2055 int layout_type = 0;
2056 getHandleIntProperty(uid, __GO_LAYOUT__, &layout_type);
2057 if (layout_type == 0 || layout_type == 1) //LAYOUT_NONE or LAYOUT_GRIDBAG
2063 int layout = openList6(parent, "layout_options", g_SCILAB_CLASS_HANDLE);
2065 switch (layout_type)
2069 std::vector<int> dims = {1, 2};
2070 int* grid = nullptr;
2071 getHandleIntVectorProperty(uid, __GO_GRID_OPT_GRID__, &grid);
2072 writeIntegerMatrix6(layout, "grid", H5T_NATIVE_INT32, "32", 2, dims.data(), grid);
2073 releaseGraphicObjectProperty(__GO_GRID_OPT_GRID__, grid, jni_int_vector, 2);
2076 getHandleIntVectorProperty(uid, __GO_GRID_OPT_PADDING__, &pad);
2077 writeIntegerMatrix6(layout, "padding", H5T_NATIVE_INT32, "32", 2, dims.data(), pad);
2078 releaseGraphicObjectProperty(__GO_GRID_OPT_PADDING__, pad, jni_int_vector, 2);
2083 std::vector<int> dims = {1, 2};
2085 getHandleIntVectorProperty(uid, __GO_BORDER_OPT_PADDING__, &pad);
2086 writeIntegerMatrix6(layout, "padding", H5T_NATIVE_INT32, "32", 2, dims.data(), pad);
2087 releaseGraphicObjectProperty(__GO_BORDER_OPT_PADDING__, pad, jni_int_vector, 2);
2096 static bool export_handle_tag(int parent, int uid)
2098 char* tag = nullptr;
2099 getHandleStringProperty(uid, __GO_TAG__, &tag);
2103 writeStringMatrix6(parent, "tag", 2, dims, &tag);
2104 releaseGraphicObjectProperty(__GO_TAG__, tag, jni_string, 1);
2108 static bool export_handle_userdata(int parent, int uid)
2112 getHandleIntProperty(uid, __GO_USER_DATA_SIZE__, &size);
2116 std::vector<int> dims = {0, 0};
2117 writeDoubleMatrix6(parent, "userdata", 2, dims.data(), NULL);
2122 getHandleIntVectorProperty(uid, __GO_USER_DATA__, &data);
2124 types::InternalType* pUD = nullptr;
2128 int* p = (int*)data;
2129 pUD = ((types::InternalType*) * p);
2134 long long* p = (long long*)data;
2135 pUD = ((types::InternalType*) * p);
2138 export_data(parent, "userdata", pUD);
2139 //do not release, data is a reference on data in model
2140 //releaseGraphicObjectProperty(__GO_USER_DATA__, data, jni_int_vector, size);
2146 static bool export_handle_datatips(int parent, int uid)
2149 getHandleIntProperty(uid, __GO_DATATIPS_COUNT__, &count);
2150 int node = openList6(parent, "datatips", g_SCILAB_CLASS_HANDLE);
2151 int* datatips = nullptr;
2155 getHandleIntVectorProperty(uid, __GO_DATATIPS__, &datatips);
2158 for (int i = 0; i < count; ++i)
2160 if (export_handle(node, std::to_string(i), datatips[i]) == false)
2162 releaseGraphicObjectProperty(__GO_DATATIPS__, datatips, jni_int_vector, count);
2168 releaseGraphicObjectProperty(__GO_DATATIPS__, datatips, jni_int_vector, count);
2173 static bool export_handle_border(int dataset, int uid);
2175 static bool export_handle_border_none(int dataset, int uid)
2178 closeList6(dataset);
2182 static bool export_handle_border_line(int dataset, int uid)
2190 char* color = nullptr;
2191 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &color);
2192 writeStringMatrix6(dataset, "color", 2, dims, &color);
2193 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, color, jni_string, 1);
2197 ret = getHandleIntProperty(uid, __GO_LINE_THICKNESS__, &thickness);
2200 writeIntegerMatrix6(dataset, "thickness", H5T_NATIVE_INT32, "32", 2, dims, &thickness);
2205 ret = getHandleBoolProperty(uid, __GO_UI_FRAME_BORDER_ROUNDED__, &rounded);
2208 writeBooleanMatrix6(dataset, "rounded", 2, dims, &rounded);
2211 closeList6(dataset);
2215 static bool export_handle_border_bevel(int dataset, int uid)
2221 char* data = nullptr;
2225 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TYPE__, &type);
2228 writeIntegerMatrix6(dataset, "type", H5T_NATIVE_INT32, "32", 2, dims, &type);
2232 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, &data);
2235 writeStringMatrix6(dataset, "highlight_out", 2, dims, &data);
2236 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
2240 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, &data);
2243 writeStringMatrix6(dataset, "highlight_in", 2, dims, &data);
2244 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, data, jni_string, 1);
2248 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_OUT__, &data);
2251 writeStringMatrix6(dataset, "shadow_out", 2, dims, &data);
2252 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
2256 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_IN__, &data);
2259 writeStringMatrix6(dataset, "shadow_in", 2, dims, &data);
2260 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_IN__, data, jni_string, 1);
2262 closeList6(dataset);
2266 static bool export_handle_border_soft_bevel(int dataset, int uid)
2268 return export_handle_border_bevel(dataset, uid);
2271 static bool export_handle_border_etched(int dataset, int uid)
2277 char* data = nullptr;
2281 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TYPE__, &type);
2284 writeIntegerMatrix6(dataset, "type", H5T_NATIVE_INT32, "32", 2, dims, &type);
2288 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, &data);
2291 writeStringMatrix6(dataset, "highlight_out", 2, dims, &data);
2292 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
2296 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_OUT__, &data);
2299 writeStringMatrix6(dataset, "shadow_out", 2, dims, &data);
2300 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
2303 closeList6(dataset);
2307 static bool export_handle_border_titled(int dataset, int uid)
2313 char* data = nullptr;
2317 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TITLE__, &title);
2320 int node = openList6(dataset, "title_border", g_SCILAB_CLASS_HANDLE);
2321 export_handle_border(node, title);
2325 getHandleStringProperty(uid, __GO_TITLE__, &data);
2328 writeStringMatrix6(dataset, "title", 2, dims, &data);
2329 releaseGraphicObjectProperty(__GO_TITLE__, data, jni_string, 1);
2333 int justification = 0;
2334 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_JUSTIFICATION__, &justification);
2337 writeIntegerMatrix6(dataset, "justification", H5T_NATIVE_INT32, "32", 2, dims, &justification);
2341 getHandleStringProperty(uid, __GO_UI_FONTNAME__, &data);
2344 writeStringMatrix6(dataset, "fontname", 2, dims, &data);
2345 releaseGraphicObjectProperty(__GO_UI_FONTNAME__, data, jni_string, 1);
2350 getHandleStringProperty(uid, __GO_UI_FONTANGLE__, &data);
2353 writeStringMatrix6(dataset, "fontangle", 2, dims, &data);
2354 releaseGraphicObjectProperty(__GO_UI_FONTANGLE__, data, jni_string, 1);
2360 ret = getHandleIntProperty(uid, __GO_UI_FONTSIZE__, &fonsize);
2363 writeIntegerMatrix6(dataset, "fontsize", H5T_NATIVE_INT32, "32", 2, dims, &fonsize);
2367 getHandleStringProperty(uid, __GO_UI_FONTWEIGHT__, &data);
2370 writeStringMatrix6(dataset, "fontweight", 2, dims, &data);
2371 releaseGraphicObjectProperty(__GO_UI_FONTWEIGHT__, data, jni_string, 1);
2377 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_POSITION__, &position);
2380 writeIntegerMatrix6(dataset, "position", H5T_NATIVE_INT32, "32", 2, dims, &position);
2384 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &data);
2387 writeStringMatrix6(dataset, "color", 2, dims, &data);
2388 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
2392 closeList6(dataset);
2396 static bool export_handle_border_empty(int dataset, int uid)
2401 double* pos = nullptr;
2404 getHandleDoubleVectorProperty(uid, __GO_POSITION__, &pos);
2407 writeDoubleMatrix6(dataset, "position", 2, dims, pos);
2408 releaseGraphicObjectProperty(__GO_POSITION__, pos, jni_double_vector, 4);
2411 closeList6(dataset);
2415 static bool export_handle_border_compound(int dataset, int uid)
2421 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_OUT_BORDER__, &out_border);
2424 int node = openList6(dataset, "out_border", g_SCILAB_CLASS_HANDLE);
2425 export_handle_border(node, out_border);
2429 getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_IN_BORDER__, &in_border);
2430 node = openList6(dataset, "in_border", g_SCILAB_CLASS_HANDLE);
2431 export_handle_border(node, in_border);
2434 closeList6(dataset);
2438 static bool export_handle_border_matte(int dataset, int uid)
2443 char* data = nullptr;
2444 double* pos = nullptr;
2449 getHandleDoubleVectorProperty(uid, __GO_POSITION__, &pos);
2450 writeDoubleMatrix6(dataset, "position", 2, dims, pos);
2451 releaseGraphicObjectProperty(__GO_POSITION__, pos, jni_double_vector, 4);
2456 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &data);
2457 writeStringMatrix6(dataset, "color", 2, dims, &data);
2458 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
2460 closeList6(dataset);
2464 static bool export_handle_border(int dataset, int uid)
2467 getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_STYLE__, &style);
2472 writeIntegerMatrix6(dataset, "style", H5T_NATIVE_INT32, "32", 2, dims, &style);
2478 return export_handle_border_none(dataset, uid);
2480 return export_handle_border_line(dataset, uid);
2482 return export_handle_border_bevel(dataset, uid);
2484 return export_handle_border_soft_bevel(dataset, uid);
2486 return export_handle_border_etched(dataset, uid);
2488 return export_handle_border_titled(dataset, uid);
2490 return export_handle_border_empty(dataset, uid);
2492 return export_handle_border_compound(dataset, uid);
2494 return export_handle_border_matte(dataset, uid);
2498 static bool export_handle_uicontrol(int parent, int uid)
2501 if (export_handle_generic(parent, uid, UicontrolHandle::getPropertyList()) == false)
2508 getHandleIntProperty(uid, __GO_UI_STRING_SIZE__, &size);
2510 getHandleIntProperty(uid, __GO_UI_STRING_COLNB__, &col);
2519 writeStringMatrix6(parent, "string", 2, dims, &empty);
2524 int row = size / col;
2527 char** string = nullptr;
2528 getHandleStringVectorProperty(uid, __GO_UI_STRING__, &string);
2529 writeStringMatrix6(parent, "string", 2, dims, string);
2530 releaseGraphicObjectProperty(__GO_UI_STRING__, string, jni_string_vector, size);
2535 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER__, &border);
2538 int ub = openList6(parent, "border", g_SCILAB_CLASS_HANDLE);
2539 export_handle_border(ub, border);
2547 static bool export_handle_uicontextmenu(int parent, int uid)
2549 if (export_handle_generic(parent, uid, UicontextmenuHandle::getPropertyList()) == false)
2558 static bool export_handle_uimenu(int parent, int uid)
2560 if (export_handle_generic(parent, uid, UimenuHandle::getPropertyList()) == false)
2569 static bool export_handle_light(int parent, int uid)
2571 if (export_handle_generic(parent, uid, LightHandle::getPropertyList()) == false)
2580 static bool export_handle_axis(int parent, int uid)
2582 if (export_handle_generic(parent, uid, AxisHandle::getPropertyList()) == false)
2591 static bool export_handle_text(int parent, int uid)
2593 if (export_handle_generic(parent, uid, TextHandle::getPropertyList()) == false)
2599 int* dims = nullptr;
2600 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dims);
2602 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
2603 writeStringMatrix6(parent, "text", 2, dims, text);
2608 //find parent axes of a entity and return path ( via children index )
2609 bool get_entity_path(int entity, std::vector<int>& path)
2616 getHandleIntProperty(entity, __GO_PARENT__, &parent);
2618 getHandleIntProperty(parent, __GO_CHILDREN_COUNT__, &count);
2619 //get children of parent to find "my" index
2620 int* children = nullptr;
2621 getHandleIntVectorProperty(parent, __GO_CHILDREN__, &children);
2623 for (int i = 0; i < count; ++i)
2625 if (children[i] == entity)
2633 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
2640 getHandleIntProperty(parent, __GO_TYPE__, &type);
2641 if (type == __GO_AXES__)
2652 static bool export_handle_legend(int parent, int uid)
2654 if (export_handle_generic(parent, uid, LegendHandle::getPropertyList()) == false)
2660 int node = openList6(parent, "links", g_SCILAB_CLASS_HANDLE);
2662 getHandleIntProperty(uid, __GO_LINKS_COUNT__, &link);
2663 int* links = nullptr;
2664 getHandleIntVectorProperty(uid, __GO_LINKS__, &links);
2665 for (int i = 0; i < link; ++i)
2667 std::vector<int> path;
2668 if (get_entity_path(links[i], path))
2672 dims[1] = static_cast<int>(path.size());
2673 writeIntegerMatrix6(node, std::to_string(i).data(), H5T_NATIVE_INT32, "32", 2, dims, path.data());
2677 releaseGraphicObjectProperty(__GO_LINKS__, links, jni_int_vector, link);
2681 int* dims = nullptr;
2682 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dims);
2684 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
2685 writeStringMatrix6(parent, "text", 2, dims, text);
2690 static bool export_handle_fec(int parent, int uid)
2692 if (export_handle_generic(parent, uid, FecHandle::getPropertyList()) == false)
2699 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_INDICES__, &indices);
2701 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_VERTICES_BY_ELEM__, &vect);
2702 double* triangles = nullptr;
2703 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_FEC_ELEMENTS__, &triangles);
2708 writeDoubleMatrix6(parent, "triangles", 2, dims, triangles);
2709 releaseGraphicObjectProperty(__GO_DATA_MODEL_FEC_ELEMENTS__, triangles, jni_double_vector, dims[0] * dims[1]);
2715 static bool export_handle_matplot(int parent, int uid)
2717 if (export_handle_generic(parent, uid, MatplotHandle::getPropertyList()) == false)
2723 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
2725 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
2727 getHandleIntProperty(uid, __GO_DATA_MODEL_MATPLOT_DATA_TYPE__, &datatype);
2729 getHandleIntProperty(uid, __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__, &imagetype);
2730 int size = (row - 1) * (col - 1);
2732 //data can be char, uchar, short, ushort, ... hide in a double*
2733 //save double like this but need to compute exact dimensions to
2736 double* data = nullptr;
2737 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &data);
2742 case MATPLOT_HM1_Char:
2743 case MATPLOT_HM1_UChar:
2744 size /= (sizeof(double) / sizeof(char));
2746 case MATPLOT_HM3_Char:
2747 case MATPLOT_HM3_UChar:
2748 size /= (sizeof(double) / sizeof(char));
2752 case MATPLOT_HM3_Double:
2755 case MATPLOT_HM4_Char:
2756 case MATPLOT_HM4_UChar:
2757 size /= (sizeof(double) / sizeof(char));
2760 case MATPLOT_HM4_Double:
2764 size /= (sizeof(double) / sizeof(char));
2765 if ((ImageType)imagetype == MATPLOT_RGB)
2769 else if ((GLType)imagetype == MATPLOT_GL_RGBA)
2776 size /= (sizeof(double) / sizeof(int));
2779 case MATPLOT_UShort:
2780 size /= (sizeof(double) / sizeof(short));
2782 case MATPLOT_Double:
2783 case MATPLOT_HM1_Double:
2792 writeDoubleMatrix6(parent, "data", 2, dims, data);
2793 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, data, jni_double_vector, size);
2798 static bool export_handle_grayplot(int parent, int uid)
2800 if (export_handle_generic(parent, uid, GrayplotHandle::getPropertyList()) == false)
2806 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
2808 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
2810 double* dataX = nullptr;
2811 double* dataY = nullptr;
2812 double* dataZ = nullptr;
2814 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2815 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2816 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2821 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2825 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2829 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2835 static bool export_handle_segs(int parent, int uid)
2837 if (export_handle_generic(parent, uid, SegsHandle::getPropertyList()) == false)
2846 static bool export_handle_arc(int parent, int uid)
2848 if (export_handle_generic(parent, uid, ArcHandle::getPropertyList()) == false)
2857 static bool export_handle_rectangle(int parent, int uid)
2859 if (export_handle_generic(parent, uid, RectangleHandle::getPropertyList()) == false)
2868 static bool export_handle_datatip(int parent, int uid)
2870 if (export_handle_generic(parent, uid, DatatipHandle::getPropertyList()) == false)
2879 static bool export_handle_polyline_shift(int parent, int uid, const std::string& name, int go_set, int go_data)
2882 getHandleBoolProperty(uid, go_set, &set);
2886 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2887 double* data = nullptr;
2888 getHandleDoubleVectorProperty(uid, go_data, &data);
2893 writeDoubleMatrix6(parent, name.data(), 2, dims, data);
2895 releaseGraphicObjectProperty(uid, data, jni_double_vector, count);
2902 writeDoubleMatrix6(parent, name.data(), 2, dims, NULL);
2908 static bool export_handle_polyline(int parent, int uid)
2910 if (export_handle_datatips(parent, uid) == false)
2915 if (export_handle_generic(parent, uid, PolylineHandle::getPropertyList()) == false)
2921 export_handle_polyline_shift(parent, uid, "x_shift", __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_X_COORDINATES_SHIFT__);
2923 export_handle_polyline_shift(parent, uid, "y_shift", __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Y_COORDINATES_SHIFT__);
2925 export_handle_polyline_shift(parent, uid, "z_shift", __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Z_COORDINATES_SHIFT__);
2927 //interp_color_vector
2929 getHandleBoolProperty(uid, __GO_INTERP_COLOR_VECTOR_SET__, &set);
2933 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2934 int* data = nullptr;
2935 getHandleIntVectorProperty(uid, __GO_INTERP_COLOR_VECTOR__, &data);
2940 writeIntegerMatrix6(parent, "interp_color_vector", H5T_NATIVE_INT32, "32", 2, dims, data);
2941 releaseGraphicObjectProperty(uid, data, jni_int_vector, count);
2948 writeIntegerMatrix6(parent, "interp_color_vector", H5T_NATIVE_INT32, "32", 2, dims, NULL);
2953 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2959 double* dataX = nullptr;
2960 double* dataY = nullptr;
2961 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2962 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2964 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2965 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2967 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, count);
2968 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, count);
2970 getHandleIntProperty(uid, __GO_DATA_MODEL_Z_COORDINATES_SET__, &set);
2973 double* dataZ = nullptr;
2974 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2975 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2976 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, count);
2983 writeDoubleMatrix6(parent, "data_z", 2, dims, NULL);
2990 static bool export_handle_surface(int parent, int uid)
2992 return export_handle_generic(parent, uid, SurfaceHandle::getPropertyList());
2995 static bool export_handle_plot3d(int parent, int uid)
2997 bool ret = export_handle_surface(parent, uid);
3000 double* colors = NULL;
3001 double* dataX = NULL;
3002 double* dataY = NULL;
3003 double* dataZ = NULL;
3006 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
3007 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
3008 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
3011 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
3013 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
3015 int* xDims = nullptr;
3016 int* yDims = nullptr;
3017 getHandleIntVectorProperty(uid, __GO_DATA_MODEL_X_DIMENSIONS__, &xDims);
3018 getHandleIntVectorProperty(uid, __GO_DATA_MODEL_Y_DIMENSIONS__, &yDims);
3023 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
3024 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, dims[0] * dims[1]);
3028 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
3029 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, dims[0] * dims[1]);
3033 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
3034 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, dims[0] * dims[1]);
3036 releaseGraphicObjectProperty(__GO_DATA_MODEL_X_DIMENSIONS__, xDims, jni_int_vector, 2);
3037 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y_DIMENSIONS__, dataZ, jni_int_vector, 2);
3044 static bool export_handle_fac3d(int parent, int uid)
3046 bool ret = export_handle_surface(parent, uid);
3049 double* colors = NULL;
3050 double* dataX = NULL;
3051 double* dataY = NULL;
3052 double* dataZ = NULL;
3055 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
3056 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
3057 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
3060 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_VERTICES_PER_GON__, &row);
3062 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_GONS__, &col);
3068 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
3069 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
3070 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
3072 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, dims[0] * dims[1]);
3073 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, dims[0] * dims[1]);
3074 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, dims[0] * dims[1]);
3076 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_COLORS__, &colors);
3080 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_COLORS__, &numColors);
3081 if (numColors == col)
3099 writeDoubleMatrix6(parent, "colors", 2, dims, colors);
3100 releaseGraphicObjectProperty(__GO_DATA_MODEL_COLORS__, colors, jni_double_vector, dims[0] * dims[1]);
3104 getHandleIntProperty(uid, __GO_DATA_MAPPING__, &cdata);
3107 writeIntegerMatrix6(parent, "cdata_mapping", H5T_NATIVE_INT32, "32", 2, dims, &cdata);
3116 static bool export_handle_champ(int parent, int uid)
3118 if (export_handle_generic(parent, uid, ChampHandle::getPropertyList()) == false)
3124 int* dimensions = NULL;
3125 double* arrowBasesX = NULL;
3126 double* arrowBasesY = NULL;
3127 double* arrowDirectionsX = NULL;
3128 double* arrowDirectionsY = NULL;
3130 getHandleIntVectorProperty(uid, __GO_CHAMP_DIMENSIONS__, &dimensions);
3133 getHandleDoubleVectorProperty(uid, __GO_BASE_X__, &arrowBasesX);
3135 dims[1] = dimensions[0];
3136 writeDoubleMatrix(parent, "base_x", 2, dims, arrowBasesX);
3137 releaseGraphicObjectProperty(__GO_BASE_X__, arrowBasesX, jni_double_vector, dims[1]);
3140 getHandleDoubleVectorProperty(uid, __GO_BASE_Y__, &arrowBasesY);
3142 dims[1] = dimensions[1];
3143 writeDoubleMatrix(parent, "base_y", 2, dims, arrowBasesY);
3144 releaseGraphicObjectProperty(__GO_BASE_Y__, arrowBasesY, jni_double_vector, dims[1]);
3147 getHandleDoubleVectorProperty(uid, __GO_DIRECTION_X__, &arrowDirectionsX);
3148 dims[0] = dimensions[0];
3149 dims[1] = dimensions[1];
3150 writeDoubleMatrix(parent, "direction_x", 2, dims, arrowDirectionsX);
3151 releaseGraphicObjectProperty(__GO_DIRECTION_X__, arrowDirectionsX, jni_double_vector, dims[0] * dims[1]);
3154 getHandleDoubleVectorProperty(uid, __GO_DIRECTION_Y__, &arrowDirectionsY);
3155 dims[0] = dimensions[0];
3156 dims[1] = dimensions[1];
3157 writeDoubleMatrix(parent, "direction_y", 2, dims, arrowDirectionsY);
3158 releaseGraphicObjectProperty(__GO_DIRECTION_Y__, arrowDirectionsY, jni_double_vector, dims[0] * dims[1]);
3160 releaseGraphicObjectProperty(__GO_CHAMP_DIMENSIONS__, dimensions, jni_int_vector, 2);
3164 static bool export_handle_label(int parent, int uid)
3166 if (export_handle_generic(parent, uid, LabelHandle::getPropertyList()) == false)
3172 int* dimensions = nullptr;
3173 char** text = nullptr;
3175 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dimensions);
3176 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
3178 std::vector<int> dims = {dimensions[0], dimensions[1]};
3179 releaseGraphicObjectProperty(__GO_TEXT_ARRAY_DIMENSIONS__, dimensions, jni_int_vector, 2);
3181 writeStringMatrix6(parent, "text", 2, dims.data(), text);
3182 releaseGraphicObjectProperty(__GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
3187 static bool export_handle_axes(int parent, int uid)
3189 if (export_handle_generic(parent, uid, AxesHandle::getPropertyList()) == false)
3196 getHandleIntProperty(uid, __GO_TITLE__, &title);
3197 export_handle(parent, "title", title);
3201 getHandleIntProperty(uid, __GO_X_AXIS_LABEL__, &x_label);
3202 export_handle(parent, "x_label", x_label);
3206 getHandleIntProperty(uid, __GO_Y_AXIS_LABEL__, &y_label);
3207 export_handle(parent, "y_label", y_label);
3211 getHandleIntProperty(uid, __GO_Z_AXIS_LABEL__, &z_label);
3212 export_handle(parent, "z_label", z_label);
3219 static bool export_handle_figure(int parent, int uid)
3221 if (export_handle_generic(parent, uid, FigureHandle::getPropertyList()) == false)
3227 export_handle_layout_options(parent, uid);
3233 static bool export_handle_compound(int parent, int uid)
3235 if (export_handle_generic(parent, uid, CompoundHandle::getPropertyList()) == false)
3244 bool export_handle(int parent, const std::string& name, int uid)
3248 getHandleIntProperty(uid, __GO_TYPE__, &type);
3250 //create handle node in __refs__
3251 int h = openList6(parent, name.data(), g_SCILAB_CLASS_HANDLE);
3258 ret = export_handle_figure(h, uid);
3263 ret = export_handle_axes(h, uid);
3268 ret = export_handle_label(h, uid);
3273 ret = export_handle_champ(h, uid);
3278 ret = export_handle_fac3d(h, uid);
3283 ret = export_handle_plot3d(h, uid);
3286 case __GO_POLYLINE__:
3288 ret = export_handle_polyline(h, uid);
3291 case __GO_DATATIP__:
3293 ret = export_handle_datatip(h, uid);
3296 case __GO_COMPOUND__:
3298 ret = export_handle_compound(h, uid);
3301 case __GO_RECTANGLE__:
3303 ret = export_handle_rectangle(h, uid);
3308 ret = export_handle_arc(h, uid);
3313 ret = export_handle_segs(h, uid);
3316 case __GO_GRAYPLOT__:
3318 ret = export_handle_grayplot(h, uid);
3321 case __GO_MATPLOT__:
3323 ret = export_handle_matplot(h, uid);
3328 ret = export_handle_fec(h, uid);
3333 ret = export_handle_legend(h, uid);
3338 ret = export_handle_text(h, uid);
3343 ret = export_handle_axis(h, uid);
3348 ret = export_handle_light(h, uid);
3353 ret = export_handle_uimenu(h, uid);
3356 case __GO_UICONTEXTMENU__:
3358 ret = export_handle_uicontextmenu(h, uid);
3361 case __GO_UICONTROL__:
3363 ret = export_handle_uicontrol(h, uid);
3375 static bool export_handle_children(int parent, int uid)
3378 getHandleIntProperty(uid, __GO_CHILDREN_COUNT__, &count);
3379 int node = openList6(parent, "children", g_SCILAB_CLASS_HANDLE);
3380 int* children = nullptr;
3384 getHandleIntVectorProperty(uid, __GO_CHILDREN__, &children);
3388 for (int i = 0; i < count; ++i)
3390 int child = children[i];
3392 getHandleBoolProperty(child, __GO_HIDDEN__, &hidden);
3395 if (export_handle(node, std::to_string(index), child) == false)
3397 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
3406 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
3411 int add_current_entity(int dataset)
3414 getHandleInt(dataset, "type", &type);
3420 return import_handle(dataset, -1);
3424 //add handle to current figure
3425 getOrCreateDefaultSubwin();
3426 int iCurrentFigure = getCurrentFigure();
3427 return import_handle(dataset, iCurrentFigure);
3429 case __GO_COMPOUND__:
3431 int axes = getOrCreateDefaultSubwin();
3432 return import_handle(dataset, axes);
3435 //add handle as child of current axes ( take care of compound ! )