1 | <html> |
---|
2 | <head> |
---|
3 | <title>GRAHI Documentation Project (GDP): SelectMap__define.pro</title> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <meta name="author" content="Antonio Santiago" /> |
---|
6 | <meta name="generator" content="PerlScript IDL documentation generator" /> |
---|
7 | <link rel="stylesheet" type="text/css" href="style.css"> |
---|
8 | <script language="javascript" type="text/javascript"> |
---|
9 | function changeVisibility(elemId){ |
---|
10 | var elem = document.getElementById(elemId).style; |
---|
11 | if(elem.display=='block') elem.display='none'; |
---|
12 | else elem.display='block'; |
---|
13 | } |
---|
14 | </script> |
---|
15 | </head> |
---|
16 | <body> |
---|
17 | <div class="head">GRAHI Documentation Project (GDP)</div><div class="descrip">Filename: <b>SelectMap__define.pro</b></div> |
---|
18 | </code></div></div><div class="comment"><div class="tag_name"><b>CLASSNAME:</b> SelectMap</br></div><div class="tag_author"><b>AUTHOR:</b> </br> Antonio Santiago Perez <a href="mailto:santiago@grahi.upc.edu"><santiago@grahi.upc.edu></a> |
---|
19 | </br> (http://asantiago.gentelibre.org) |
---|
20 | </br></div><div class="tag_description"><b>DESCRIPTION:</b> </br> Show a background image and make line selection. The |
---|
21 | </br> coordenates of initial/final points of the line seleccion are |
---|
22 | </br> returned normalized respect widget and image size. |
---|
23 | </br></div><div class="tag_methods"><b>METHODS:</b></br></div><div class="tag_history"><b>HISTORY:</b></br> Mon Nov 15 17:44:54 2004, Antonio Santiago |
---|
24 | </br> <a href="mailto:santiago@grahi.upc.edu"><santiago@grahi.upc.edu></a> |
---|
25 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_0');">+Code:</a></br><div class="code_text" id="code_0"><code><b>PRO</b> SelectMap__define |
---|
26 | </br> |
---|
27 | </br> struct = { SelectMap, $ |
---|
28 | </br> INHERITS EventAction, $ |
---|
29 | </br> parent_id: 0L, $ <i><b>;Parent widget</b></i></br> base_id: 0L, $ <i><b>;WIDGET_BASE of the object.</b></i></br> widget_id: 0L, $ <i><b>;WIDGET_DRAW inside widget_base.</b></i></br> |
---|
30 | </br> oWindow: OBJ_NEW(), $ <i><b>;The window</b></i></br> oView: OBJ_NEW(), $ <i><b>;The view</b></i></br> oModel: OBJ_NEW(), $ <i><b>;The model</b></i></br> |
---|
31 | </br> oImage: OBJ_NEW(), $ <i><b>;Background image</b></i></br> oPalette: OBJ_NEW(), $ <i><b>;Palette for the image</b></i></br> oSelectLine: OBJ_NEW(), $ <i><b>;Selection line</b></i></br> |
---|
32 | </br> size: [0., 0.], $ <i><b>;Widget draw size</b></i></br> map_size: [0., 0.], $ <i><b>;Image size</b></i></br> |
---|
33 | </br><i><b> ;;Line selection |
---|
34 | </b></i></br> line_sel: [[0.,0.], [0.,0.]], $ <i><b>;Initial/final poinst of the</b></i></br><i><b> ;selected line with coordenates respect |
---|
35 | </b></i></br><i><b> ;widget_draw size. |
---|
36 | </b></i></br> line_map_sel: [[0.,0.], [0.,0.]], $ <i><b>;Initial/final points of the</b></i></br><i><b> ;selected line with coordenates respect |
---|
37 | </b></i></br><i><b> ;image size. |
---|
38 | </b></i></br><i><b> ;;Square selection |
---|
39 | </b></i></br> square_sel: [[0.,0.], [0.,0.], $ <i><b>;Initial/final poinst of the</b></i></br> [0.,0.], [0.,0.]], $ <i><b>;selected square with</b></i></br><i><b> ;coordenates respect |
---|
40 | </b></i></br><i><b> ;widget_draw size. |
---|
41 | </b></i></br> square_map_sel: [[0.,0.], [0.,0.], $ <i><b>;Initial/final points of the</b></i></br> [0.,0.], [0.,0.]], $ <i><b>;selected square with</b></i></br><i><b> ;coordenates respect |
---|
42 | </b></i></br><i><b> ;image size. |
---|
43 | </b></i></br> |
---|
44 | </br> selectionType: '', $ <i><b>;Specifies the selection type: LINE/SQUARE</b></i></br> bSelecting: 0B, $ <i><b>;Are we making a selection?</b></i></br> bHideSelection: 0B, $ <i><b>;Is visible the selection line?</b></i></br> bDynamicSelection: 0B $ <i><b>;Emit SELECTION signals when we are</b></i></br><i><b> ;making the selection? |
---|
45 | </b></i></br> } |
---|
46 | </br><b>END</b> |
---|
47 | </br> |
---|
48 | </br> |
---|
49 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::Init</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Creates an instance of 'SelectMap' class. |
---|
50 | </br></div><div class="tag_parameters"><b>PARAMETERS:</b></br> parent - Parents widget ID. |
---|
51 | </br></div><div class="tag_parameters"><b>EXTRA PARAMETERS:</b></br> extra - Extra KEYWORD with options to be passed to the |
---|
52 | </br> widget_draw. |
---|
53 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_1');">+Code:</a></br><div class="code_text" id="code_1"><code><b>FUNCTION</b> SelectMap::Init, parent, <b>_EXTRA</b>=extra |
---|
54 | </br> |
---|
55 | </br><i><b> ;;Initilize superclass |
---|
56 | </b></i></br> result = self->EventAction::Init() |
---|
57 | </br> |
---|
58 | </br> <b>IF</b> <b>NOT</b> <b>KEYWORD_SET</b>(parent) <b>THEN</b> <b>RETURN</b>, 0 |
---|
59 | </br> |
---|
60 | </br><i><b> ;;Create widget and object hieriarchy. |
---|
61 | </b></i></br> wBase = <b>WIDGET_BASE</b>(parent) |
---|
62 | </br> wDraw = <b>WIDGET_DRAW</b>(wBase, GRAPHICS_LEVEL=2, /EXPOSE_EVENTS, $ |
---|
63 | </br> /BUTTON_EVENTS, /MOTION_EVENTS, <b>_EXTRA</b>=extra, $ |
---|
64 | </br> UVALUE={class_name: 'SelectMap', object: self, $ |
---|
65 | </br> handler: 'EventHandler'}) |
---|
66 | </br> |
---|
67 | </br> self.parent_id = parent |
---|
68 | </br> self.base_id = wBase |
---|
69 | </br> self.widget_id = wDraw |
---|
70 | </br> |
---|
71 | </br><i><b> ;;Register the 'event' of the class |
---|
72 | </b></i></br> self->AddEvent, 'SELECTION' |
---|
73 | </br> self->AddEvent, 'MOTION' |
---|
74 | </br> |
---|
75 | </br> self->Initialize |
---|
76 | </br> |
---|
77 | </br> <b>RETURN</b>, 1 |
---|
78 | </br><b>END</b> |
---|
79 | </br> |
---|
80 | </br> |
---|
81 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::Initialize</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Initialize the state of the object. If it is executed when the |
---|
82 | </br> object is running the object's state goes back to the same as |
---|
83 | </br> the creation state. All possible used memory are free. |
---|
84 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_2');">+Code:</a></br><div class="code_text" id="code_2"><code><b>PRO</b> SelectMap::Initialize |
---|
85 | </br> |
---|
86 | </br><i><b> ;;Free memory usage |
---|
87 | </b></i></br> self->Clear |
---|
88 | </br> |
---|
89 | </br><i><b> ;;Realize the WIDGET_BASE and get the IDLgrWindow object from, |
---|
90 | </b></i></br><i><b> ;;WIDGET_DRAW |
---|
91 | </b></i></br> <b>WIDGET_CONTROL</b>, self.base_id , /REALIZE |
---|
92 | </br> <b>WIDGET_CONTROL</b>, self.widget_id, GET_VALUE=oWindow |
---|
93 | </br> oWindow->SetProperty, QUALITY=0 |
---|
94 | </br> |
---|
95 | </br> oView = OBJ_NEW('IDLgrView', ZCLIP=[0.2,-0.2], $ |
---|
96 | </br> VIEWPLANE_RECT=[0,0,1,1], COLOR=[50,50,70]) |
---|
97 | </br> oModel = OBJ_NEW('IDLgrModel') |
---|
98 | </br> oLight = OBJ_NEW('IDLgrLight', TYPE=1, LOCATION=[0,0,12], $ |
---|
99 | </br> INTENSITY=0.95) |
---|
100 | </br> |
---|
101 | </br><i><b> ;;Initialize attributes |
---|
102 | </b></i></br> geom = <b>WIDGET_INFO</b>(self.widget_id, /GEOMETRY) |
---|
103 | </br> self.size = [geom.xsize, geom.ysize] |
---|
104 | </br> self.map_size = [0., 0.] |
---|
105 | </br> self.line_sel = [[0.,0.], [0.,0.]] |
---|
106 | </br> self.line_map_sel = [[0.,0.], [0.,0.]] |
---|
107 | </br> self.selectionType = 'SQUARE' |
---|
108 | </br> self.bHideSelection = 0 <i><b>;Hide selection</b></i></br> self.bDynamicSelection = 0 <i><b>;No dynamic selection</b></i></br> self.bSelecting = 0 |
---|
109 | </br> |
---|
110 | </br><i><b> ;;Save references to the objects |
---|
111 | </b></i></br> oView->Add, oModel |
---|
112 | </br> oModel->Add, oLight |
---|
113 | </br> |
---|
114 | </br> self.oWindow = oWindow |
---|
115 | </br> self.oView = oView |
---|
116 | </br> self.oModel = oModel |
---|
117 | </br> |
---|
118 | </br><b>END</b> |
---|
119 | </br> |
---|
120 | </br> |
---|
121 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::Cleanup</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Free memory used by the object. |
---|
122 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_3');">+Code:</a></br><div class="code_text" id="code_3"><code><b>PRO</b> SelectMap::Cleanup |
---|
123 | </br> |
---|
124 | </br> <b>OBJ_DESTROY</b>, [self.oWindow] |
---|
125 | </br> |
---|
126 | </br> self->Clear |
---|
127 | </br> |
---|
128 | </br> self->EventAction::Cleanup |
---|
129 | </br><b>END</b> |
---|
130 | </br> |
---|
131 | </br> |
---|
132 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::Clear</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Free memory used by the object. |
---|
133 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_4');">+Code:</a></br><div class="code_text" id="code_4"><code><b>PRO</b> SelectMap::Clear |
---|
134 | </br><i><b> ;;When destroy de IDLgrView the IDLgrModel are destroyed with all |
---|
135 | </b></i></br><i><b> ;;its contents, included the image and seleccion line. |
---|
136 | </b></i></br> <b>OBJ_DESTROY</b>, [self.oView, self.oPalette, self.oSelectLine] |
---|
137 | </br><b>END</b> |
---|
138 | </br> |
---|
139 | </br> |
---|
140 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::SetPalette</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Sets a color palette used to show bachground image. Only takes |
---|
141 | </br> efect if the background image is a X,Y array. |
---|
142 | </br></div><div class="tag_parameters"><b>PARAMETERS:</b></br> colors - 256x3 array values (RGB). |
---|
143 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_5');">+Code:</a></br><div class="code_text" id="code_5"><code><b>PRO</b> SelectMap::SetPalette, colors |
---|
144 | </br> |
---|
145 | </br><i><b> ;;Destroy the last palette (if exists) |
---|
146 | </b></i></br> <b>OBJ_DESTROY</b>, self.oPalette |
---|
147 | </br> |
---|
148 | </br> oPalette = OBJ_NEW('IDLgrPalette', colors[*,0], colors[*,1], colors[*,2]) |
---|
149 | </br> |
---|
150 | </br><i><b> ;;Save reference to the palette. |
---|
151 | </b></i></br> self.oPalette = oPalette |
---|
152 | </br><b>END</b> |
---|
153 | </br> |
---|
154 | </br> |
---|
155 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::SetMap</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Sets a background image. The image can be a (x,y) array that |
---|
156 | </br> will be colored with the specified palette or may be a |
---|
157 | </br> (3,x,y), (x,3,y) or (x,y,3) array (like an 'jpeg' image). |
---|
158 | </br></div><div class="tag_parameters"><b>PARAMETERS:</b></br> data_map - Array 2D or 3D with the image to show. |
---|
159 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_6');">+Code:</a></br><div class="code_text" id="code_6"><code><b>PRO</b> SelectMap::SetMap, data_map |
---|
160 | </br> |
---|
161 | </br><i><b> ;;Destroy previeus objects. |
---|
162 | </b></i></br> <b>OBJ_DESTROY</b>, [self.oImage, self.oSelectLine] |
---|
163 | </br> |
---|
164 | </br><i><b> ;;Get dimension of the image and calcula the normalization factors |
---|
165 | </b></i></br><i><b> ;;depending on the type of the image. |
---|
166 | </b></i></br> sizes = <b>SIZE</b>(data_map, /DIMENSIONS) |
---|
167 | </br> |
---|
168 | </br> <b>IF</b> <b>N_ELEMENTS</b>(sizes) <b>EQ</b> 3 <b>THEN</b> <b>BEGIN</b> |
---|
169 | </br><i><b> ;;Image 3,X,Y |
---|
170 | </b></i></br> <b>IF</b> sizes[0] <b>LE</b> 4 <b>THEN</b> <b>BEGIN</b> |
---|
171 | </br> xsize = sizes[1] |
---|
172 | </br> ysize = sizes[2] |
---|
173 | </br> xconv = NORMALIZE([0, xsize-1], Position=[0,1]) |
---|
174 | </br> yconv = NORMALIZE([0, ysize-1], Position=[0,1]) |
---|
175 | </br> <b>ENDIF</b> |
---|
176 | </br><i><b> ;;Image X,3,Y |
---|
177 | </b></i></br> <b>IF</b> sizes[1] <b>LE</b> 4 <b>THEN</b> <b>BEGIN</b> |
---|
178 | </br> xsize = sizes[0] |
---|
179 | </br> ysize = sizes[2] |
---|
180 | </br> xconv = NORMALIZE([0, xsize-1], Position=[0,1]) |
---|
181 | </br> yconv = NORMALIZE([0, ysize-1], Position=[0,1]) |
---|
182 | </br> <b>ENDIF</b> |
---|
183 | </br><i><b> ;;Image X,Y,3 |
---|
184 | </b></i></br> <b>IF</b> sizes[2] <b>LE</b> 4 <b>THEN</b> <b>BEGIN</b> |
---|
185 | </br> xsize = sizes[0] |
---|
186 | </br> ysize = sizes[1] |
---|
187 | </br> xconv = NORMALIZE([0, xsize-1], Position=[0,1]) |
---|
188 | </br> yconv = NORMALIZE([0, ysize-1], Position=[0,1]) |
---|
189 | </br> <b>ENDIF</b> |
---|
190 | </br> <b>ENDIF</b> <b>ELSE</b> <b>BEGIN</b> |
---|
191 | </br><i><b> ;;Image X,Y |
---|
192 | </b></i></br> xsize = sizes[0] |
---|
193 | </br> ysize = sizes[1] |
---|
194 | </br> xconv = NORMALIZE([0, xsize-1], Position=[0,1]) |
---|
195 | </br> yconv = NORMALIZE([0, ysize-1], Position=[0,1]) |
---|
196 | </br> <b>ENDELSE</b> |
---|
197 | </br> |
---|
198 | </br><i><b> ;;Save the dimensions of the image. |
---|
199 | </b></i></br> self.map_size = [xsize, ysize] |
---|
200 | </br> |
---|
201 | </br><i><b> ;;Create the image as a texture of polygon. |
---|
202 | </b></i></br> oImage = OBJ_NEW('IDLgrImage', data_map, PALETTE=self.oPalette, $ |
---|
203 | </br> XCOORD_CONV=xconv, YCOORD_CONV=yconv) |
---|
204 | </br> |
---|
205 | </br><i><b> ;;Create the selection line object |
---|
206 | </b></i></br> <b>IF</b> self.selectionType <b>EQ</b> 'LINE' <b>THEN</b> <b>BEGIN</b> |
---|
207 | </br> connect_line = [2, 0, 1] |
---|
208 | </br> oSelectLine = OBJ_NEW('IDLgrPolyline', self.line_map_sel, $ |
---|
209 | </br> POLYLINES=connect_line, $ |
---|
210 | </br> COLOR=[150,150,150], THICK=2, $ |
---|
211 | </br> HIDE=self.bHideSelection, $ |
---|
212 | </br> XCOORD_CONV=xconv, YCOORD_CONV=yconv) |
---|
213 | </br> <b>ENDIF</b> <b>ELSE</b> <b>BEGIN</b> |
---|
214 | </br> connect_line = [4, 0, 1, 2, 3] |
---|
215 | </br> oSelectLine = OBJ_NEW('IDLgrPolyline', self.square_map_sel, $ |
---|
216 | </br> POLYLINES=connect_line, $ |
---|
217 | </br> COLOR=[150,150,150], THICK=2, $ |
---|
218 | </br> HIDE=self.bHideSelection, $ |
---|
219 | </br> XCOORD_CONV=xconv, YCOORD_CONV=yconv) |
---|
220 | </br> <b>ENDELSE</b> |
---|
221 | </br> |
---|
222 | </br><i><b> ;;Save object references |
---|
223 | </b></i></br> self.oModel->Add, oImage |
---|
224 | </br> self.oModel->Add, oSelectLine |
---|
225 | </br> self.oImage = oImage |
---|
226 | </br> self.oSelectLine = oSelectLine |
---|
227 | </br> |
---|
228 | </br><b>END</b> |
---|
229 | </br> |
---|
230 | </br> |
---|
231 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::Draw</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Draws the object. |
---|
232 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_7');">+Code:</a></br><div class="code_text" id="code_7"><code><b>PRO</b> SelectMap::Draw |
---|
233 | </br> self.oWindow->Draw, self.oView |
---|
234 | </br><b>END</b> |
---|
235 | </br> |
---|
236 | </br> |
---|
237 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::GetProperty</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Get the the properties of the object. |
---|
238 | </br></div><div class="tag_parameters"><b>KEYWORD PARAMETERS:</b></br> id - ID of the WIDGET_BASE over the object are created. |
---|
239 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_8');">+Code:</a></br><div class="code_text" id="code_8"><code> <b>PRO</b> SelectMap::GetProperty, ID=id |
---|
240 | </br> |
---|
241 | </br> id = self.base_id |
---|
242 | </br> <b>END</b> |
---|
243 | </br> |
---|
244 | </br> |
---|
245 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::SetProperty</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Sets the properties of the object. |
---|
246 | </br></div><div class="tag_parameters"><b>KEYWORD PARAMETERS:</b></br> hide_selection - Show/hide the selection line. |
---|
247 | </br> dynamic_selection - If true, SELECTION events are emited while a |
---|
248 | </br> selecction is doing. |
---|
249 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_9');">+Code:</a></br><div class="code_text" id="code_9"><code><b>PRO</b> SelectMap::SetProperty, $ |
---|
250 | </br> SELECTION_TYPE=selection_type, $ |
---|
251 | </br> DYNAMIC_SELECTION=dynamic_selection, $ |
---|
252 | </br> HIDE_SELECTION=hide_selection |
---|
253 | </br> |
---|
254 | </br> <b>IF</b> selection_type <b>EQ</b> 'LINE' <b>OR</b> selection_type <b>EQ</b> 'SQUARE' <b>THEN</b> <b>BEGIN</b> |
---|
255 | </br> self.selectionType = selection_type |
---|
256 | </br> <b>ENDIF</b> |
---|
257 | </br> |
---|
258 | </br> <b>IF</b> <b>N_ELEMENTS</b>(dynamic_selection) <b>THEN</b> <b>BEGIN</b> |
---|
259 | </br> self.bDynamicSelection = dynamic_selection |
---|
260 | </br> <b>ENDIF</b> |
---|
261 | </br> |
---|
262 | </br> <b>IF</b> <b>N_ELEMENTS</b>(hide_selection) <b>THEN</b> <b>BEGIN</b> |
---|
263 | </br> self.bHideSelection = hide_selection |
---|
264 | </br> self.oSelectLine->SetProperty, HIDE=hide_selection |
---|
265 | </br> <b>ENDIF</b> |
---|
266 | </br> |
---|
267 | </br> <b>END</b> |
---|
268 | </br> |
---|
269 | </br> |
---|
270 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap_EventHandler</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Object's event handler. |
---|
271 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_10');">+Code:</a></br><div class="code_text" id="code_10"><code><b>PRO</b> SelectMap::EventHandler, event |
---|
272 | </br> |
---|
273 | </br><i><b> ;;Expose Event |
---|
274 | </b></i></br> <b>IF</b> event.type <b>EQ</b> 4 <b>THEN</b> <b>BEGIN</b> |
---|
275 | </br> self->Draw |
---|
276 | </br> <b>ENDIF</b> |
---|
277 | </br> |
---|
278 | </br><i><b> ;;Mouse down button |
---|
279 | </b></i></br> <b>IF</b> (event.type <b>EQ</b> 0) <b>AND</b> (event.press <b>EQ</b> 1) <b>THEN</b> <b>BEGIN</b> |
---|
280 | </br> <b>IF</b> <b>NOT</b> self.bHideSelection <b>THEN</b> <b>BEGIN</b> |
---|
281 | </br><i><b> ;;Set that a selection is doing |
---|
282 | </b></i></br> self.bSelecting = 1 |
---|
283 | </br> |
---|
284 | </br><i><b> ;;Update the line coordenates |
---|
285 | </b></i></br> self->UpdateLineSelection, event, /ALL |
---|
286 | </br> self->UpdateSquareSelection, event, /ALL |
---|
287 | </br> <b>IF</b> self.selectionType <b>EQ</b> 'LINE' <b>THEN</b> <b>BEGIN</b> |
---|
288 | </br> connect_line = [2, 0, 1] |
---|
289 | </br> self.oSelectLine->SetProperty, DATA=self.line_map_sel, $ |
---|
290 | </br> COLOR=[255,255,0], POLYLINE=connect_line |
---|
291 | </br> <b>ENDIF</b> <b>ELSE</b> <b>BEGIN</b> |
---|
292 | </br> connect_line = [4, 0, 1, 2, 3] |
---|
293 | </br> self.oSelectLine->SetProperty, DATA=self.square_map_sel, $ |
---|
294 | </br> COLOR=[255,255,0], POLYLINE=connect_line |
---|
295 | </br> <b>ENDELSE</b> |
---|
296 | </br> <b>ENDIF</b> |
---|
297 | </br> |
---|
298 | </br> <b>ENDIF</b> |
---|
299 | </br> |
---|
300 | </br><i><b> ;;Mouse up button |
---|
301 | </b></i></br> <b>IF</b> (event.type <b>EQ</b> 1) <b>AND</b> (event.release <b>EQ</b> 1)<b>THEN</b> <b>BEGIN</b> |
---|
302 | </br> |
---|
303 | </br><i><b> ;;Set that the selection are finished |
---|
304 | </b></i></br> self.bSelecting = 0 |
---|
305 | </br> |
---|
306 | </br><i><b> ;;Update the line corrdenates. |
---|
307 | </b></i></br> self->UpdateLineSelection, event |
---|
308 | </br> self->UpdateSquareSelection, event |
---|
309 | </br> <b>IF</b> self.selectionType <b>EQ</b> 'LINE' <b>THEN</b> <b>BEGIN</b> |
---|
310 | </br> self.oSelectLine->SetProperty, DATA=self.line_map_sel, $ |
---|
311 | </br> COLOR=[255,255,255] |
---|
312 | </br> <b>ENDIF</b> <b>ELSE</b> <b>BEGIN</b> |
---|
313 | </br> self.oSelectLine->SetProperty, DATA=self.square_map_sel, $ |
---|
314 | </br> COLOR=[255,255,255] |
---|
315 | </br> <b>ENDELSE</b> |
---|
316 | </br> |
---|
317 | </br><i><b> ;;Generate a 'SELECTION' event. |
---|
318 | </b></i></br> self->Draw |
---|
319 | </br> self->EmitEvent, 'SELECTION', $ |
---|
320 | </br> EVENT_STRUCT={line_sel: self.line_sel, $ |
---|
321 | </br> line_map_sel: self.line_map_sel} |
---|
322 | </br> <b>ENDIF</b> |
---|
323 | </br> |
---|
324 | </br><i><b> ;;Mouse move |
---|
325 | </b></i></br> <b>IF</b> (event.type <b>EQ</b> 2) <b>THEN</b> <b>BEGIN</b> |
---|
326 | </br><i><b> ;;If a selection is doing actualize the coordenates. |
---|
327 | </b></i></br> <b>IF</b> self.bSelecting <b>THEN</b> <b>BEGIN</b> |
---|
328 | </br> self->UpdateLineSelection, event |
---|
329 | </br> self->UpdateSquareSelection, event |
---|
330 | </br> <b>IF</b> self.selectionType <b>EQ</b> 'LINE' <b>THEN</b> <b>BEGIN</b> |
---|
331 | </br> self.oSelectLine->SetProperty, DATA=self.line_map_sel |
---|
332 | </br> <b>ENDIF</b> <b>ELSE</b> <b>BEGIN</b> |
---|
333 | </br> self.oSelectLine->SetProperty, DATA=self.square_map_sel |
---|
334 | </br> <b>ENDELSE</b> |
---|
335 | </br> |
---|
336 | </br> self->Draw |
---|
337 | </br> <b>ENDIF</b> |
---|
338 | </br> |
---|
339 | </br><i><b> ;;Generate a 'MOTION' event. |
---|
340 | </b></i></br> values = [event.x, event.y] |
---|
341 | </br> convert = self->ConvertValuesW2M(values) |
---|
342 | </br> self->EmitEvent, 'MOTION', $ |
---|
343 | </br> EVENT_STRUCT={ point_sel: values, $ |
---|
344 | </br> point_map_sel: convert } |
---|
345 | </br> <b>ENDIF</b> |
---|
346 | </br> |
---|
347 | </br><b>END</b> |
---|
348 | </br> |
---|
349 | </br> |
---|
350 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::UpdateLineSelection</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Get the actual coordenate points and convert respect the image |
---|
351 | </br> size. |
---|
352 | </br></div><div class="tag_parameters"><b>KEYWORD PARAMETERS:</b></br> all - If set specify that the two points (origin, final) of |
---|
353 | </br> the selection line must to be initialize. If not set, |
---|
354 | </br> only the final point is converted. |
---|
355 | </br></div><b>NOTE:</b> The 0 and 2 points of the square are the initial and final</br> points respectively. |
---|
356 | </br></div><div class="code"><a href="#" onClick="changeVisibility('code_11');">+Code:</a></br><div class="code_text" id="code_11"><code><b>PRO</b> SelectMap::UpdateLineSelection, event, ALL=all |
---|
357 | </br> |
---|
358 | </br> xpoint = (event.x > 0) < (self.size[0]-1) |
---|
359 | </br> ypoint = (event.y > 0) < (self.size[1]-1) |
---|
360 | </br> |
---|
361 | </br> <b>IF</b> <b>KEYWORD_SET</b>(all) <b>THEN</b> <b>BEGIN</b> |
---|
362 | </br> self.line_sel[*,0] = [xpoint, ypoint] |
---|
363 | </br> self.line_map_sel[*,0] = self->ConvertValuesW2M(self.line_sel[*,0]) |
---|
364 | </br> <b>ENDIF</b> |
---|
365 | </br> |
---|
366 | </br> self.line_sel[*,1] = [xpoint, ypoint] |
---|
367 | </br> self.line_map_sel[*,1] = self->ConvertValuesW2M(self.line_sel[*,1]) |
---|
368 | </br><b>END</b> |
---|
369 | </br> |
---|
370 | </br> |
---|
371 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::UpdateSquareSelection</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Get the actual coordenate points and convert respect the image |
---|
372 | </br> size. |
---|
373 | </br></div><div class="tag_parameters"><b>KEYWORD PARAMETERS:</b></br> all - If set specify that the two points (origin, final) of |
---|
374 | </br> the selection line must to be initialize. If not set, |
---|
375 | </br> only the final point is converted. |
---|
376 | </br></div><b>NOTE:</b> The 0 and 2 points of the square are the initial and final</br> points respectively. |
---|
377 | </br></div><div class="code"><a href="#" onClick="changeVisibility('code_12');">+Code:</a></br><div class="code_text" id="code_12"><code><b>PRO</b> SelectMap::UpdateSquareSelection, event, ALL=all |
---|
378 | </br> |
---|
379 | </br> xpoint = (event.x > 0) < (self.size[0]-1) |
---|
380 | </br> ypoint = (event.y > 0) < (self.size[1]-1) |
---|
381 | </br> |
---|
382 | </br> <b>IF</b> <b>KEYWORD_SET</b>(all) <b>THEN</b> <b>BEGIN</b> |
---|
383 | </br><i><b> ;;Initial point |
---|
384 | </b></i></br> self.square_sel[*,0] = [xpoint, ypoint] |
---|
385 | </br> self.square_map_sel[*,0] = self->ConvertValuesW2M([xpoint, ypoint]) |
---|
386 | </br> <b>ENDIF</b> |
---|
387 | </br> |
---|
388 | </br><i><b> ;;Final point |
---|
389 | </b></i></br> self.square_sel[*,2] = [xpoint, ypoint] |
---|
390 | </br> self.square_map_sel[*,2] = self->ConvertValuesW2M([xpoint, ypoint]) |
---|
391 | </br> |
---|
392 | </br><i><b> ;;Other points |
---|
393 | </b></i></br> xinit = self.square_sel[0,0] |
---|
394 | </br> yinit = self.square_sel[1,0] |
---|
395 | </br> width = xinit - xpoint |
---|
396 | </br> height = yinit - ypoint |
---|
397 | </br> |
---|
398 | </br> self.square_sel[*,1] = [(xinit + width), ypoint] |
---|
399 | </br> self.square_map_sel[*,1] = self->ConvertValuesW2M([xpoint, ypoint]) |
---|
400 | </br> |
---|
401 | </br> self.square_sel[*,3] = [xpoint, (ypoint + height)] |
---|
402 | </br> self.square_map_sel[*,3] = self->ConvertValuesW2M([xpoint, ypoint]) |
---|
403 | </br> |
---|
404 | </br> |
---|
405 | </br><b>END</b> |
---|
406 | </br> |
---|
407 | </br> |
---|
408 | </br></code></div></div><div class="comment"><div class="tag_name"><b>NAME:</b> SelectMap::ConvertValuesW2M</br></div><div class="tag_description"><b>DESCRIPTION:</b></br> Convert a pair of values from widget size relative coordenatos |
---|
409 | </br> to the image relativa size coordenates. |
---|
410 | </br></div></div><div class="code"><a href="#" onClick="changeVisibility('code_13');">+Code:</a></br><div class="code_text" id="code_13"><code><b>FUNCTION</b> SelectMap::ConvertValuesW2M, values |
---|
411 | </br> |
---|
412 | </br> values[0] = (values[0] > 0) < (self.size[0]-1) |
---|
413 | </br> values[1] = (values[1] > 0) < (self.size[1]-1) |
---|
414 | </br> |
---|
415 | </br> convert = values |
---|
416 | </br> convert[0] = values[0] * (self.map_size[0]-1) / (self.size[0]-1) |
---|
417 | </br> convert[1] = values[1] * (self.map_size[1]-1) / (self.size[1]-1) |
---|
418 | </br> |
---|
419 | </br> <b>RETURN</b>, convert |
---|
420 | </br><b>END</b> |
---|
421 | </br> |
---|
422 | </br> |
---|
423 | </br> |
---|
424 | </br></code></div></div><div class="final">· Created by the PerlScript documentation generator for IDL · <br> · <i>Thu Dec 2 16:01:50 2004</i> ·</div></body></html> |
---|