]> www.wagner.pp.ru Git - oss/fgis.git/blob - dll/fgisEppEdit.c
First checked in version
[oss/fgis.git] / dll / fgisEppEdit.c
1 /*
2  * High - level editing operations for fGIS raster editor
3  * 
4  *
5  */
6 #include <stdlib.h>
7 #include <math.h>
8 #include <tcl.h>
9 #include <epp.h>
10 char *mapErrorExplanation[]={NULL,
11    "Coordinates outside physical borders of file",
12    "Raster is not editable",
13    "File read error",
14    "File write error",
15    "Memory exhaused",
16    "File access denied",
17    "File not found",
18    "File doesn't conform format",
19    "File creation error",
20  };
21 /*
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
27  */
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);
31     return TCL_ERROR;
32   }
33   if (value>=(1<<epp->kind)) {
34       Tcl_SetResult(interp,"Value too large for this raster",TCL_STATIC);
35       return TCL_ERROR;
36   }
37   return TCL_OK;
38 }
39
40 /*
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
45  */
46 int Fgis_DrawCell(Tcl_Interp *interp,EPP* epp,double x,double y, int value)
47 {
48   map_error=0;
49   epp_put(epp,epp_col(epp,x),epp_row(epp,y),value);
50   if (map_error) {
51     Tcl_SetResult(interp,mapErrorExplanation[map_error],TCL_STATIC);
52     map_error=0;
53     return TCL_ERROR;   
54   }
55   return TCL_OK;
56 }
57
58 /*
59  * Draws circle with center in given point and radius given in
60  * map units
61  *
62  */
63 int Fgis_DrawCircle(Tcl_Interp *interp,EPP* epp,double x,double y,double r,
64      int value)
65 {
66  return TCL_OK;
67 }
68
69 /*
70  * Draws circle with center in given point and radius given in
71  * raster cells 
72  *
73  */
74 int Fgis_DrawCircleInt(Tcl_Interp *interp, EPP *epp, double x, double y,
75     int r, int value)
76 {
77  return TCL_OK;
78 }
79 /*
80  * Draws filled rectangle
81  *
82  *
83  */
84
85 int Fgis_DrawBox(Tcl_Interp *interp, EPP *epp, double x1, double y1,
86   double x2, double y2, int value)
87 {int i,
88      row1=epp_row(epp,y1),
89      row2=epp_row(epp,y2),
90      col1=epp_col(epp,x1),
91      col2=epp_col(epp,x2);
92   if (row1<epp->fr) row1=epp->fr;
93   if (row2>=epp->lr) row2=epp->lr-1;
94   if (row1>row2) {
95     Tcl_SetResult(interp,mapErrorExplanation[ME_POINT_OUTSIDE],TCL_STATIC);
96     return TCL_ERROR;
97   }
98   map_error=0;
99   for (i=row1;i<=row2;i++) {
100     epp_putline(epp,col1,col2,i,value);
101     if (map_error) {
102        Tcl_SetResult(interp,mapErrorExplanation[map_error],TCL_STATIC);
103        map_error=0;
104        return TCL_ERROR;
105     }
106   }
107   return TCL_OK;
108 }
109 /*
110  *  Draws rectangular frame with width, given in pixels
111  *
112  *
113  */
114
115 int Fgis_DrawFrame(Tcl_Interp *interp, EPP *epp, double x1, double y1,
116   double x2, double y2, int width, int value)
117 {
118  return TCL_OK;
119 }
120 /*
121  * Draws polyline
122  *
123  */
124 int Fgis_DrawLine(Tcl_Interp *interp, EPP *epp, int pointc, double *pointv,
125   int width,  int value)
126 {
127
128  return TCL_OK;
129 }
130
131 /*
132  * Draws filled polygon
133  *
134  */
135 int Fgis_DrawPolygon(Tcl_Interp *interp, EPP *epp, int pointc, double *pointv,
136   int value)
137 {
138
139  return TCL_OK;
140 }
141 /*
142  * Fills area of raster until encounters different class than in starting
143  * point. Takes into account four neighbours (left, right, top, bottom)
144  *
145  */
146 int Fgis_Fill4(Tcl_Interp *interp, EPP *epp, double x, double y, int value)
147 {
148
149  return TCL_OK;
150 }
151
152 /*
153  * Fills area of raster until encounters given class 
154  * Takes into account four neighbours (left, right, top, bottom)
155  *
156  */
157 int Fgis_Fill4Until(Tcl_Interp *interp, EPP *epp, double x, double y, 
158  int value, int stopValue)
159 {
160  return TCL_OK;
161
162 }
163  
164 /*
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)
168  */
169 int Fgis_Fill8(Tcl_Interp *interp, EPP *epp, double x, double y, int value)
170 {
171  return TCL_OK;
172 }
173
174 /*
175  * Fills area of raster until encounters given class 
176  * Takes into account eight neighbours (left, right, top, bottom 
177  * and four diagonals)
178  */
179 int Fgis_Fill8Until(Tcl_Interp *interp, EPP *epp, double x, double y,
180  int value, int stopValue)
181 {
182  return TCL_OK;
183
184 }  
185
186