/*------------------------------------------------------------------------*/ int set_title_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { int iType = -1; int *piType = &iType; getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piType); if (iType == __GO_AXES__) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "title"); return SET_PROPERTY_ERROR; } Scierror(999, _("Can not set directly a label object.\n")); return SET_PROPERTY_ERROR; }
void ScilabView::createObject(char const* pstId) { //std::cerr << "[ScilabView] ++ createObject UID=" << pstId << std::endl; int iType = -1; int *piType = &iType; getGraphicObjectProperty(pstId, __GO_TYPE__, jni_int, (void **)&piType); if (iType != -1 && iType == __GO_FIGURE__) { m_figureList[pstId] = -1; setCurrentFigure(pstId); } // Register object handle. getObjectHandle(pstId); }
/*------------------------------------------------------------------------*/ void* get_background_property(void* _pvCtx, int iObjUID) { int iBackground = 0; int *piBackground = &iBackground; getGraphicObjectProperty(iObjUID, __GO_BACKGROUND__, jni_int, (void **)&piBackground); if (piBackground == NULL) { /* This object has not a background color */ Scierror(999, _("'%s' property does not exist for this handle.\n"), "background"); return NULL; } return sciReturnDouble(iBackground); }
/*------------------------------------------------------------------------*/ int set_tics_labels_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { BOOL status = FALSE; int iNbTicksLabels = 0; int* piNbTicksLabels = &iNbTicksLabels; char** stringVector = NULL; if (valueType != sci_strings) { Scierror(999, _("Wrong type for '%s' property: String matrix expected.\n"), "tics_labels"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(iObjUID, __GO_NUMBER_TICKS_LABELS__, jni_int, (void**)&piNbTicksLabels); if (piNbTicksLabels == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "tics_labels"); return SET_PROPERTY_ERROR; } if (iNbTicksLabels > nbRow * nbCol) { Scierror(999, _("Wrong size for '%s' property: At least %d elements expected.\n"), "tics_labels", iNbTicksLabels); return SET_PROPERTY_ERROR; } stringVector = createCopyStringMatrixFromStack(_pvData, nbRow * nbCol); /* Check if we should load LaTex / MathML Java libraries */ loadTextRenderingAPI(stringVector, nbRow * nbCol, 1); status = setGraphicObjectProperty(iObjUID, __GO_TICKS_LABELS__, stringVector, jni_string_vector, nbRow * nbCol); destroyStringArray(stringVector, nbRow * nbCol); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "tics_labels"); return SET_PROPERTY_ERROR; } }
/*------------------------------------------------------------------------*/ void* get_figure_size_property(void* _pvCtx, int iObjUID) { double figureSize[2]; int* intSize = NULL; getGraphicObjectProperty(iObjUID, __GO_SIZE__, jni_int_vector, (void **)&intSize); if (intSize == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "figure_size"); return NULL; } figureSize[0] = (double)intSize[0]; figureSize[1] = (double)intSize[1]; return sciReturnRowVector(figureSize, 2); }
/** * Old z_componet property, warns the user */ void* get_tip_z_component_property(void* _pvCtx, int iObjUID) { char * tip_display_components; getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_COMPONENTS__, jni_string, (void **)&tip_display_components); //Only warns if the property exists for the object. if (tip_display_components == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "z_component"); } else { Scierror(999, _("'%s' property is obsolete and will be removed, use '%s' instead.\n"), "z_component", "display_components"); } return NULL; }
int GetUicontrolMax(void* _pvCtx, char *sciObjUID) { double maxValue = 0; double* pdblMaxValue = &maxValue; getGraphicObjectProperty(sciObjUID, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue); if (pdblMaxValue == NULL) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Max"); return FALSE; } else { return sciReturnDouble(_pvCtx, maxValue); } }
void* GetUicontrolMin(void* _pvCtx, int iObjUID) { double minValue = 0; double* pdblMinValue = &minValue; getGraphicObjectProperty(iObjUID, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue); if (pdblMinValue == NULL) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Min"); return NULL; } else { return sciReturnDouble(minValue); } }
int NgonGridGrayplotDataDecomposer::fillIndices(char* id, int* buffer, int bufferLength, int logMask) { double* x = NULL; double* y = NULL; double* z = NULL; double zShift = 0.0; double* pdZShift = &zShift; int numX = 0; int* piNumX = &numX; int numY = 0; int* piNumY = &numY; int dataMapping = 0; int* piDataMapping = &dataMapping; int perNodeValues = 1; int numberIndices = 0; NgonGridGrayplotDataDecomposer* decomposer = get(); getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_X__, jni_int, (void**) &piNumX); getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_Y__, jni_int, (void**) &piNumY); /* 0 indices if 0 points */ if (numX == 0 || numY == 0) { return 0; } getGraphicObjectProperty(id, __GO_DATA_MAPPING__, jni_int, (void**) &piDataMapping); getGraphicObjectProperty(id, __GO_DATA_MODEL_X__, jni_double_vector, (void**) &x); getGraphicObjectProperty(id, __GO_DATA_MODEL_Y__, jni_double_vector, (void**) &y); getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &z); getGraphicObjectProperty(id, __GO_DATA_MODEL_Z_COORDINATES_SHIFT__, jni_double, (void**) &pdZShift); /* * Data mapping values 0 and 1 respectively correspond to scaled and direct colors, for which per-node * and per-facet values are respectively used. */ perNodeValues = !dataMapping; numberIndices = decomposer->fillTriangleIndices(buffer, bufferLength, logMask, x, y, &zShift, z, perNodeValues, numX, numY); return numberIndices; }
void ScilabView::updateObject(char const* pstId, int iProperty) { //std::cerr << "[ScilabView] == updateObject UID=" << pstId << " PROPERTY=" << pstProperty << std::endl; /* ** Take care of update if the value update is ID and object type is a Figure I manage. */ if (iProperty == __GO_ID__ && m_figureList.find(pstId) != m_figureList.end()) { int iNewId = 0; int *piNewId = &iNewId; getGraphicObjectProperty(pstId, __GO_ID__, jni_int, (void **)&piNewId); m_figureList[pstId] = iNewId; //std::cerr << "### [ScilabView] updateMap UID=" << pstId << " id=" << iNewId << std::endl; } }
/*------------------------------------------------------------------------*/ int get_figure_position_property(char *pobjUID) { double figurePos[2] ; int* position; getGraphicObjectProperty(pobjUID, __GO_POSITION__, jni_int_vector, &position); if (position == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"),"figure_position") ; return -1; } figurePos[0] = (double) position[0] ; figurePos[1] = (double) position[1] ; return sciReturnRowVector( figurePos, 2 ) ; }
/** * Convert pixel coordinates to 2D view coordinate * @param pObjUID subwindow identifier * @param userCoord pixel coordinates * @param userCoords2D user coordinates in default 2D plane */ void sciGet2dViewCoordFromPixel(char * pObjUID, const int pixelCoords[2], double userCoords2D[2]) { int iType = -1; int *piType = &iType; getGraphicObjectProperty(pObjUID, __GO_TYPE__, jni_int, (void **)&piType); if (iType == __GO_AXES__) { sciGetJava2dViewCoordFromPixel(pObjUID, pixelCoords, userCoords2D); } else { Scierror(999, _("Coordinates modifications are only applicable on axes objects.\n")); userCoords2D[0] = 0.0; userCoords2D[1] = 0.0; } }
int GetUicontrolStyle(void* _pvCtx, char *sciObjUID) { int iStyle = -1; int *piStyle = &iStyle; getGraphicObjectProperty(sciObjUID, __GO_STYLE__, jni_int, (void **) &piStyle); if (piStyle != NULL) { return sciReturnString(_pvCtx, IntToStyle(iStyle)); } else { Scierror(999, const_cast<char*>(_("No '%s' property for this object.\n")), "Style"); return FALSE; } }
/*------------------------------------------------------------------------*/ int get_y_location_property(char *pobjUID) { int iLocation = 0; int* piLocation = &iLocation; #if 0 if (sciGetEntityType (pobj) != SCI_SUBWIN) { Scierror(999, _("'%s' property does not exist for this handle.\n"),"y_location"); return -1; } #endif getGraphicObjectProperty(pobjUID, __GO_Y_AXIS_LOCATION__, jni_int, &piLocation); if (piLocation == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"),"y_location"); return -1; } if (iLocation == 4) { return sciReturnString( "left" ); } else if (iLocation == 5) { return sciReturnString( "right" ); } else if (iLocation == 2) { return sciReturnString( "middle" ); } else if (iLocation == 3) { return sciReturnString( "origin" ); } else { Scierror(999, _("Wrong value for '%s' property.\n"),"y_location"); return -1; } }
/*------------------------------------------------------------------------*/ int get_image_type_property(void* _pvCtx, char* pobjUID) { int imagetype = 0; int * piImagetype = &imagetype; ImageType itype = (ImageType)imagetype; getGraphicObjectProperty(pobjUID, __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__, jni_int, (void **)&piImagetype); if (piImagetype == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "image_type"); return -1; } switch (itype) { case MATPLOT_RGB : return sciReturnString(_pvCtx, "rgb"); case MATPLOT_RGBA : return sciReturnString(_pvCtx, "rgba"); case MATPLOT_GRAY : return sciReturnString(_pvCtx, "gray"); case MATPLOT_INDEX : return sciReturnString(_pvCtx, "index"); case MATPLOT_RED : return sciReturnString(_pvCtx, "red"); case MATPLOT_GREEN : return sciReturnString(_pvCtx, "green"); case MATPLOT_BLUE : return sciReturnString(_pvCtx, "blue"); case MATPLOT_RGB_332 : return sciReturnString(_pvCtx, "rgb332"); case MATPLOT_RGB_444 : return sciReturnString(_pvCtx, "rgb444"); case MATPLOT_RGBA_4444 : return sciReturnString(_pvCtx, "rgba444"); case MATPLOT_RGB_555 : return sciReturnString(_pvCtx, "rgb555"); case MATPLOT_RGBA_5551 : return sciReturnString(_pvCtx, "rgba5551"); default : Scierror(999, _("Wrong value for '%s' property.\n"), "image_type"); return -1; } }
/* return TRUE if the window has been redrawn */ BOOL checkRedrawing(void) { int iAutoClear = 0; int* piAutoClear = &iAutoClear; // nbCheckRedraw++; // fprintf(stderr, "[DEBUG] checkRedrawing : %d\n", nbCheckRedraw); int iSubWinID = getCurrentSubWin(); getGraphicObjectProperty(iSubWinID, __GO_AUTO_CLEAR__, jni_bool, (void **)&piAutoClear); if (iAutoClear) { reinitSubWin(iSubWinID); return TRUE; } return FALSE; }
int GetUicontrolBackgroundColor(void* _pvCtx, char *sciObjUID) { double *tmp = NULL; int status = 0; getGraphicObjectProperty(sciObjUID, __GO_UI_BACKGROUNDCOLOR__, jni_double_vector, (void **) &tmp); if (tmp == NULL) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "BackgroundColor"); return FALSE; } else { status = sciReturnRowVector(_pvCtx, tmp, 3); delete[] tmp; return status; } }
int GetUicontrolPosition(void* _pvCtx, char *sciObjUID) { double* position = NULL; int status = FALSE; getGraphicObjectProperty(sciObjUID, __GO_POSITION__, jni_double_vector, (void**) &position); if (position == NULL) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "Position"); return FALSE; } else { status = sciReturnRowVector(_pvCtx, position, 4); delete[] position; return status; } }
int GetUiobjectForegroundColor(char* sciObjUID) { double *tmp; int status = 0; getGraphicObjectProperty(sciObjUID, const_cast<char*>(__GO_UI_FOREGROUNDCOLOR__), jni_double_vector, (void **) &tmp); if (tmp == NULL) { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "ForegroundColor"); return FALSE; } else { status = sciReturnRowVector(tmp, 3); delete[] tmp; return status; } }
/*------------------------------------------------------------------------*/ void* get_zoom_state_property(void* _pvCtx, int iObjUID) { int iZoomState = 0; int *piZoomState = &iZoomState; getGraphicObjectProperty(iObjUID, __GO_ZOOM_ENABLED__, jni_bool, (void **)&piZoomState); if (piZoomState == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "zoom_state"); return NULL; } if (iZoomState) { return sciReturnString("on"); } return sciReturnString("off"); }
void* GetUicontrolSliderStep(void* _pvCtx, int iObjUID) { double *sliderStep = NULL; void* status = NULL; getGraphicObjectProperty(iObjUID, __GO_UI_SLIDERSTEP__, jni_double_vector, (void**) &sliderStep); if (sliderStep != NULL) { status = sciReturnRowVector(sliderStep, 2); delete[] sliderStep; return status; } else { Scierror(999, const_cast<char*>(_("'%s' property does not exist for this handle.\n")), "SliderStep"); return NULL; } }
/*------------------------------------------------------------------------*/ int get_tag_property(void* _pvCtx, char* pobjUID) { char* tag = NULL; int status = 0; getGraphicObjectProperty(pobjUID, __GO_TAG__, jni_string, (void**) &tag); if (tag == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "Tag"); return FALSE; } else { status = sciReturnString(_pvCtx, tag); free(tag); return status; } }
/* Get the label of an uimenu */ void* GetUimenuLabel(void* _pvCtx, int iOobjUID) { char *label = NULL; void* status = NULL; getGraphicObjectProperty(iOobjUID, __GO_UI_LABEL__, jni_string, (void **)&label); if (label == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "Label"); return NULL; } else { status = sciReturnString(label); free(label); return status; } }
/* * To do: compute and return color indices instead of directly looking * up colors from the colormap. */ void Plot3DDecomposer::fillColors(char* id, float* buffer, int bufferLength, int elementsSize) { char* parentFigure = NULL; char* parent = NULL; double* z = NULL; double* colormap = NULL; int numX = 0; int* piNumX = &numX; int numY = 0; int* piNumY = &numY; int colormapSize = 0; int* piColormapSize = &colormapSize; Plot3DDecomposer* decomposer = get(); getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_X__, jni_int, (void**) &piNumX); getGraphicObjectProperty(id, __GO_DATA_MODEL_NUM_Y__, jni_int, (void**) &piNumY); getGraphicObjectProperty(id, __GO_DATA_MODEL_Z__, jni_double_vector, (void**) &z); getGraphicObjectProperty(id, __GO_PARENT__, jni_string, (void**) &parent); /* Temporary: to avoid getting a null parent_figure property when the object is built */ if (strcmp(parent, "") == 0) { return; } getGraphicObjectProperty(id, __GO_PARENT_FIGURE__, jni_string, (void**) &parentFigure); if (parentFigure == NULL) { return; } getGraphicObjectProperty(parentFigure, __GO_COLORMAP__, jni_double_vector, (void**) &colormap); getGraphicObjectProperty(parentFigure, __GO_COLORMAP_SIZE__, jni_int, (void**) &piColormapSize); decomposer->fillNormalizedZGridColors(buffer, bufferLength, elementsSize, colormap, colormapSize, z, numX, numY); releaseGraphicObjectProperty(__GO_COLORMAP__, colormap, jni_double_vector, colormapSize); }
/*------------------------------------------------------------------------*/ int set_interp_color_mode_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { BOOL status = FALSE; int b = (int)FALSE; int iInterpColorVectorSet = 0; int* piInterpColorVectorSet = &iInterpColorVectorSet; b = tryGetBooleanValueFromStack(_pvData, valueType, nbRow, nbCol, "interp_color_mode"); if (b == NOT_A_BOOLEAN_VALUE) { return SET_PROPERTY_ERROR; } if (b == TRUE) { getGraphicObjectProperty(iObjUID, __GO_INTERP_COLOR_VECTOR_SET__, jni_bool, (void **)&piInterpColorVectorSet); if (piInterpColorVectorSet == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "interp_color_mode"); return SET_PROPERTY_ERROR; } if (iInterpColorVectorSet == FALSE) { Scierror(999, _("You must first specify an %s for this object.\n"), "interp_color_vector"); return SET_PROPERTY_ERROR; } } status = setGraphicObjectProperty(iObjUID, __GO_INTERP_COLOR_MODE__, &b, jni_bool, 1); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "interp_color_mode"); return SET_PROPERTY_ERROR; } }
void fillTextureCoordinates(int id, float* BUFF, int bufferLength) { int iType = 0; int *piType = &iType; getGraphicObjectProperty(id, __GO_TYPE__, jni_int, (void**) &piType); switch (iType) { case __GO_FAC3D__ : Fac3DDecomposer::fillTextureCoordinates(id, BUFF, bufferLength); break; case __GO_FEC__ : MeshFecDataDecomposer::fillTextureCoordinates(id, BUFF, bufferLength); break; case __GO_POLYLINE__ : PolylineDecomposer::fillTextureCoordinates(id, BUFF, bufferLength); break; } }
/** * Convert 2d view coordinates to pixel coordinates * @param pObjUID subwindow identifier * @param userCoords2D coordinates in the default 2D plane * @param pixelsCoords pixel coordinates */ void sciGet2dViewPixelCoordinates(char * pObjUID, const double userCoords2D[2], int pixelCoords[2]) { int iType = -1; char *piType = (char *)&iType; getGraphicObjectProperty(pObjUID, __GO_TYPE__, jni_int, (void **)&piType); if (iType == __GO_AXES__) { /* create a 3d user coord */ double userCoord3D[3] = {userCoords2D[0], userCoords2D[1], 0.0}; sciGetJava2dViewPixelCoordinates(pObjUID, userCoord3D, pixelCoords); } else { Scierror(999, _("Coordinates modifications are only applicable on axes objects.\n")); pixelCoords[0] = -1; pixelCoords[1] = -1; } }
/** * Get the viewing area of a subwindow acoording to its axes scale and margins * result is in pixels */ void sciGetViewingArea(char * pObjUID, int * xPos, int * yPos, int * width, int * height) { int iType = -1; int *piType = &iType; getGraphicObjectProperty(pObjUID, __GO_TYPE__, jni_int, (void **)&piType); if (iType == __GO_AXES__) { sciGetJavaViewingArea(pObjUID, xPos, yPos, width, height); } else { *xPos = -1; *yPos = -1; *width = -1; *height = -1; Scierror(999, _("Only axes handles have a viewing area.")); } }
/*------------------------------------------------------------------------*/ int get_font_foreground_property(char *pobjUID) { int iFontColor = 0; int* fontColor = &iFontColor; getGraphicObjectProperty(pobjUID, __GO_FONT_COLOR__, jni_int, &fontColor); if (fontColor == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"),"font_foreground"); return -1; } return sciReturnInt(*fontColor); /* To be implemented later since it involves color range checks */ #if 0 return sciReturnInt( sciGetFontForegroundToDisplay( pobj ) ); #endif }
/*------------------------------------------------------------------------*/ int set_format_n_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { BOOL status = FALSE; char* format = NULL; char * oldFormat = NULL; StringMatrix * labels = NULL; if (valueType != sci_strings) { Scierror(999, _("Wrong type for '%s' property: String expected.\n"), "format_n"); return SET_PROPERTY_ERROR; } format = (char*)_pvData; getGraphicObjectProperty(iObjUID, __GO_FORMATN__, jni_string, (void **)&oldFormat); if (strcmp(format, oldFormat) == 0) { return SET_PROPERTY_SUCCEED; } status = setGraphicObjectProperty(iObjUID, __GO_FORMATN__, format, jni_string, 1); if (status == TRUE) { labels = computeDefaultTicsLabels(iObjUID); if (labels != NULL) { char ** data = getStrMatData(labels); setGraphicObjectProperty(iObjUID, __GO_TICKS_LABELS__, data, jni_string_vector, labels->nbCol * labels->nbRow); deleteMatrix(labels); } return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "format_n"); return SET_PROPERTY_ERROR; } }