Statistics
| Revision:

svn-gvsig-desktop / tags / v1_9_Build_1253 / extensions / extCAD / sm / SelectionCADTool.sm @ 47746

History | View | Annotate | Download (4.55 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 java.awt.event.InputEvent
13
%import com.iver.andami.PluginServices
14

    
15

    
16
%map Selection
17
%%
18
// A task begins life in suspended animation.
19

    
20
FirstPoint
21

    
22
  Entry {
23
    setQuestion(
24
    PluginServices.getText(this,"insert_point_selection"));
25
    setDescription(new String[]{"cancel"});
26
    }
27
  Exit{
28
    }
29

    
30
  {
31

    
32
    addPoint( pointX:double,pointY:double,event:InputEvent)
33
      [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint")]
34
      SecondPoint{
35
        setQuestion(PluginServices.getText(this,"insert_second_point"));
36
        setDescription(new String[]{"cancel"});
37
        addPoint( pointX,pointY,event);
38
        }
39
    addPoint( pointX:double,pointY:double,event:InputEvent)
40
      [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")]
41
      WithSelectedFeatures {
42
        setQuestion(PluginServices.getText(this,"select_handlers"));
43
        setDescription(new String[]{"cancel"});
44
        addPoint( pointX,pointY,event);
45
        end();
46
        }
47
}
48

    
49
SecondPoint{
50
  // Si hemos conseguido seleccionar algo
51
  addPoint( pointX:double,pointY:double,event:InputEvent)
52
      [ctxt.selectWithSecondPoint(pointX,pointY, event) > 0]
53
      WithSelectedFeatures {
54
        setQuestion(PluginServices.getText(this,"select_handlers"));
55
        setDescription(new String[]{"cancel"});
56
        addPoint( pointX,pointY,event);
57
        end();
58
        }
59
  // Si no lo hemos conseguido
60
  addPoint( pointX:double,pointY:double,event:InputEvent)
61
      FirstPoint {
62
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
63
        setDescription(new String[]{"cancel"});
64
        addPoint(pointX,pointY,event);
65
        }
66
  addOption(s:String)
67
      FirstPoint{
68
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
69
        setDescription(new String[]{"cancel"});
70
        setType(s);
71
        }
72

    
73
}
74
WithSelectedFeatures{
75

    
76
  // Si hemos pinchado encima de un handler
77
  addPoint( pointX:double,pointY:double,event:InputEvent)
78
  [ctxt.selectHandlers(pointX, pointY, event)>0]
79
      WithHandlers {
80
        setQuestion(PluginServices.getText(this,"insert_destination_point"));
81
        setDescription(new String[]{"cancel"});
82
        addPoint( pointX,pointY,event);
83
        // refresh();
84
        }
85

    
86
  // Si no hemos cogido un handler, probamos a seleccionar
87
  // otra entidad
88
  addPoint( pointX:double,pointY:double,event:InputEvent)
89
    [ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")]
90
      WithSelectedFeatures {
91
        setQuestion(PluginServices.getText(this,"select_handlers"));
92
        setDescription(new String[]{"cancel"});
93
        addPoint( pointX,pointY,event);
94
        }
95

    
96

    
97
  // Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial
98
  addPoint( pointX:double,pointY:double,event:InputEvent)
99
      FirstPoint {
100
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
101
        setDescription(new String[]{"cancel"});
102
        addPoint( pointX,pointY,event);
103
        // refresh();
104
        }
105
	 addOption(s:String)
106
      FirstPoint{
107
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
108
        setDescription(new String[]{"cancel"});
109
        setType(s);
110
        }
111
}
112

    
113
WithHandlers{
114
  addPoint( pointX:double,pointY:double,event:InputEvent)
115
      WithSelectedFeatures {
116
        setQuestion(PluginServices.getText(this,"select_handlers"));
117
        setDescription(new String[]{"cancel"});
118
        addPoint( pointX,pointY,event);
119
        refresh();
120
        }
121
}
122

    
123
Default
124
{
125
	addOption(s:String)
126
      [s.equals("")]
127
      FirstPoint{
128
        restorePreviousTool();
129
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
130
        setDescription(new String[]{"cancel"});
131
        end();
132
        }
133
  addOption(s:String)
134
    [s.equals(PluginServices.getText(this,"cancel"))]
135
    FirstPoint{
136
      end();
137
      }
138
    addOption(s:String)
139
		FirstPoint{
140
			throwOptionException(PluginServices.getText(this,"incorrect_option"),s);
141
			}
142
	addValue(d:double)
143
		FirstPoint{
144
			throwValueException(PluginServices.getText(this,"incorrect_value"),d);
145
			}
146
	addPoint(pointX:double,pointY:double,event:InputEvent)
147
		FirstPoint{
148
			throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY);
149
			}
150
}
151
%%