Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_RELEASE / extensions / extCAD / sm / SelectionCADTool.sm @ 9167

History | View | Annotate | Download (4.6 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
%import com.iver.andami.PluginServices
15

    
16

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

    
21
FirstPoint
22

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

    
31
  {
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
        setQuestion(PluginServices.getText(this,"insert_second_point"));
37
        setDescription(new String[]{"cancel"});
38
        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
        setDescription(new String[]{"cancel"});
45
        addPoint( pointX,pointY,event);
46
        end();
47
        }
48
}
49

    
50
SecondPoint{
51
  // 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
        setDescription(new String[]{"cancel"});
57
        addPoint( pointX,pointY,event);
58
        end();
59
        }
60
  // Si no lo hemos conseguido
61
  addPoint( pointX:double,pointY:double,event:InputEvent)
62
      FirstPoint {
63
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
64
        setDescription(new String[]{"cancel"});
65
        addPoint(pointX,pointY,event);
66
        }
67
  addOption(s:String)
68
      FirstPoint{
69
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
70
        setDescription(new String[]{"cancel"});
71
        setType(s);
72
        }
73

    
74
}
75
WithSelectedFeatures{
76

    
77
  // 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
        setDescription(new String[]{"cancel"});
83
        addPoint( pointX,pointY,event);
84
        // refresh();
85
        }
86

    
87
  // 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
        setDescription(new String[]{"cancel"});
94
        addPoint( pointX,pointY,event);
95
        }
96

    
97

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

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

    
124
Default
125
{
126
	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
  addOption(s:String)
135
    [s.equals(PluginServices.getText(this,"cancel"))]
136
    FirstPoint{
137
      end();
138
      }
139
    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
}
152
%%