3D Deallocating
This topic deals with how items are selected in CanvasMap. When the user clicks on an item (something that appears in the GUI), any objects that are currently selected must first be unselected. Then the new item is selected. Users may also click on something that triggers an unselected without selecting a new item (i.e. nothing is then selected).
Approach:
- Because just about anything can be selected, the Selected flag is handled in CMBase.
- SetSelected(true) is called to select something. This can be from outisde CanvasMap but is typically in reponse to a mousedown in a CMIitem
- SetSelected(false) is called to unselect an item
- SetSelected(Flag) takes the following action If the selection has changed (i.e. Selected!=NewSelected)
- If something is being selected
- Calls the MainContains to UnselectAll()
- Sets Selected=true
- Calls MakeSelected()
- Calls the MainContaner to let everyone know SelectionChanged(Target)
- else something is being deselected
- Sets Selected=false
- Calls Object.Unselected()
- Calls the Maincontainer to let everyone know SelectionChanged(Target)
- If something is being selected
- UnSelectAll(SendMessages)
- Calls all children to UnselectAll(SendMessages)
- If the item is selected
- Sets Selected=false
- Calls Unselected()
- If SendMessages==true
- Sends SELECTION_CHANGED message to MainContainer
Overriding
Note that selecting refers to selections of items in the MainContainer hierarchy. Objects will need to manage internal selections. As an example, a use may have selected a polygon in a layer and then selects another polygon in the same layer. This does not require a call to SetSelected() but the class will need to handle repainting and anyother issues internally. SetSelected() can be called but it will not have any effect because the object is already selected. Internal selections should call TheMainContainer.SelectionChanged() to send messages to listeners about selection changes that are internal to the item.
- UnselectThisAndChildren() - called by SetSelect() to unselect all items in the hierarhcy.
- if the object is selected
- Calls Unselected()
- Returns true
- if the object is selected
- Unselected()
- Deselects the object
Messages
SELECTION_CHANGED is sent when the selectoin has changed to a new object.
Code
CMBase: SetSelected(Flag) - public function called to select a specific item. This function just calls CMBase.SetSelected(Target,Flag).
static CMBase.SetSelected(TargetItem,Flag)
protected CMBase.MakeSelected() - override to do antyhing that is needed when an object is selected (i.e. add tools to the tool bar)
protected CMBase.Unselected() - override to undo anything that was done when the object was selected (i.e. clear the tool bar)