/*------------------------------------------------------------------------*/ int set_current_entity_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { char* curEntity = NULL ; if (pobjUID != NULL) { /* This property should not be called on an handle */ Scierror(999, _("'%s' property does not exist for this handle.\n"), "current_entity"); return -1; } if ( !( valueType == sci_handles ) ) { Scierror(999, _("Wrong type for '%s' property: Handle expected.\n"), "current_entity"); return SET_PROPERTY_ERROR ; } curEntity = (char*)getObjectFromHandle( getHandleFromStack( stackPointer ) ) ; if ( curEntity == NULL ) { Scierror(999, _("Wrong value for '%s' property: Must be a valid handle.\n"), "current_entity"); return SET_PROPERTY_ERROR ; } setCurrentObject(curEntity) ; return SET_PROPERTY_SUCCEED ; }
/*------------------------------------------------------------------------*/ int set_current_axes_property(char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { char * curAxesUID = NULL; char * parentFigureUID = NULL; char * type; if (pobjUID != NULL) { /* This property should not be called on a handle */ Scierror(999, _("'%s' property does not exist for this handle.\n"), "current_axes"); return SET_PROPERTY_ERROR; } if ( !isParameterHandle( valueType ) ) { Scierror(999, _("Wrong type for '%s' property: Handle expected.\n"), "current_axes"); return SET_PROPERTY_ERROR; } curAxesUID = getObjectFromHandle( getHandleFromStack( stackPointer ) ); if ( curAxesUID == NULL) { Scierror(999, _("Wrong value for '%s' property: Must be a valid handle.\n"), "current_entity"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(curAxesUID, __GO_TYPE__, jni_string, &type); if (strcmp(type, __GO_AXES__) != 0) { Scierror(999, _("Wrong value for '%s' property: Must be a handle on a axes.\n"), "current_axes"); return SET_PROPERTY_ERROR; } /* The current Axes' parent Figure's selected child property must be updated */ getGraphicObjectProperty(curAxesUID, __GO_PARENT__, jni_string, &parentFigureUID); setGraphicObjectProperty(parentFigureUID, __GO_SELECTED_CHILD__, curAxesUID, jni_string, 1); setCurrentSubWin(curAxesUID); /* F.Leray 11.02.05 : if the new selected subwin is not inside the current figure, */ /* we must also set the current figure to the subwin's parent */ if (!isCurrentFigure(parentFigureUID)) { setCurrentFigure(parentFigureUID); } return SET_PROPERTY_SUCCEED; }
/*--------------------------------------------------------------------------*/ int sci_is_handle_valid(char *fname, unsigned long fname_len) { /* Call isValid = is_handle_valid(h) with h a matrix of handle */ /* and isValid a matrix of boolean */ int nbCol = 0; int nbRow = 0; int nbHandle = 0; int handleStackPointer = 0; int resultStackPointer = 0; int i = 0; CheckRhs(1, 1); CheckLhs(0, 1); /* Get handles matrix */ if (VarType(1) != sci_handles) { Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of handle expected.\n"), fname, 1); return -1; } GetRhsVar(1, (char *)GRAPHICAL_HANDLE_DATATYPE, &nbRow, &nbCol, &handleStackPointer); nbHandle = nbRow * nbCol; /* create output matrix */ CreateVar(Rhs + 1, (char *)MATRIX_OF_BOOLEAN_DATATYPE, &nbRow, &nbCol, &resultStackPointer); /* Check each handle */ for (i = 0; i < nbHandle; i++) { *istk(resultStackPointer + i) = ((getObjectFromHandle((long)getHandleFromStack((size_t)(handleStackPointer + i))) != NULL) ? TRUE : FALSE); } LhsVar(1) = Rhs + 1; PutLhsVar(); return 0; }
/*------------------------------------------------------------------------*/ int set_links_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { BOOL status = FALSE; int type = -1; int *piType = &type; char* parentAxes = NULL; char** links = NULL; int i = 0; int iLinksCount = 0; int* piLinksCount = &iLinksCount; if ( !( valueType == sci_handles ) ) { Scierror(999, _("Wrong type for '%s' property: Graphic handle array expected.\n"), "links"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(pobjUID, __GO_LINKS_COUNT__, jni_int, (void**)&piLinksCount); if (piLinksCount == NULL) { Scierror(999, _("'%s' property does not exist for this handle.\n"), "links"); return SET_PROPERTY_ERROR; } if (nbRow*nbCol != iLinksCount) { Scierror(999, _("Wrong size for '%s' property: %d elements expected.\n"), "links", iLinksCount); return SET_PROPERTY_ERROR; } links = (char**) MALLOC(iLinksCount * sizeof(char*)); if (links == NULL) { Scierror(999, _("%s: No more memory.\n"), "set_z_ticks_property"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(pobjUID, __GO_PARENT_AXES__, jni_string, (void **)&parentAxes); status = TRUE; for (i = 0 ; i < iLinksCount ; i++) { char* polylineParentAxes; char* polylineObjectUID = (char*)getObjectFromHandle( getHandleFromStack( stackPointer + i ) ); getGraphicObjectProperty(polylineObjectUID, __GO_TYPE__, jni_int, (void **)&piType); if (type != __GO_POLYLINE__) { Scierror(999, _("%s: Input argument #%d must be a '%s' handle.\n"), "links", i, "polyline"); status = FALSE; break; } links[i] = polylineObjectUID; getGraphicObjectProperty(polylineObjectUID, __GO_PARENT_AXES__, jni_string, (void **)&polylineParentAxes); if (strcmp(polylineParentAxes, parentAxes) != 0) { Scierror(999, _("%s: Input argument and the legend must have the same parent axes.\n"), "links"); status = FALSE; break; } } if (status == FALSE) { FREE(links); return SET_PROPERTY_ERROR; } status = setGraphicObjectProperty(pobjUID, __GO_LINKS__, links, jni_string_vector, iLinksCount); FREE(links); if (status == TRUE) { return SET_PROPERTY_SUCCEED; } else { Scierror(999, _("'%s' property does not exist for this handle.\n"), "links"); return SET_PROPERTY_ERROR; } }
/*--------------------------------------------------------------------------*/ int sci_unzoom(char *fname,unsigned long fname_len) { /* number of object to unzoom */ int nbObjects = 0; /* ids of object to unzoom */ char** objectsId = NULL; char* objectUID = NULL; /* object type */ int iType = -1; int *piType = &iType; CheckRhs(0,1) ; CheckLhs(0,1) ; if ( Rhs == 0 ) { objectUID = (char*)getCurrentFigure(); if (objectUID != NULL) { sciUnzoomFigure(objectUID); } } else { int m = 0,n = 0,i = 0; size_t stackPointer = 0; GetRhsVar(1, GRAPHICAL_HANDLE_DATATYPE, &m, &n, &stackPointer); nbObjects = m * n; objectsId = MALLOC(nbObjects * sizeof(char*)); if (objectsId == NULL) { Scierror(999, _("%s: No more memory.\n"),fname); return -1; } /* first pass, check that all the handles are subwindows or figures */ /* and copy them into an array of objects */ for (i = 0; i < nbObjects; i++ ) { objectUID = (char*)getObjectFromHandle(getHandleFromStack(stackPointer + i)); getGraphicObjectProperty(objectUID, __GO_TYPE__, jni_int, (void **) &piType); if (iType != __GO_FIGURE__ && iType != __GO_AXES__) { FREE(objectsId); Scierror(999, _("%s: Wrong type for input argument: Vector of Axes and Figure handles expected.\n"),fname); return -1; } objectsId[i] = objectUID; } /* second pass un zoom the objects */ sciUnzoomArray(objectsId, nbObjects); FREE(objectsId); } LhsVar(1)=0; PutLhsVar(); return 0; }