Revision 2

View differences:

org.gvsig.vectorediting/trunk/docs/dt-gvsig-edicion.rst
1
=================================================================
2
 New gvSIG 2.1+ vector editing support
3
=================================================================
4

  
5
-------------------
6
 Technical design
7
-------------------
8

  
9
:Company:   gvSIG Association 
10
:Author:    DiSiD Corporation, S.L.
11
:Revision:  $Rev: $
12
:Date:      $Date: $
13
:Copyright: 
14

  
15
.. contents::
16
   :depth: 2
17
   :backlinks: none
18

  
19
.. sectnum::
20
   :depth: 2
21
   :start: 1
22

  
23
.. |year| date:: %Y
24

  
25
.. header:: 
26
      
27
   .. class:: headertable
28

  
29
   +-----------------------+-------------------------+
30
   |.. class:: left        |.. class:: right         |
31
   |                       |                         |
32
   | Requisitos            |###Page###               |
33
   +-----------------------+-------------------------+ 
34

  
35

  
36
.. footer:: 
37

  
38
    .. include:: <isonum.txt>
39

  
40
    .. class:: left
41

  
42
    *New gvSIG 2.1+ vector editing support - Technical design*
43

  
44
    |copy| |year| ** 
45

  
46

  
47
Introduction
48
=============
49

  
50
gvSIG 2.1 provides vector editing support, which was already available since gvSIG 1.9, and has been migrated and adapted to the newer versions. But from the user point of view it lacks usability and an uniform way of interacting with the user. A lot of the editing tools provided in gvSIG are lacking from the usability point of view, as well as the limitations they have.
51

  
52
From the point of view of a developer, it is a bit cumbersome to develop new vector editing tools, with too much responsability given to each tool implementation. Also there is not a well defined API to be able to use the vector editing support out of the user interface.
53

  
54
To be able to solve those problems, a new project has been started to create a new vector editing implementation, from the core editing support to each of the editing tools. To make the most of it, a new list of funtional and technical requirements have been gathered, and a new functional analysis has been performed.
55

  
56
This document is the technical design of the new vector editing library and support for gvSIG 2.1+, taking into account the new requirements and the functional analysis.
57

  
58
First, a list of new technical requirements gathered while creating the technical design will be listed to have a bit of context of the proposed design. Next, the APIs and implementations of the different modules of the editing support will be defined.
59

  
60
Technical requirements
61
=======================
62

  
63
* As this may be a mid/long term project, a way to be able to coexist the old vector editing implementation with the new one must be provided. The idea is for the user to be able to install the new editing support and disable the old one, without needing another gvSIG desktop installation. That means no changes to gvSIG core projects need to be performed, or the ones to perform must be compatible with the old vector editing.
64

  
65
* The way to integrate de editing support in gvSIG, taking into account the previous requirement is to use MapControl Behavior objects.
66

  
67
* Andami Extension objects will be used to register the vector editing tools, managing also the status (enabled, active, ...) required by Andami while being added as toolbar buttons and menu entries.
68

  
69
* An editing tool library must be implemented which allows to use it not only from the user interface, like for example a gvSIG personalization, an addon or a script.
70

  
71
Technical design
72
=====================
73

  
74
To have a bit of context of the proposed design, we will first provide a description of how should work the new editing support for an example tool, and some needs for the editing library API and SPI. Next, the API, SPI, implementation and other packages will be defined.
75

  
76
Example use case description
77
-------------------------------
78

  
79
When gvSIG is launched, a EditingExtension registers an EditingBehavior in MapControl to provide user interaction with the editing tools. When an EditingTool is started, the EditingBehavior will interact with the tool to:
80

  
81
* Get the first/next parameter required by the tool
82
* Get the information of a parameter: type, description, ...
83
* Get a Geometry to represent the current editing status.
84

  
85
The EditingBehavior responsability will be to interact with the user to provide the EditingTool with the required parameters. That interaction will be performed through three different ways:
86

  
87
* Left button mouse clicks: mainly used to get map locations.
88
* Contextual menu options: to select between available options or open a dialog with a form to fill the required parameter values.
89
* Through the text console.
90

  
91
Each editing tool or group of tools have an Extension which registers the related toolbar buttons and menu entries, as well as register the editing tools in the editing library SPI. Also the Extension must be able to activate the editing tool when the user clicks in the related toolbar button or menu entry. That means an Extension will require to interact with the editing library for the following actions:
92

  
93
* Register an editing tool.
94
* Ask if an editing tool is enabled or active for the current context.
95
* Start an editing tool.
96

  
97
With this context, an example use case of a editing tool to create a Curve geometry will be as follows:
98

  
99
* The user clicks on the create Curve button, and the related Extension activates the CurveEditingTool.
100
* The EditingBehavior asks the tool for a mouse icon to use, or uses a default one.
101
* The EditingBehavior asks the tool for the first parameter.
102
* The CurveEditingTool responds with a parameter of type *List of Points*.
103
* The EditingBehavior activates a message in the console asking for the X,Y values of the next Point. 
104
* The user has then three options to provide the point: 
105
  * Click with the mouse left button in the map.
