root / trunk / extensions / extCAD / sm / SelectionCADTool.sm @ 4448
History | View | Annotate | Download (2.98 KB)
1 |
// -*- tab-width: 4; -*- |
---|---|
2 |
|
3 |
%{ |
4 |
// |
5 |
// Vicente Caballero Navarro |
6 |
%} |
7 |
|
8 |
%start Selection::FirstPoint |
9 |
%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 |
%import java.awt.event.InputEvent |
14 |
|
15 |
|
16 |
%map Selection |
17 |
%% |
18 |
// A task begins life in suspended animation. |
19 |
|
20 |
FirstPoint |
21 |
|
22 |
Entry { |
23 |
setQuestion("SELECCION" + "\n" + |
24 |
"Precise punto del rect?ngulo de selecci?n"); |
25 |
setDescription(new String[]{"Cancelar"}); |
26 |
} |
27 |
Exit{ |
28 |
} |
29 |
|
30 |
{ |
31 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
32 |
[ctxt.selectFeatures(pointX,pointY) && ctxt.getNextState().equals("Selection.SecondPoint")] |
33 |
SecondPoint{ |
34 |
setQuestion("Precise segundo punto del rect?ngulo de seleccion"); |
35 |
setDescription(new String[]{"Cancelar"}); |
36 |
addPoint( pointX,pointY,event); |
37 |
} |
38 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
39 |
[ctxt.getNextState().equals("Selection.WithSelectedFeatures")] |
40 |
WithSelectedFeatures { |
41 |
setQuestion("select_handlers"); |
42 |
setDescription(new String[]{"Cancelar"}); |
43 |
addPoint( pointX,pointY,event); |
44 |
} |
45 |
} |
46 |
|
47 |
SecondPoint{ |
48 |
// Si hemos conseguido seleccionar algo |
49 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
50 |
[ctxt.selectWithSecondPoint(pointX,pointY) > 0] |
51 |
WithSelectedFeatures { |
52 |
setQuestion("select_handlers"); |
53 |
setDescription(new String[]{"Cancelar"}); |
54 |
addPoint( pointX,pointY,event); |
55 |
} |
56 |
// Si no lo hemos conseguido |
57 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
58 |
FirstPoint { |
59 |
setQuestion("Precise punto del rect?ngulo de selecci?n"); |
60 |
setDescription(new String[]{"Cancelar"}); |
61 |
|
62 |
} |
63 |
|
64 |
|
65 |
} |
66 |
WithSelectedFeatures{ |
67 |
|
68 |
// Si hemos pinchado encima de un handler |
69 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
70 |
[ctxt.selectHandlers(pointX, pointY)>0] |
71 |
WithHandlers { |
72 |
setQuestion("Precise punto destino"); |
73 |
setDescription(new String[]{"Cancelar"}); |
74 |
addPoint( pointX,pointY,event); |
75 |
// refresh(); |
76 |
} |
77 |
|
78 |
// Si no hemos cogido un handler, probamos a seleccionar |
79 |
// otra entidad |
80 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
81 |
[ctxt.selectFeatures(pointX,pointY) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")] |
82 |
WithSelectedFeatures { |
83 |
setQuestion("select_handlers"); |
84 |
setDescription(new String[]{"Cancelar"}); |
85 |
addPoint( pointX,pointY,event); |
86 |
} |
87 |
|
88 |
|
89 |
// Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial |
90 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
91 |
FirstPoint { |
92 |
setQuestion("Precise punto del rect?ngulo de selecci?n"); |
93 |
setDescription(new String[]{"Cancelar"}); |
94 |
addPoint( pointX,pointY,event); |
95 |
// refresh(); |
96 |
} |
97 |
|
98 |
} |
99 |
|
100 |
WithHandlers{ |
101 |
addPoint( pointX:double,pointY:double,event:InputEvent) |
102 |
WithSelectedFeatures { |
103 |
setQuestion("select_handlers"); |
104 |
setDescription(new String[]{"Cancelar"}); |
105 |
addPoint( pointX,pointY,event); |
106 |
refresh(); |
107 |
} |
108 |
} |
109 |
|
110 |
Default |
111 |
{ |
112 |
addOption(s:String) |
113 |
[s.equals("Cancelar")] |
114 |
FirstPoint{ |
115 |
end(); |
116 |
} |
117 |
} |
118 |
%% |