Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extTopology / sm / TopologicalEditVertexCADTool.sm @ 28489

History | View | Annotate | Download (5.28 KB)

1 19998 azabala
2
%{
3
/**
4
 Finite state machine, generated with fsm tool
5
 (http://smc.sourceforge.net)
6
 @author Alvaro Zabala
7
*/
8
%}
9
10
%start TopologicalEdition::FirstPoint
11
%class TopologicalEditVertexCADTool
12
%package com.iver.cit.gvsig.cad.sm
13
%import com.iver.cit.gvsig.cad.TopologicalEditVertexCADTool
14
%import java.awt.event.InputEvent
15
%import com.iver.andami.PluginServices
16
17
18
%map TopologicalEdition
19
%%
20
21
22
23
FirstPoint
24
25
  Entry {
26
    setQuestion(PluginServices.getText(this,"insert_point_selection"));
27
    setDescription(new String[]{"cancel"});
28
  }
29
30
  Exit{
31
  }
32
33
  {
34
35
  addPoint( pointX:double,pointY:double,event:InputEvent)
36
  [ctxt.getType().equals(PluginServices.getText(this,"simple")) &&
37
   ctxt.selectFeatures(pointX,pointY, event) &&
38
   ctxt.getNextState().equals("TopologicalEdition.SecondPoint")]
39
      SecondPoint{
40
        setQuestion(PluginServices.getText(this,"insert_second_point"));
41
        setDescription(new String[]{"cancel"});
42
        addPoint( pointX,pointY,event);
43
       }
44
45
  addPoint( pointX:double,pointY:double,event:InputEvent)
46
  [ctxt.getType().equals(PluginServices.getText(this,"simple")) &&
47
   ctxt.getNextState().equals("TopologicalEdition.WithSelectedFeatures")]
48
	  WithSelectedFeatures {
49
	    	setQuestion(PluginServices.getText(this,"select_handlers"));
50
	    	setDescription(new String[]{"cancel"});
51
	    	//Ver si lo borramos
52
	    	addPoint( pointX,pointY,event);
53
	    	end();
54
	  }
55
56
	   addPoint( pointX:double,pointY:double,event:InputEvent)
57
  [ctxt.getType().equals(PluginServices.getText(this,"simple")) &&
58
   ctxt.getNextState().equals("TopologicalEdition.WithHandlers")]
59
	  WithHandlers {
60
	    	setQuestion(PluginServices.getText(this,"select_handlers"));
61
	    	setDescription(new String[]{"cancel"});
62
	    	//Ver si lo borramos
63
        	addPoint( pointX,pointY,event);
64
        	refresh();
65
	  }
66
}
67
68
69
WithSelectedFeatures{
70
  // Si hemos pinchado encima de un handler
71
  addPoint( pointX:double,pointY:double,event:InputEvent)
72
  [ctxt.selectHandlers(pointX, pointY, event)>0]
73
      WithHandlers {
74
        setQuestion(PluginServices.getText(this,"insert_destination_point"));
75
        setDescription(new String[]{"cancel"});
76
        addPoint( pointX,pointY,event);
77
        // refresh();
78
        refresh();
79
        }
80
81
82
  // Si no hemos cogido un handler, probamos a seleccionar
83
  // otra entidad
84
  addPoint( pointX:double,pointY:double,event:InputEvent)
85
    [ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("TopologicalEdition.WithSelectedFeatures")]
86
      WithSelectedFeatures {
87
        setQuestion(PluginServices.getText(this,"select_handlers"));
88
        setDescription(new String[]{"cancel"});
89
        addPoint( pointX,pointY,event);
90
        }
91
92
93
  // Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial
94
  addPoint( pointX:double,pointY:double,event:InputEvent)
95
      FirstPoint {
96
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
97
        setDescription(new String[]{"cancel"});
98
        addPoint( pointX,pointY,event);
99
        // refresh();
100
        }
101
	 addOption(s:String)
102
      FirstPoint{
103
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
104
        setDescription(new String[]{"cancel"});
105
        setType(s);
106
        }
107
}
108
109
110
SecondPoint{
111
  // Si hemos conseguido seleccionar algo
112
  addPoint( pointX:double,pointY:double,event:InputEvent)
113
      [ctxt.selectWithSecondPoint(pointX,pointY, event) > 0]
114
      WithSelectedFeatures {
115
        setQuestion(PluginServices.getText(this,"select_handlers"));
116
        setDescription(new String[]{"cancel"});
117
        addPoint( pointX,pointY,event);
118
        end();
119
        }
120
  // Si no lo hemos conseguido
121
  addPoint( pointX:double,pointY:double,event:InputEvent)
122
      FirstPoint {
123
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
124
        setDescription(new String[]{"cancel"});
125
        addPoint(pointX,pointY,event);
126
        }
127
  addOption(s:String)
128
      FirstPoint{
129
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
130
        setDescription(new String[]{"cancel"});
131
        setType(s);
132
        }
133
134
}
135
136
WithHandlers{
137
  addPoint( pointX:double,pointY:double,event:InputEvent)
138 20052 azabala
      	FirstPoint{
139
      	//WithSelectedFeatures {
140 19998 azabala
        setQuestion(PluginServices.getText(this,"select_handlers"));
141
        setDescription(new String[]{"cancel"});
142
        addPoint( pointX,pointY,event);
143
        refresh();
144
        }
145
}
146
147
148
149
150
Default
151
{
152
	addOption(s:String)
153
      [s.equals("")]
154
      FirstPoint{
155
        restorePreviousTool();
156
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
157
        setDescription(new String[]{"cancel"});
158
        end();
159
        }
160
161
  addOption(s:String)
162
    [s.equals(PluginServices.getText(this,"cancel"))]
163
    FirstPoint{
164
      end();
165
      }
166
167
    addOption(s:String)
168
		FirstPoint{
169
			throwOptionException(PluginServices.getText(this,"incorrect_option"),s);
170
			}
171
172
	addValue(d:double)
173
		FirstPoint{
174
			throwValueException(PluginServices.getText(this,"incorrect_value"),d);
175
			}
176
177
	addPoint(pointX:double,pointY:double,event:InputEvent)
178
		FirstPoint{
179
			throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY);
180
			}
181
}
182
%%