106
  * Write in the console the X,Y values of the point.
107
  * Opens the contextual menu and select the option to provide the X,Y values, which will open a dialog with a form to write the two values.
108
* Each time the user moves the mouse cursor, the EditingBehavior requests the tool a Geometry to draw with the current context and the map location of the mouse cursor. In this case, the Geometry will be a Curve created with the user already defined points and, as the last point, the current mouse cursor location.
109
* Once the value of the point is provided by the user to the EditingBehavior (through mouse, dialog or console), it creates a Point and provides the value to the tool and asks for another Point to the user, with an option to allow the user to end the Curve:
110
  * With a mouse left button double click.
111
  * With a value in the console (*?E?*)
112
  * With an option in the contextual menu.
113
* This process is repited until the user ends the list of points.
114
* The EditingBehavior notifies the tool the list of Points is finished.
115
* The tool creates a curve with the provided points, and a Feature is created and inserted into the current Layer FeatureStore.
116
* The tool ends and it is activated again by default. The user may create another Curve or activate another tool.
117
* In any point of the process, the user may activate another tool o pulse the *Esc* to finish the current tool execution and start again. **NOTE: if the user has already provided some data, ?ask him to confirm the cancelation and lose the data?**
118

  
119
API
120
----
121

  
122
This is the API of the vector editing library, which wil be based on the gvSIG tools PBI model (Provider Based Implementation).
123

  
124
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api
125
* Package: or.gvsig.vectorediting.lib.api
126

  
127
EditingManager (extends o.g.t.s.Manager)
128
*********************************************
129

  
130
The API will provide the following services:
131

  
132
* Provide an EditingService for an editing tool.
133

  
134
* Provide information of an editing tool:: EditingServiceInfo
135

  
136
EditingService (extends Service)
137
*****************************************************
138

  
139
* Start the edition.
140

  
141
* Provide the following parameter required by the tool
142

  
143
* Set the current parameter value.
144

  
145
* Provide a Geometry to draw the current editing context, taking into account the values previously provided by the user and a Point with the current mouse cursor location.
146

  
147
* Cancel the execution of the tool.
148

  
149
* ?Ask for the Geometries or Features created, updated or removed by the tool?
150

  
151
EditingServiceInfo
152
*****************************************************
153

  
154
* Provide read only information about a tool:
155
  * Tool name.
156
  * Tool description (?use as contextual help?)
157
  * Mouse icon.
158
  * The geometry type being managed.
159
  * If the tool creates new geometries.
160
  * The list of the parameters.
161
* Provide read only information about a tool parameter :: EditingServiceParameter
162

  
163
EditingServiceParameter
164
*****************************************************
165

  
166
* Provide read only information about a parameter:
167

  
168
  * Parameter name.
169

  
170
  * Parameter description (?use as contextual help?)
171

  
172
  * Parameter type: 
173

  
174
    * Location Point
175
    * List of Location Points
176
    * Option
177
    * Value (*?typed value: string, integer, ...?*)
178
    * New Geometry of a given type.
179
    * Selection of one or many geometries/features.  
180

  
181
SPI
182
-----
183

  
184
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.spi
185
* Package: or.gvsig.vectorediting.lib.spi
186

  
187
EditingServiceManager (extends ProviderManager)
188
*****************************************************
189

  
190
* Registration of editing tools :: EditingProviderFactory.
191

  
192
EditingProviderServices (extends ProviderServices)
193
*****************************************************
194

  
195
* Store a new or updated Feature.
196

  
197
* Delete a Feature.
198

  
199
* ?Get the Symbol to draw a Geometry?.
200

  
201
* Create new Features based on another ones, following the common criteria about the alphanumeric information:
202
  * New Features created from an old one (ex: Split): clone all data, but the primary keys.
