static char *getAxe(char const* pFigureUID, scicos_block * block, int input) { char *pAxe; int i; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return NULL; } // fast path for an existing object if (sco->scope.cachedAxeUID != NULL && sco->scope.cachedAxeUID[input] != NULL) { return sco->scope.cachedAxeUID[input]; } pAxe = findChildWithKindAt(pFigureUID, __GO_AXES__, input); /* * Allocate if necessary */ if (pAxe == NULL) { cloneAxesModel(pFigureUID); pAxe = findChildWithKindAt(pFigureUID, __GO_AXES__, input); } /* * Setup on first access */ if (pAxe != NULL) { // allocate the polylines through the getter for (i = 0; i < block->insz[input]; i++) { getPolyline(pAxe, block, input, i); } setAxesSettings(pAxe, block, input); } /* * then cache with local storage */ if (pAxe != NULL && sco->scope.cachedAxeUID != NULL && sco->scope.cachedAxeUID[input] == NULL) { sco->scope.cachedAxeUID[input] = strdup(pAxe); releaseGraphicObjectProperty(__GO_PARENT__, pAxe, jni_string, 1); } return sco->scope.cachedAxeUID[input]; }
static int getAxe(int iFigureUID, scicos_block * block) { int iAxe; int i; int nclk = block->nipar - 6; sco_data *sco = getScoData(block); // assert the sco is not NULL if (sco == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedAxeUID) { return sco->scope.cachedAxeUID; } iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); /* * Allocate if necessary */ if (iAxe == 0) { cloneAxesModel(iFigureUID); iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); } /* * Setup on first access */ if (iAxe != 0) { // allocate the segs through the getter for (i = 0; i < nclk; i++) { getSegs(iAxe, block, i); } } else { return 0; } /* * then cache with a local storage */ sco->scope.cachedAxeUID = iAxe; return sco->scope.cachedAxeUID; }
static char *getAxe(char const* pFigureUID, scicos_block * block) { char *pAxe; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return NULL; } // fast path for an existing object if (sco->scope.cachedAxeUID != NULL) { return sco->scope.cachedAxeUID; } pAxe = findChildWithKindAt(pFigureUID, __GO_AXES__, 0); /* * Allocate if necessary */ if (pAxe == NULL) { cloneAxesModel(pFigureUID); pAxe = findChildWithKindAt(pFigureUID, __GO_AXES__, 0); } /* * Setup on first access */ if (pAxe != NULL) { getGrayplot(pAxe, block); } /* * then cache with local storage */ if (pAxe != NULL && sco->scope.cachedAxeUID == NULL) { sco->scope.cachedAxeUID = strdup(pAxe); releaseGraphicObjectProperty(__GO_PARENT__, pAxe, jni_string, 1); } return sco->scope.cachedAxeUID; }
static int getAxe(int iFigureUID, scicos_block * block) { int iAxe; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedAxeUID) { return sco->scope.cachedAxeUID; } iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); /* * Allocate if necessary */ if (iAxe == 0) { cloneAxesModel(iFigureUID); iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); } /* * Setup on first access */ if (iAxe != 0) { getGrayplot(iAxe, block); } else { return 0; } /* * then cache with local storage */ sco->scope.cachedAxeUID = iAxe; return sco->scope.cachedAxeUID; }
static int getAxe(int iFigureUID, scicos_block * block) { int iAxe; int i__1 = 1; sco_data *sco = (sco_data *) * (block->work); // assert the sco is not NULL if (sco == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedAxeUID) { return sco->scope.cachedAxeUID; } iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); /* * Allocate if necessary */ if (iAxe == 0) { cloneAxesModel(iFigureUID); iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0); } if (iAxe != 0) { setGraphicObjectProperty(iAxe, __GO_BOX_TYPE__, &i__1, jni_int, 1); getPlot3d(iAxe, block); } else { return 0; } /* * then cache with local storage */ sco->scope.cachedAxeUID = iAxe; return sco->scope.cachedAxeUID; }
/*--------------------------------------------------------------------------*/ int sci_delete(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddrl1 = NULL; long long* l1 = NULL; int* piAddrl2 = NULL; char* l2 = NULL; int m1 = 0, n1 = 0, lw = 0; unsigned long hdl = 0; int nb_handles = 0, i = 0, dont_overload = 0; int iObjUID = 0; int iFigureUID = 0; int* piChildrenUID = NULL; int iChildrenCount = 0; int* childrencount = &iChildrenCount; int iHidden = 0; int *piHidden = &iHidden; int iParentUID = 0; int* piParentUID = &iParentUID; int iParentType = -1; int *piParentType = &iParentType; int iObjType = -1; int *piObjType = &iObjType; CheckInputArgument(pvApiCtx, 0, 1); CheckOutputArgument(pvApiCtx, 0, 1); if (nbInputArgument(pvApiCtx) == 0) /* Delete current object */ { iObjUID = getCurrentObject(); if (iObjUID == 0) { //No current object, we can leave AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } hdl = (unsigned long)getHandle(iObjUID); dont_overload = 1; nb_handles = 1; } else { sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } switch (getInputArgumentType(pvApiCtx, 1)) { case sci_matrix: { if (isEmptyMatrix(pvApiCtx, piAddrl1)) { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 1; } else { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } break; } case sci_handles: /* delete Entity given by a handle */ // Retrieve a matrix of handle at position 1. sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1); /* Gets the Handle passed as argument */ if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } nb_handles = m1 * n1; if (nbInputArgument(pvApiCtx) == 2) { sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) /* Gets the command name */ { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 2); return 1; } } hdl = (unsigned long) * (l1); /* Puts the value of the Handle to hdl */ break; case sci_strings: /* delete("all") */ CheckInputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 1); return 1; } if (strcmp((l2), "all") == 0) { int i = 0; int iFigureNumber = sciGetNbFigure(); if (iFigureNumber == 0) { //no graphic windows, we can leave AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } iFigureUID = getCurrentFigure(); getGraphicObjectProperty(iFigureUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&childrencount); getGraphicObjectProperty(iFigureUID, __GO_CHILDREN__, jni_int_vector, (void **)&piChildrenUID); for (i = 0; i < childrencount[0]; ++i) { getGraphicObjectProperty(piChildrenUID[i], __GO_HIDDEN__, jni_bool, (void **)&piHidden); if (iHidden == 0) { deleteGraphicObject(piChildrenUID[i]); } } /* * Clone a new Axes object using the Axes model which is then * attached to the 'cleaned' Figure. */ cloneAxesModel(iFigureUID); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } else { Scierror(999, _("%s: Wrong value for input argument #%d: '%s' expected.\n"), fname, 1, "all"); return 0; } break; default: // Overload lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); C2F(overload) (&lw, "delete", 6); return 0; } } for (i = 0; i < nb_handles; i++) { int iTemp = 0; if (nbInputArgument(pvApiCtx) != 0) { hdl = (unsigned long) * (l1 + i); /* Puts the value of the Handle to hdl */ } iObjUID = getObjectFromHandle(hdl); if (iObjUID == 0) { Scierror(999, _("%s: The handle is not valid.\n"), fname); return 0; } if (isFigureModel(iObjUID) || isAxesModel(iObjUID)) { Scierror(999, _("This object cannot be deleted.\n")); return 0; } /* Object type */ getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piObjType); if (iObjType == __GO_AXES__) { /* Parent object */ iParentUID = getParentObject(iObjUID); /* Parent type */ getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); } if (iObjType == __GO_LABEL__) { Scierror(999, _("A Label object cannot be deleted.\n")); return 0; } //bug #11485 : duplicate pobjUID before delete it. iTemp = iObjUID; deleteGraphicObject(iObjUID); /* ** All figure must have at least one axe child. ** If the last one is removed, add a new default one. */ if (iObjType == __GO_AXES__ && iParentType == __GO_FIGURE__) { int iChild = 0; int iChildCount = 0; int *piChildCount = &iChildCount; char **pstChildren = NULL; int iChildType = -1; int *piChildType = &iChildType; int iAxesFound = 0; int iDefaultAxes = -1; int *piDefaultAxes = &iDefaultAxes; getGraphicObjectProperty(iParentUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&piChildCount); getGraphicObjectProperty(iParentUID, __GO_CHILDREN__, jni_int_vector, (void **)&piChildrenUID); getGraphicObjectProperty(iParentUID, __GO_DEFAULT_AXES__, jni_bool, (void **)&piDefaultAxes); for (iChild = 0; iChild < iChildCount; iChild++) { getGraphicObjectProperty(piChildrenUID[iChild], __GO_TYPE__, jni_int, (void **)&piChildType); if (iChildType == __GO_AXES__) { if (getCurrentSubWin() == iTemp) // Current axes has been deleted { setCurrentSubWin(piChildrenUID[iChild]); } iAxesFound = 1; break; } } if (!iAxesFound && iDefaultAxes != 0) { /* * Clone a new Axes object using the Axes model which is then * attached to the newly created Figure. */ cloneAxesModel(iParentUID); } } } if (!dont_overload) { // Overload lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); C2F(overload) (&lw, "delete", 6); } else { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); } if (l2) { freeAllocatedSingleString(l2); } return 0; }
/*--------------------------------------------------------------------------*/ types::Function::ReturnValue sci_xset(types::typed_list &in, int _iRetCount, types::typed_list &out) { wchar_t* pwcsWhat = NULL; std::list<types::Double*> lpDblInputs; int iSubwinUID = 0; if (in.size() == 0) { return Overload::call(L"%_xset", in, _iRetCount, out); } if (in.size() > 6) { Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "xset", 1, 6); return types::Function::Error; } if (_iRetCount > 1) { Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "xset", 1); return types::Function::Error; } if (in[0]->isString() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 1); return types::Function::Error; } types::String* pStr = in[0]->getAs<types::String>(); if (pStr->isScalar() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 1); return types::Function::Error; } pwcsWhat = pStr->get(0); if (ConfigGraphicVariable::bPropertyFound(pwcsWhat) == false) { char* pstWhat = wide_string_to_UTF8(pwcsWhat); Scierror(999, _("%s: Unrecognized input argument: '%s'.\n"), "xset", pstWhat); FREE(pstWhat); return types::Function::Error; } // Only in case of "fpf" and "auto clear", the second argument is a string // Only "default" case have one input argument if (ConfigGraphicVariable::getPropertyValue(pwcsWhat) != 15 && // fpf ConfigGraphicVariable::getPropertyValue(pwcsWhat) != 2 && // auto clear ConfigGraphicVariable::getPropertyValue(pwcsWhat) != 10) // default { for (unsigned int i = 1 ; i < in.size() ; i++) { if (in[i]->isDouble() == false) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), "xset", i + 1); } } } switch (ConfigGraphicVariable::getPropertyValue(pwcsWhat)) { case 15 : // fpf { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } if (in[1]->isString() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 2); return types::Function::Error; } types::String* pStrValue = in[1]->getAs<types::String>(); if (pStrValue->isScalar() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 2); return types::Function::Error; } ConfigGraphicVariable::setFPF(pStrValue->get(0)); } break; case 2 : // auto clear { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } if (in[1]->isString() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 2); return types::Function::Error; } types::String* pStrValue = in[1]->getAs<types::String>(); if (pStrValue->isScalar() == false) { Scierror(999, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "xset", 2); return types::Function::Error; } int bAutoClear = 0; if (wcscmp(pStrValue->get(0), L"on") == 0) { bAutoClear = 1; } setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_AUTO_CLEAR__, &bAutoClear, jni_bool, 1); } break; case 5 : // clipping { int clipState = 2; double dvalues[4]; if (in.size() == 2) { types::Double* pDblArg = in[1]->getAs<types::Double>(); if (pDblArg->getSize() != 4) { Scierror(999, _("%s: Wrong size for input argument #%d: A %d-element vector expected.\n"), "xset", 2, 4); return types::Function::Error; } memcpy(dvalues, pDblArg->get(), 4 * sizeof(double)); } else if (in.size() != 5) { Scierror(77, _("%s: Wrong number of input arguments: %d or %d expected.\n"), "xset", 2, 5); return types::Function::Error; } else { for (int i = 0; i < 4 ; i++) { dvalues[i] = in[i + 1]->getAs<types::Double>()->get(0); } } iSubwinUID = getOrCreateDefaultSubwin(); setGraphicObjectProperty(iSubwinUID, __GO_CLIP_BOX__, dvalues, jni_double_vector, 4); setGraphicObjectProperty(iSubwinUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); } break; case 8 : // colormap { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "xset", 2); return types::Function::Error; } types::Double* pDblArg = in[1]->getAs<types::Double>(); getOrCreateDefaultSubwin(); setGraphicObjectProperty(getCurrentFigure(), __GO_COLORMAP__, pDblArg->get(), jni_double_vector, pDblArg->getSize()); } break; case 21 : // mark size { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "xset", 2); return types::Function::Error; } int markSize = (int)in[1]->getAs<types::Double>()->get(0); int markSizeUnit = 1; /* force switch to tabulated mode : old syntax / 0 : point, 1 : tabulated */ iSubwinUID = getOrCreateDefaultSubwin(); setGraphicObjectProperty(iSubwinUID, __GO_MARK_SIZE_UNIT__, &markSizeUnit, jni_int, 1); setGraphicObjectProperty(iSubwinUID, __GO_MARK_SIZE__, &markSize, jni_int, 1); } break; case 20 : // mark { if (in.size() != 3) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 3); return types::Function::Error; } int markStyle = (int) in[1]->getAs<types::Double>()->get(0); int markSize = (int) in[2]->getAs<types::Double>()->get(0); int markSizeUnit = 1; /* force switch to tabulated mode : old syntax / 0 : point, 1 : tabulated */ int markMode = 1; iSubwinUID = getOrCreateDefaultSubwin(); setGraphicObjectProperty(iSubwinUID, __GO_MARK_MODE__, &markMode, jni_bool, 1); setGraphicObjectProperty(iSubwinUID, __GO_MARK_SIZE_UNIT__, &markSizeUnit, jni_int, 1); /* force switch to tabulated mode : old syntax */ setGraphicObjectProperty(iSubwinUID, __GO_MARK_STYLE__, &markStyle, jni_int, 1); setGraphicObjectProperty(iSubwinUID, __GO_MARK_SIZE__, &markSize, jni_int, 1); } break; case 13 : // font size { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } double fontSize = in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_FONT_SIZE__, &fontSize, jni_double, 1); } break; case 10 : // default { if (in.size() != 1) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 1); return types::Function::Error; } unsigned short* defcolors = ConfigGraphicVariable::getDefaultColormap(); int piFigurePosition[2] = {200, 200}; int piFigureSize[2] = {500, 500}; int piAxesSize[2] = {498, 366}; int piViewPort[2] = {0, 0}; int piEmptyMatrix[4] = {1, 0, 0, 0}; // init variables int iZero = 0; BOOL bTrue = TRUE; BOOL bFalse = FALSE; int m = NUMCOLORS_SCI; int i = 0; int iCopy = 3; int defaultBackground = -2; // reset format ConfigGraphicVariable::setFPF(L""); double* pdblColorMap = new double[m * 3]; if (pdblColorMap == NULL) { Scierror(999, _("%s: No more memory.\n"), "xset"); return types::Function::Error; } // Create figure if it not exist. int iFigureUID = getCurrentFigure(); if (iFigureUID == 0) { iFigureUID = createNewFigureWithAxes(); setCurrentFigure(iFigureUID); delete[] pdblColorMap; return types::Function::OK; } // Create new axes and set it in current figure int iSubWinUID = getCurrentSubWin(); if (iSubWinUID != 0) { int iChildrenCount = 0; int* childrencount = &iChildrenCount; int* childrenUID = 0; int iHidden = 0; int *piHidden = &iHidden; getGraphicObjectProperty(iFigureUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&childrencount); getGraphicObjectProperty(iFigureUID, __GO_CHILDREN__, jni_string_vector, (void **)&childrenUID); for (i = 0; i < childrencount[0]; ++i) { getGraphicObjectProperty(childrenUID[i], __GO_HIDDEN__, jni_bool, (void **)&piHidden); if (iHidden == 0) { deleteGraphicObject(childrenUID[i]); } } } cloneAxesModel(iFigureUID); // Set default figure properties setGraphicObjectProperty(iFigureUID, __GO_POSITION__, piFigurePosition, jni_int_vector, 2); setGraphicObjectProperty(iFigureUID, __GO_SIZE__, piFigureSize, jni_int_vector, 2); setGraphicObjectProperty(iFigureUID, __GO_AXES_SIZE__, piAxesSize, jni_int_vector, 2); setGraphicObjectProperty(iFigureUID, __GO_AUTORESIZE__, &bTrue, jni_bool, 1); setGraphicObjectProperty(iFigureUID, __GO_VIEWPORT__, piViewPort, jni_int_vector, 2); setGraphicObjectProperty(iFigureUID, __GO_NAME__, _("Figure n°%d"), jni_string, 1); setGraphicObjectProperty(iFigureUID, __GO_INFO_MESSAGE__, "", jni_string, 1); setGraphicObjectProperty(iFigureUID, __GO_PIXEL_DRAWING_MODE__, &iCopy, jni_int, 1); setGraphicObjectProperty(iFigureUID, __GO_ANTIALIASING__, &iZero, jni_int, 1); setGraphicObjectProperty(iFigureUID, __GO_IMMEDIATE_DRAWING__, &bTrue, jni_bool, 1); setGraphicObjectProperty(iFigureUID, __GO_BACKGROUND__, &defaultBackground, jni_int, 1); setGraphicObjectProperty(iFigureUID, __GO_VISIBLE__, &bTrue, jni_bool, 1); setGraphicObjectProperty(iFigureUID, __GO_ROTATION_TYPE__, &iZero, jni_int, 1); setGraphicObjectProperty(iFigureUID, __GO_EVENTHANDLER__, "", jni_string, 1); setGraphicObjectProperty(iFigureUID, __GO_EVENTHANDLER_ENABLE__, &bFalse, jni_bool, 1); setGraphicObjectProperty(iFigureUID, __GO_USER_DATA__, piEmptyMatrix, jni_int_vector, 4); setGraphicObjectProperty(iFigureUID, __GO_RESIZEFCN__, "", jni_string, 1); setGraphicObjectProperty(iFigureUID, __GO_TAG__, "", jni_string, 1); for (i = 0; i < m; i++) { pdblColorMap[i] = (double)(defcolors[3 * i] / 255.0); pdblColorMap[i + m] = (double)(defcolors[3 * i + 1] / 255.0); pdblColorMap[i + 2 * m] = (double)(defcolors[3 * i + 2] / 255.0); } setGraphicObjectProperty(iFigureUID, __GO_COLORMAP__, pdblColorMap, jni_double_vector, 3 * m); setGraphicObjectProperty(iFigureUID, __GO_PARENT__, "", jni_string, 1); delete[] pdblColorMap; } break; case 6 : // clipgrf { int clipState = 1; /* special treatement for xset("cligrf") */ setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_CLIP_STATE__, &clipState, jni_int, 1); } break; case 4 : // clipoff { int clipState = 0; /* special treatement for xset("clipoff") */ setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_CLIP_STATE__, &clipState, jni_int, 1); } break; case 16 : // hidden3d { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int hiddenColor = (int) in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_HIDDEN_COLOR__, &hiddenColor, jni_int, 1); } break; case 12 : // font { if (in.size() != 3) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 3); return types::Function::Error; } int fontStyle = (int) in[1]->getAs<types::Double>()->get(0); double fontSize = in[2]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_FONT_SIZE__, &fontSize, jni_double, 1); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_FONT_STYLE__, &fontStyle, jni_int, 1); } break; case 11 : // window case 30 : // figure { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } // Find if window already exists, if not create a new one int iID = (int)in[1]->getAs<types::Double>()->get(0); int iFigureUID = getFigureFromIndex(iID); int iAxesUID = 0; int* piAxesUID = &iAxesUID; if (iFigureUID == 0) { iFigureUID = createNewFigureWithAxes(); setGraphicObjectProperty(iFigureUID, __GO_ID__, &iID, jni_int, 1); } setCurrentFigure(iFigureUID); getGraphicObjectProperty(iFigureUID, __GO_SELECTED_CHILD__, jni_int, (void**)&piAxesUID); setCurrentSubWin(iAxesUID); } break; case 14 : // foreground case 7 : // color case 23 : // pattern { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int iColor = (int) in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_LINE_COLOR__, &iColor, jni_int, 1); } break; case 3 : // background { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int iColor = (int) in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_BACKGROUND__, &iColor, jni_int, 1); } break; case 25 : // thickness { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } sciSetLineWidth(getOrCreateDefaultSubwin(), (int)in[1]->getAs<types::Double>()->get(0)); } break; case 19 : // line style { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int lineStyle = (int) in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_LINE_STYLE__, &lineStyle, jni_int, 1); } break; case 9 : // dashes { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int lineStyle = (int) in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_LINE_STYLE__, &lineStyle, jni_int, 1); } break; case 33 : // wresize { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int iAutoResizeMode = (int)in[1]->getAs<types::Double>()->get(0); setGraphicObjectProperty(getOrCreateDefaultSubwin(), __GO_AUTORESIZE__, &iAutoResizeMode, jni_bool, 1); } break; case 32 : // wpos { int figurePosition[2]; if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } getOrCreateDefaultSubwin(); figurePosition[0] = (int)in[1]->getAs<types::Double>()->get(0); figurePosition[1] = (int)in[1]->getAs<types::Double>()->get(1); setGraphicObjectProperty(getCurrentFigure(), __GO_POSITION__, figurePosition, jni_int_vector, 2); } break; case 31 : // wpdim case 28 : // wdim { int figureSize[2] = {0, 0}; if (in.size() != 2 && in.size() != 3) { Scierror(77, _("%s: Wrong number of input arguments: %d or %d expected.\n"), "xset", 2, 3); return types::Function::Error; } figureSize[0] = (int)in[1]->getAs<types::Double>()->get(0); if (in.size() == 3) { figureSize[1] = (int)in[2]->getAs<types::Double>()->get(0); } /* Xwindows limits dimensions to 2^16 */ if ((figureSize[0] > 65535) || (figureSize[1] > 65535)) { figureSize[0] = std::min(figureSize[0], 65535); figureSize[1] = std::min(figureSize[1], 65535); if (ConfigVariable::getWarningMode()) { sciprint(_("%s: window dimensions have been set less than 2^16.\n"), "xset"); } } getOrCreateDefaultSubwin(); setGraphicObjectProperty(getCurrentFigure(), __GO_SIZE__, figureSize, jni_int_vector, 2); } break; case 27 : // viewport { if (in.size() != 3) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 3); return types::Function::Error; } int viewport[4] = {0, 0, 0, 0}; viewport[0] = (int)in[1]->getAs<types::Double>()->get(0); viewport[1] = (int)in[2]->getAs<types::Double>()->get(0); getOrCreateDefaultSubwin(); setGraphicObjectProperty(getCurrentFigure(), __GO_VIEWPORT__, viewport, jni_int_vector, 2); } break; case 18 : // line mode { if (in.size() != 2) { Scierror(77, _("%s: Wrong number of input arguments: %d expected.\n"), "xset", 2); return types::Function::Error; } int iSubwinUID = getOrCreateDefaultSubwin(); int iZero = 0; int iOne = 1; if (in[1]->getAs<types::Double>()->get(0) == 0) { setGraphicObjectProperty(iSubwinUID, __GO_LINE_MODE__, &iZero, jni_bool, 1); } else { setGraphicObjectProperty(iSubwinUID, __GO_LINE_MODE__, &iOne, jni_bool, 1); } } break; default : { char* pstWhat = wide_string_to_UTF8(pwcsWhat); Scierror(999, _("%s: Unrecognized input argument: '%s'.\n"), "xset", pstWhat); FREE(pstWhat); return types::Function::Error; } } return types::Function::OK; }