QgsGeometry *QgsRubberBand::asGeometry() { QgsGeometry *geom = NULL; switch ( mGeometryType ) { case QGis::Polygon: { QgsPolygon polygon; QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin(); for ( ; it != mPoints.constEnd(); ++it ) { polygon.append( getPolyline( *it ) ); } geom = QgsGeometry::fromPolygon( polygon ); break; } case QGis::Point: { QgsMultiPoint multiPoint; QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin(); for ( ; it != mPoints.constEnd(); ++it ) { multiPoint += getPolyline( *it ); } geom = QgsGeometry::fromMultiPoint( multiPoint ); break; } case QGis::Line: default: { if ( mPoints.size() > 0 ) { if ( mPoints.size() > 1 ) { QgsMultiPolyline multiPolyline; QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin(); for ( ; it != mPoints.constEnd(); ++it ) { multiPolyline.append( getPolyline( *it ) ); } geom = QgsGeometry::fromMultiPolyline( multiPolyline ); } else { geom = QgsGeometry::fromPolyline( getPolyline( mPoints[0] ) ); } } break; } } return geom; }
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 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 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; 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 != 0) { 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 polylines through the getter for (i = 0; i < block->insz[0]; i++) { getPolyline(iAxe, block, i); } } else { return 0; } /* * then cache with a local storage */ sco->scope.cachedAxeUID = iAxe; return sco->scope.cachedAxeUID; }
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); }