/*--------------------------------------------------------------------------*/ int sci_exportUI(char * fname, unsigned long fname_len) { int iFigureId = 0; // id of the figure to export int iRows = 0; int iCols = 0; size_t stackPointer = 0; CheckLhs(0, 1); CheckRhs(1, 1); if (GetType(1) == sci_handles) // exportUI(figHandle) { const char *pstFigureUID = NULL; int iHandleType = -1; int *piHandleType = &iHandleType; int *piFigureId = &iFigureId; GetRhsVar(1, GRAPHICAL_HANDLE_DATATYPE, &iRows, &iCols, &stackPointer); if (iRows * iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); } pstFigureUID = getObjectFromHandle((unsigned long) * (hstk(stackPointer))); getGraphicObjectProperty(pstFigureUID, __GO_TYPE__, jni_int, (void **)&piHandleType); if (iHandleType == __GO_FIGURE__) { Scierror(999, _("%s: Wrong type for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } getGraphicObjectProperty(pstFigureUID, __GO_ID__, jni_int, (void **)&piFigureId); } else if (GetType(1) == sci_matrix) // exportUI(figId) { GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &iRows, &iCols, &stackPointer); if (iRows * iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } iFigureId = (int) * (stk(stackPointer)); } else { Scierror(999, _("%s: Wrong type for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } // call the export function exportUserInterface(iFigureId); LhsVar(1) = 0; PutLhsVar(); return 0; }
/*--------------------------------------------------------------------------*/ int sci_exportUI(char * fname, unsigned long fname_len) { SciErr sciErr; int* piAddrstackPointer = NULL; int iFigureId = 0; // id of the figure to export int *piFigureId = &iFigureId; int iRows = 0; int iCols = 0; int iHandleType = -1; int *piHandleType = &iHandleType; CheckOutputArgument(pvApiCtx, 0, 1); CheckInputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrstackPointer); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (checkInputArgumentType(pvApiCtx, 1, sci_handles)) // exportUI(figHandle) { char *pstFigureUID = NULL; char *pstHandleType = NULL; long long* stackPointer = NULL; // Retrieve a matrix of handle at position 1. sciErr = getMatrixOfHandle(pvApiCtx, piAddrstackPointer, &iRows, &iCols, &stackPointer); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: Handle matrix expected.\n"), fname, 1); return 1; } if (iRows * iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); } pstFigureUID = getObjectFromHandle((unsigned long) * stackPointer); getGraphicObjectProperty(pstFigureUID, __GO_TYPE__, jni_int, (void **)&piHandleType); if (iHandleType == __GO_FIGURE__) { Scierror(999, _("%s: Wrong type for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } getGraphicObjectProperty(pstFigureUID, __GO_ID__, jni_int, (void **)&piFigureId); } else if (checkInputArgumentType(pvApiCtx, 1, sci_matrix)) // exportUI(figId) { double* stackPointer = NULL; // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddrstackPointer, &iRows, &iCols, &stackPointer); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1); return 1; } if (iRows * iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } iFigureId = (int) * stackPointer; } else { Scierror(999, _("%s: Wrong type for input argument #%d: A Real Scalar or a 'Figure' handle expected.\n"), fname, 1); return FALSE; } // call the export function exportUserInterface(iFigureId); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }