static BOOL setSegsBuffers(scicos_block * block, int maxNumberOfPoints) { int iFigureUID; int iAxeUID; int iSegsUID; int i; int nclk = block->nipar - 6; BOOL result = TRUE; int color; iFigureUID = getFigure(block); iAxeUID = getAxe(iFigureUID, block); for (i = 0; i < nclk; i++) { iSegsUID = getSegs(iAxeUID, block, i); result = setGraphicObjectProperty(iSegsUID, __GO_NUMBER_ARROWS__, &maxNumberOfPoints, jni_int, 1); /* * Update color due to bug #9902 * http://bugzilla.scilab.org/show_bug.cgi?id=9902 */ color = block->ipar[2 + i]; if (color > 0) { setGraphicObjectProperty(iSegsUID, __GO_SEGS_COLORS__, &color, jni_int_vector, 1); } } return result; }
static BOOL setPolylinesBounds(scicos_block * block) { char const* pFigureUID; char *pAxeUID; BOOL result; double dataBounds[6]; double rotationAngle[2]; dataBounds[0] = block->rpar[0]; // xMin dataBounds[1] = block->rpar[1]; // xMax dataBounds[2] = block->rpar[2]; // yMin dataBounds[3] = block->rpar[3]; // yMax dataBounds[4] = block->rpar[4]; // zMin dataBounds[5] = block->rpar[5]; // zMax rotationAngle[0] = block->rpar[6]; // alpha rotationAngle[1] = block->rpar[7]; // theta pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block); result = setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6); result &= setGraphicObjectProperty(pAxeUID, __GO_ROTATION_ANGLES__, rotationAngle, jni_double_vector, 2); return result; }
static char const* getFigure(scicos_block * block) { signed int figNum; char const* pFigureUID = NULL; char *pAxe = NULL; int i__1 = 1; 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.cachedFigureUID != NULL) { return sco->scope.cachedFigureUID; } figNum = block->ipar[0]; // with a negative id, use the block number indexed from a constant. if (figNum < 0) { figNum = 20000 + get_block_number(); } pFigureUID = getFigureFromIndex(figNum); // create on demand if (pFigureUID == NULL) { pFigureUID = createNewFigureWithAxes(); setGraphicObjectProperty(pFigureUID, __GO_ID__, &figNum, jni_int, 1); // the stored uid is a reference to the figure map, not to the current figure pFigureUID = getFigureFromIndex(figNum); sco->scope.cachedFigureUID = pFigureUID; setGraphicObjectProperty(pFigureUID, __GO_COLORMAP__, &block->rpar[2], jni_double_vector, block->ipar[2]); // allocate the axes through the getter pAxe = getAxe(pFigureUID, block); /* * Setup according to block settings */ setLabel(pAxe, __GO_X_AXIS_LABEL__, "x"); setLabel(pAxe, __GO_Y_AXIS_LABEL__, "y"); setGraphicObjectProperty(pAxe, __GO_X_AXIS_VISIBLE__, &i__1, jni_bool, 1); setGraphicObjectProperty(pAxe, __GO_Y_AXIS_VISIBLE__, &i__1, jni_bool, 1); } if (pFigureUID != NULL && sco->scope.cachedFigureUID == NULL) { sco->scope.cachedFigureUID = pFigureUID; } return pFigureUID; }
static BOOL pushData(scicos_block * block, int input, int row) { char const* pFigureUID; char *pAxeUID; char *pPolylineUID; double *data; sco_data *sco; BOOL result = TRUE; pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block, input); pPolylineUID = getPolyline(pAxeUID, block, input, row); sco = getScoData(block); if (sco == NULL) return FALSE; // select the right input and row data = sco->internal.data[input][row]; result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_X__, sco->internal.time[input], jni_double_vector, sco->internal.maxNumberOfPoints[input]); result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_Y__, data, jni_double_vector, sco->internal.maxNumberOfPoints[input]); return result; }
static BOOL setPolylinesBounds(scicos_block * block, int input, int periodCounter) { char const* pFigureUID; char *pAxeUID; double dataBounds[6]; int nin = block->nin; double period = block->rpar[block->nrpar - 3 * nin + input]; dataBounds[0] = periodCounter * period; // xMin dataBounds[1] = (periodCounter + 1) * period; // xMax dataBounds[2] = block->rpar[block->nrpar - 2 * nin + 2 * input]; // yMin dataBounds[3] = block->rpar[block->nrpar - 2 * nin + 2 * input + 1]; // yMax dataBounds[4] = -1.0; // zMin dataBounds[5] = 1.0; // zMax #ifndef S_SPLINT_S LOG("%s: %s at %d to %f\n", "cmscope", "setPolylinesBounds", input, dataBounds[1]); #endif /* !S_SPLINT_S */ pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block, input); return setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6); }
static BOOL setPolylinesBuffers(scicos_block * block, int input, int maxNumberOfPoints) { int i; char const* pFigureUID; char *pAxeUID; char *pPolylineUID; BOOL result = TRUE; int polylineSize[2] = { 1, maxNumberOfPoints }; #ifndef S_SPLINT_S LOG("%s: %s at %d to %d\n", "cmscope", "setPolylinesBuffers", input, maxNumberOfPoints); #endif /* !S_SPLINT_S */ pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block, input); for (i = 0; i < block->insz[input]; i++) { pPolylineUID = getPolyline(pAxeUID, block, input, i); result &= setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__, polylineSize, jni_int_vector, 2); } return result; }
static BOOL pushData(scicos_block * block, double *data) { char const* pFigureUID; char *pAxeUID; char *pGrayplotUID; BOOL result; int i; int m, n; double alpha, beta; double *scaledData; pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block); pGrayplotUID = getGrayplot(pAxeUID, block); m = GetInPortSize(block, 1, 1); n = GetInPortSize(block, 1, 2); if (m * n <= 0) { set_block_error(-5); return FALSE; } /* * Scale the data */ alpha = block->rpar[0]; beta = block->rpar[1]; scaledData = (double *)MALLOC(m * n * sizeof(double)); if (scaledData == NULL) { return FALSE; } for (i = 0; i < m * n; i++) { scaledData[i] = floor(alpha * data[i] + beta); } result = setGraphicObjectProperty(pGrayplotUID, __GO_DATA_MODEL_Z__, scaledData, jni_double_vector, m * n); FREE(scaledData); return result; }
static BOOL setPolylinesBounds(scicos_block * block) { char const* pFigureUID; char *pAxeUID; double dataBounds[6]; dataBounds[0] = block->rpar[0]; // xMin dataBounds[1] = block->rpar[1]; // xMax dataBounds[2] = block->rpar[2]; // yMin dataBounds[3] = block->rpar[3]; // yMax dataBounds[4] = -1.0; // zMin dataBounds[5] = 1.0; // zMax pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block); return setGraphicObjectProperty(pAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6); }
static BOOL pushData(scicos_block * block, double *data) { char const* pFigureUID; char *pAxeUID; char *pPlot3dUID; BOOL result; int m, n; pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block); pPlot3dUID = getPlot3d(pAxeUID, block); m = GetInPortSize(block, 1, 1); n = GetInPortSize(block, 1, 2); result = setGraphicObjectProperty(pPlot3dUID, __GO_DATA_MODEL_Z__, data, jni_double_vector, m * n); return result; }
static BOOL pushData(scicos_block * block, double *data) { int iFigureUID; int iAxeUID; int iPlot3dUID; BOOL result; int m, n; iFigureUID = getFigure(block); iAxeUID = getAxe(iFigureUID, block); iPlot3dUID = getPlot3d(iAxeUID, block); m = GetInPortSize(block, 1, 1); n = GetInPortSize(block, 1, 2); result = setGraphicObjectProperty(iPlot3dUID, __GO_DATA_MODEL_Z__, data, jni_double_vector, m * n); return result; }
static BOOL pushData(scicos_block * block, int input) { int iFigureUID; int iAxeUID; int iSegsUID; int dataLen; double *base; double *direction; sco_data *sco; BOOL result; iFigureUID = getFigure(block); iAxeUID = getAxe(iFigureUID, block); iSegsUID = getSegs(iAxeUID, block, input); sco = getScoData(block); if (sco == NULL) { return FALSE; } // select the right input and row base = sco->internal.data[2 * input]; direction = sco->internal.data[2 * input + 1]; dataLen = 3 * sco->internal.maxNumberOfPoints[input]; result = setGraphicObjectProperty(iSegsUID, __GO_BASE__, base, jni_double_vector, dataLen); if (result == FALSE) { return result; } result = setGraphicObjectProperty(iSegsUID, __GO_DIRECTION__, direction, jni_double_vector, dataLen); return result; }
static BOOL pushData(scicos_block * block, int row) { char const* pFigureUID; char *pAxeUID; char *pPolylineUID; double *coordinates; sco_data *sco; pFigureUID = getFigure(block); pAxeUID = getAxe(pFigureUID, block); pPolylineUID = getPolyline(pAxeUID, block, row); sco = getScoData(block); if (sco == NULL) { return FALSE; } // select the right input and row coordinates = sco->internal.coordinates[row]; return setGraphicObjectProperty(pPolylineUID, __GO_DATA_MODEL_COORDINATES__, coordinates, jni_double_vector, sco->internal.maxNumberOfPoints); }
static int getFigure(scicos_block * block) { signed int figNum; int iFigureUID = 0; int iAxe = 0; int i__1 = 1; 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.cachedFigureUID) { return sco->scope.cachedFigureUID; } figNum = block->ipar[0]; // with a negative id, use the block number indexed from a constant. if (figNum < 0) { figNum = 20000 + get_block_number(); } iFigureUID = getFigureFromIndex(figNum); // create on demand if (iFigureUID == 0) { iFigureUID = createNewFigureWithAxes(); setGraphicObjectProperty(iFigureUID, __GO_ID__, &figNum, jni_int, 1); // the stored uid is a reference to the figure map, not to the current figure iFigureUID = getFigureFromIndex(figNum); sco->scope.cachedFigureUID = iFigureUID; // set configured parameters setFigureSettings(iFigureUID, block); // allocate the axes through the getter iAxe = getAxe(iFigureUID, block); /* * Setup according to block settings */ setLabel(iAxe, __GO_X_AXIS_LABEL__, "t"); setLabel(iAxe, __GO_Y_AXIS_LABEL__, "y"); setGraphicObjectProperty(iAxe, __GO_X_AXIS_VISIBLE__, &i__1, jni_bool, 1); setGraphicObjectProperty(iAxe, __GO_Y_AXIS_VISIBLE__, &i__1, jni_bool, 1); setBounds(block, iAxe, 0); } if (sco->scope.cachedFigureUID == 0) { sco->scope.cachedFigureUID = iFigureUID; } return iFigureUID; }
static void appendData(scicos_block * block, int input, double t) { sco_data *sco = getScoData(block); int maxNumberOfPoints = sco->internal.maxNumberOfPoints[input]; int numberOfPoints = sco->internal.numberOfPoints[input]; int i; int nclk = block->nipar - 6; /* * Handle the case where the t is greater than the data_bounds */ if (t > ((sco->scope.periodCounter + 1) * block->rpar[0])) { sco->scope.periodCounter++; // reset the number of points for all the segs numberOfPoints = 0; for (i = 0; i < nclk; i++) { sco->internal.numberOfPoints[i] = 0; } if (setBounds(block, getAxe(getFigure(block), block), sco->scope.periodCounter) == FALSE) { set_block_error(-5); freeScoData(block); sco = NULL; } } /* * Handle the case where the scope has more points than maxNumberOfPoints */ if (sco != NULL && numberOfPoints >= maxNumberOfPoints) { // on a full scope, re-alloc maxNumberOfPoints = maxNumberOfPoints + DEFAULT_MAX_NUMBER_OF_POINTS; sco = reallocScoData(block, input, maxNumberOfPoints); // reconfigure related graphic objects if (setSegsBuffers(block, maxNumberOfPoints) == FALSE) { set_block_error(-5); freeScoData(block); sco = NULL; } } /* * Update data */ if (sco != NULL) { int setLen; /* * Base pointer */ for (setLen = maxNumberOfPoints - numberOfPoints - 1; setLen >= 0; setLen--) { sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 0] = t; // x sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 1] = 0; // y sco->internal.data[2 * input + 0][3 * (numberOfPoints + setLen) + 2] = (double) input; // z } /* * Direction pointer */ for (setLen = maxNumberOfPoints - numberOfPoints - 1; setLen >= 0; setLen--) { sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 0] = t; // x sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 1] = 0.8; // y sco->internal.data[2 * input + 1][3 * (numberOfPoints + setLen) + 2] = (double) input; // z } sco->internal.numberOfPoints[input]++; } }