/*--------------------------------------------------------------------------*/ int sci_xtitle(char * fname, unsigned long fname_len) { SciErr sciErr; int* piAddr4 = NULL; int* boxPtr = NULL; int* piAddrStr = NULL; int narg = 0; int nbLabels = 0; /* number of modified labels */ int box = 0; BOOL isBoxSpecified = FALSE; int iSubwinUID = 0; static rhs_opts opts[] = { { -1, "boxed", -1, 0, 0, NULL}, { -1, NULL, -1, 0, 0, NULL} }; if (nbInputArgument(pvApiCtx) <= 0) { sci_demo(fname, fname_len); return 0; } CheckInputArgument(pvApiCtx, 1, 5); nbLabels = nbInputArgument(pvApiCtx); /* get the given options from the name in opts */ if (!getOptionals(pvApiCtx, fname, opts)) { /* error */ return 0; } /* compatibility with previous version in which box was put */ /* at the fourth position */ if (nbInputArgument(pvApiCtx) == 4) { int type = getInputArgumentType(pvApiCtx, 4); if (type == 1 || type == 8)/* double or int */ { int n = 0, m = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 4. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr4, &m, &n, &boxPtr); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 4); return 1; } //CheckScalar if (m != 1 || n != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, 4); return 1; } box = *boxPtr; nbLabels--; /* it is not a label text */ isBoxSpecified = TRUE; } } if (opts[0].iPos != -1 && !isBoxSpecified) { /* check if "box" is in the options */ getScalarBoolean(pvApiCtx, opts[0].piAddr, &box); if (opts[0].iRows != 1 || opts[0].iCols != 1) { /* check size */ Scierror(999, _("%s: Wrong type for input argument: Scalar expected.\n"), fname); return 1; } nbLabels--; /* it is not a label text */ } iSubwinUID = getOrCreateDefaultSubwin(); for (narg = 1 ; narg <= nbLabels ; narg++) { int m = 0, n = 0; char **Str = NULL; int iModifiedLabel = 0; int* piModifiedLabel = &iModifiedLabel; sciErr = getVarAddressFromPosition(pvApiCtx, narg, &piAddrStr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of string at position narg. if (getAllocatedMatrixOfString(pvApiCtx, piAddrStr, &m, &n, &Str)) { Scierror(202, _("%s: Wrong type for argument #%d: String matrix expected.\n"), fname, narg); return 1; } if (m * n == 0) { continue; } switch (narg) { case 1: getGraphicObjectProperty(iSubwinUID, __GO_TITLE__, jni_int, (void **)&piModifiedLabel); break; case 2: getGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_LABEL__, jni_int, (void **)&piModifiedLabel); break; case 3: getGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_LABEL__, jni_int, (void **)&piModifiedLabel); break; case 4: getGraphicObjectProperty(iSubwinUID, __GO_Z_AXIS_LABEL__, jni_int, (void **)&piModifiedLabel); break; default: break; } #if 0 startFigureDataWriting(pFigure); #endif sciSetText(iModifiedLabel, Str, m, n); setGraphicObjectProperty(iModifiedLabel, __GO_FILL_MODE__, &box, jni_bool, 1); #if 0 endFigureDataWriting(pFigure); #endif freeArrayOfString(Str, m * n); } setCurrentObject(iSubwinUID); #if 0 sciDrawObj(pFigure); #endif AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_xtitle( char * fname, unsigned long fname_len ) { int narg; int nbLabels; /* number of modified labels */ int box = 0; BOOL isBoxSpecified = FALSE; char * psubwinUID = NULL; static rhs_opts opts[] = { {-1,"boxed","i" ,0,0,0}, {-1,NULL ,NULL,0,0,0} }; if (Rhs <= 0) { sci_demo(fname, fname_len); return 0; } CheckRhs(1,5); nbLabels = Rhs; /* get the given options from the name in opts */ if ( !get_optionals(fname,opts) ) { /* error */ return 0; } /* compatibility with previous version in which box was put */ /* at the fourth position */ if ( Rhs == 4 ) { int type = GetType(4); if ( type == 1 || type == 8 )/* double or int */ { int n,m; int boxPtr = -1 ; /* pointer of box on the stack */ GetRhsVar(4,MATRIX_OF_INTEGER_DATATYPE,&m,&n,&boxPtr); CheckScalar(4,m,n); box = *istk( boxPtr ); nbLabels--; /* it is not a label text */ isBoxSpecified = TRUE; } } if ( opts[0].position != -1 && !isBoxSpecified ) { /* check if "box" is in the options */ box = *istk(opts[0].l) ; if ( opts[0].m * opts[0].n != 1 ) { /* check size */ Scierror( 999, _("%s: Wrong type for input argument: Scalar expected.\n"), fname ); return 1; } nbLabels--; /* it is not a label text */ } psubwinUID = getOrCreateDefaultSubwin(); for ( narg = 1 ; narg <= nbLabels ; narg++) { int m,n; char **Str; char * modifiedLabel = NULL; GetRhsVar(narg,MATRIX_OF_STRING_DATATYPE,&m,&n,&Str); if ( m*n == 0 ) { continue; } switch(narg) { case 1: getGraphicObjectProperty(psubwinUID, __GO_TITLE__, jni_string, &modifiedLabel); break; case 2: getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, &modifiedLabel); break; case 3: getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, &modifiedLabel); break; case 4: getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, &modifiedLabel); break; default: break; } #if 0 startFigureDataWriting(pFigure); #endif sciSetText(modifiedLabel, Str, m, n); setGraphicObjectProperty(modifiedLabel, __GO_FILL_MODE__, &box, jni_bool, 1); #if 0 endFigureDataWriting(pFigure); #endif freeArrayOfString(Str,m*n); } setCurrentObject(psubwinUID); #if 0 sciDrawObj(pFigure); #endif LhsVar(1)=0; C2F(putlhsvar)(); return 0; }