CanvasMap
Getting Started Tutorials 3D Reference

Class CMBase

CMBase
This class provides basic support for objects that appear in the table of contents (TOC).

- Selecting and unselecting
- Getting and Setting Settings
- Getting and Setting Properties (settings, children, and anything else required to recreate the map)
- Manages children and being contained by a parent object
- Listeners


Copyright (C) 2020, Humboldt State University, Jim Graham

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see
.

Name Name CMTYPE_STRING Name that appears in the item and layer lists Open Open CMTYPE_BOOLEAN false true if the object is open in the editor tree PropertyURL PropertyURL CMTYPE_STRING optional URL to load properties (jjg?)

Static Functions

ReturnsFunctionThrows
UniqueNumber GetUniqueNumber()
Selected SetSelected()

Object Functions

ReturnsFunctionThrows
Name Deallocate()
AddChild(TheObject)
RemoveChild(Index)
InsertChild(Index)
NumChildren GetNumChildren(TheClass)
TheChild GetChild(Index, TheClass)
ChildIndex GetChildIndex(TheChild)
MoveChild(TheChild, Index)
TheChild GetNumDescendants(Index, TheClass)
GetDescendant(Index, CurrentRow)
SendMessageToDescendants()
UniqueNumber AddListener(TheFunction, TheMessage, TheListener)
RemoveListener(TheMessage, UniqueNumber)
SendMessageToListeners(TheMessage, AdditionalInfo)
Settings GetAllSettings()
SetAllSettings(NewSettings)
Value GetGroupDefs(Group, Default)
GetSettingDefinition(Param1, Param2)
GetSetting(Param1, Param2, Param3)
SetSetting(Param1, Param2, Param3)
UnselectAll()

Static Functions

UniqueNumber=GetUniqueNumber()

Gets an integer that is unique for this instance of CanvasMap. This is
used to ensure that all messages have a unique value.

Has to appear here because it is called below

Returns: UniqueNumber - unique integer

Selected=SetSelected()

Sets this object to be the one the user has selected

Returns: Selected - flag

Object Functions

Name=Deallocate()

Gets the current name of the object

Returns: Name - the name of this object

AddChild(TheObject)

Adds an entry to the child array

Parameters:
    TheObject - Object to add as a child to this object.

RemoveChild(Index)

Removes an entry from the child array

Parameters:
    Index - Index of the child to remove starting at 0 or the child itself

InsertChild(Index)

Inserts a child object into the child array

Parameters:
    Index - Index of the child to insert or an existing child at the position of insertion

NumChildren=GetNumChildren(TheClass)

Gets the number of children the object contains.

Parameters:
    TheClass - optional class to filter the children

Returns: NumChildren - the number of children contained in this object.

TheChild=GetChild(Index, TheClass)

Gets a child from the object

Parameters:
    Index - zero-based index to the desired child. If not provided, the first entry is returned.
    TheClass - optional class to filter the children

Returns: TheChild - the child object contained within this object.

ChildIndex=GetChildIndex(TheChild)

Return the index for the specified child object. If the
child does not appear in the CMScene, return -1

Parameters:
    TheChild -

Returns: ChildIndex - null

MoveChild(TheChild, Index)

Moves a child to a new location in the list (used to move layers).
This does not need to be overriden because RemoveChild() and InsertChild() are used.

Parameters:
    TheChild - either the child to remove or an index to the child
    Index - Index of the child to remove starting at 0

TheChild=GetNumDescendants(Index, TheClass)

Gets the total number of descendants that are in this object. This includes
direct children, their children, and so on.

Parameters:
    Index - zero-based index to the desired child
    TheClass - optional class to filter the children

Returns: TheChild - the child object contained within this object.

GetDescendant(Index, CurrentRow)

Returns a descendent of this object.

Parameters:
    Index - 0 this object's first child, 2 for this objects first grandchild or second child, etc.
    CurrentRow - optional parameter for the row we are current looking for a descendent on.

SendMessageToDescendants()

General function to send a message to all the descendents of an object.
Used to send event messages to children.

UniqueNumber=AddListener(TheFunction, TheMessage, TheListener)

Add a listener to listen for messages from this object. Messages are
delivered with the function call:

TheFunction(TheSender,TheListener,AdditionalInfo)

TheFunction will receive the messages when sent by TheSender. TheListener
is the object that added itself as the listener so the function can access
its properties. AdditionaInfo is provided by the sender based on the type of message.

Parameters:
    TheFunction - The function that will listen to messages
    TheMessage - The message number the object wants to listen to
    TheListener - The object that will receive messages from this object.

Returns: UniqueNumber - returns a unique number for the function that has been added so it can be removed easily.

RemoveListener(TheMessage, UniqueNumber)

Removes a listener from the list of listeners

Parameters:
    TheMessage - The message that the listener was listening for
    UniqueNumber - the unique number that was generated when the listener was added.

SendMessageToListeners(TheMessage, AdditionalInfo)

Removes a listener from the list of listeners

Parameters:
    TheMessage - The message to send
    AdditionalInfo - additional information based on the message type

Settings=GetAllSettings()

Get a set of settings.

Returns: Settings - current settings object (may be undefined)

SetAllSettings(NewSettings)

Sets all the settings for this object.

Parameters:
    NewSettings - The settings to replace the existing settings.

Value=GetGroupDefs(Group, Default)

Get a group of settings. Does not check for errors and the returned result could be undefined.

Parameters:
    Group - Group for the setting
    Default - default value to use in none has been specified as of yet (optional)

Returns: Value - currnet group entry or undefined.

GetSettingDefinition(Param1, Param2)

Gets the setting definition for a group/setting pair.

Parameters:
    Param1 - Either the setting name or the group name
    Param2 - Setting name, default, or undefined

GetSetting(Param1, Param2, Param3)

Sets a set of settings for this object. The TimeSlice must already exist within the object.

Parameters:
    Param1 - Either the setting name or the group name
    Param2 - Setting name, default, or undefined
    Param3 - default, or undefined

SetSetting(Param1, Param2, Param3)

Sets a set of settings for this object. ct.

Parameters:
    Param1 - Group or setting
    Param2 - Setting or value
    Param3 - Value

UnselectAll()

Unselect all objects