2 * High - level editing operations for fGIS raster editor
10 char *mapErrorExplanation[]={NULL,
11 "Coordinates outside physical borders of file",
12 "Raster is not editable",
18 "File doesn't conform format",
19 "File creation error",
22 * Checks if given EPP file is open in read-write mode and
23 * given value is good class value for it.
24 * Should be called each time when one of drawing routines from
25 * this file is about to be called.
26 * Returns TCL_ERROR and leaves error message in interp->result
28 int Fgis_RasterEditable(Tcl_Interp *interp,EPP *epp,char *rastername,int value)
29 { if (!(epp->mode&MAP_LOADED)) {
30 Tcl_AppendResult(interp,"Raster ",rastername," is read-only",NULL);
33 if (value>=(1<<epp->kind)) {
34 Tcl_SetResult(interp,"Value too large for this raster",TCL_STATIC);
41 * Modifies given cell.
42 * Return value: 0 on success, nonzero if error
43 * Side effects: modifies raster if arguments are good
44 * leaves error message in interp->result, if they are bad
46 int Fgis_DrawCell(Tcl_Interp *interp,EPP* epp,double x,double y, int value)
49 epp_put(epp,epp_col(epp,x),epp_row(epp,y),value);
51 Tcl_SetResult(interp,mapErrorExplanation[map_error],TCL_STATIC);
59 * Draws circle with center in given point and radius given in
63 int Fgis_DrawCircle(Tcl_Interp *interp,EPP* epp,double x,double y,double r,
70 * Draws circle with center in given point and radius given in
74 int Fgis_DrawCircleInt(Tcl_Interp *interp, EPP *epp, double x, double y,
80 * Draws filled rectangle
85 int Fgis_DrawBox(Tcl_Interp *interp, EPP *epp, double x1, double y1,
86 double x2, double y2, int value)
92 if (row1<epp->fr) row1=epp->fr;
93 if (row2>=epp->lr) row2=epp->lr-1;
95 Tcl_SetResult(interp,mapErrorExplanation[ME_POINT_OUTSIDE],TCL_STATIC);
99 for (i=row1;i<=row2;i++) {
100 epp_putline(epp,col1,col2,i,value);
102 Tcl_SetResult(interp,mapErrorExplanation[map_error],TCL_STATIC);
110 * Draws rectangular frame with width, given in pixels
115 int Fgis_DrawFrame(Tcl_Interp *interp, EPP *epp, double x1, double y1,
116 double x2, double y2, int width, int value)
124 int Fgis_DrawLine(Tcl_Interp *interp, EPP *epp, int pointc, double *pointv,
125 int width, int value)
132 * Draws filled polygon
135 int Fgis_DrawPolygon(Tcl_Interp *interp, EPP *epp, int pointc, double *pointv,
142 * Fills area of raster until encounters different class than in starting
143 * point. Takes into account four neighbours (left, right, top, bottom)
146 int Fgis_Fill4(Tcl_Interp *interp, EPP *epp, double x, double y, int value)
153 * Fills area of raster until encounters given class
154 * Takes into account four neighbours (left, right, top, bottom)
157 int Fgis_Fill4Until(Tcl_Interp *interp, EPP *epp, double x, double y,
158 int value, int stopValue)
165 * Fills area of raster until encounters different class than in starting
166 * point. Takes into account eight neighbours (left, right, top, bottom
167 * and four diagonals)
169 int Fgis_Fill8(Tcl_Interp *interp, EPP *epp, double x, double y, int value)
175 * Fills area of raster until encounters given class
176 * Takes into account eight neighbours (left, right, top, bottom
177 * and four diagonals)
179 int Fgis_Fill8Until(Tcl_Interp *interp, EPP *epp, double x, double y,
180 int value, int stopValue)