/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
ViewVC logotype

Annotation of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47431 - (hide annotations)
Fri Jan 7 17:47:24 2005 UTC (15 years ago) by bennob
Original Path: trunk/Src/bench/Eiffel/interface/new_graphical/case_tool/eiffel_view/cluster_figure.e
File size: 8725 byte(s)
Optimized loop over linkable_figure.links

1 manus 26913 indexing
2 bennob 47281 description: "Common functionality for all views of ES_CLUSTERs"
3     author: ""
4 manus 26913 date: "$Date$"
5     revision: "$Revision$"
6    
7     deferred class
8 bennob 47281 EIFFEL_CLUSTER_FIGURE
9    
10 manus 26913 inherit
11 bennob 47281 EG_RESIZABLE_CLUSTER_FIGURE
12 manus 26913 redefine
13 bennob 47281 default_create,
14     initialize,
15     model,
16 manus 26913 world,
17 bennob 47281 on_linkable_add,
18     on_handle_start,
19     on_handle_end,
20     recycle
21 manus 26913 end
22 bennob 47281
23     EB_CONSTANTS
24 manus 26913 undefine
25 bennob 47281 default_create
26 manus 26913 end
27 bennob 47394
28 manus 26913 feature {NONE} -- Initialization
29    
30 bennob 47281 default_create is
31     -- Create an CLUSTER_FIGURE.
32 manus 26913 do
33 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
34    
35     set_accept_cursor (cursors.cur_cluster)
36     set_deny_cursor (cursors.cur_x_cluster)
37    
38     start_actions.extend (agent save_position)
39     end_actions.extend (agent extend_history)
40     move_actions.extend (agent on_move)
41 manus 26913 end
42 bennob 47281
43 manus 26913 initialize is
44 bennob 47281 -- Initialize `Current' with `model'.
45 manus 26913 do
46 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
47 bennob 47394 pebble_function := agent on_pebble_request
48 bennob 47281 model.needed_on_diagram_changed_actions.extend (agent on_needed_on_diagram_changed)
49 manus 26913 end
50    
51 bennob 47281 feature -- Status report
52 manus 26913
53 bennob 47281 is_iconified: BOOLEAN
54     -- Is `Current' iconified.
55    
56     feature -- Access
57 manus 26913
58 bennob 47281 model: ES_CLUSTER
59     -- Model for `Current'.
60    
61     world: EIFFEL_WORLD is
62     -- World `Current' is part of.
63 manus 26913 do
64 bennob 47281 Result ?= Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
65 manus 26913 end
66 bennob 47281
67 manus 26913 feature -- Element change
68    
69 bennob 47281 recycle is
70     -- Free `Current's resources.
71 manus 26913 do
72 bennob 47281 Precursor {EG_RESIZABLE_CLUSTER_FIGURE}
73     start_actions.prune_all (agent save_position)
74     end_actions.prune_all (agent extend_history)
75     move_actions.prune_all (agent on_move)
76     model.needed_on_diagram_changed_actions.prune_all (agent on_needed_on_diagram_changed)
77 manus 26913 end
78 bennob 47281
79    
80     apply_right_angles is
81     -- Apply right angles to all links in `links' and all elements in `Current'.
82 manus 26913 local
83 bennob 47281 l_item: EIFFEL_LINK_FIGURE
84     l_links: like links
85     i, nb: INTEGER
86     clu: EIFFEL_CLUSTER_FIGURE
87     cla: EIFFEL_CLASS_FIGURE
88 manus 26913 do
89 bennob 47281 from
90     l_links := links
91     i := 1
92     nb := l_links.count
93     until
94     i > nb
95     loop
96     l_item ?= l_links.i_th (i)
97     if l_item /= Void then
98     l_item.apply_right_angles
99 manus 26913 end
100 bennob 47281 i := i + 1
101 manus 26913 end
102 bennob 47281 from
103     start
104     until
105     after
106     loop
107     clu ?= item
108     if clu /= Void then
109     clu.apply_right_angles
110 manus 26913 else
111 bennob 47281 cla ?= item
112     if cla /= Void then
113     cla.apply_right_angles
114     end
115 manus 26913 end
116 bennob 47281 forth
117 manus 26913 end
118     end
119    
120 bennob 47281 feature {EG_LAYOUT} -- Layouting
121 manus 26913
122 bennob 47281 set_to_minimum_size is
123     -- Set `Current's to `minimum_size'.
124     deferred
125 manus 26913 end
126 bennob 47281
127     feature {EIFFEL_WORLD} -- Show/Hide
128 manus 26913
129 bennob 47281 disable_shown is
130     -- Hide `Current'.
131     deferred
132     ensure
133     set: not is_shown
134 manus 26913 end
135 bennob 47281
136     enable_shown is
137     -- Show `Current'.
138     deferred
139     ensure
140     set: is_shown
141     end
142    
143     is_shown: BOOLEAN
144     -- Is `Current' shown?
145    
146     feature {EIFFEL_CLUSTER_FIGURE} -- Expand/Collapse
147 manus 26913
148 bennob 47281 collapse is
149     -- Hide all elements in `Current' and minimize `Current'.
150 manus 26913 local
151 bennob 47281 linkable_figure: EG_LINKABLE_FIGURE
152     cluster_figure: EIFFEL_CLUSTER_FIGURE
153 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
154     l_item: EG_LINK_FIGURE
155     i, nb: INTEGER
156 manus 26913 do
157     from
158 bennob 47281 start
159 manus 26913 until
160 bennob 47281 after
161 manus 26913 loop
162 bennob 47281 linkable_figure ?= item
163     if linkable_figure /= Void then
164 bennob 47394 if linkable_figure.is_show_requested then
165 bennob 47281 linkable_figure.hide
166     linkable_figure.disable_sensitive
167     from
168 bennob 47431 l_links := linkable_figure.links
169     i := 1
170     nb := l_links.count
171 bennob 47281 until
172 bennob 47431 i > nb
173 bennob 47281 loop
174 bennob 47431 l_item := l_links.i_th (i)
175     l_item.hide
176     l_item.disable_sensitive
177     i := i + 1
178 bennob 47281 end
179     cluster_figure ?= linkable_figure
180     if cluster_figure /= Void and then not cluster_figure.is_iconified then
181     cluster_figure.collapse
182     end
183     end
184 manus 26913 end
185 bennob 47281 forth
186 manus 26913 end
187 bennob 47281 resizer_top_left.disable_sensitive
188     resizer_top_right.disable_sensitive
189     resizer_bottom_right.disable_sensitive
190     resizer_bottom_left.disable_sensitive
191 manus 26913 end
192 bennob 47281
193     expand is
194     -- Show all not iconified elements in `Current'.
195     local
196     linkable_figure: EG_LINKABLE_FIGURE
197     l_other: EG_LINKABLE_FIGURE
198     l_link: EG_LINK_FIGURE
199     cluster_figure: EIFFEL_CLUSTER_FIGURE
200     e_item: ES_ITEM
201 bennob 47431 l_links: ARRAYED_LIST [EG_LINK_FIGURE]
202     i, nb: INTEGER
203 manus 26913 do
204     from
205 bennob 47281 start
206 manus 26913 until
207 bennob 47281 after
208 manus 26913 loop
209 bennob 47281 linkable_figure ?= item
210     if linkable_figure /= Void then
211     e_item ?= linkable_figure.model
212     if e_item = Void or else e_item.is_needed_on_diagram then
213     linkable_figure.show
214     linkable_figure.enable_sensitive
215     from
216 bennob 47431 l_links := linkable_figure.links
217     i := 1
218     nb := l_links.count
219 bennob 47281 until
220 bennob 47431 i > nb
221 bennob 47281 loop
222 bennob 47431 l_link := l_links.i_th (i)
223 bennob 47281 if l_link.source = linkable_figure then
224     l_other := l_link.target
225     else
226     l_other := l_link.source
227     end
228     if l_other.is_show_requested then
229     l_link.show
230     l_link.enable_sensitive
231     end
232 bennob 47431 i := i + 1
233 bennob 47281 end
234     cluster_figure ?= linkable_figure
235     if cluster_figure /= Void and then not cluster_figure.is_iconified then
236     cluster_figure.expand
237     end
238     end
239     end
240     forth
241 manus 26913 end
242 bennob 47281 resizer_top_left.enable_sensitive
243     resizer_top_right.enable_sensitive
244     resizer_bottom_right.enable_sensitive
245     resizer_bottom_left.enable_sensitive
246 manus 26913 end
247 bennob 47281
248     feature {NONE} -- Implementation
249 manus 26913
250 bennob 47281 on_needed_on_diagram_changed is
251     -- `model'.`is_needed_on_diagram' changed.
252     do
253     if model.is_needed_on_diagram then
254     show
255     enable_sensitive
256     else
257     hide
258     disable_sensitive
259     end
260     request_update
261 manus 26913 end
262    
263 bennob 47281 save_position is
264     -- Make a backup of current coordinates.
265 manus 26913 do
266 bennob 47281 saved_x := port_x
267     saved_y := port_y
268    
269 manus 26913 end
270 bennob 47281
271     saved_x, saved_y: INTEGER
272     -- Saved positions.
273    
274     on_move (ax, ay: INTEGER; x_tilt, y_tilt, pressure: DOUBLE; screen_x, screen_y: INTEGER) is
275     -- Cluster is moving.
276 manus 26913 do
277 bennob 47281 world.context_editor.restart_force_directed
278     if world.is_right_angles then
279     apply_right_angles
280 manus 26913 end
281     end
282    
283 bennob 47281 extend_history is
284     -- Register move in the history.
285     local
286     ce: EB_CONTEXT_EDITOR
287     do
288     ce := world.context_editor
289     world.context_editor.history.do_named_undoable (
290     interface_names.t_Diagram_move_cluster_cmd,
291     [<<agent set_port_position (port_x, port_y), agent ce.restart_force_directed>>],
292     [<<agent set_port_position (saved_x, saved_y), agent ce.restart_force_directed>>])
293     if world.context_editor.is_force_directed_used then
294     set_is_fixed (True)
295     end
296 manus 26913 end
297 bennob 47281
298     on_linkable_add (a_linkable: EG_LINKABLE) is
299     -- `a_linkable' was added to the cluster.
300 manus 26913 local
301 bennob 47281 l_world: like world
302     linkable_fig: EG_LINKABLE_FIGURE
303     link_fig: EG_LINK_FIGURE
304     scsc: EG_CLUSTER_FIGURE
305     e_item: ES_ITEM
306     cs_link: EIFFEL_CLIENT_SUPPLIER_FIGURE
307     i_link: EIFFEL_INHERITANCE_FIGURE
308     c_fig: EG_LINKABLE_FIGURE
309 manus 26913 do
310 bennob 47281 l_world := world
311     if l_world /= Void then
312     linkable_fig ?= l_world.items_to_figure_lookup_table.item (a_linkable)
313     check
314     linkable_fig_is_in_view_but_not_in_cluster: linkable_fig /= Void not has (linkable_fig)
315     end
316     extend (linkable_fig)
317     linkable_fig.set_cluster (Current)
318    
319 manus 26913 from
320 bennob 47281 l_world.links.start
321 manus 26913 until
322 bennob 47281 l_world.links.after
323 manus 26913 loop
324 bennob 47281 link_fig := l_world.links.item
325     if link_fig.source /= Void and then link_fig.target /= Void then
326     e_item ?= link_fig.model
327     if e_item = Void or else e_item.is_needed_on_diagram then
328     scsc := world.smallest_common_supercluster (link_fig.source, link_fig.target)
329     if scsc /= Void and then not scsc.has (link_fig) then
330     scsc.go_i_th (scsc.number_of_figures)
331     cs_link ?= link_fig
332     if cs_link /= Void or else scsc.index = scsc.count then
333     scsc.put_right (link_fig)
334     else
335     from
336     i_link := Void
337     c_fig := Void
338     until
339     i_link /= Void or else c_fig /= Void
340     loop
341     scsc.forth
342     i_link ?= scsc.item
343     c_fig ?= scsc.item
344     end
345     scsc.put_left (link_fig)
346     end
347     end
348     end
349 manus 26913 end
350 bennob 47281 l_world.links.forth
351 manus 26913 end
352     end
353 bennob 47281 request_update
354 manus 26913 end
355 bennob 47281
356     on_handle_start is
357     -- User started to move `Current'.
358     do
359     was_fixed := is_fixed
360     if world.context_editor.is_force_directed_used then
361     set_is_fixed (True)
362     end
363     end
364    
365     on_handle_end is
366     -- User ended to move `Current'.
367     do
368     set_is_fixed (was_fixed)
369     end
370 manus 26913
371 bennob 47281 update_links is
372     -- Update all links in `Current'.
373 manus 26913 local
374 bennob 47281 i, nb: INTEGER
375     l_link: EG_LINK_FIGURE
376 manus 26913 do
377     from
378 bennob 47281 i := 1
379 manus 26913 until
380 bennob 47281 i > nb
381 manus 26913 loop
382 bennob 47281 l_link ?= i_th (i)
383     if l_link /= Void then
384     l_link.update
385 manus 26913 end
386 bennob 47281 i := i + 1
387 manus 26913 end
388     end
389 bennob 47281
390 bennob 47394 on_pebble_request: CLUSTER_STONE is
391     -- Pebble request.
392     do
393     if model /= Void then
394     create Result.make (model.cluster_i)
395     end
396     end
397    
398 bennob 47281 end -- class EIFFEL_CLUSTER_FIGURE

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23