203
  * New Feature created from a set of Features (ex: Union): for every attribute, if the values are the same for all the source Features, ignoring null values, clone it. Otherwise leave as null.
204

  
205

  
206
DefaultEditingServiceInfo and DefaultEditingServiceParameter
207
**************************************************************
208

  
209
* Default implementations to be used by the tools.
210

  
211
EditingProviderFactory (ProviderFactory)
212
*****************************************************
213

  
214
* Provide information of the tool (see EditingManager's API).
215

  
216
* Provide information of a tool parameter (see EditingManager's API).
217

  
218
EditingProvider (Provider)
219
*****************************************************
220

  
221
* Provide the following parameter.
222
* Provide a Geometry to draw the current editing context (see EditingService's API).
223
* End the editing process and store changes.
224
* Cancel the editing process and discard changes. 
225

  
226
Implementation
227
----------------
228

  
229
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl
230
* Package: or.gvsig.vectorediting.lib.impl
231

  
232
Provides the implementation of the library components, extending the related base tools implementations.
233

  
234
Editing Plugin
235
---------------
236

  
237
* Project: org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin
238
* Package: or.gvsig.vectorediting.app.mainplugin
239

  
240
Provides the implementation of the main editing plugin, and integrates the editing library API, SPI and implementation in gvSIG.
241

  
242
EditingExtension
243
*****************************************************
244

  
245
Registers the EditingBehavior in MapContext, as well as the actions to activate/deactivate editing.
246

  
247
Also activates the console when editing is started, puts the selected layer store in editing mode, and notifies about the begin and end of editing mode.
248

  
249
EditingBehavior
250
*****************************************************
251

  
252
Implementation of Behavior which interacts with the editing tools.
253

  
254
.. admonition:: Doubt
255

  
256
   ?Create instead as an interface in the API, and create a default implementation in the library implementation?
257

  
258
BaseEditingServiceExtension
259
*****************************************************
260

  
261
Default implementation to be used by editing tool plugins. 
262

  
263
.. admonition:: Doubt
264

  
265
   Not sure if there is a mechanism to be able to have a single final implementation, or each extension must extend this one.
266

  
267
Other themes to take into account
268
-----------------------------------
269

  
270
Geometry construction
271
***********************
272

  
273
All geometries being constructed, not already available in the Geometry Library, must be added as operations.
274

  
275
Snappers
276
------------
277

  
278
Snapper support is defined in MapControl, with the current snappers available in the gvSIG main plugin. The current editing plugin only activates them and provides a configuration panel.
279

  
280
That panel should be moved out of the editing plugin to a new one, which also adds actions to enable or activate snappers by the user, also with a key shortcut.
281

  
282
Geometries composed of other geometries
283
-----------------------------------------
284

  
285
* A mechanism must be defined to allow a way for a tool to ask for new geometries, and the editing manager to be able to call other tools which create the required geometry type, in a kind of "reentering" mode.
286
  Two different approaches have been discussed:
287
  * The same EditingProvider should allow to create only Geometries instead of Features, with some kind of parameter or new methos.
288
  * Separate provider types, with the ones which create Features and other ones which create basic geometries.
289

  
290
Templates
291
----------------
292

  
293
As a future functionality, the user would be able to define templates for creating new Features, with default values for:
294

  
295
* Alphanumeric attributes
296
* Type of geometry
297
* Editing tool to use
298
* Simbology to apply
299

  
300
Now we are not going to implement this, but it would be nice if we could take this improvement into account so it could be implemented in the future without much changes.
301

  
302
Toolbar button with many option
303
---------------------------------
304

  
305
* As this needs support in Andami, for now all editing tools will be implemented simple. Ex: create a circle now asks first if the user wants to create it with center and radios or with three points. It should be implemented as two separated tools.
306

  
307
* In Andami it could be implemented as a way to group toolbar buttons in button menus, which could be defined through the config.xml file.
308

  
309

  

Also available in: Unified diff