root / tags / v1_1_Build_1005 / extensions / extCAD / sm / SelectionCADTool.sm @ 12355
History | View | Annotate | Download (4.6 KB)
1 | 3828 | caballero | // -*- tab-width: 4; -*- |
---|---|---|---|
2 | |||
3 | %{ |
||
4 | // |
||
5 | // Vicente Caballero Navarro |
||
6 | %} |
||
7 | |||
8 | 3978 | caballero | %start Selection::FirstPoint |
9 | 3828 | caballero | %class SelectionCADTool |
10 | %package com.iver.cit.gvsig.gui.cad.tools.smc |
||
11 | %import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool |
||
12 | %import com.iver.cit.gvsig.fmap.layers.FBitSet |
||
13 | 4324 | caballero | %import java.awt.event.InputEvent |
14 | 4583 | caballero | %import com.iver.andami.PluginServices |
15 | 3828 | caballero | |
16 | 4324 | caballero | |
17 | 3978 | caballero | %map Selection |
18 | 3828 | caballero | %% |
19 | // A task begins life in suspended animation. |
||
20 | |||
21 | 3978 | caballero | FirstPoint |
22 | 3828 | caballero | |
23 | 4708 | caballero | Entry { |
24 | 4892 | caballero | setQuestion( |
25 | 5207 | caballero | PluginServices.getText(this,"insert_point_selection")); |
26 | setDescription(new String[]{"cancel"}); |
||
27 | 4708 | caballero | } |
28 | Exit{ |
||
29 | } |
||
30 | 3828 | caballero | |
31 | 4708 | caballero | { |
32 | |||
33 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
34 | [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint")] |
||
35 | SecondPoint{ |
||
36 | 5207 | caballero | setQuestion(PluginServices.getText(this,"insert_second_point")); |
37 | setDescription(new String[]{"cancel"}); |
||
38 | 4708 | caballero | addPoint( pointX,pointY,event); |
39 | } |
||
40 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
41 | [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")] |
||
42 | WithSelectedFeatures { |
||
43 | setQuestion(PluginServices.getText(this,"select_handlers")); |
||
44 | 5207 | caballero | setDescription(new String[]{"cancel"}); |
45 | 4708 | caballero | addPoint( pointX,pointY,event); |
46 | end(); |
||
47 | } |
||
48 | 3828 | caballero | } |
49 | |||
50 | 3978 | caballero | SecondPoint{ |
51 | 4708 | caballero | // Si hemos conseguido seleccionar algo |
52 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
53 | [ctxt.selectWithSecondPoint(pointX,pointY, event) > 0] |
||
54 | WithSelectedFeatures { |
||
55 | setQuestion(PluginServices.getText(this,"select_handlers")); |
||
56 | 5207 | caballero | setDescription(new String[]{"cancel"}); |
57 | 4708 | caballero | addPoint( pointX,pointY,event); |
58 | end(); |
||
59 | } |
||
60 | // Si no lo hemos conseguido |
||
61 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
62 | FirstPoint { |
||
63 | 5207 | caballero | setQuestion(PluginServices.getText(this,"insert_point_selection")); |
64 | setDescription(new String[]{"cancel"}); |
||
65 | 4708 | caballero | addPoint(pointX,pointY,event); |
66 | } |
||
67 | addOption(s:String) |
||
68 | FirstPoint{ |
||
69 | 5207 | caballero | setQuestion(PluginServices.getText(this,"insert_point_selection")); |
70 | setDescription(new String[]{"cancel"}); |
||
71 | 4708 | caballero | setType(s); |
72 | } |
||
73 | 4448 | fjp | |
74 | } |
||
75 | WithSelectedFeatures{ |
||
76 | |||
77 | 4708 | caballero | // Si hemos pinchado encima de un handler |
78 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
79 | [ctxt.selectHandlers(pointX, pointY, event)>0] |
||
80 | WithHandlers { |
||
81 | setQuestion(PluginServices.getText(this,"insert_destination_point")); |
||
82 | 5207 | caballero | setDescription(new String[]{"cancel"}); |
83 | 4708 | caballero | addPoint( pointX,pointY,event); |
84 | // refresh(); |
||
85 | } |
||
86 | 4448 | fjp | |
87 | 4708 | caballero | // Si no hemos cogido un handler, probamos a seleccionar |
88 | // otra entidad |
||
89 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
90 | [ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")] |
||
91 | WithSelectedFeatures { |
||
92 | setQuestion(PluginServices.getText(this,"select_handlers")); |
||
93 | 5207 | caballero | setDescription(new String[]{"cancel"}); |
94 | 4708 | caballero | addPoint( pointX,pointY,event); |
95 | } |
||
96 | 3844 | caballero | |
97 | |||
98 | 4708 | caballero | // Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial |
99 | addPoint( pointX:double,pointY:double,event:InputEvent) |
||
100 | FirstPoint { |
||
101 | 5207 | caballero | setQuestion(PluginServices.getText(this,"insert_point_selection")); |
102 | setDescription(new String[]{"cancel"}); |
||
103 | 4708 | caballero | addPoint( pointX,pointY,event); |
104 | // refresh(); |
||
105 | } |
||
106 | addOption(s:String) |
||
107 | FirstPoint{ |
||
108 | 5207 | caballero | setQuestion(PluginServices.getText(this,"insert_point_selection")); |
109 | setDescription(new String[]{"cancel"}); |
||
110 | 4708 | caballero | setType(s); |
111 | } |
||
112 | 3828 | caballero | } |
113 | 3978 | caballero | |
114 | 4445 | fjp | WithHandlers{ |
115 | 4708 | caballero | addPoint( pointX:double,pointY:double,event:InputEvent) |
116 | WithSelectedFeatures { |
||
117 | setQuestion(PluginServices.getText(this,"select_handlers")); |
||
118 | 5207 | caballero | setDescription(new String[]{"cancel"}); |
119 | 4708 | caballero | addPoint( pointX,pointY,event); |
120 | refresh(); |
||
121 | } |
||
122 | 4445 | fjp | } |
123 | |||
124 | 3828 | caballero | Default |
125 | { |
||
126 | 9065 | caballero | addOption(s:String) |
127 | [s.equals("")] |
||
128 | FirstPoint{ |
||
129 | restorePreviousTool(); |
||
130 | setQuestion(PluginServices.getText(this,"insert_point_selection")); |
||
131 | setDescription(new String[]{"cancel"}); |
||
132 | end(); |
||
133 | } |
||
134 | 4708 | caballero | addOption(s:String) |
135 | [s.equals(PluginServices.getText(this,"cancel"))] |
||
136 | FirstPoint{ |
||
137 | end(); |
||
138 | } |
||
139 | 5730 | caballero | addOption(s:String) |
140 | FirstPoint{ |
||
141 | throwOptionException(PluginServices.getText(this,"incorrect_option"),s); |
||
142 | } |
||
143 | addValue(d:double) |
||
144 | FirstPoint{ |
||
145 | throwValueException(PluginServices.getText(this,"incorrect_value"),d); |
||
146 | } |
||
147 | addPoint(pointX:double,pointY:double,event:InputEvent) |
||
148 | FirstPoint{ |
||
149 | throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY); |
||
150 | } |
||
151 | 3828 | caballero | } |
152 | %% |