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 int import_handle_polyline(int dataset, int parent)
1235 int polyline = createGraphicObject(__GO_POLYLINE__);
1236 createDataObject(polyline, __GO_POLYLINE__);
1238 //import "standards" properties
1239 import_handle_generic(dataset, polyline, parent, PolylineHandle::getPropertyList(), true);
1243 import_polyline_shift(dataset, polyline, "x_shift", __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_X_COORDINATES_SHIFT__);
1245 import_polyline_shift(dataset, polyline, "y_shift", __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Y_COORDINATES_SHIFT__);
1247 import_polyline_shift(dataset, polyline, "z_shift", __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Z_COORDINATES_SHIFT__);
1250 //interp_color_vector
1255 int* data = nullptr;
1257 getHandleIntVector(dataset, "interp_color_vector", &row, &col, &data);
1261 setGraphicObjectProperty(polyline, __GO_INTERP_COLOR_VECTOR__, data, jni_double_vector, row * col);
1269 setGraphicObjectProperty(polyline, __GO_INTERP_COLOR_VECTOR_SET__, &set, jni_bool, 1);
1274 int numElementsArray[2];
1276 double* dataX = nullptr;
1277 double* dataY = nullptr;
1278 double* dataZ = nullptr;
1279 getHandleDoubleVector(dataset, "data_x", &numElementsArray[0], &numElementsArray[1], &dataX);
1280 size = numElementsArray[0] * numElementsArray[1];
1281 getHandleDoubleVector(dataset, "data_y", &numElementsArray[0], &numElementsArray[1], &dataY);
1283 if (numElementsArray[0] * numElementsArray[1] != size)
1285 std::cout << "size trouble !!!" << std::endl;
1288 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, numElementsArray, jni_int_vector, 2);
1289 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_X__, dataX, jni_double_vector, size);
1290 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, size);
1294 numElementsArray[0] = 0;
1295 numElementsArray[1] = 0;
1296 getHandleDoubleVector(dataset, "data_z", &numElementsArray[0], &numElementsArray[1], &dataZ);
1297 if (numElementsArray[0] * numElementsArray[1] != 0)
1299 setGraphicObjectPropertyAndNoWarn(polyline, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, size);
1303 setGraphicObjectProperty(polyline, __GO_DATA_MODEL_Z_COORDINATES_SET__, &zSet, jni_int, 1);
1311 import_handle_datatips(dataset, polyline);
1313 closeList6(dataset);
1317 static int import_handle_surface(int dataset, int uid, int parent)
1319 //import "standards" properties
1320 import_handle_generic(dataset, uid, parent, SurfaceHandle::getPropertyList(), true);
1324 static int import_handle_plot3d(int dataset, int parent)
1326 int plot = createGraphicObject(__GO_PLOT3D__);
1327 createDataObject(plot, __GO_PLOT3D__);
1328 import_handle_surface(dataset, plot, parent);
1332 double* dataX = nullptr;
1334 double* dataY = nullptr;
1336 double* dataZ = nullptr;
1338 getHandleDoubleVector(dataset, "data_x", &xR, &xC, &dataX);
1339 getHandleDoubleVector(dataset, "data_y", &yR, &yC, &dataY);
1340 getHandleDoubleVector(dataset, "data_z", &zR, &zC, &dataZ);
1350 result = setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_GRID_SIZE__, gridSize, jni_int_vector, 4);
1352 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_X__, dataX, jni_double_vector, xR * xC);
1353 setGraphicObjectPropertyAndNoWarn(plot, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, yR * yC);
1354 setGraphicObjectProperty(plot, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, zR * zC);
1361 closeList6(dataset);
1365 static int import_handle_fac3d(int dataset, int parent)
1367 int fac = createGraphicObject(__GO_FAC3D__);
1368 createDataObject(fac, __GO_FAC3D__);
1370 import_handle_surface(dataset, fac, parent);
1374 double* dataX = nullptr;
1376 double* dataY = nullptr;
1378 double* dataZ = nullptr;
1380 getHandleDoubleVector(dataset, "data_x", &xR, &xC, &dataX);
1381 getHandleDoubleVector(dataset, "data_y", &yR, &yC, &dataY);
1382 getHandleDoubleVector(dataset, "data_z", &zR, &zC, &dataZ);
1386 double* colors = nullptr;
1387 getHandleDoubleVector(dataset, "colors", &cR, &cC, &colors);
1388 int cSize = cR * cC;
1390 int numElementsArray[3];
1392 numElementsArray[0] = xC;
1393 numElementsArray[1] = xR;
1394 numElementsArray[2] = cSize;
1396 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, numElementsArray, jni_int_vector, 3);
1398 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_X__, dataX, jni_double_vector, xR * xC);
1399 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_Y__, dataY, jni_double_vector, yR * yC);
1400 setGraphicObjectPropertyAndNoWarn(fac, __GO_DATA_MODEL_Z__, dataZ, jni_double_vector, zR * zC);
1401 setGraphicObjectProperty(fac, __GO_DATA_MODEL_COLORS__, colors, jni_double_vector, cSize);
1411 getHandleInt(dataset, "cdata_mapping", &cdata);
1412 setGraphicObjectProperty(fac, __GO_DATA_MAPPING__, &cdata, jni_int, 1);
1415 closeList6(dataset);
1420 static int import_handle_champ(int dataset, int parent)
1422 //need to get properties and call a "creator" :x
1424 int champ = createGraphicObject(__GO_CHAMP__);
1431 double* baseX = nullptr;
1432 getHandleDoubleVector(dataset, "base_x", &row, &col, &baseX);
1435 double* baseY = nullptr;
1436 getHandleDoubleVector(dataset, "base_y", &row, &col, &baseY);
1438 num = dims[0] * dims[1];
1440 double* directionX = nullptr;
1441 getHandleDoubleVector(dataset, "direction_x", &row, &col, &directionX);
1443 double* directionY = nullptr;
1444 getHandleDoubleVector(dataset, "direction_y", &row, &col, &directionY);
1446 setGraphicObjectProperty(champ, __GO_NUMBER_ARROWS__, &num, jni_int, 1);
1447 setGraphicObjectProperty(champ, __GO_CHAMP_DIMENSIONS__, dims, jni_int_vector, 2);
1448 setGraphicObjectProperty(champ, __GO_BASE_X__, baseX, jni_double_vector, dims[0]);
1449 setGraphicObjectProperty(champ, __GO_BASE_Y__, baseY, jni_double_vector, dims[1]);
1450 setGraphicObjectProperty(champ, __GO_DIRECTION_X__, directionX, jni_double_vector, dims[0] * dims[1]);
1451 setGraphicObjectProperty(champ, __GO_DIRECTION_Y__, directionY, jni_double_vector, dims[0] * dims[1]);
1455 delete[] directionX;
1456 delete[] directionY;
1458 //import "standards" properties
1459 import_handle_generic(dataset, champ, parent, ChampHandle::getPropertyList(), true);
1461 closeList6(dataset);
1464 static int import_handle_label(int dataset, int uid)
1466 //import "standards" properties
1467 //do not create releationship between parent
1468 import_handle_generic(dataset, uid, -1, LabelHandle::getPropertyList(), true);
1471 std::vector<int> dims(2);
1472 char** data = nullptr;
1473 int node = getHandleStringVector(dataset, "text", &dims[0], &dims[1], &data);
1475 setGraphicObjectProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, dims.data(), jni_int_vector, 2);
1476 setGraphicObjectProperty(uid, __GO_TEXT_STRINGS__, data, jni_string_vector, dims[0] * dims[1]);
1477 freeStringMatrix(node, data);
1480 closeList6(dataset);
1484 static int import_handle_axes(int dataset, int parent)
1486 //how to manage call by %h_copy ?
1488 int axes = createSubWin(parent);
1492 setGraphicObjectProperty(axes, __GO_VISIBLE__, &visible, jni_bool, 1);
1494 //import "standards" properties
1495 import_handle_generic(dataset, axes, parent, AxesHandle::getPropertyList(), true);
1499 int *ptitle = &title;
1500 int nodeTitle = getDataSetIdFromName(dataset, "title");
1501 getGraphicObjectProperty(axes, __GO_TITLE__, jni_int, (void **)&ptitle);
1502 import_handle_label(nodeTitle, title);
1506 int *px_label = &x_label;
1507 int nodeX = getDataSetIdFromName(dataset, "x_label");
1508 getGraphicObjectProperty(axes, __GO_X_AXIS_LABEL__, jni_int, (void **)&px_label);
1509 import_handle_label(nodeX, x_label);
1513 int *py_label = &y_label;
1514 int nodeY = getDataSetIdFromName(dataset, "y_label");
1515 getGraphicObjectProperty(axes, __GO_Y_AXIS_LABEL__, jni_int, (void **)&py_label);
1516 import_handle_label(nodeY, y_label);
1520 int *pz_label = &z_label;
1521 int nodeZ = getDataSetIdFromName(dataset, "z_label");
1522 getGraphicObjectProperty(axes, __GO_Z_AXIS_LABEL__, jni_int, (void **)&pz_label);
1523 import_handle_label(nodeZ, z_label);
1525 //set real visible state
1526 getHandleInt(dataset, "visible", &visible);
1527 setGraphicObjectProperty(axes, __GO_VISIBLE__, &visible, jni_bool, 1);
1529 closeList6(dataset);
1533 static int import_handle_layout_options(int dataset, int frame)
1535 int layout_type = 0;
1536 getHandleInt(dataset, "layout", &layout_type);
1539 int* data = nullptr;
1541 switch (layout_type)
1545 int node = getDataSetIdFromName(dataset, "layout_options");
1546 getHandleIntVector(node, "grid", &row, &col, &data);
1547 if (data && row * col == 2)
1549 setGraphicObjectProperty(frame, __GO_GRID_OPT_GRID__, data, jni_int_vector, 2);
1555 getHandleIntVector(node, "padding", &row, &col, &data);
1556 if (data && row * col == 2)
1558 setGraphicObjectProperty(frame, __GO_GRID_OPT_PADDING__, data, jni_int_vector, 2);
1569 int node = getDataSetIdFromName(dataset, "layout_options");
1570 getHandleIntVector(node, "padding", &row, &col, &data);
1571 if (data && row * col == 2)
1573 setGraphicObjectProperty(frame, __GO_BORDER_OPT_PADDING__, data, jni_int_vector, 2);
1587 static int import_handle_figure(int dataset, int parent)
1589 //some properties must be set @ creation time
1591 getHandleInt(dataset, "menubar", &menubar);
1593 getHandleInt(dataset, "toolbar", &toolbar);
1595 getHandleBool(dataset, "dockable", &dockable);
1596 int default_axes = 0;
1597 getHandleBool(dataset, "default_axes", &default_axes);
1599 //force visible true FOR DEBUG ONLY
1602 //create a new hidden figure
1603 int fig = createFigure(dockable, menubar, toolbar, default_axes, visible);
1604 int id = getValidDefaultFigureId();
1605 setGraphicObjectProperty(fig, __GO_ID__, &id, jni_int, 1);
1608 getHandleBool(dataset, "menubar_visible", &menu);
1609 int notmenu = !menu;
1611 getHandleBool(dataset, "infobar_visible", &info);
1612 int notinfo = !info;
1614 getHandleBool(dataset, "toolbar_visible", &tool);
1615 int nottool = !tool;
1617 //force inverse flag
1618 setGraphicObjectProperty(fig, __GO_MENUBAR_VISIBLE__, ¬menu, jni_bool, 1);
1619 setGraphicObjectProperty(fig, __GO_INFOBAR_VISIBLE__, ¬info, jni_bool, 1);
1620 setGraphicObjectProperty(fig, __GO_TOOLBAR_VISIBLE__, ¬tool, jni_bool, 1);
1623 setGraphicObjectProperty(fig, __GO_MENUBAR_VISIBLE__, &menu, jni_bool, 1);
1624 setGraphicObjectProperty(fig, __GO_INFOBAR_VISIBLE__, &info, jni_bool, 1);
1625 setGraphicObjectProperty(fig, __GO_TOOLBAR_VISIBLE__, &tool, jni_bool, 1);
1627 //import "standards" properties
1628 import_handle_generic(dataset, fig, -1, FigureHandle::getPropertyList(), true);
1630 import_handle_layout_options(dataset, fig);
1631 closeList6(dataset);
1635 int import_handle(int dataset, int parent)
1639 getHandleInt(dataset, "type", &type);
1644 return import_handle_figure(dataset, parent);
1648 return import_handle_axes(dataset, parent);
1652 return import_handle_champ(dataset, parent);
1656 return import_handle_fac3d(dataset, parent);
1660 return import_handle_plot3d(dataset, parent);
1662 case __GO_COMPOUND__:
1664 return import_handle_compound(dataset, parent);
1666 case __GO_POLYLINE__:
1668 return import_handle_polyline(dataset, parent);
1670 case __GO_RECTANGLE__:
1672 return import_handle_rectangle(dataset, parent);
1676 return import_handle_arc(dataset, parent);
1680 return import_handle_segs(dataset, parent);
1682 case __GO_GRAYPLOT__:
1684 return import_handle_grayplot(dataset, parent);
1686 case __GO_MATPLOT__:
1688 return import_handle_matplot(dataset, parent);
1692 return import_handle_fec(dataset, parent);
1696 return import_handle_legend(dataset, parent);
1700 return import_handle_text(dataset, parent);
1704 return import_handle_axis(dataset, parent);
1708 return import_handle_light(dataset, parent);
1712 return import_handle_uimenu(dataset, parent);
1714 case __GO_UICONTEXTMENU__:
1716 return import_handle_uicontextmenu(dataset, parent);
1718 case __GO_UICONTROL__:
1720 return import_handle_uicontrol(dataset, parent);
1726 void update_link_path(int legend, Links::PathList& paths)
1728 //find legend parent axes ( origin of path items )
1731 int axes = legend; //start point
1733 getGraphicObjectProperty(legend, __GO_PARENT_AXES__, jni_int, (void**)&paxes);
1734 std::vector<int> links;
1735 //loop on child following path index
1736 for (auto & path : paths)
1739 for (int j = 0; j < path.size(); ++j)
1741 int index = path[path.size() - 1 - j];
1743 int* pcount = &count;
1744 getGraphicObjectProperty(current, __GO_CHILDREN_COUNT__, jni_int, (void**)&pcount);
1745 if (count == 0 || index >= count)
1747 getGraphicObjectProperty(current, __GO_TYPE__, jni_int, (void**)&ptype);
1751 int* children = nullptr;
1752 getGraphicObjectProperty(current, __GO_CHILDREN__, jni_int_vector, (void**)&children);
1754 current = children[index];
1756 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
1759 links.push_back(current);
1762 setGraphicObjectProperty(legend, __GO_LINKS__, links.data(), jni_int_vector, static_cast<int>(links.size()));
1765 static bool getHandleBoolProperty(int uid, int prop, int* data)
1769 getGraphicObjectProperty(uid, prop, jni_bool, (void **)&pVal);
1770 if (pVal == nullptr)
1779 static bool getHandleIntProperty(int uid, int prop, int* data)
1783 getGraphicObjectProperty(uid, prop, jni_int, (void **)&pVal);
1784 if (pVal == nullptr)
1793 static bool getHandleDoubleProperty(int uid, int prop, double* data)
1796 double* pVal = &val;
1797 getGraphicObjectProperty(uid, prop, jni_double, (void **)&pVal);
1798 if (pVal == nullptr)
1807 static void getHandleStringProperty(int uid, int prop, char** str)
1809 getGraphicObjectProperty(uid, prop, jni_string, (void **)str);
1813 static void getHandleBoolVectorProperty(int uid, int prop, int** vals)
1815 getGraphicObjectProperty(uid, prop, jni_bool_vector, (void **)vals);
1818 static void getHandleIntVectorProperty(int uid, int prop, int** vals)
1820 getGraphicObjectProperty(uid, prop, jni_int_vector, (void **)vals);
1823 static void getHandleDoubleVectorProperty(int uid, int prop, double** vals)
1825 getGraphicObjectProperty(uid, prop, jni_double_vector, (void **)vals);
1828 static void getHandleStringVectorProperty(int uid, int prop, char*** vals)
1830 getGraphicObjectProperty(uid, prop, jni_string_vector, (void **)vals);
1833 static bool export_handle_generic(int parent, int uid, const HandleProp& props);
1834 static bool export_handle_layout_options(int parent, int uid);
1835 static bool export_handle_userdata(int parent, int uid);
1836 static bool export_handle_tag(int parent, int uid);
1837 static bool export_handle_figure(int parent, int uid);
1838 static bool export_handle_axes(int parent, int uid);
1839 static bool export_handle_label(int parent, int uid);
1840 static bool export_handle_champ(int parent, int uid);
1841 static bool export_handle_children(int parent, int uid);
1843 static bool export_handle_generic(int parent, int uid, const HandleProp& props)
1845 for (auto & prop : props)
1847 const char* name = prop.first.data();
1848 std::vector<int> info(prop.second);
1851 if (info.size() == 3)
1860 std::vector<int> dims = {1, 1};
1862 getHandleBoolProperty(uid, go, &val);
1863 writeBooleanMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1868 std::vector<int> dims = {1, 1};
1870 getHandleDoubleProperty(uid, go, &val);
1871 writeDoubleMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1876 std::vector<int> dims = {1, 1};
1878 getHandleIntProperty(uid, go, &val);
1879 writeIntegerMatrix6(parent, name, H5T_NATIVE_INT32, "32", static_cast<int>(dims.size()), dims.data(), &val);
1884 std::vector<int> dims = {1, 1};
1886 getHandleStringProperty(uid, go, &val);
1887 writeStringMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), &val);
1888 releaseGraphicObjectProperty(go, val, jni_string, 1);
1893 else //vector variable
1898 int col = info.size() > 3 ? info[4] : -1;
1906 getHandleIntProperty(uid, row, &row);
1915 getHandleIntProperty(uid, col, &col);
1920 case jni_bool_vector:
1922 std::vector<int> dims = {row, col};
1924 getHandleBoolVectorProperty(uid, go, &vals);
1925 writeBooleanMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
1926 releaseGraphicObjectProperty(go, vals, jni_bool_vector, row * col);
1929 case jni_double_vector:
1931 std::vector<int> dims = {row, col};
1933 getHandleDoubleVectorProperty(uid, go, &vals);
1934 writeDoubleMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
1935 releaseGraphicObjectProperty(go, vals, jni_double_vector, row * col);
1938 case jni_int_vector:
1940 std::vector<int> dims = {row, col};
1942 getHandleIntVectorProperty(uid, go, &vals);
1943 writeIntegerMatrix6(parent, name, H5T_NATIVE_INT32, "32", static_cast<int>(dims.size()), dims.data(), vals);
1944 releaseGraphicObjectProperty(go, vals, jni_int_vector, row * col);
1947 case jni_string_vector:
1949 std::vector<int> dims = {row, col};
1951 getHandleStringVectorProperty(uid, go, &vals);
1952 writeStringMatrix6(parent, name, static_cast<int>(dims.size()), dims.data(), vals);
1953 releaseGraphicObjectProperty(go, vals, jni_string_vector, row * col);
1965 export_handle_userdata(parent, uid);
1967 export_handle_tag(parent, uid);
1969 export_handle_children(parent, uid);
1973 static bool export_handle_layout_options(int parent, int uid)
1975 int layout_type = 0;
1976 getHandleIntProperty(uid, __GO_LAYOUT__, &layout_type);
1977 if (layout_type == 0 || layout_type == 1) //LAYOUT_NONE or LAYOUT_GRIDBAG
1983 int layout = openList6(parent, "layout_options", g_SCILAB_CLASS_HANDLE);
1985 switch (layout_type)
1989 std::vector<int> dims = {1, 2};
1990 int* grid = nullptr;
1991 getHandleIntVectorProperty(uid, __GO_GRID_OPT_GRID__, &grid);
1992 writeIntegerMatrix6(layout, "grid", H5T_NATIVE_INT32, "32", 2, dims.data(), grid);
1993 releaseGraphicObjectProperty(__GO_GRID_OPT_GRID__, grid, jni_int_vector, 2);
1996 getHandleIntVectorProperty(uid, __GO_GRID_OPT_PADDING__, &pad);
1997 writeIntegerMatrix6(layout, "padding", H5T_NATIVE_INT32, "32", 2, dims.data(), pad);
1998 releaseGraphicObjectProperty(__GO_GRID_OPT_PADDING__, pad, jni_int_vector, 2);
2003 std::vector<int> dims = {1, 2};
2005 getHandleIntVectorProperty(uid, __GO_BORDER_OPT_PADDING__, &pad);
2006 writeIntegerMatrix6(layout, "padding", H5T_NATIVE_INT32, "32", 2, dims.data(), pad);
2007 releaseGraphicObjectProperty(__GO_BORDER_OPT_PADDING__, pad, jni_int_vector, 2);
2016 static bool export_handle_tag(int parent, int uid)
2018 char* tag = nullptr;
2019 getHandleStringProperty(uid, __GO_TAG__, &tag);
2023 writeStringMatrix6(parent, "tag", 2, dims, &tag);
2024 releaseGraphicObjectProperty(__GO_TAG__, tag, jni_string, 1);
2028 static bool export_handle_userdata(int parent, int uid)
2032 getHandleIntProperty(uid, __GO_USER_DATA_SIZE__, &size);
2036 std::vector<int> dims = {0, 0};
2037 writeDoubleMatrix6(parent, "userdata", 2, dims.data(), NULL);
2042 getHandleIntVectorProperty(uid, __GO_USER_DATA__, &data);
2044 types::InternalType* pUD = nullptr;
2048 int* p = (int*)data;
2049 pUD = ((types::InternalType*) * p);
2054 long long* p = (long long*)data;
2055 pUD = ((types::InternalType*) * p);
2058 export_data(parent, "userdata", pUD);
2059 //do not release, data is a reference on data in model
2060 //releaseGraphicObjectProperty(__GO_USER_DATA__, data, jni_int_vector, size);
2066 static bool export_handle_datatips(int parent, int uid)
2069 getHandleIntProperty(uid, __GO_DATATIPS_COUNT__, &count);
2070 int node = openList6(parent, "datatips", g_SCILAB_CLASS_HANDLE);
2071 int* datatips = nullptr;
2075 getHandleIntVectorProperty(uid, __GO_DATATIPS__, &datatips);
2078 for (int i = 0; i < count; ++i)
2080 if (export_handle(node, std::to_string(i), datatips[i]) == false)
2082 releaseGraphicObjectProperty(__GO_DATATIPS__, datatips, jni_int_vector, count);
2088 releaseGraphicObjectProperty(__GO_DATATIPS__, datatips, jni_int_vector, count);
2093 static bool export_handle_border(int dataset, int uid);
2095 static bool export_handle_border_none(int dataset, int uid)
2098 closeList6(dataset);
2102 static bool export_handle_border_line(int dataset, int uid)
2110 char* color = nullptr;
2111 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &color);
2112 writeStringMatrix6(dataset, "color", 2, dims, &color);
2113 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, color, jni_string, 1);
2117 ret = getHandleIntProperty(uid, __GO_LINE_THICKNESS__, &thickness);
2120 writeIntegerMatrix6(dataset, "thickness", H5T_NATIVE_INT32, "32", 2, dims, &thickness);
2125 ret = getHandleBoolProperty(uid, __GO_UI_FRAME_BORDER_ROUNDED__, &rounded);
2128 writeBooleanMatrix6(dataset, "rounded", 2, dims, &rounded);
2131 closeList6(dataset);
2135 static bool export_handle_border_bevel(int dataset, int uid)
2141 char* data = nullptr;
2145 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TYPE__, &type);
2148 writeIntegerMatrix6(dataset, "type", H5T_NATIVE_INT32, "32", 2, dims, &type);
2152 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, &data);
2155 writeStringMatrix6(dataset, "highlight_out", 2, dims, &data);
2156 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
2160 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, &data);
2163 writeStringMatrix6(dataset, "highlight_in", 2, dims, &data);
2164 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, data, jni_string, 1);
2168 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_OUT__, &data);
2171 writeStringMatrix6(dataset, "shadow_out", 2, dims, &data);
2172 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
2176 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_IN__, &data);
2179 writeStringMatrix6(dataset, "shadow_in", 2, dims, &data);
2180 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_IN__, data, jni_string, 1);
2182 closeList6(dataset);
2186 static bool export_handle_border_soft_bevel(int dataset, int uid)
2188 return export_handle_border_bevel(dataset, uid);
2191 static bool export_handle_border_etched(int dataset, int uid)
2197 char* data = nullptr;
2201 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TYPE__, &type);
2204 writeIntegerMatrix6(dataset, "type", H5T_NATIVE_INT32, "32", 2, dims, &type);
2208 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, &data);
2211 writeStringMatrix6(dataset, "highlight_out", 2, dims, &data);
2212 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, data, jni_string, 1);
2216 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_SHADOW_OUT__, &data);
2219 writeStringMatrix6(dataset, "shadow_out", 2, dims, &data);
2220 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_SHADOW_OUT__, data, jni_string, 1);
2223 closeList6(dataset);
2227 static bool export_handle_border_titled(int dataset, int uid)
2233 char* data = nullptr;
2237 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_TITLE__, &title);
2240 int node = openList6(dataset, "title_border", g_SCILAB_CLASS_HANDLE);
2241 export_handle_border(node, title);
2245 getHandleStringProperty(uid, __GO_TITLE__, &data);
2248 writeStringMatrix6(dataset, "title", 2, dims, &data);
2249 releaseGraphicObjectProperty(__GO_TITLE__, data, jni_string, 1);
2253 int justification = 0;
2254 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_JUSTIFICATION__, &justification);
2257 writeIntegerMatrix6(dataset, "justification", H5T_NATIVE_INT32, "32", 2, dims, &justification);
2261 getHandleStringProperty(uid, __GO_UI_FONTNAME__, &data);
2264 writeStringMatrix6(dataset, "fontname", 2, dims, &data);
2265 releaseGraphicObjectProperty(__GO_UI_FONTNAME__, data, jni_string, 1);
2270 getHandleStringProperty(uid, __GO_UI_FONTANGLE__, &data);
2273 writeStringMatrix6(dataset, "fontangle", 2, dims, &data);
2274 releaseGraphicObjectProperty(__GO_UI_FONTANGLE__, data, jni_string, 1);
2280 ret = getHandleIntProperty(uid, __GO_UI_FONTSIZE__, &fonsize);
2283 writeIntegerMatrix6(dataset, "fontsize", H5T_NATIVE_INT32, "32", 2, dims, &fonsize);
2287 getHandleStringProperty(uid, __GO_UI_FONTWEIGHT__, &data);
2290 writeStringMatrix6(dataset, "fontweight", 2, dims, &data);
2291 releaseGraphicObjectProperty(__GO_UI_FONTWEIGHT__, data, jni_string, 1);
2297 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_POSITION__, &position);
2300 writeIntegerMatrix6(dataset, "position", H5T_NATIVE_INT32, "32", 2, dims, &position);
2304 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &data);
2307 writeStringMatrix6(dataset, "color", 2, dims, &data);
2308 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
2312 closeList6(dataset);
2316 static bool export_handle_border_empty(int dataset, int uid)
2321 double* pos = nullptr;
2324 getHandleDoubleVectorProperty(uid, __GO_POSITION__, &pos);
2327 writeDoubleMatrix6(dataset, "position", 2, dims, pos);
2328 releaseGraphicObjectProperty(__GO_POSITION__, pos, jni_double_vector, 4);
2331 closeList6(dataset);
2335 static bool export_handle_border_compound(int dataset, int uid)
2341 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_OUT_BORDER__, &out_border);
2344 int node = openList6(dataset, "out_border", g_SCILAB_CLASS_HANDLE);
2345 export_handle_border(node, out_border);
2349 getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_IN_BORDER__, &in_border);
2350 node = openList6(dataset, "in_border", g_SCILAB_CLASS_HANDLE);
2351 export_handle_border(node, in_border);
2354 closeList6(dataset);
2358 static bool export_handle_border_matte(int dataset, int uid)
2363 char* data = nullptr;
2364 double* pos = nullptr;
2369 getHandleDoubleVectorProperty(uid, __GO_POSITION__, &pos);
2370 writeDoubleMatrix6(dataset, "position", 2, dims, pos);
2371 releaseGraphicObjectProperty(__GO_POSITION__, pos, jni_double_vector, 4);
2376 getHandleStringProperty(uid, __GO_UI_FRAME_BORDER_COLOR__, &data);
2377 writeStringMatrix6(dataset, "color", 2, dims, &data);
2378 releaseGraphicObjectProperty(__GO_UI_FRAME_BORDER_COLOR__, data, jni_string, 1);
2380 closeList6(dataset);
2384 static bool export_handle_border(int dataset, int uid)
2387 getHandleIntProperty(uid, __GO_UI_FRAME_BORDER_STYLE__, &style);
2392 writeIntegerMatrix6(dataset, "style", H5T_NATIVE_INT32, "32", 2, dims, &style);
2398 return export_handle_border_none(dataset, uid);
2400 return export_handle_border_line(dataset, uid);
2402 return export_handle_border_bevel(dataset, uid);
2404 return export_handle_border_soft_bevel(dataset, uid);
2406 return export_handle_border_etched(dataset, uid);
2408 return export_handle_border_titled(dataset, uid);
2410 return export_handle_border_empty(dataset, uid);
2412 return export_handle_border_compound(dataset, uid);
2414 return export_handle_border_matte(dataset, uid);
2418 static bool export_handle_uicontrol(int parent, int uid)
2421 if (export_handle_generic(parent, uid, UicontrolHandle::getPropertyList()) == false)
2428 getHandleIntProperty(uid, __GO_UI_STRING_SIZE__, &size);
2430 getHandleIntProperty(uid, __GO_UI_STRING_COLNB__, &col);
2439 writeStringMatrix6(parent, "string", 2, dims, &empty);
2444 int row = size / col;
2447 char** string = nullptr;
2448 getHandleStringVectorProperty(uid, __GO_UI_STRING__, &string);
2449 writeStringMatrix6(parent, "string", 2, dims, string);
2450 releaseGraphicObjectProperty(__GO_UI_STRING__, string, jni_string_vector, size);
2455 ret = getHandleIntProperty(uid, __GO_UI_FRAME_BORDER__, &border);
2458 int ub = openList6(parent, "border", g_SCILAB_CLASS_HANDLE);
2459 export_handle_border(ub, border);
2467 static bool export_handle_uicontextmenu(int parent, int uid)
2469 if (export_handle_generic(parent, uid, UicontextmenuHandle::getPropertyList()) == false)
2478 static bool export_handle_uimenu(int parent, int uid)
2480 if (export_handle_generic(parent, uid, UimenuHandle::getPropertyList()) == false)
2489 static bool export_handle_light(int parent, int uid)
2491 if (export_handle_generic(parent, uid, LightHandle::getPropertyList()) == false)
2500 static bool export_handle_axis(int parent, int uid)
2502 if (export_handle_generic(parent, uid, AxisHandle::getPropertyList()) == false)
2511 static bool export_handle_text(int parent, int uid)
2513 if (export_handle_generic(parent, uid, TextHandle::getPropertyList()) == false)
2519 int* dims = nullptr;
2520 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dims);
2522 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
2523 writeStringMatrix6(parent, "text", 2, dims, text);
2528 //find parent axes of a entity and return path ( via children index )
2529 bool get_entity_path(int entity, std::vector<int>& path)
2536 getHandleIntProperty(entity, __GO_PARENT__, &parent);
2538 getHandleIntProperty(parent, __GO_CHILDREN_COUNT__, &count);
2539 //get children of parent to find "my" index
2540 int* children = nullptr;
2541 getHandleIntVectorProperty(parent, __GO_CHILDREN__, &children);
2543 for (int i = 0; i < count; ++i)
2545 if (children[i] == entity)
2553 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
2560 getHandleIntProperty(parent, __GO_TYPE__, &type);
2561 if (type == __GO_AXES__)
2572 static bool export_handle_legend(int parent, int uid)
2574 if (export_handle_generic(parent, uid, LegendHandle::getPropertyList()) == false)
2580 int node = openList6(parent, "links", g_SCILAB_CLASS_HANDLE);
2582 getHandleIntProperty(uid, __GO_LINKS_COUNT__, &link);
2583 int* links = nullptr;
2584 getHandleIntVectorProperty(uid, __GO_LINKS__, &links);
2585 for (int i = 0; i < link; ++i)
2587 std::vector<int> path;
2588 if (get_entity_path(links[i], path))
2592 dims[1] = static_cast<int>(path.size());
2593 writeIntegerMatrix6(node, std::to_string(i).data(), H5T_NATIVE_INT32, "32", 2, dims, path.data());
2597 releaseGraphicObjectProperty(__GO_LINKS__, links, jni_int_vector, link);
2601 int* dims = nullptr;
2602 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dims);
2604 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
2605 writeStringMatrix6(parent, "text", 2, dims, text);
2610 static bool export_handle_fec(int parent, int uid)
2612 if (export_handle_generic(parent, uid, FecHandle::getPropertyList()) == false)
2619 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_INDICES__, &indices);
2621 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_VERTICES_BY_ELEM__, &vect);
2622 double* triangles = nullptr;
2623 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_FEC_ELEMENTS__, &triangles);
2628 writeDoubleMatrix6(parent, "triangles", 2, dims, triangles);
2629 releaseGraphicObjectProperty(__GO_DATA_MODEL_FEC_ELEMENTS__, triangles, jni_double_vector, dims[0] * dims[1]);
2635 static bool export_handle_matplot(int parent, int uid)
2637 if (export_handle_generic(parent, uid, MatplotHandle::getPropertyList()) == false)
2643 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
2645 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
2647 getHandleIntProperty(uid, __GO_DATA_MODEL_MATPLOT_DATA_TYPE__, &datatype);
2649 getHandleIntProperty(uid, __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__, &imagetype);
2650 int size = (row - 1) * (col - 1);
2652 //data can be char, uchar, short, ushort, ... hide in a double*
2653 //save double like this but need to compute exact dimensions to
2656 double* data = nullptr;
2657 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &data);
2662 case MATPLOT_HM1_Char:
2663 case MATPLOT_HM1_UChar:
2664 size /= (sizeof(double) / sizeof(char));
2666 case MATPLOT_HM3_Char:
2667 case MATPLOT_HM3_UChar:
2668 size /= (sizeof(double) / sizeof(char));
2672 case MATPLOT_HM3_Double:
2675 case MATPLOT_HM4_Char:
2676 case MATPLOT_HM4_UChar:
2677 size /= (sizeof(double) / sizeof(char));
2680 case MATPLOT_HM4_Double:
2684 size /= (sizeof(double) / sizeof(char));
2685 if ((ImageType)imagetype == MATPLOT_RGB)
2689 else if ((GLType)imagetype == MATPLOT_GL_RGBA)
2696 size /= (sizeof(double) / sizeof(int));
2699 case MATPLOT_UShort:
2700 size /= (sizeof(double) / sizeof(short));
2702 case MATPLOT_Double:
2703 case MATPLOT_HM1_Double:
2712 writeDoubleMatrix6(parent, "data", 2, dims, data);
2713 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, data, jni_double_vector, size);
2718 static bool export_handle_grayplot(int parent, int uid)
2720 if (export_handle_generic(parent, uid, GrayplotHandle::getPropertyList()) == false)
2726 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
2728 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
2730 double* dataX = nullptr;
2731 double* dataY = nullptr;
2732 double* dataZ = nullptr;
2734 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2735 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2736 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2741 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2745 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2749 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2755 static bool export_handle_segs(int parent, int uid)
2757 if (export_handle_generic(parent, uid, SegsHandle::getPropertyList()) == false)
2766 static bool export_handle_arc(int parent, int uid)
2768 if (export_handle_generic(parent, uid, ArcHandle::getPropertyList()) == false)
2777 static bool export_handle_rectangle(int parent, int uid)
2779 if (export_handle_generic(parent, uid, RectangleHandle::getPropertyList()) == false)
2788 static bool export_handle_datatip(int parent, int uid)
2790 if (export_handle_generic(parent, uid, DatatipHandle::getPropertyList()) == false)
2799 static bool export_handle_polyline_shift(int parent, int uid, const std::string& name, int go_set, int go_data)
2802 getHandleBoolProperty(uid, go_set, &set);
2806 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2807 double* data = nullptr;
2808 getHandleDoubleVectorProperty(uid, go_data, &data);
2813 writeDoubleMatrix6(parent, name.data(), 2, dims, data);
2815 releaseGraphicObjectProperty(uid, data, jni_double_vector, count);
2822 writeDoubleMatrix6(parent, name.data(), 2, dims, NULL);
2828 static bool export_handle_polyline(int parent, int uid)
2830 if (export_handle_datatips(parent, uid) == false)
2835 if (export_handle_generic(parent, uid, PolylineHandle::getPropertyList()) == false)
2841 export_handle_polyline_shift(parent, uid, "x_shift", __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_X_COORDINATES_SHIFT__);
2843 export_handle_polyline_shift(parent, uid, "y_shift", __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Y_COORDINATES_SHIFT__);
2845 export_handle_polyline_shift(parent, uid, "z_shift", __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__, __GO_DATA_MODEL_Z_COORDINATES_SHIFT__);
2847 //interp_color_vector
2849 getHandleBoolProperty(uid, __GO_INTERP_COLOR_VECTOR_SET__, &set);
2853 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2854 int* data = nullptr;
2855 getHandleIntVectorProperty(uid, __GO_INTERP_COLOR_VECTOR__, &data);
2860 writeIntegerMatrix6(parent, "interp_color_vector", H5T_NATIVE_INT32, "32", 2, dims, data);
2861 releaseGraphicObjectProperty(uid, data, jni_int_vector, count);
2868 writeIntegerMatrix6(parent, "interp_color_vector", H5T_NATIVE_INT32, "32", 2, dims, NULL);
2873 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_ELEMENTS__, &count);
2879 double* dataX = nullptr;
2880 double* dataY = nullptr;
2881 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2882 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2884 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2885 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2887 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, count);
2888 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, count);
2890 getHandleIntProperty(uid, __GO_DATA_MODEL_Z_COORDINATES_SET__, &set);
2893 double* dataZ = nullptr;
2894 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2895 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2896 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, count);
2903 writeDoubleMatrix6(parent, "data_z", 2, dims, NULL);
2910 static bool export_handle_surface(int parent, int uid)
2912 return export_handle_generic(parent, uid, SurfaceHandle::getPropertyList());
2915 static bool export_handle_plot3d(int parent, int uid)
2917 bool ret = export_handle_surface(parent, uid);
2920 double* colors = NULL;
2921 double* dataX = NULL;
2922 double* dataY = NULL;
2923 double* dataZ = NULL;
2926 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2927 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2928 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2931 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_X__, &row);
2933 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_Y__, &col);
2935 int* xDims = nullptr;
2936 int* yDims = nullptr;
2937 getHandleIntVectorProperty(uid, __GO_DATA_MODEL_X_DIMENSIONS__, &xDims);
2938 getHandleIntVectorProperty(uid, __GO_DATA_MODEL_Y_DIMENSIONS__, &yDims);
2943 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2944 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, dims[0] * dims[1]);
2948 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2949 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, dims[0] * dims[1]);
2953 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2954 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, dims[0] * dims[1]);
2956 releaseGraphicObjectProperty(__GO_DATA_MODEL_X_DIMENSIONS__, xDims, jni_int_vector, 2);
2957 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y_DIMENSIONS__, dataZ, jni_int_vector, 2);
2964 static bool export_handle_fac3d(int parent, int uid)
2966 bool ret = export_handle_surface(parent, uid);
2969 double* colors = NULL;
2970 double* dataX = NULL;
2971 double* dataY = NULL;
2972 double* dataZ = NULL;
2975 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_X__, &dataX);
2976 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Y__, &dataY);
2977 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_Z__, &dataZ);
2980 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_VERTICES_PER_GON__, &row);
2982 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_GONS__, &col);
2988 writeDoubleMatrix6(parent, "data_x", 2, dims, dataX);
2989 writeDoubleMatrix6(parent, "data_y", 2, dims, dataY);
2990 writeDoubleMatrix6(parent, "data_z", 2, dims, dataZ);
2992 releaseGraphicObjectProperty(__GO_DATA_MODEL_X__, dataX, jni_double_vector, dims[0] * dims[1]);
2993 releaseGraphicObjectProperty(__GO_DATA_MODEL_Y__, dataY, jni_double_vector, dims[0] * dims[1]);
2994 releaseGraphicObjectProperty(__GO_DATA_MODEL_Z__, dataZ, jni_double_vector, dims[0] * dims[1]);
2996 getHandleDoubleVectorProperty(uid, __GO_DATA_MODEL_COLORS__, &colors);
3000 getHandleIntProperty(uid, __GO_DATA_MODEL_NUM_COLORS__, &numColors);
3001 if (numColors == col)
3019 writeDoubleMatrix6(parent, "colors", 2, dims, colors);
3020 releaseGraphicObjectProperty(__GO_DATA_MODEL_COLORS__, colors, jni_double_vector, dims[0] * dims[1]);
3024 getHandleIntProperty(uid, __GO_DATA_MAPPING__, &cdata);
3027 writeIntegerMatrix6(parent, "cdata_mapping", H5T_NATIVE_INT32, "32", 2, dims, &cdata);
3036 static bool export_handle_champ(int parent, int uid)
3038 if (export_handle_generic(parent, uid, ChampHandle::getPropertyList()) == false)
3044 int* dimensions = NULL;
3045 double* arrowBasesX = NULL;
3046 double* arrowBasesY = NULL;
3047 double* arrowDirectionsX = NULL;
3048 double* arrowDirectionsY = NULL;
3050 getHandleIntVectorProperty(uid, __GO_CHAMP_DIMENSIONS__, &dimensions);
3053 getHandleDoubleVectorProperty(uid, __GO_BASE_X__, &arrowBasesX);
3055 dims[1] = dimensions[0];
3056 writeDoubleMatrix(parent, "base_x", 2, dims, arrowBasesX);
3057 releaseGraphicObjectProperty(__GO_BASE_X__, arrowBasesX, jni_double_vector, dims[1]);
3060 getHandleDoubleVectorProperty(uid, __GO_BASE_Y__, &arrowBasesY);
3062 dims[1] = dimensions[1];
3063 writeDoubleMatrix(parent, "base_y", 2, dims, arrowBasesY);
3064 releaseGraphicObjectProperty(__GO_BASE_Y__, arrowBasesY, jni_double_vector, dims[1]);
3067 getHandleDoubleVectorProperty(uid, __GO_DIRECTION_X__, &arrowDirectionsX);
3068 dims[0] = dimensions[0];
3069 dims[1] = dimensions[1];
3070 writeDoubleMatrix(parent, "direction_x", 2, dims, arrowDirectionsX);
3071 releaseGraphicObjectProperty(__GO_DIRECTION_X__, arrowDirectionsX, jni_double_vector, dims[0] * dims[1]);
3074 getHandleDoubleVectorProperty(uid, __GO_DIRECTION_Y__, &arrowDirectionsY);
3075 dims[0] = dimensions[0];
3076 dims[1] = dimensions[1];
3077 writeDoubleMatrix(parent, "direction_y", 2, dims, arrowDirectionsY);
3078 releaseGraphicObjectProperty(__GO_DIRECTION_Y__, arrowDirectionsY, jni_double_vector, dims[0] * dims[1]);
3080 releaseGraphicObjectProperty(__GO_CHAMP_DIMENSIONS__, dimensions, jni_int_vector, 2);
3084 static bool export_handle_label(int parent, int uid)
3086 if (export_handle_generic(parent, uid, LabelHandle::getPropertyList()) == false)
3092 int* dimensions = nullptr;
3093 char** text = nullptr;
3095 getHandleIntVectorProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, &dimensions);
3096 getHandleStringVectorProperty(uid, __GO_TEXT_STRINGS__, &text);
3098 std::vector<int> dims = {dimensions[0], dimensions[1]};
3099 releaseGraphicObjectProperty(__GO_TEXT_ARRAY_DIMENSIONS__, dimensions, jni_int_vector, 2);
3101 writeStringMatrix6(parent, "text", 2, dims.data(), text);
3102 releaseGraphicObjectProperty(__GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
3107 static bool export_handle_axes(int parent, int uid)
3109 if (export_handle_generic(parent, uid, AxesHandle::getPropertyList()) == false)
3116 getHandleIntProperty(uid, __GO_TITLE__, &title);
3117 export_handle(parent, "title", title);
3121 getHandleIntProperty(uid, __GO_X_AXIS_LABEL__, &x_label);
3122 export_handle(parent, "x_label", x_label);
3126 getHandleIntProperty(uid, __GO_Y_AXIS_LABEL__, &y_label);
3127 export_handle(parent, "y_label", y_label);
3131 getHandleIntProperty(uid, __GO_Z_AXIS_LABEL__, &z_label);
3132 export_handle(parent, "z_label", z_label);
3139 static bool export_handle_figure(int parent, int uid)
3141 if (export_handle_generic(parent, uid, FigureHandle::getPropertyList()) == false)
3147 export_handle_layout_options(parent, uid);
3153 static bool export_handle_compound(int parent, int uid)
3155 if (export_handle_generic(parent, uid, CompoundHandle::getPropertyList()) == false)
3164 bool export_handle(int parent, const std::string& name, int uid)
3168 getHandleIntProperty(uid, __GO_TYPE__, &type);
3170 //create handle node in __refs__
3171 int h = openList6(parent, name.data(), g_SCILAB_CLASS_HANDLE);
3178 ret = export_handle_figure(h, uid);
3183 ret = export_handle_axes(h, uid);
3188 ret = export_handle_label(h, uid);
3193 ret = export_handle_champ(h, uid);
3198 ret = export_handle_fac3d(h, uid);
3203 ret = export_handle_plot3d(h, uid);
3206 case __GO_POLYLINE__:
3208 ret = export_handle_polyline(h, uid);
3211 case __GO_DATATIP__:
3213 ret = export_handle_datatip(h, uid);
3216 case __GO_COMPOUND__:
3218 ret = export_handle_compound(h, uid);
3221 case __GO_RECTANGLE__:
3223 ret = export_handle_rectangle(h, uid);
3228 ret = export_handle_arc(h, uid);
3233 ret = export_handle_segs(h, uid);
3236 case __GO_GRAYPLOT__:
3238 ret = export_handle_grayplot(h, uid);
3241 case __GO_MATPLOT__:
3243 ret = export_handle_matplot(h, uid);
3248 ret = export_handle_fec(h, uid);
3253 ret = export_handle_legend(h, uid);
3258 ret = export_handle_text(h, uid);
3263 ret = export_handle_axis(h, uid);
3268 ret = export_handle_light(h, uid);
3273 ret = export_handle_uimenu(h, uid);
3276 case __GO_UICONTEXTMENU__:
3278 ret = export_handle_uicontextmenu(h, uid);
3281 case __GO_UICONTROL__:
3283 ret = export_handle_uicontrol(h, uid);
3295 static bool export_handle_children(int parent, int uid)
3298 getHandleIntProperty(uid, __GO_CHILDREN_COUNT__, &count);
3299 int node = openList6(parent, "children", g_SCILAB_CLASS_HANDLE);
3300 int* children = nullptr;
3304 getHandleIntVectorProperty(uid, __GO_CHILDREN__, &children);
3308 for (int i = 0; i < count; ++i)
3310 int child = children[i];
3312 getHandleBoolProperty(child, __GO_HIDDEN__, &hidden);
3315 if (export_handle(node, std::to_string(index), child) == false)
3317 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
3326 releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, count);
3331 int add_current_entity(int dataset)
3334 getHandleInt(dataset, "type", &type);
3339 return import_handle(dataset, -1);
3343 //add handle to current figure
3344 getOrCreateDefaultSubwin();
3345 int iCurrentFigure = getCurrentFigure();
3346 return import_handle(dataset, iCurrentFigure);
3350 //add handle as child of current axes ( take care of compound ! )