Mod digitize tab.php
From MapbenderWiki
Contents |
list of methods
button handling
displayButtons()
- this function is invoked on load. All buttons defined by element vars (buttonDig_ arrays) are initialized.
initDigButton(ind, pos)
- the button at index ind is initialized with the values of buttonDig_..[pos]. The enabled and disabled functions are being set as well.
digitizeEnable(obj)
- triggers the corresponding functions after the button obj has been enabled.
digitizeDisable(obj)
- triggers the corresponding functions after the button obj has been disabled.
point, line and polygon insertion
mod_digitize_go()
- starts tracking the mouse coordinates and checks if snapping occurs. When the mouse button is pressed, mod_digitize_start is invoked.
mod_digitize_start()
- adds a new basepoint to the current geometry.
mod_digitize_timeout()
- ends the current insertion or action.
basepoint handling
handleBasepoint(obj, i, j, k)
- this function checks what to do with a basepoint that is currently under the mouse pointer. Depending on what action is intended, other methods (the following) are invoked.
- the following global variables are required for basepoint handling:
- basepointObj: the basepoint itself (a div tag with css class 'bp', see digitize.css).
- basepointMemberIndex: the index of the member in the geometry array that contains the vertex representing the basepoint.
- basepointGeometryIndex: the index of the geography in the geometry array that contains the vertex representing the basepoint.
- basepointPointIndex: the index of the point in the geometry array that contains the vertex representing the basepoint.
- basepointDragActive: true if the basepoint is currently being moved (begins when the mouse button is pressed over a basepoint, ends when it is released)
convertLinepointToBasepoint(obj, i, j, k)
- this function is invoked when the mouse is over a linepoint. When the mouse is clicked, the method insert basepoint is called.
insertBasepoint()
- adds a new vertex with the coordinates of the mouse position into the geometry array.
deleteBasepoint()
- deletes all points in the geometry array that have the same coordinates as the basepoint.
selectBasepoint()
- when a basepoint move is intended, this function is invoked when the mouse button is pressed. It stores the start coordinates in a global variable and sets basepointDragActive to true, so other functions know that a basepoint is currently being dragged.
dragBasepoint()
- when a basepoint is being dragged and the mouse button is down, this function will track the mouse position. Instead of the basepoint, a transparent object the size of the mapframe is being displayed.
releaseBasepoint()
- when a basepoint is being dragged and the mouse button is released, this function is invoked and the geometry will be updated.
display
drawDashedLine()
- displays all visible geometries of the geometry array. Returns a string containg the div tags. Invokes the function updateListOfGeometries().
updateListOfGeometries()
- updates the list of geometries after the geometry array. This function is invoked only at the end of drawDashedLines().
evaluateDashes(start, end, i, j, k)
- this function calculates the line points between start and end vertices; i,j and k represent the indices of the adjacent basepoint in the geometry array. This information is needed when a linepoint is being converted to a basepoint.
calculateDashes(p, q, width, height)
- calculates the visible part of the line defined by vertices p and q. width and height are referring to the size of the mapframe. Returns an array of two points or false, if the line is not visible in the current map.
module registration
registerFunctions()
- this method is called onload. The given functions will be invoked whenever they are triggered.
checkTag()
- checks if a div tag with id of the digitize frame (given in the element vars: mod_digitize_elName) exists in frame mod_digitize_target. If yes, these element's attributes are set and itself is returned, if not, it is created (with attributes) and returned if an element with id like mod_digitize_elName exists and it is not a div tag, false is returned.
setStyleForTargetFrame()
- this adds the stylesheet to the map frame.
initialiseSnapping()
- enables snapping.
