static char *getPlot3d(char *pAxeUID, scicos_block * block) { char *pPlot3d; 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.cachedPlot3dUID != NULL) { return sco->scope.cachedPlot3dUID; } pPlot3d = findChildWithKindAt(pAxeUID, __GO_PLOT3D__, 0); /* * Allocate if necessary */ if (pPlot3d == NULL) { pPlot3d = createGraphicObject(__GO_PLOT3D__); if (pPlot3d != NULL) { createDataObject(pPlot3d, __GO_PLOT3D__); setGraphicObjectRelationship(pAxeUID, pPlot3d); } } /* * Setup on first access */ if (pPlot3d != NULL) { setBounds(block, pAxeUID, pPlot3d); setPlot3dSettings(pPlot3d); setDefaultValues(block, pPlot3d); { int iClipState = 1; //on setGraphicObjectProperty(pPlot3d, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with a local storage */ if (pPlot3d != NULL && sco->scope.cachedPlot3dUID == NULL) { sco->scope.cachedPlot3dUID = strdup(pPlot3d); releaseGraphicObjectProperty(__GO_PARENT__, pPlot3d, jni_string, 1); } return sco->scope.cachedPlot3dUID; }
static int getGrayplot(int iAxeUID, scicos_block * block) { int iGrayplot; int i__0 = 0; 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.cachedGrayplotUID) { return sco->scope.cachedGrayplotUID; } iGrayplot = findChildWithKindAt(iAxeUID, __GO_GRAYPLOT__, 0); /* * Allocate if necessary */ if (iGrayplot == 0) { iGrayplot = createGraphicObject(__GO_GRAYPLOT__); if (iGrayplot != 0) { createDataObject(iGrayplot, __GO_GRAYPLOT__); setGraphicObjectRelationship(iAxeUID, iGrayplot); } else { return 0; } } /* * Setup on first access */ setGraphicObjectProperty(iGrayplot, __GO_DATA_MAPPING__, &i__0, jni_int, 1); setBounds(block, iAxeUID, iGrayplot); setDefaultValues(block, iGrayplot); { int iClipState = 1; //on setGraphicObjectProperty(iGrayplot, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedGrayplotUID = iGrayplot; return sco->scope.cachedGrayplotUID; }
static int getPlot3d(int iAxeUID, scicos_block * block) { int iPlot3d; 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.cachedPlot3dUID) { return sco->scope.cachedPlot3dUID; } iPlot3d = findChildWithKindAt(iAxeUID, __GO_PLOT3D__, 0); /* * Allocate if necessary */ if (iPlot3d == 0) { iPlot3d = createGraphicObject(__GO_PLOT3D__); if (iPlot3d != 0) { createDataObject(iPlot3d, __GO_PLOT3D__); setGraphicObjectRelationship(iAxeUID, iPlot3d); } else { return 0; } } /* * Setup on first access */ setBounds(block, iAxeUID, iPlot3d); setPlot3dSettings(iPlot3d); setDefaultValues(block, iPlot3d); { int iClipState = 1; //on setGraphicObjectProperty(iPlot3d, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedPlot3dUID = iPlot3d; return sco->scope.cachedPlot3dUID; }
/* allocate and set a new label to default values */ int initLabel(int iParentObjUID) { int iNewLabel = NULL; int iHidden = 1; int autoPosition = 1; iNewLabel = createGraphicObject(__GO_LABEL__); /* Hide Label as they are non explicit children */ setGraphicObjectProperty(iNewLabel, __GO_HIDDEN__, &iHidden, jni_bool, 1); setGraphicObjectProperty(iNewLabel, __GO_AUTO_POSITION__, &autoPosition, jni_bool, 1); setGraphicObjectProperty(iNewLabel, __GO_AUTO_ROTATION__, &autoPosition, jni_bool, 1); /* Sets the label's parent */ setGraphicObjectRelationship(iParentObjUID, iNewLabel); cloneGraphicContext(iParentObjUID, iNewLabel); cloneFontContext(iParentObjUID, iNewLabel); return iNewLabel; }
/*--------------------------------------------------------------------------*/ int sci_xrects(char *fname, void *pvApiCtx) { SciErr sciErr; int* piAddrl1 = NULL; double* l1 = NULL; int* piAddr2 = NULL; int* l2 = NULL; int m1 = 0, n1 = 0, m2 = 0, n2 = 0; long hdl = 0; int i = 0; int iSubwinUID = 0; int foreground = 0; int *piForeground = &foreground; int iCompoundUID = 0; CheckInputArgument(pvApiCtx, 1, 2); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } if (m1 != 4) { Scierror(999, _("%s: Wrong size for input argument #%d: %s expected.\n"), fname, 1, "(4,n)"); return 0; } if (nbInputArgument(pvApiCtx) == 2) { sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr2, &m2, &n2, &l2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2); return 1; } //CheckVector if (m2 != 1 && n2 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 2); return 1; } if (m2 * n2 != n1) { Scierror(999, _("%s: Incompatible length for input arguments #%d and #%d.\n"), fname, 1, 2); return 0; } } else { m2 = 1; n2 = n1; sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 2, m2, n2, &l2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } for (i = 0; i < n2; ++i) { l2[i] = 0; } } iSubwinUID = getOrCreateDefaultSubwin(); // Create compound. iCompoundUID = createGraphicObject(__GO_COMPOUND__); /* Sets the parent-child relationship for the Compound */ setGraphicObjectRelationship(iSubwinUID, iCompoundUID); /** Get Subwin line color */ getGraphicObjectProperty(iSubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piForeground); for (i = 0; i < n1; ++i) { /* j = (i==0) ? 0 : 1; */ if (l2[i] == 0) { /** fil(i) = 0 rectangle i is drawn using the current line style (or color).**/ /* color setting is done now */ Objrect((l1 + (4 * i)), (l1 + (4 * i) + 1), (l1 + (4 * i) + 2), (l1 + (4 * i) + 3), &foreground, NULL, FALSE, TRUE, &hdl); } else { if (l2[i] < 0) { /** fil(i) < 0 rectangle i is drawn using the line style (or color) **/ int tmp = - (*(int*)(l2 + i)); Objrect((l1 + (4 * i)), (l1 + (4 * i) + 1), (l1 + (4 * i) + 2), (l1 + (4 * i) + 3), &tmp, NULL, FALSE, TRUE, &hdl); } else { /** fil(i) > 0 rectangle i is filled using the pattern (or color) **/ Objrect((l1 + (4 * i)), (l1 + (4 * i) + 1), (l1 + (4 * i) + 2), (l1 + (4 * i) + 3), NULL, l2 + i, TRUE, FALSE, &hdl); } } // Add newly created object to Compound setGraphicObjectRelationship(iCompoundUID, getObjectFromHandle(hdl)); } /** make Compound current object **/ setCurrentObject(iCompoundUID); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_uicontrol(char *fname, void* pvApiCtx) { SciErr sciErr; int nbRow = 0, nbCol = 0, k = 0; int setStatus = SET_PROPERTY_SUCCEED; int PARENT_NOT_FOUND = -2; int NOT_FOUND = -1; int inputIndex = 0, beginIndex = 0; char *propertyName = NULL; char *styleProperty = NULL; int iPropertiesCount = sizeof(propertiesNames) / sizeof(char**); unsigned long GraphicHandle = 0; int found = 0; /* Does the property exists ? */ int *propertiesValuesIndices = NULL; int iParentType = -1; int *piParentType = &iParentType; int iParentStyle = -1; int *piParentStyle = &iParentStyle; int iParentUID = 0; int iUicontrol = 0; int iCurrentFigure = 0; CheckOutputArgument(pvApiCtx, 0, 1); //init properties index init_property_index(); if (nbInputArgument(pvApiCtx) == 0) { /* Create a pushbutton in current figure */ /* Create a new pushbutton */ GraphicHandle = getHandle(CreateUIControl(NULL)); /* Set current figure as parent */ iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } iUicontrol = getObjectFromHandle(GraphicHandle); setGraphicObjectRelationship(iCurrentFigure, iUicontrol); } else if (nbInputArgument(pvApiCtx) == 1) { /* Create a pushbutton in figure given as parameter */ /* Or give focus to the uicontrol given as parameter */ int* piAddr = NULL; int iType = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 0; } if (isHandleType(pvApiCtx, piAddr) == FALSE && isStringType(pvApiCtx, piAddr) == FALSE) { OverLoad(1); return FALSE; } #if 0 // Allow XML loading else if (isStringType(pvApiCtx, piAddr)) { char* pstXmlfile = NULL; char* pstExpandedPath = NULL; if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, 1); return FALSE; } if (getAllocatedSingleString(pvApiCtx, piAddr, &pstXmlfile)) { freeAllocatedSingleString(pstXmlfile); Scierror(999, _("%s: No more memory.\n"), fname); return FALSE; } pstExpandedPath = expandPathVariable(pstXmlfile); freeAllocatedSingleString(pstXmlfile); iUicontrol = xmlload(pstExpandedPath); if (iUicontrol < 1) { Scierror(999, _("%s: can not read file %s.\n"), fname, pstExpandedPath); FREE(pstExpandedPath); return 0; } FREE(pstExpandedPath); GraphicHandle = getHandle(iUicontrol); /* Create return variable */ if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; } #endif // Allow XML loading else /* Get parent ID */ { int* piAddr = NULL; long long hParent = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A graphic handle expected.\n"), fname, 1); return FALSE; } if (getScalarHandle(pvApiCtx, piAddr, &hParent)) { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } iParentUID = getObjectFromHandle((long)hParent); if (iParentUID != 0) { getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType == __GO_UICONTROL__) /* Focus management */ { GraphicHandle = (unsigned long)hParent; requestFocus(iParentUID); } else if (iParentType == __GO_FIGURE__ || iParentType == __GO_UIMENU__) /* PushButton creation */ { /* Create a new pushbutton */ GraphicHandle = getHandle(CreateUIControl(NULL)); iUicontrol = getObjectFromHandle(GraphicHandle); /* First parameter is the parent */ setGraphicObjectRelationship(iParentUID, iUicontrol); setStatus = callSetProperty(pvApiCtx, iUicontrol, &hParent, sci_handles, 1, 1, (char*)propertiesNames[parent_property]); if (setStatus == SET_PROPERTY_ERROR) { Scierror(999, _("%s: Could not set property '%s'.\n"), fname, propertyName); return FALSE; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s', '%s' or '%s' handle expected.\n"), fname, 1, "Uicontrol", "Figure", "Uimenu"); return FALSE; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s', '%s' or '%s' handle expected.\n"), fname, 1, "Uicontrol", "Figure", "Uimenu"); return FALSE; } } } else { if (!checkInputArgumentType(pvApiCtx, 1, sci_handles) && !checkInputArgumentType(pvApiCtx, 1, sci_strings)) { OverLoad(1); return FALSE; } /* Allocate memory to store the position of properties in uicontrol call */ if ((propertiesValuesIndices = (int*)MALLOC(sizeof(int) * iPropertiesCount)) == NULL) { Scierror(999, _("%s: No more memory.\n"), fname); return FALSE; } /* Init all positions to NOT_FOUND */ for (inputIndex = 0; inputIndex < iPropertiesCount; inputIndex++) { propertiesValuesIndices[inputIndex] = NOT_FOUND; /* Property initialized as not found */ } /** * Odd number of input arguments * First input is the parent ID * All event inputs are property names * All odd (except first) inputs are property values */ if (nbInputArgument(pvApiCtx) % 2 == 1) { if ((!checkInputArgumentType(pvApiCtx, 1, sci_handles))) { if ((checkInputArgumentType(pvApiCtx, 1, sci_matrix))) { int* piAddr = NULL; double dblValue = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A graphic handle expected.\n"), fname, 1); return FALSE; } if (getScalarDouble(pvApiCtx, piAddr, &dblValue)) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } iParentUID = getFigureFromIndex((int)dblValue); } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } } else /* Get parent ID */ { int* piAddr = NULL; long long hParent = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddr) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } if (getScalarHandle(pvApiCtx, piAddr, &hParent)) { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } iParentUID = getObjectFromHandle((long)hParent); } if (iParentUID == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType != __GO_FIGURE__) { getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle); if (iParentType != __GO_UICONTROL__ || (iParentStyle != __GO_UI_FRAME__ && iParentStyle != __GO_UI_TAB__ && iParentStyle != __GO_UI_LAYER__)) { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or a '%s' handle expected.\n"), fname, 1, "Figure", "Frame uicontrol"); return FALSE; } } /* First parameter is the parent */ propertiesValuesIndices[parent_property] = 1; // First input parameter which is a property name beginIndex = 2; } /** * Even number of input arguments * All odd inputs are property names * All even inputs are property values */ else { // First input parameter which is a property name beginIndex = 1; } /* Get all properties positions */ for (inputIndex = beginIndex; inputIndex < Rhs; inputIndex = inputIndex + 2) { /* Read property name */ if ((!checkInputArgumentType(pvApiCtx, inputIndex, sci_strings))) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, inputIndex); return FALSE; } else { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, inputIndex, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddr, &propertyName)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, inputIndex); return 1; } /* Bug 3031 */ /* We only want to compare propertyName along its length */ /* 'posi' must be matched to 'position' */ found = 0; for (k = 0; k < iPropertiesCount ; k++) { if (strlen(propertyName) <= strlen(propertiesNames[k])) { if (strnicmp(propertyName, propertiesNames[k], strlen(propertyName)) == 0) { propertiesValuesIndices[k] = inputIndex + 1; /* Position of value for property */ found = 1; break; } } } freeAllocatedSingleString(propertyName); if (found == 0) { Scierror(999, _("%s: Unknown property: %s for '%s' handles.\n"), fname, propertyName, "Uicontrol"); return FALSE; } } } if (propertiesValuesIndices[style_property] != NOT_FOUND) /* Style found */ { if ((checkInputArgumentType(pvApiCtx, propertiesValuesIndices[style_property], sci_strings))) { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[style_property], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddr, &styleProperty)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[style_property]); return 1; } if (strcmp(styleProperty, "frame") == 0) { //check scrollable property to create a scroll frame instead of normal frame if (propertiesValuesIndices[scrollable_property] != NOT_FOUND) { char* pstScroll = NULL; int iScroll = 0; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[scrollable_property], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isStringType(pvApiCtx, piAddr) == 0 && isBooleanType(pvApiCtx, piAddr) == 0 && isScalar(pvApiCtx, piAddr) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: string or boolean expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } if (isStringType(pvApiCtx, piAddr)) { if (getAllocatedSingleString(pvApiCtx, piAddr, &pstScroll)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } if (strcmp(pstScroll, "on") == 0) { iScroll = 1; } freeAllocatedSingleString(pstScroll); } else { if (getScalarBoolean(pvApiCtx, piAddr, &iScroll)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[scrollable_property]); return 1; } } if (iScroll) { freeAllocatedSingleString(styleProperty); styleProperty = os_strdup("framescrollable"); } propertiesValuesIndices[scrollable_property] = NOT_FOUND; } } } else { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, propertiesValuesIndices[style_property]); return FALSE; } } /* Create a new uicontrol */ iUicontrol = CreateUIControl(styleProperty); freeAllocatedSingleString(styleProperty); if (iUicontrol == 0) /* Error in creation */ { Scierror(999, _("%s: Could not create 'Uicontrol' handle.\n"), fname); return FALSE; } GraphicHandle = getHandle(iUicontrol); /* If no parent given then the current figure is the parent */ if (propertiesValuesIndices[parent_property] == NOT_FOUND) { /* Set the parent */ iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } propertiesValuesIndices[parent_property] = PARENT_NOT_FOUND; } /* Read and set all properties */ for (inputIndex = 1; inputIndex < iPropertiesCount; inputIndex++) /* Style has already been set */ { if (propertiesValuesIndices[inputIndex] == PARENT_NOT_FOUND) { //special case for not specified parent //but set relationship at the good moment. setGraphicObjectRelationship(iCurrentFigure, iUicontrol); } else if (propertiesValuesIndices[inputIndex] != NOT_FOUND) { int* piAddr = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, propertiesValuesIndices[inputIndex], &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (inputIndex == user_data_property || inputIndex == userdata_property) /* User data settings */ { nbRow = -1; nbCol = -1; setStatus = callSetProperty(pvApiCtx, iUicontrol, piAddr, 0, 0, 0, (char*)propertiesNames[inputIndex]); } else /* All other properties */ { /* Read property value */ switch (getInputArgumentType(pvApiCtx, propertiesValuesIndices[inputIndex])) { case sci_matrix: { double* pdblValue = NULL; sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &nbRow, &nbCol, &pdblValue); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pdblValue, sci_matrix, nbRow, nbCol, (char*)propertiesNames[inputIndex]); break; } case sci_strings: /* Index for String & TooltipString properties: Can be more than one character string */ if ((inputIndex == string_property) || (inputIndex == tooltipstring_property)) { char** pstValue = NULL; if (getAllocatedMatrixOfString(pvApiCtx, piAddr, &nbRow, &nbCol, &pstValue)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pstValue, sci_strings, nbRow, nbCol, (char*)propertiesNames[inputIndex]); freeAllocatedMatrixOfString(nbRow, nbCol, pstValue); } else { char* pstValue = NULL; if (getAllocatedSingleString(pvApiCtx, piAddr, &pstValue)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } nbRow = (int)strlen(pstValue); nbCol = 1; setStatus = callSetProperty(pvApiCtx, iUicontrol, pstValue, sci_strings, nbRow, nbCol, (char*)propertiesNames[inputIndex]); freeAllocatedSingleString(pstValue); } break; case sci_handles: { long long* pHandles = NULL; sciErr = getMatrixOfHandle(pvApiCtx, piAddr, &nbRow, &nbCol, &pHandles); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, propertiesValuesIndices[inputIndex]); return 1; } setStatus = callSetProperty(pvApiCtx, iUicontrol, pHandles, sci_handles, nbRow, nbCol, (char*)propertiesNames[inputIndex]); break; } case sci_tlist: //constraints and border { setStatus = callSetProperty(pvApiCtx, iUicontrol, piAddr, sci_tlist, 1, 1, (char*)propertiesNames[inputIndex]); break; } default: setStatus = SET_PROPERTY_ERROR; break; } } if (setStatus == SET_PROPERTY_ERROR) { Scierror(999, _("%s: Could not set property '%s'.\n"), fname, (char*)propertiesNames[inputIndex]); return FALSE; } } } } if (propertiesValuesIndices != NULL && (propertiesValuesIndices[sliderstep_property] == NOT_FOUND && (propertiesValuesIndices[min_property] != NOT_FOUND || propertiesValuesIndices[max_property] != NOT_FOUND))) /* SliderStep property not set */ { /* Set SliderStep property to [1/100*(Max-Min) 1/10*(Max-Min)] */ double maxValue = 0; double* pdblMaxValue = &maxValue; double minValue = 0; double* pdblMinValue = &minValue; double pdblStep[2]; getGraphicObjectProperty(iUicontrol, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue); getGraphicObjectProperty(iUicontrol, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue); pdblStep[0] = 0.01 * (maxValue - minValue); pdblStep[1] = 0.1 * (maxValue - minValue); setGraphicObjectProperty(iUicontrol, __GO_UI_SLIDERSTEP__, pdblStep, jni_double_vector, 2); } if ((nbInputArgument(pvApiCtx) < 2) || (propertiesValuesIndices[position_property] == NOT_FOUND)) /* Position property not set */ { double* pdblPosition = NULL; getGraphicObjectProperty(iUicontrol, __GO_POSITION__, jni_double_vector, (void**) &pdblPosition); setGraphicObjectProperty(iUicontrol, __GO_POSITION__, pdblPosition, jni_double_vector, 4); releaseGraphicObjectProperty(__GO_POSITION__, pdblPosition, jni_double_vector, 4); } if ((nbInputArgument(pvApiCtx) < 2) || (propertiesValuesIndices[visible_property] == NOT_FOUND)) /* Visible property not set */ { /* Force the uicontrol to be visible because is invisible by default in the model (See bug #10346) */ int b = (int)TRUE; setGraphicObjectProperty(iUicontrol, __GO_VISIBLE__, &b, jni_bool, 1); } FREE(propertiesValuesIndices); /* Create return variable */ if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; }
/*--------------------------------------------------------------------------*/ int sci_xfpolys(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddrl1 = NULL; double* l1 = NULL; int* piAddrl2 = NULL; double* l2 = NULL; int* piAddr3 = NULL; int* l3 = NULL; int m1 = 0, n1 = 0; int m2 = 0, n2 = 0; int m3 = 0, n3 = 0; int mn2 = 0; int v1 = 0; /* v1 is the flag used for flat (v1==1) or interpolated (v1==2) shading */ int i = 0; long hdl = 0; char *pstSubWinUID = NULL; char *pstFigureUID = NULL; char *pstCompoundUID = NULL; int iSubWinForeground = 0; int iImmediateDrawing = 0; int *piImmediateDrawing = &iImmediateDrawing; int iFalse = 0; int iColorMapSize = 0; int* piColorMapSize = &iColorMapSize; int iForeGround = 0; int* piForeGround = &iForeGround; int iVisible = 0; int *piVisible = &iVisible; CheckInputArgument(pvApiCtx, 2, 3); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2); return 1; } //CheckSameDims if (m1 != m2 || n1 != n2) { Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1); return 1; } mn2 = m2 * n2; if (mn2 == 0) { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } if (nbInputArgument(pvApiCtx) == 3) { sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 3. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr3, &m3, &n3, &l3); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3); return 1; } if (m3 * n3 == m1 * n1) { //CheckSameDims if (m1 != m3 || n1 != n3) { Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1); return 1; } v1 = 2; /* interpolated shading */ if (m3 != 3 && m3 != 4) { Scierror(999, _("%s: Interpolated shading only works for polygons of size %d or %d\n"), fname, 3, 4); return 0; } } else { //CheckVector if (m3 != 1 && n3 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 3); return 1; } //CheckDimProp if (m3 * n3 != n2) { Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname); return 1; } v1 = 1; /* flat shading */ } } else { int un = 1, ix = 0; sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 3, un, n2, &l3); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } for (ix = 0; ix < n2; ++ix) { *(int*)(l3 + ix) = 0; } m3 = n3 = 1; } pstSubWinUID = (char*)getOrCreateDefaultSubwin(); getGraphicObjectProperty(pstSubWinUID, __GO_PARENT__, jni_string, (void**)&pstFigureUID); getGraphicObjectProperty(pstFigureUID, __GO_IMMEDIATE_DRAWING__, jni_bool, (void **)&piImmediateDrawing); setGraphicObjectProperty(pstFigureUID, __GO_IMMEDIATE_DRAWING__, &iFalse, jni_bool, 1); //get color map size getGraphicObjectProperty(pstFigureUID, __GO_COLORMAP_SIZE__, jni_int, (void**)&piColorMapSize); //get current foreground color getGraphicObjectProperty(pstSubWinUID, __GO_LINE_COLOR__, jni_int, (void**)&piForeGround); // Create compound. pstCompoundUID = createGraphicObject(__GO_COMPOUND__); setGraphicObjectProperty(pstCompoundUID, __GO_VISIBLE__, &iFalse, jni_bool, 1); /* Sets the parent-child relationship for the Compound */ setGraphicObjectRelationship(pstSubWinUID, pstCompoundUID); for (i = 0; i < n1; ++i) { if (m3 == 1 || n3 == 1) /* color vector specified */ { if (*(int*)(l3 + i) == 0) { if (iForeGround == -1) { iSubWinForeground = iColorMapSize + 1; } else if (iForeGround == -2) { iSubWinForeground = iColorMapSize + 2; } else { iSubWinForeground = iForeGround; } Objpoly((l1 + (i * m1)), (l2 + (i * m1)), m1, 1, iSubWinForeground, &hdl); } else { Objfpoly((l1 + (i * m1)), (l2 + (i * m1)), m1, (int*)(l3 + i), &hdl, v1); } } else /* we have a color matrix used for interpolated shading : one color per vertex */ { Objfpoly((l1 + (i * m1)), (l2 + (i * m1)), m1, (int*)(l3 + i * m3), &hdl, v1); } // Add newly created object to Compound setGraphicObjectRelationship(pstCompoundUID, getObjectFromHandle(hdl)); } setCurrentObject(pstCompoundUID); setGraphicObjectProperty(pstFigureUID, __GO_IMMEDIATE_DRAWING__, &piImmediateDrawing, jni_bool, 1); getGraphicObjectProperty(pstFigureUID, __GO_VISIBLE__, jni_bool, (void **)&piVisible); setGraphicObjectProperty(pstCompoundUID, __GO_VISIBLE__, &iVisible, jni_bool, 1); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_xpolys(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddrl1 = NULL; double* l1 = NULL; int* piAddrl2 = NULL; double* l2 = NULL; int* piAddr3 = NULL; int* l3 = NULL; int m1 = 0, n1 = 0; int m2 = 0, n2 = 0; int m3 = 0, n3 = 0; int i = 0; long hdl = 0; char *pstFigureUID = NULL; char *pstSubWinUID = NULL; char *pstCompoundUID = NULL; int iFalse = 0; int iVisible = 0; int *piVisible = &iVisible; CheckInputArgument(pvApiCtx, 2, 3); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2); return 1; } //CheckSameDims if (m1 != m2 || n1 != n2) { Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1); return 1; } if (m1 * n1 == 0 || m2 * n2 == 0) { /* dimension 0, 0 polyline to draw */ AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } pstSubWinUID = (char*)getOrCreateDefaultSubwin(); pstFigureUID = (char*)getCurrentFigure(); // Create compound. pstCompoundUID = createGraphicObject(__GO_COMPOUND__); setGraphicObjectProperty(pstCompoundUID, __GO_VISIBLE__, &iFalse, jni_bool, 1); /* Sets the parent-child relationship for the Compound */ setGraphicObjectRelationship(pstSubWinUID, pstCompoundUID); if (nbInputArgument(pvApiCtx) == 3) { sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 3. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr3, &m3, &n3, &l3); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3); return 1; } //CheckVector if (m3 != 1 && n3 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 3); return 1; } //CheckDimProp if (m3 * n3 < n1) { Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname); return 1; } /* Construct the polylines */ for (i = 0; i < n1; ++i) { Objpoly((l1 + (i * m1)), (l2 + (i * m2)), m1, 0, *(int*)(l3 + i), &hdl); // Add newly created object to Compound setGraphicObjectRelationship(pstCompoundUID, getObjectFromHandle(hdl)); } } else { for (i = 0; i < n1; ++i) { Objpoly((l1 + (i * m1)), (l2 + (i * m2)), m1, 0, 1, &hdl); // Add newly created object to Compound setGraphicObjectRelationship(pstCompoundUID, getObjectFromHandle(hdl)); } } getGraphicObjectProperty(pstFigureUID, __GO_VISIBLE__, jni_bool, (void **)&piVisible); setGraphicObjectProperty(pstCompoundUID, __GO_VISIBLE__, &iVisible, jni_bool, 1); setCurrentObject(pstCompoundUID); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_uimenu(char *fname, void *pvApiCtx) { SciErr sciErr; int nbRow = 0, nbCol = 0; int setStatus = SET_PROPERTY_SUCCEED; int inputIndex = 0, beginIndex = 0; char *propertyName = NULL; int iParentUID = 0; unsigned long GraphicHandle = 0; int parentDefined = FALSE; int iCurrentFigure = 0; int iParentType = -1; int *piParentType = &iParentType; /* Create a new menu */ GraphicHandle = getHandle(CreateUimenu()); /* If no nbInputArgument(pvApiCtx) -> current figure is the parent (Ascendant compatibility) */ if (nbInputArgument(pvApiCtx) == 0) { // Set the parent property iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } setGraphicObjectRelationship(iCurrentFigure, getObjectFromHandle(GraphicHandle)); } /** * Odd number of input arguments * First input is the parent ID * All event inputs are property names * All odd (except first) inputs are property values */ if (nbInputArgument(pvApiCtx) % 2 == 1) { if ((!checkInputArgumentType(pvApiCtx, 1, sci_handles))) { Scierror(999, _("%s: Wrong type for input argument #%d: A graphic handle expected.\n"), fname, 1); return FALSE; } else /* Get parent ID */ { int *piAddr = NULL; long long hParent = 0; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of handle at position 1. // YOU MUST REMOVE YOUR VARIABLE DECLARATION "int stkAdr". if (getScalarHandle(pvApiCtx, piAddr, &hParent)) { Scierror(202, _("%s: Wrong type for input argument #%d: Handle expected.\n"), fname, 1); return 1; } iParentUID = getObjectFromHandle((long)hParent); if (iParentUID != 0) { getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType != __GO_FIGURE__ && iParentType != __GO_UIMENU__) { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or '%s' handle expected.\n"), fname, 1, "Figure", "Uimenu"); return FALSE; } // Set the parent property callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), &hParent, sci_handles, 1, 1, "parent"); // Set the flag to avoid setting the parent two times parentDefined = TRUE; } else { Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or '%s' handle expected.\n"), fname, 1, "Figure", "Uimenu"); return FALSE; } // First input parameter which is a property name beginIndex = 2; } } /** * Even number of input arguments * All odd inputs are property names * All even inputs are property values */ else { // First input parameter which is a property name beginIndex = 1; } /* Read and set all properties */ for (inputIndex = beginIndex; inputIndex < nbInputArgument(pvApiCtx); inputIndex = inputIndex + 2) { int* piAddrValue = NULL; int* piAddrProperty = NULL; int isUserDataProperty = 0; int iPropertyValuePositionIndex = inputIndex + 1; size_t posStackOrAdr = 0; /* Read property name */ if ((!checkInputArgumentType(pvApiCtx, inputIndex, sci_strings))) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, inputIndex); return FALSE; } else { sciErr = getVarAddressFromPosition(pvApiCtx, inputIndex, &piAddrProperty); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddrProperty, &propertyName)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, inputIndex); return 1; } if (stricmp(propertyName, "parent") == 0) { parentDefined = TRUE; } isUserDataProperty = (stricmp(propertyName, "user_data") == 0) || (stricmp(propertyName, "userdata") == 0); } sciErr = getVarAddressFromPosition(pvApiCtx, iPropertyValuePositionIndex, &piAddrValue); if (sciErr.iErr) { printError(&sciErr, 0); freeAllocatedSingleString(propertyName); return 1; } if (isUserDataProperty) { nbRow = -1; nbCol = -1; setStatus = callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), piAddrValue, 0, 0, 0, propertyName); } else { /* Read property value */ switch (getInputArgumentType(pvApiCtx, iPropertyValuePositionIndex)) { case sci_matrix: { double* pdblValue = NULL; sciErr = getMatrixOfDouble(pvApiCtx, piAddrValue, &nbRow, &nbCol, &pdblValue); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, iPropertyValuePositionIndex); freeAllocatedSingleString(propertyName); return 1; } setStatus = callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), pdblValue, sci_matrix, nbRow, nbCol, propertyName); break; } case sci_strings: { char* pstValue = NULL; if (getAllocatedSingleString(pvApiCtx, piAddrValue, &pstValue)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, iPropertyValuePositionIndex); freeAllocatedSingleString(propertyName); return 1; } nbRow = (int)strlen(pstValue); nbCol = 1; setStatus = callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), pstValue, sci_strings, nbRow, nbCol, propertyName); freeAllocatedSingleString(pstValue); break; } case sci_handles: { long long* phValues = NULL; sciErr = getMatrixOfHandle(pvApiCtx, piAddrValue, &nbRow, &nbCol, &phValues); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, iPropertyValuePositionIndex); freeAllocatedSingleString(propertyName); return 1; } setStatus = callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), phValues, sci_handles, nbRow, nbCol, propertyName); break; } case sci_list: { getListItemNumber(pvApiCtx, piAddrValue, &nbRow); nbCol = 1; setStatus = callSetProperty(pvApiCtx, getObjectFromHandle(GraphicHandle), piAddrValue, sci_list, nbRow, nbCol, propertyName); break; } default: { setStatus = SET_PROPERTY_ERROR; break; } } } if (setStatus == SET_PROPERTY_ERROR) { Scierror(999, _("%s: Could not set property '%s'.\n"), fname, propertyName); freeAllocatedSingleString(propertyName); return FALSE; } freeAllocatedSingleString(propertyName); } /* If the parent is not given, the current figure is set as parent */ if (!parentDefined && (nbInputArgument(pvApiCtx) != 0)) { // Set the parent property iCurrentFigure = getCurrentFigure(); if (iCurrentFigure == 0) { iCurrentFigure = createNewFigureWithAxes(); } setGraphicObjectRelationship(iCurrentFigure, getObjectFromHandle(GraphicHandle)); } /* Create return variable */ nbRow = 1; nbCol = 1; // YOU MUST REMOVE YOUR VARIABLE DECLARATION "int stkAdr". if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, GraphicHandle)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; }
/*------------------------------------------------ * plot3d *-----------------------------------------------*/ void Objplot3d (char * fname , int * isfac , int * izcol , double x[] , double y[] , double z[] , double * zcol , int * m , int * n , double * theta , double * alpha , char * legend, int * iflag , double * ebox , int * m1 , /*Adding F.Leray 12.03.04 and 19.03.04*/ int * n1 , int * m2 , int * n2 , int * m3 , int * n3 , int * m3n , int * n3n) /* F.Leray 25.04.05 : warning here legends means "X@Y@Z": it is labels writings!! */ /* legends has not the same meaning than inside plot2dn (there, it is really the legends of the plotted curves)*/ { sciTypeOf3D typeof3d; int flagcolor = 0; int* pObj = NULL; int i = 0; int iSubwinUID = 0; int firstPlot = 0; int clipState = 0; int iNewSurfaceUID = 0; /* ================================================= * Force SubWindow properties according to arguments * ================================================= */ iSubwinUID = getCurrentSubWin(); checkRedrawing(); initSubWinTo3d(iSubwinUID, legend, iflag, *alpha, *theta, ebox, x, *m1 **n1, y, *m2 **n2, z, *m3 **n3); /* ================================================= * Analyze arguments to find entity type * ================================================= */ if (*isfac == 1) { if (*izcol == 0) { if (strcmp(fname, "plot3d1") == 0) { typeof3d = SCI_FAC3D; flagcolor = 1; } else { typeof3d = SCI_FAC3D; flagcolor = 0; } } else if (*izcol == 2) { typeof3d = SCI_FAC3D; flagcolor = 3; } else { typeof3d = SCI_FAC3D; flagcolor = 2; } } else if (*isfac == 0) { if (strcmp(fname, "plot3d1") == 0) { typeof3d = SCI_PLOT3D; flagcolor = 1; } else { typeof3d = SCI_PLOT3D; flagcolor = 0; } } else { typeof3d = SCI_PARAM3D1; flagcolor = 1; } /* ================================================= * Construct the Entities * ================================================= */ /*Distinction here between SCI_PARAM3D1 and others*/ if (typeof3d != SCI_PARAM3D1) { int dimvectx = -1; int dimvecty = -1; if (*isfac == 1) { /* x is considered as a matrix */ dimvectx = -1; } else if (*m1 == 1) /* x is a row vector */ { dimvectx = *n1; } else if (*n1 == 1) /* x is a column vector */ { dimvectx = *m1; } else /* x is a matrix */ { dimvectx = -1; } if (dimvectx > 1) { int monotony = checkMonotony(x, dimvectx); if (monotony == 0) { Scierror(999, _("%s: x vector is not monotonous.\n"), "Objplot3d"); return; } } if (*isfac == 1) { /* y is considered as a matrix */ dimvecty = -1; } else if (*m2 == 1) /* y is a row vector */ { dimvecty = *n2; } else if (*n2 == 1) /* y is a column vector */ { dimvecty = *m2; } else /* y is a matrix */ { dimvecty = -1; } if (dimvecty > 1) { /* test the monotony on y*/ int monotony = checkMonotony(y, dimvecty); if (monotony == 0) { Scierror(999, _("%s: y vector is not monotonous.\n"), "Objplot3d"); return; } } iNewSurfaceUID = ConstructSurface(iSubwinUID, typeof3d, x, y, z, zcol, *izcol, *m, *n, iflag, ebox, flagcolor, isfac, m1, n1, m2, n2, m3, n3, m3n, n3n); if (iNewSurfaceUID == 0) { Scierror(999, _("%s: No more memory.\n"), "Objplot3d"); return; } setCurrentObject(iNewSurfaceUID); /* Force clipping, 1: CLIPGRF */ clipState = 1; setGraphicObjectProperty(iNewSurfaceUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); } else { int iNewPolylineUID = 0; int iCurrentSubwinUID = 0; if ((pObj = (int*)MALLOC (*n * sizeof (int))) == NULL) { Scierror(999, "%s: No more memory.\n", fname); return; } iCurrentSubwinUID = getCurrentSubWin(); for (i = 0; i < *n; ++i) { if ((*n > 0) && (zcol != (double *)NULL)) { if ((int) zcol[i] > 0) { int intzcol = (int) zcol[i]; iNewPolylineUID = ConstructPolyline (iCurrentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, &intzcol, NULL, NULL, NULL, NULL, TRUE, FALSE, FALSE, FALSE); } else { int intzcol = (int) - zcol[i]; iNewPolylineUID = ConstructPolyline (iCurrentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, NULL, NULL, &intzcol, NULL, NULL, FALSE, FALSE, TRUE, FALSE); } } else { /* default case, nothing is given */ int curcolor = 0; int *piCurColor = &curcolor; getGraphicObjectProperty(iCurrentSubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piCurColor); iNewPolylineUID = ConstructPolyline(iCurrentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, &curcolor, NULL, NULL, NULL, NULL, TRUE, FALSE, FALSE, FALSE); } if (iNewPolylineUID == 0) { Scierror(999, _("%s: No more memory.\n"), fname); FREE(pObj); return; } setCurrentObject(iNewPolylineUID); setGraphicObjectRelationship(iCurrentSubwinUID, iNewPolylineUID); /* Force clipping, 1: CLIPGRF */ clipState = 1; setGraphicObjectProperty(iNewPolylineUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); pObj[i] = iNewPolylineUID; } /** construct Compound and make it current object**/ if (*n > 1) { int o = createCompound (iCurrentSubwinUID, pObj, *n); setCurrentObject(o); } FREE(pObj); } /* ================================================= * Redraw Figure * ================================================= */ // subwin has been modified firstPlot = 0; setGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); }
static char *getPolyline(char *pAxeUID, scicos_block * block, int row) { char *pPolyline; static double d__0 = 0.0; static BOOL b__true = TRUE; int color; int markSize; double lineThickness; 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.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[row] != NULL) { return sco->scope.cachedPolylinesUIDs[row]; } pPolyline = findChildWithKindAt(pAxeUID, __GO_POLYLINE__, row); /* * Allocate if necessary */ if (pPolyline == NULL) { pPolyline = createGraphicObject(__GO_POLYLINE__); if (pPolyline != NULL) { createDataObject(pPolyline, __GO_POLYLINE__); setGraphicObjectRelationship(pAxeUID, pPolyline); } } /* * Setup on first access */ if (pPolyline != NULL) { /* * Default setup of the nGons property */ { int nGons = 1; setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_NUM_GONS__, &nGons, jni_int, 1); } color = block->ipar[3 + row]; markSize = block->ipar[3 + block->ipar[1] + row]; lineThickness = (double)markSize; if (color > 0) { setGraphicObjectProperty(pPolyline, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_COLOR__, &color, jni_int, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_THICKNESS__, &lineThickness, jni_double, 1); } else { color = -color; setGraphicObjectProperty(pPolyline, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_STYLE__, &color, jni_int, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_SIZE__, &markSize, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(pPolyline, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with a local storage */ if (pPolyline != NULL && sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[row] == NULL) { sco->scope.cachedPolylinesUIDs[row] = strdup(pPolyline); releaseGraphicObjectProperty(__GO_PARENT__, pPolyline, jni_string, 1); } return sco->scope.cachedPolylinesUIDs[row]; }
/*--------------------------------------------------------------------------*/ int sci_xpoly(char * fname, unsigned long fname_len) { SciErr sciErr; int* piAddrl1 = NULL; double* l1 = NULL; int* piAddrl2 = NULL; double* l2 = NULL; int* piAddrl3 = NULL; char* l3 = NULL; int* piAddrl4 = NULL; double* l4 = NULL; char *psubwinUID = NULL; char* pobjUID = NULL; int m1 = 0, n1 = 0, m2 = 0 , n2 = 0, m4 = 0, n4 = 0, close = 0, mn2 = 0; long hdl = 0;/* NG */ int mark = 0;/* NG */ int markMode = 0; int lineMode = 0; int foreground = 0; int iTmp = 0; int* piTmp = &iTmp; CheckInputArgument(pvApiCtx, 2, 4); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2); return 1; } //CheckSameDims if (m1 != m2 || n1 != n2) { Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1); return 1; } mn2 = m2 * n2; if (nbInputArgument(pvApiCtx) >= 3) { sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrl3); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 3. if (getAllocatedSingleString(pvApiCtx, piAddrl3, &l3)) { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 3); return 1; } if (strcmp((l3), "lines") == 0) { strcpy(C2F(cha1).buf, "xlines"); mark = 1; /* NG */ } else if (strcmp((l3), "marks") == 0) { strcpy(C2F(cha1).buf, "xmarks"); mark = 0; /* NG */ } else { Scierror(999, _("%s: Wrong value for input argument #%d: '%s' or '%s' expected.\n"), fname, 3, "lines", "marks"); return 0; } } else { strcpy(C2F(cha1).buf, "xlines"); mark = 1; /* NG */ } if (nbInputArgument(pvApiCtx) >= 4) { sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrl4); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 4. sciErr = getMatrixOfDouble(pvApiCtx, piAddrl4, &m4, &n4, &l4); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 4); return 1; } //CheckScalar if (m4 != 1 || n4 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, 4); return 1; } close = (int) * (l4); } /* NG beg */ psubwinUID = (char*)getOrCreateDefaultSubwin(); Objpoly ((l1), (l2), mn2, close, mark, &hdl); pobjUID = (char*)getObjectFromHandle(hdl); /* the polyline newly created */ setGraphicObjectRelationship(psubwinUID, pobjUID); /* * The contour properties set calls below were * already present and have been updated for the MVC. */ if (mark == 0) { /* marks are enabled but markstyle & foreground is determined by parents' markstyle & foreground */ markMode = 1; lineMode = 0; getGraphicObjectProperty(psubwinUID, __GO_MARK_STYLE__, jni_int, (void**)&piTmp); setGraphicObjectProperty(pobjUID, __GO_MARK_STYLE__, piTmp, jni_int, 1); } else { markMode = 0; lineMode = 1; getGraphicObjectProperty(psubwinUID, __GO_LINE_STYLE__, jni_int, (void**)&piTmp); sciSetLineStyle(pobjUID, iTmp); } getGraphicObjectProperty(psubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piTmp); foreground = iTmp; setGraphicObjectProperty(pobjUID, __GO_LINE_COLOR__, &foreground, jni_int, 1); setGraphicObjectProperty(pobjUID, __GO_MARK_MODE__, &markMode, jni_bool, 1); setGraphicObjectProperty(pobjUID, __GO_LINE_MODE__, &lineMode, jni_bool, 1); /* NG end */ AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); freeAllocatedSingleString(l3); return 0; }
/*--------------------------------------------------------------------------*/ int sci_swap_handles(char * fname, unsigned long fname_len) { SciErr sciErr; int* piAddrfirstHdlStkIndex = NULL; long long* firstHdlStkIndex = NULL; int* piAddrsecondHdlStkIndex = NULL; long long* secondHdlStkIndex = NULL; int firstHdlCol = 0; int firstHdlRow = 0; int secondHdlCol = 0; int secondHdlRow = 0; char *pstHandle_1 = NULL; char *pstHandle_2 = NULL; char *pstParent_1 = NULL; char *pstParent_2 = NULL; int iChildrenCount = 0; int *piChildrenCount = &iChildrenCount; char **pstChildrenUID = NULL; int i = 0; long h = 0; CheckInputArgument(pvApiCtx, 2, 2); CheckOutputArgument(pvApiCtx, 0, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrfirstHdlStkIndex); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of handle at position 1. sciErr = getMatrixOfHandle(pvApiCtx, piAddrfirstHdlStkIndex, &firstHdlRow, &firstHdlCol, &firstHdlStkIndex); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrsecondHdlStkIndex); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of handle at position 2. sciErr = getMatrixOfHandle(pvApiCtx, piAddrsecondHdlStkIndex, &secondHdlRow, &secondHdlCol, &secondHdlStkIndex); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 2); return 1; } if (firstHdlRow * firstHdlCol != 1 || secondHdlRow * secondHdlCol != 1) { Scierror(999, _("%s: Routine can only swap two single handles.\n"), fname); return 0; } /* get the two handles and swap them */ h = (long) * (firstHdlStkIndex); pstHandle_1 = (char*)getObjectFromHandle(h); h = (long) * (secondHdlStkIndex); pstHandle_2 = (char*)getObjectFromHandle(h); getGraphicObjectProperty(pstHandle_1, __GO_PARENT__, jni_string, (void **)&pstParent_1); getGraphicObjectProperty(pstHandle_2, __GO_PARENT__, jni_string, (void **)&pstParent_2); // Check if objects do not have the same parent if (strcmp(pstParent_1, pstParent_2) == 0) { getGraphicObjectProperty(pstParent_1, __GO_CHILDREN_COUNT__, jni_int, (void **)&piChildrenCount); getGraphicObjectProperty(pstParent_1, __GO_CHILDREN__, jni_string_vector, (void **)&pstChildrenUID); for (i = 0 ; i < iChildrenCount ; ++i) { if (strcmp(pstChildrenUID[i], pstHandle_1) == 0) { pstChildrenUID[i] = pstHandle_2; } else if (strcmp(pstChildrenUID[i], pstHandle_2) == 0) { pstChildrenUID[i] = pstHandle_1; } } setGraphicObjectProperty(pstParent_1, __GO_CHILDREN__, pstChildrenUID, jni_string_vector, iChildrenCount); } else { setGraphicObjectRelationship(pstParent_1, pstHandle_2); setGraphicObjectRelationship(pstParent_2, pstHandle_1); } AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*------------------------------------------------------------------------*/ int set_parent_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol) { int iParentUID = 0; int iParentType = -1; int *piParentType = &iParentType; int iParentStyle = -1; int *piParentStyle = &iParentStyle; int iObjType = -1; int *piObjType = &iObjType; getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piObjType); if (iObjType == __GO_UICONTROL__) { if (valueType == sci_handles) { iParentUID = getObjectFromHandle((long)((long long*)_pvData)[0]); } else if (valueType == sci_matrix) { iParentUID = getFigureFromIndex((int)((double*)_pvData)[0]); } else { Scierror(999, _("Wrong type for '%s' property: '%s' handle or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } if (iParentUID == 0) { // Can not set the parent Scierror(999, _("Wrong value for '%s' property: A '%s' or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType != __GO_FIGURE__) { getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle); if (iParentType != __GO_UICONTROL__ || (iParentStyle != __GO_UI_FRAME__ && iParentStyle != __GO_UI_TAB__ && iParentStyle != __GO_UI_LAYER__)) { Scierror(999, _("Wrong value for '%s' property: A '%s' or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } } setGraphicObjectRelationship(iParentUID, iObjUID); return SET_PROPERTY_SUCCEED; } if (iObjType == __GO_UIMENU__) { if ((valueType != sci_handles) && (valueType != sci_matrix)) /* sci_matrix used for adding menus in console menu */ { Scierror(999, _("Wrong type for '%s' property: '%s' handle or '%s' handle expected.\n"), "Parent", "Figure", "Uimenu"); return SET_PROPERTY_ERROR; } else { return setMenuParent(iObjUID, _pvData, valueType, nbRow, nbCol); } } if (iObjType == __GO_AXES__) { if (valueType == sci_handles) { iParentUID = getObjectFromHandle((long)((long long*)_pvData)[0]); } else if (valueType == sci_matrix) { iParentUID = getFigureFromIndex((int)((double*)_pvData)[0]); } else { Scierror(999, _("Wrong type for '%s' property: '%s' handle or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } if (iParentUID == 0) { // Can not set the parent Scierror(999, _("Wrong value for '%s' property: A '%s' or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); if (iParentType != __GO_FIGURE__) { getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle); if (iParentStyle != __GO_UI_FRAME__) { Scierror(999, _("Wrong value for '%s' property: A '%s' or '%s' handle expected.\n"), "Parent", "Figure", "Frame uicontrol"); return SET_PROPERTY_ERROR; } } setGraphicObjectRelationship(iParentUID, iObjUID); return SET_PROPERTY_SUCCEED; } Scierror(999, _("Parent property can not be modified directly.\n")); return SET_PROPERTY_ERROR; }
/*------------------------------------------------ * plot3d *-----------------------------------------------*/ void Objplot3d (char * fname , int * isfac , int * izcol , double x[] , double y[] , double z[] , double * zcol , int * m , int * n , double * theta , double * alpha , char * legend, int * iflag , double * ebox , int * m1 , /*Adding F.Leray 12.03.04 and 19.03.04*/ int * n1 , int * m2 , int * n2 , int * m3 , int * n3 , int * m3n , int * n3n) /* F.Leray 25.04.05 : warning here legends means "X@Y@Z": it is labels writings!! */ /* legends has not the same meaning than inside plot2dn (there, it is really the legends of the plotted curves)*/ { sciTypeOf3D typeof3d; int flagcolor = 0; long *hdltab = NULL; int i = 0; char *psubwinUID = NULL; char *pobjUID = NULL; char *parentFigureUID = NULL; double drect[6]; double rotationAngles[2]; double* dataBounds = NULL; char * loc = NULL; char * legx = NULL; char * legy = NULL; char * legz = NULL; char* labelId = NULL; /* char * buff = NULL; */ int flag_x = 1; int flag_y = 1; int dimvectx = -1; int dimvecty = -1; int view = 0; int linLogFlag; int firstPlot = 0; int *piFirstPlot = &firstPlot; int box = 0; int axisVisible = 0; int autoScale = 0; int *piAutoScale = &autoScale; int isoview = 0; int clipState = 0; char *pNewSurfaceUID = NULL; /* Initialisation drect A.C pour debuggueur */ drect[0] = 0.0; drect[1] = 0.0; drect[2] = 0.0; drect[3] = 0.0; drect[4] = 0.0; drect[5] = 0.0; /* ================================================= * Force SubWindow properties according to arguments * ================================================= */ parentFigureUID = (char*)getCurrentFigure(); psubwinUID = (char*)getCurrentSubWin(); checkRedrawing(); /* Force 3D view */ view = 1; setGraphicObjectProperty(psubwinUID, __GO_VIEW__, &view, jni_int, 1); if (legend != NULL) { int textDimensions[2] = {1, 1}; /* F.Leray 25.04.05 replace the default labels by the user labels if specified */ loc = (char *) MALLOC((strlen(legend) + 1) * sizeof(char)); if (loc == NULL) { Scierror(999, _("%s: No more memory.\n"), "Objplot3d"); } strcpy(loc, legend); /* legx=strtok_r(loc,"@",&buff); */ legx = strtok(loc, "@"); if (legx != NULL) { getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_TEXT_ARRAY_DIMENSIONS__, textDimensions, jni_int_vector, 2); setGraphicObjectProperty(labelId, __GO_TEXT_STRINGS__, &legx, jni_string_vector, textDimensions[0]*textDimensions[1]); } /* legy=strtok_r((char *)0,"@",&buff); */ legy = strtok((char *)NULL, "@"); /* NULL to begin at the last read character */ if (legy != NULL) { getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_TEXT_ARRAY_DIMENSIONS__, textDimensions, jni_int_vector, 2); setGraphicObjectProperty(labelId, __GO_TEXT_STRINGS__, &legy, jni_string_vector, textDimensions[0]*textDimensions[1]); } /* legz=strtok_r((char *)0,"@",&buff); */ legz = strtok((char *)NULL, "@"); if (legz != NULL) { getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_TEXT_ARRAY_DIMENSIONS__, textDimensions, jni_int_vector, 2); setGraphicObjectProperty(labelId, __GO_TEXT_STRINGS__, &legz, jni_string_vector, textDimensions[0]*textDimensions[1]); } } /* Force psubwin->logflags to linear */ linLogFlag = 0; setGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LOG_FLAG__, &linLogFlag, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_FIRST_PLOT__, jni_bool, (void **)&piFirstPlot); if (firstPlot == 0 && (iflag[2] == 0 || iflag[2] == 1)) { /* Nothing to do: we leave as before */ } else { int labelVisible; if (iflag[2] == 0 || iflag[2] == 1) { if (firstPlot) { /* 0: OFF */ box = 0; axisVisible = 0; setGraphicObjectProperty(psubwinUID, __GO_X_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_BOX_TYPE__, &box, jni_int, 1); labelVisible = 0; getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); } /*else no changes : the axes visible properties are driven by the previous plot */ } else if (iflag[2] == 2) { /* 2: HIDDEN_AXES */ box = 2; /* for 2d use only (when switching to 2d mode) */ setGraphicObjectProperty(psubwinUID, __GO_BOX_TYPE__, &box, jni_int, 1); axisVisible = 0; setGraphicObjectProperty(psubwinUID, __GO_X_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); labelVisible = 0; getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); } else if (iflag[2] == 3) { /* 1: ON */ box = 1; /* for 2d use only (when switching to 2d mode) */ setGraphicObjectProperty(psubwinUID, __GO_BOX_TYPE__, &box, jni_int, 1); axisVisible = 0; setGraphicObjectProperty(psubwinUID, __GO_X_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); labelVisible = 1; getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); } else if (iflag[2] == 4) { /* 1: ON */ box = 1; setGraphicObjectProperty(psubwinUID, __GO_BOX_TYPE__, &box, jni_int, 1); axisVisible = 1; setGraphicObjectProperty(psubwinUID, __GO_X_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); labelVisible = 1; getGraphicObjectProperty(psubwinUID, __GO_X_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Y_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); getGraphicObjectProperty(psubwinUID, __GO_Z_AXIS_LABEL__, jni_string, (void **)&labelId); setGraphicObjectProperty(labelId, __GO_VISIBLE__, &labelVisible, jni_bool, 1); } } rotationAngles[0] = *alpha; rotationAngles[1] = *theta; setGraphicObjectProperty(psubwinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2); getGraphicObjectProperty(psubwinUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&dataBounds); getGraphicObjectProperty(psubwinUID, __GO_AUTO_SCALE__, jni_bool, (void **)&piAutoScale); if (autoScale) { /* compute and merge new specified bounds with data bounds */ switch (iflag[1]) { case 0: /* do not change data bounds */ break; case 1 : case 3 : case 5 : case 7 : /* Force data bounds=ebox */ drect[0] = ebox[0]; /*xmin*/ drect[2] = ebox[2]; /*ymin*/ drect[1] = ebox[1]; /*xmax*/ drect[3] = ebox[3]; /*ymax*/ drect[4] = ebox[4]; /*zmin*/ drect[5] = ebox[5]; /*zmax*/ break; case 2 : case 4 : case 6 : case 8:/* Force data bounds to the x and y bounds */ getDrect(x, (*m1) * (*n1), &drect[0], &drect[1], dataBounds[0], dataBounds[1]); getDrect(y, (*m2) * (*n2), &drect[2], &drect[3], dataBounds[2], dataBounds[3]); getDrect(z, (*m3) * (*n3), &drect[4], &drect[5], dataBounds[4], dataBounds[5]); break; } /* merge data bounds and drect */ if (!firstPlot) { drect[0] = Min(dataBounds[0], drect[0]); /* xmin */ drect[1] = Max(dataBounds[1], drect[1]); /* xmax */ drect[2] = Min(dataBounds[2], drect[2]); /* ymin */ drect[3] = Max(dataBounds[3], drect[3]); /* ymax */ drect[4] = Min(dataBounds[4], drect[4]); /* zmin */ drect[5] = Max(dataBounds[5], drect[5]); /* zmax */ } if (iflag[1] != 0) { setGraphicObjectProperty(psubwinUID, __GO_DATA_BOUNDS__, drect, jni_double_vector, 6); } } if (iflag[1] != 0) { isoview = (iflag[1] == 3 || iflag[1] == 4 || iflag[1] == 5 || iflag[1] == 6); setGraphicObjectProperty(psubwinUID, __GO_ISOVIEW__, &isoview, jni_bool, 1); } /* ================================================= * Analyze arguments to find entity type * ================================================= */ if (*isfac == 1) { if (*izcol == 0) { if (strcmp(fname, "plot3d1") == 0) { typeof3d = SCI_FAC3D; flagcolor = 1; } else { typeof3d = SCI_FAC3D; flagcolor = 0; } } else if (*izcol == 2) { typeof3d = SCI_FAC3D; flagcolor = 3; } else { typeof3d = SCI_FAC3D; flagcolor = 2; } } else if (*isfac == 0) { if (strcmp(fname, "plot3d1") == 0) { typeof3d = SCI_PLOT3D; flagcolor = 1; } else { typeof3d = SCI_PLOT3D; flagcolor = 0; } } else { typeof3d = SCI_PARAM3D1; flagcolor = 1; } /* ================================================= * Construct the Entities * ================================================= */ /*Distinction here between SCI_PARAM3D1 and others*/ if (typeof3d != SCI_PARAM3D1) { if (*isfac == 1) { /* x is considered as a matrix */ dimvectx = -1; } else if (*m1 == 1) /* x is a row vector */ { dimvectx = *n1; } else if (*n1 == 1) /* x is a column vector */ { dimvectx = *m1; } else /* x is a matrix */ { dimvectx = -1; } if (dimvectx > 1) { int monotony = checkMonotony(x, dimvectx); if (monotony == 0) { Scierror(999, _("%s: x vector is not monotonous.\n"), "Objplot3d"); return; } flag_x = monotony; } if (*isfac == 1) { /* y is considered as a matrix */ dimvecty = -1; } else if (*m2 == 1) /* y is a row vector */ { dimvecty = *n2; } else if (*n2 == 1) /* y is a column vector */ { dimvecty = *m2; } else /* y is a matrix */ { dimvecty = -1; } if (dimvecty > 1) { /* test the monotony on y*/ int monotony = checkMonotony(y, dimvecty); if (monotony == 0) { Scierror(999, _("%s: y vector is not monotonous.\n"), "Objplot3d"); return; } flag_y = monotony; } pNewSurfaceUID = ConstructSurface(psubwinUID, typeof3d, x, y, z, zcol, *izcol, *m, *n, iflag, ebox, flagcolor, isfac, m1, n1, m2, n2, m3, n3, m3n, n3n); if (pNewSurfaceUID == NULL) { Scierror(999, _("%s: No more memory.\n"), "Objplot3d"); return; } setCurrentObject(pNewSurfaceUID); /* Force clipping, 1: CLIPGRF */ clipState = 1; setGraphicObjectProperty(pNewSurfaceUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); releaseGraphicObjectProperty(__GO_PARENT__, pNewSurfaceUID, jni_string, 1); } else { char* pNewPolylineUID = NULL; char* currentSubwinUID = NULL; if ((hdltab = MALLOC (*n * sizeof (long))) == NULL) { Scierror(999, "%s: No more memory.\n", fname); return; } currentSubwinUID = (char*)getCurrentSubWin(); for (i = 0; i < *n; ++i) { /* F.Leray Pb here: In fact we do not create a Surface but one or several 3D Polylines Pb comes when wanting to access the fields "surface_color" or "flag" for example in function sciSet (cf. matdes.c). Question 1: Are these properties accessible from a SCI_PARAM3D1 ? Question 2: Is "flag" obsolete and replaced by "color_mode"?*/ if ((*n > 0) && (zcol != (double *)NULL)) { if ((int) zcol[i] > 0) { int intzcol = (int) zcol[i]; pNewPolylineUID = ConstructPolyline (currentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, &intzcol, NULL, NULL, NULL, NULL, TRUE, FALSE, FALSE, FALSE); } else { int intzcol = (int) - zcol[i]; pNewPolylineUID = ConstructPolyline (currentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, NULL, NULL, &intzcol, NULL, NULL, FALSE, FALSE, TRUE, FALSE); } } else { /* default case, nothing is given */ int curcolor = 0; int *piCurColor = &curcolor; getGraphicObjectProperty(currentSubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piCurColor); pNewPolylineUID = ConstructPolyline(currentSubwinUID, &(x[*m * i]), &(y[*m * i]), &(z[*m * i]), 0, *m, 1, &curcolor, NULL, NULL, NULL, NULL, TRUE, FALSE, FALSE, FALSE); } if (pNewPolylineUID == NULL) { Scierror(999, _("%s: No more memory.\n"), fname); FREE(hdltab); return; } setCurrentObject(pNewPolylineUID); setGraphicObjectRelationship(currentSubwinUID, pNewPolylineUID); releaseGraphicObjectProperty(__GO_PARENT__, pNewPolylineUID, jni_string, 1); pNewPolylineUID = NULL; pobjUID = (char*)getCurrentObject(); /* Force clipping, 1: CLIPGRF */ clipState = 1; setGraphicObjectProperty(pobjUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); hdltab[i] = getHandle(pobjUID); } /** construct Compound and make it current object**/ if (*n > 1) { char* o = ConstructCompound (hdltab, *n); setCurrentObject(o); releaseGraphicObjectProperty(__GO_PARENT__, o, jni_string, 1); } FREE(hdltab); } /* ================================================= * Redraw Figure * ================================================= */ // subwin has been modified firstPlot = 0; setGraphicObjectProperty(psubwinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); FREE(loc); loc = NULL; }
/* DJ.A 08/01/04 */ int C2F(graphicsmodels) (void) { double margins[4]; double clipRegion[4]; int clipRegionSet = 0; int firstPlot = 0; int result = 0; int iFiguremdlUID = 0; int iAxesmdlUID = 0; /* ** Init Figure Model */ // Create default figure by Asking MVC a new one. iFiguremdlUID = createGraphicObject(__GO_FIGUREMODEL__); setFigureModel(iFiguremdlUID); InitFigureModel(iFiguremdlUID); sciInitGraphicMode(iFiguremdlUID); /* ** Init Axes Model */ // Create default Axes by Asking MVC a new one. iAxesmdlUID = createGraphicObject(__GO_AXESMODEL__); setAxesModel(iAxesmdlUID); /* Sets the parent-child relationship between the default Figure and Axes */ setGraphicObjectRelationship(iFiguremdlUID, iAxesmdlUID); /* Axes Model properties */ result = InitAxesModel(); if (result < 0) { strcpy(error_message, _("Default axes cannot be created.\n")); return 0; } /* Margins and clip region */ margins[0] = 0.125; margins[1] = 0.125; margins[2] = 0.125; margins[3] = 0.125; setGraphicObjectProperty(iAxesmdlUID, __GO_MARGINS__, margins, jni_double_vector, 4); clipRegion[0] = 0.0; clipRegion[1] = 0.0; clipRegion[2] = 0.0; clipRegion[3] = 0.0; setGraphicObjectProperty(iAxesmdlUID, __GO_CLIP_BOX__, clipRegion, jni_double_vector, 4); clipRegionSet = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_CLIP_BOX_SET__, &clipRegionSet, jni_bool, 1); /* * Specifies that no high-level drawing function has been called yet. */ firstPlot = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); #if 0 ppaxesmdl->FirstPlot = TRUE; #endif return 1; }
static char *getPolyline(char *pAxeUID, scicos_block * block, int input, int row) { char *pPolyline; double d__0 = 0.0; BOOL b__true = TRUE; int color; 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.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[input] != NULL && sco->scope.cachedPolylinesUIDs[input][row] != NULL) { return sco->scope.cachedPolylinesUIDs[input][row]; } pPolyline = findChildWithKindAt(pAxeUID, __GO_POLYLINE__, row); /* * Allocate if necessary */ if (pPolyline == NULL) { pPolyline = createGraphicObject(__GO_POLYLINE__); if (pPolyline != NULL) { createDataObject(pPolyline, __GO_POLYLINE__); setGraphicObjectRelationship(pAxeUID, pPolyline); } } /* * Setup on first access */ if (pPolyline != NULL) { /* * Default setup (will crash if removed) */ { int polylineSize[2] = { 1, block->ipar[2] }; setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, polylineSize, jni_int_vector, 2); } setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_X__, &d__0, jni_double_vector, 1); setGraphicObjectProperty(pPolyline, __GO_DATA_MODEL_Y__, &d__0, jni_double_vector, 1); // ipar=[win;size(in,'*');N;wpos(:);wdim(:);in(:);clrs(:);heritance] // 1 1 1 2 2 nin nin 1 color = block->ipar[7 + block->nin + input + row]; if (color > 0) { LOG("%s: %s at %d at %d to %d\n", "cmscope", "set lines mode", input, row, color); setGraphicObjectProperty(pPolyline, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_LINE_COLOR__, &color, jni_int, 1); } else { color = -color; LOG("%s: %s at %d at %d to %d\n", "cmscope", "set mark mode", input, row, -color); setGraphicObjectProperty(pPolyline, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(pPolyline, __GO_MARK_STYLE__, &color, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(pPolyline, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } } /* * then cache with local storage */ if (sco->scope.cachedPolylinesUIDs != NULL && sco->scope.cachedPolylinesUIDs[input] != NULL) { sco->scope.cachedPolylinesUIDs[input][row] = strdup(pPolyline); releaseGraphicObjectProperty(__GO_PARENT__, pPolyline, jni_string, 1); } return sco->scope.cachedPolylinesUIDs[input][row]; }
/*--------------------------------------------------------------------------*/ int sci_swap_handles( char * fname, unsigned long fname_len ) { int firstHdlCol ; int firstHdlRow ; int secondHdlCol ; int secondHdlRow ; int firstHdlStkIndex ; int secondHdlStkIndex ; char *pstHandle_1; char *pstHandle_2; char *pstParent_1; char *pstParent_2; int iChildrenCount = 0; int *piChildrenCount = &iChildrenCount; char **pstChildrenUID; int i = 0; long h = 0; CheckRhs( 2, 2 ) ; CheckLhs( 0, 1 ) ; GetRhsVar( 1,GRAPHICAL_HANDLE_DATATYPE, &firstHdlRow, &firstHdlCol, &firstHdlStkIndex ); GetRhsVar( 2,GRAPHICAL_HANDLE_DATATYPE, &secondHdlRow, &secondHdlCol, &secondHdlStkIndex ); if ( firstHdlRow * firstHdlCol != 1 || secondHdlRow * secondHdlCol != 1 ) { Scierror(999,_("%s: Routine can only swap two single handles.\n"),fname); return 0 ; } /* get the two handles and swap them */ h = (long)*hstk(firstHdlStkIndex); pstHandle_1 = getObjectFromHandle(h); h = (long)*hstk(secondHdlStkIndex); pstHandle_2 = getObjectFromHandle(h); getGraphicObjectProperty(pstHandle_1, __GO_PARENT__, jni_string, &pstParent_1); getGraphicObjectProperty(pstHandle_2, __GO_PARENT__, jni_string, &pstParent_2); // Check if objects do not have the same parent if (strcmp(pstParent_1, pstParent_2) == 0) { getGraphicObjectProperty(pstParent_1, __GO_CHILDREN_COUNT__, jni_int, (void **)&piChildrenCount); getGraphicObjectProperty(pstParent_1, __GO_CHILDREN__, jni_string_vector, (void **)&pstChildrenUID); for (i = 0 ; i < iChildrenCount ; ++i) { if (strcmp(pstChildrenUID[i], pstHandle_1) == 0) { pstChildrenUID[i] = pstHandle_2; } else if (strcmp(pstChildrenUID[i], pstHandle_2) == 0) { pstChildrenUID[i] = pstHandle_1; } } setGraphicObjectProperty(pstParent_1, __GO_CHILDREN__, pstChildrenUID, jni_string_vector, iChildrenCount); } else { setGraphicObjectRelationship(pstParent_1, pstHandle_2); setGraphicObjectRelationship(pstParent_2, pstHandle_1); } LhsVar(1) = 0 ; PutLhsVar(); return 0 ; }
static int getSegs(int iAxeUID, scicos_block * block, int input) { int iSegs; BOOL b__true = TRUE; double d__1 = 1.0; double d__0 = 0.0; int color; sco_data *sco = getScoData(block); // assert the sco is not NULL if (sco == NULL || sco->scope.cachedSegsUIDs == NULL) { return 0; } // fast path for an existing object if (sco->scope.cachedSegsUIDs[input]) { return sco->scope.cachedSegsUIDs[input]; } iSegs = findChildWithKindAt(iAxeUID, __GO_SEGS__, input); /* * Allocate if necessary */ if (iSegs == 0) { iSegs = createGraphicObject(__GO_SEGS__); if (iSegs != 0) { createDataObject(iSegs, __GO_SEGS__); setGraphicObjectRelationship(iAxeUID, iSegs); } else { return 0; } } /* * Setup on first access */ setGraphicObjectProperty(iSegs, __GO_NUMBER_ARROWS__, &sco->internal.maxNumberOfPoints[input], jni_int, 1); // Setup properties setGraphicObjectProperty(iSegs, __GO_LINE_THICKNESS__, &d__1, jni_double, 1); setGraphicObjectProperty(iSegs, __GO_ARROW_SIZE__, &d__0, jni_double, 1); color = block->ipar[2 + input]; if (color > 0) { setGraphicObjectProperty(iSegs, __GO_LINE_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(iSegs, __GO_SEGS_COLORS__, &color, jni_int_vector, 1); } else { int iMarkSize = 4; color = -color; setGraphicObjectProperty(iSegs, __GO_MARK_MODE__, &b__true, jni_bool, 1); setGraphicObjectProperty(iSegs, __GO_MARK_STYLE__, &color, jni_int, 1); setGraphicObjectProperty(iSegs, __GO_MARK_SIZE__, &iMarkSize, jni_int, 1); } { int iClipState = 1; //on setGraphicObjectProperty(iSegs, __GO_CLIP_STATE__, &iClipState, jni_int, 1); } /* * then cache with a local storage */ sco->scope.cachedSegsUIDs[input] = iSegs; return sco->scope.cachedSegsUIDs[input]; }
/*--------------------------------------------------------------------------*/ int sci_xrect( char *fname, unsigned long fname_len ) { long hdl = 0; int m1 = 0,n1 = 0,l1 = 0,m2 = 0,n2 = 0,l2 = 0,m3 = 0,n3 = 0,l3 = 0,m4 = 0,n4 = 0,l4 = 0; char* psubwinUID = NULL; int foreground = 0; int *piForeground = &foreground; CheckRhs(1,4); psubwinUID = (char*)getOrCreateDefaultSubwin(); switch( Rhs ) { case 1 : GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l1); CheckLength(1,m1*n1,4); getGraphicObjectProperty(psubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piForeground); if (strcmp(fname,"xrect")==0) { Objrect (stk(l1),stk(l1+1),stk(l1+2),stk(l1+3), &foreground,NULL,FALSE,TRUE,&hdl); } else { /* xfrect case */ Objrect (stk(l1),stk(l1+1),stk(l1+2),stk(l1+3), NULL,&foreground,TRUE,FALSE,&hdl); } if ( hdl < 0 ) { break; } break; case 4 : getGraphicObjectProperty(psubwinUID, __GO_LINE_COLOR__, jni_int, (void**)&piForeground); GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&m1,&n1,&l1); CheckScalar(1,m1,n1); GetRhsVar(2,MATRIX_OF_DOUBLE_DATATYPE,&m2,&n2,&l2); CheckScalar(2,m2,n2); GetRhsVar(3,MATRIX_OF_DOUBLE_DATATYPE,&m3,&n3,&l3); CheckScalar(3,m3,n3); GetRhsVar(4,MATRIX_OF_DOUBLE_DATATYPE,&m4,&n4,&l4); CheckScalar(4,m4,n4); if (strcmp(fname,"xrect")==0) { Objrect (stk(l1),stk(l2),stk(l3),stk(l4), &foreground,NULL,FALSE,TRUE,&hdl); } else { Objrect (stk(l1),stk(l2),stk(l3),stk(l4), NULL,&foreground,TRUE,FALSE,&hdl); } if ( hdl < 0 ) { break; } break; default : Scierror(999,_("%s: Wrong number of input argument(s): %d or %d expected.\n"),fname, 1,4); break ; } if ( hdl > 0 ) { setGraphicObjectRelationship(psubwinUID, getObjectFromHandle(hdl)); LhsVar(1)=0; PutLhsVar(); } return 0; }