Model Railroad System  2.2.2
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CTCPanel::CTCPanel Class Reference

Main CTC Panel megawidget. More...

Public Member Functions

 CTCPanel (name,...)
 Build and install all component widgets and process configuration. More...
 
 updateSR (canvas, newheight, newwidth)
 Method to update one of the canvases scroll region. More...
 
 zoomBy (zoomFactor)
 Method to zoom the display by a zoom factor. More...
 
 setZoom (zoomFactor)
 Method to set the zoom factor to a specific factor. More...
 
 getZoom ()
 Return the zoom (scaling) factor. More...
 
 getv (name)
 Method to get the value (or state) of an object. More...
 
 setv (name, value)
 Method to set the value (or state) of an object. More...
 
 geti (name, ind)
 Method to get the indicator state of an object. More...
 
 seti (name, ind, value)
 Method to set the indicator state of an object. More...
 
 itemcget (name, option)
 Method to get a configuration option from an object. More...
 
 itemconfigure (name,...)
 Method to set a configuration option from an object. More...
 
 exists (name)
 Test if the named object exists. More...
 
 delete (name)
 Delete a named object. More...
 
 move (name, x, y)
 Move a named object. More...
 
 invoke (name)
 Method to invoke an object. More...
 
 coords (name, tname)
 Method to fetch the coordinates of some part of an object. More...
 
 bind (name,...)
 Method to set a binding on an Object. More...
 
 print (name, fp)
 Method to print the named object to the specificied file channel. More...
 
 objectlist (cp="", class="")
 Method to return the list of objects. More...
 
 cplist ()
 Method to return the list of controlpoints. More...
 
 create_SWPlate (name,...)
 Method to create a switch plate object. More...
 
 create_SIGPlate (name,...)
 Method to create a signal plate object. More...
 
 create_CodeButton (name,...)
 Method to create a code button object. More...
 
 create_Toggle (name,...)
 Method to create a toggle switch object. More...
 
 create_Lamp (name,...)
 Method to create a lamp object. More...
 
 create_CTCLabel (name,...)
 Method to create a CTC Label label object. More...
 
 create_Switch (name,...)
 Method to create a switch (turnout) object. More...
 
 create_SchLabel (name,...)
 Method to create a schematic label object. More...
 
 create_StraightBlock (name,...)
 Method to create a straight block of track object. More...
 
 create_EndBumper (name,...)
 Method to create a end bumper of track object. More...
 
 create_CurvedBlock (name,...)
 Method to create a curved block of track object. More...
 
 create_ScissorCrossover (name,...)
 Method to create a scissor crossover object. More...
 
 create_Crossover (name,...)
 Method to create a crossover object. More...
 
 create_Crossing (name,...)
 Method to create a track crossing object. More...
 
 create_SingleSlip (name,...)
 Method to create a single slip object. More...
 
 create_DoubleSlip (name,...)
 Method to create a double slip object. More...
 
 create_ThreeWaySW (name,...)
 Method to create a three way switch object. More...
 
 create_HiddenBlock (name,...)
 Method to create a hidden block of track object. More...
 
 create_StubYard (name,...)
 Method to create a stub (deadend) yard object. More...
 
 create_ThroughYard (name,...)
 Method to create a through yard object. More...
 
 create_PushButton (name,...)
 Method to create a push button object. More...
 
 create_Signal (name,...)
 Method to create a signal object. More...
 
 schematic_crosshair (...)
 Display crosshairs on the schematic canvas. More...
 
 controls_crosshair (...)
 Display crosshairs on the controls canvas. More...
 

Protected Member Functions

 checkInitCP (cp)
 Method to check that a control point has been initialized. More...
 
 updateAndSyncCP (cp)
 Method to update and syncronize a control point. More...
 
 lappendCP (cp, slot, what)
 Method to lappend something to a slot in a control point's data. More...
 
 lremoveCP (cp, slot, what)
 Method to remove something from a slot in a control point's data. More...
 

Private Member Functions

 _PosInteger (option, value)
 Method to validate a positive non zero integer option. More...
 
 _CtcMainSyncX (this, other, first, last)
 Internal method to x scroll updates. More...
 
 _CtcMainHScroll2 (...)
 Internal method to scroll two canvases at the same time. More...
 
 _crosshairStart (canvas, xvar, yvar)
 Start using the crosshairs. More...
 
 _crosshairMove (canvas, xvar, yvar, mx, my)
 Bound to mouse movement events. More...
 
 _crosshairEnd (canvas, xvar, yvar, mx, my)
 Bound to left button down. More...
 

Private Attributes

 schematic
 The schematic component. More...
 
 schematicYscroll
 The schematic y scroll bar component. More...
 
 xscroll
 The shared x scroll bar component. More...
 
 controls
 The controls component. More...
 
 controlsYscroll
 The controls y scroll bar component. More...
 
 scale
 The current scale value. More...
 
 CPList
 The list of control points. More...
 
 CPData
 The Control point data array. More...
 
 Objects
 The object array. More...
 
 _ch_oldgrab
 Used save the old grab. More...
 
 _ch_oldfocus
 Used save the old focus. More...
 

Detailed Description

Main CTC Panel megawidget.


This megawidget implements two display areas, each with a vertical (Y) scrollbar. They share a horizontal (X) scrollbar. The upper display area contains schematic trackwork and the lower display area contains various switches, buttons, and lamps that deal with trackage control points.

Parameters
pathPathname of the widget.
...Options:
  • -schematicbackground The background color of the schematic display. Defaults to black.
  • -controlbackground The background color of the control display. Defaults to darkgreen.
  • -width The total width of the megawidget.
  • -height The total height of the megawidget.
Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ CTCPanel()

CTCPanel::CTCPanel::CTCPanel ( name  ,
  ... 
)

Build and install all component widgets and process configuration.

Parameters
...Argument list (option value pairs). Gets passed to the implicitly defined configurelist method.

Member Function Documentation

◆ _crosshairEnd()

CTCPanel::CTCPanel::_crosshairEnd ( canvas  ,
xvar  ,
yvar  ,
mx  ,
my   
)
private

Bound to left button down.

Ends crosshairs and returns the results.

Parameters
canvasThe canvas the crosshairs are on.
xvarThe name of the global variable to receive the X result.
yvarThe name of the global variable to receive the Y result.
mxThe X mouse position.
myThe Y mouse position.

◆ _crosshairMove()

CTCPanel::CTCPanel::_crosshairMove ( canvas  ,
xvar  ,
yvar  ,
mx  ,
my   
)
private

Bound to mouse movement events.

Parameters
canvasThe canvas the crosshairs are on.
xvarThe name of the global variable to receive the X result.
yvarThe name of the global variable to receive the Y result.
mxThe X mouse position.
myThe Y mouse position.

◆ _crosshairStart()

CTCPanel::CTCPanel::_crosshairStart ( canvas  ,
xvar  ,
yvar   
)
private

Start using the crosshairs.

Parameters
canvasThe canvas the crosshairs are on.
xvarThe name of the global variable to receive the X result.
yvarThe name of the global variable to receive the Y result.

◆ _CtcMainHScroll2()

CTCPanel::CTCPanel::_CtcMainHScroll2 (   ...)
private

Internal method to scroll two canvases at the same time.

Bound to the horizontal scrollbar's -command.

Parameters
...The arguments passed from the scroll bar.

◆ _CtcMainSyncX()

CTCPanel::CTCPanel::_CtcMainSyncX ( this  ,
other  ,
first  ,
last   
)
private

Internal method to x scroll updates.

Updates the scrolling for both canvases, making sure that they are in sync. The scrollbar is also updated. This method is bound to the -xscrollcommands of the schematic and controls canvases.

Parameters
thisThe canvas whose scrolling changed.
otherThe other canvas, which needs to be syncronized.
firstThe coordinate of the first (left most) visible part of the canvas. Passed from the canvas.
lastThe coordinate of the last (right most) visible part of the canvas. Passed from the canvas.

◆ _PosInteger()

CTCPanel::CTCPanel::_PosInteger ( option  ,
value   
)
private

Method to validate a positive non zero integer option.

Parameters
optionThe option name.
valueThe value to validate.

◆ bind()

CTCPanel::CTCPanel::bind ( name  ,
  ... 
)

Method to set a binding on an Object.

Parameters
nameThe name of the object to set a binding on.
sequenceThe event sequence to bind to.
scriptThe script to run when the binding event occurs. If the script is prefixed with a "+", it is appended to any existing script.
Returns
The empty string in all cases where script is non-empty. If the script is missing, returns the current binding for the specificed sequence. If neither sequence nor script is supplied, then returns a list of all bindings. See the bind sub-command of canvas.

◆ checkInitCP()

CTCPanel::CTCPanel::checkInitCP ( cp  )
protected

Method to check that a control point has been initialized.

Should only be called from object constructors.

Parameters
cpThe name of the control point.

◆ controls_crosshair()

CTCPanel::CTCPanel::controls_crosshair (   ...)

Display crosshairs on the controls canvas.

Parameters
...Options:
  • -xvar Global variable to receive the X result.
  • -yvar Global variable to receive the Y result.

◆ coords()

CTCPanel::CTCPanel::coords ( name  ,
tname   
)

Method to fetch the coordinates of some part of an object.

Parameters
nameThe name of the object to fetch coordinates from.
tnameThe name of the terminal of the object to fetch the coordinates of. See the individual element descriptions for valid terminal names.

◆ cplist()

CTCPanel::CTCPanel::cplist ( )

Method to return the list of controlpoints.

◆ create_CodeButton()

CTCPanel::CTCPanel::create_CodeButton ( name  ,
  ... 
)

Method to create a code button object.

Parameters
nameThe name of the new code button.
...The argument list for the object constructor.

See CodeButton for defails.

◆ create_Crossing()

CTCPanel::CTCPanel::create_Crossing ( name  ,
  ... 
)

Method to create a track crossing object.

Parameters
nameThe name of the new crossing.
...The argument list for the object constructor.

See Crossing for defails.

◆ create_Crossover()

CTCPanel::CTCPanel::create_Crossover ( name  ,
  ... 
)

Method to create a crossover object.

Parameters
nameThe name of the new crossover.
...The argument list for the object constructor.

See Crossover for defails.

◆ create_CTCLabel()

CTCPanel::CTCPanel::create_CTCLabel ( name  ,
  ... 
)

Method to create a CTC Label label object.

Parameters
nameThe name of the new label.
...The argument list for the object constructor.

See CTCLabel for defails.

◆ create_CurvedBlock()

CTCPanel::CTCPanel::create_CurvedBlock ( name  ,
  ... 
)

Method to create a curved block of track object.

Parameters
nameThe name of the new track block.
...The argument list for the object constructor.

See CurvedBlock for defails.

◆ create_DoubleSlip()

CTCPanel::CTCPanel::create_DoubleSlip ( name  ,
  ... 
)

Method to create a double slip object.

Parameters
nameThe name of the new switch.
...The argument list for the object constructor.

See DoubleSlip for defails.

◆ create_EndBumper()

CTCPanel::CTCPanel::create_EndBumper ( name  ,
  ... 
)

Method to create a end bumper of track object.

Parameters
nameThe name of the new track block.
...The argument list for the object constructor.

See EndBumper for defails.

◆ create_HiddenBlock()

CTCPanel::CTCPanel::create_HiddenBlock ( name  ,
  ... 
)

Method to create a hidden block of track object.

Parameters
nameThe name of the new track block.
...The argument list for the object constructor.

See HiddenBlock for defails.

◆ create_Lamp()

CTCPanel::CTCPanel::create_Lamp ( name  ,
  ... 
)

Method to create a lamp object.

Parameters
nameThe name of the new lamp.
...The argument list for the object constructor.

See Lamp for defails.

◆ create_PushButton()

CTCPanel::CTCPanel::create_PushButton ( name  ,
  ... 
)

Method to create a push button object.

Parameters
nameThe name of the push button.
...The argument list for the object constructor.

See PushButton for defails.

◆ create_SchLabel()

CTCPanel::CTCPanel::create_SchLabel ( name  ,
  ... 
)

Method to create a schematic label object.

Parameters
nameThe name of the new label.
...The argument list for the object constructor.

See SchLabel for defails.

◆ create_ScissorCrossover()

CTCPanel::CTCPanel::create_ScissorCrossover ( name  ,
  ... 
)

Method to create a scissor crossover object.

Parameters
nameThe name of the new crossover.
...The argument list for the object constructor.

See ScissorCrossover for defails.

◆ create_Signal()

CTCPanel::CTCPanel::create_Signal ( name  ,
  ... 
)

Method to create a signal object.

Parameters
nameThe name of the signal.
...The argument list for the object constructor.

See Signal for defails.

◆ create_SIGPlate()

CTCPanel::CTCPanel::create_SIGPlate ( name  ,
  ... 
)

Method to create a signal plate object.

Parameters
nameThe name of the new signal plate.
...The argument list for the object constructor.

See SIGPlate for defails.

◆ create_SingleSlip()

CTCPanel::CTCPanel::create_SingleSlip ( name  ,
  ... 
)

Method to create a single slip object.

Parameters
nameThe name of the new switch.
...The argument list for the object constructor.

See SingleSlip for defails.

◆ create_StraightBlock()

CTCPanel::CTCPanel::create_StraightBlock ( name  ,
  ... 
)

Method to create a straight block of track object.

Parameters
nameThe name of the new track block.
...The argument list for the object constructor.

See StraightBlock for defails.

◆ create_StubYard()

CTCPanel::CTCPanel::create_StubYard ( name  ,
  ... 
)

Method to create a stub (deadend) yard object.

Parameters
nameThe name of the new yard.
...The argument list for the object constructor.

See StubYard for defails.

◆ create_Switch()

CTCPanel::CTCPanel::create_Switch ( name  ,
  ... 
)

Method to create a switch (turnout) object.

Parameters
nameThe name of the new switch.
...The argument list for the object constructor.

See Switch for defails.

◆ create_SWPlate()

CTCPanel::CTCPanel::create_SWPlate ( name  ,
  ... 
)

Method to create a switch plate object.

Parameters
nameThe name of the new switch plate.
...The argument list for the object constructor.

See SWPlate for details.

◆ create_ThreeWaySW()

CTCPanel::CTCPanel::create_ThreeWaySW ( name  ,
  ... 
)

Method to create a three way switch object.

Parameters
nameThe name of the new switch.
...The argument list for the object constructor.

See ThreeWaySW for defails.

◆ create_ThroughYard()

CTCPanel::CTCPanel::create_ThroughYard ( name  ,
  ... 
)

Method to create a through yard object.

Parameters
nameThe name of the new yard.
...The argument list for the object constructor.

See ThroughYard for defails.

◆ create_Toggle()

CTCPanel::CTCPanel::create_Toggle ( name  ,
  ... 
)

Method to create a toggle switch object.

Parameters
nameThe name of the new toggle switch.
...The argument list for the object constructor.

See Toggle for defails.

◆ delete()

CTCPanel::CTCPanel::delete ( name  )

Delete a named object.

Parameters
nameThe name of the object to delete.

◆ exists()

CTCPanel::CTCPanel::exists ( name  )

Test if the named object exists.

Parameters
nameThe object to test for.

◆ geti()

CTCPanel::CTCPanel::geti ( name  ,
ind   
)

Method to get the indicator state of an object.

Parameters
nameThe name of the object to fetch the indicator state of.
indThe indicator whose state is return. See the individual element descriptions for valid indicator names.

◆ getv()

CTCPanel::CTCPanel::getv ( name  )

Method to get the value (or state) of an object.

Parameters
nameThe name of the object to fetch the value of.

◆ getZoom()

CTCPanel::CTCPanel::getZoom ( )

Return the zoom (scaling) factor.

◆ invoke()

CTCPanel::CTCPanel::invoke ( name  )

Method to invoke an object.

Returns true if the element is occupied.

Parameters
nameThe name of the object to invoke.

See the individual object invoke methods for details.

◆ itemcget()

CTCPanel::CTCPanel::itemcget ( name  ,
option   
)

Method to get a configuration option from an object.

Parameters
nameThe object whose configuration option is to be fetched from.
optionThe option to fetch. See the individual element descriptions for valid options.

◆ itemconfigure()

CTCPanel::CTCPanel::itemconfigure ( name  ,
  ... 
)

Method to set a configuration option from an object.

Parameters
nameThe object whose configuration option is to be configured.
...The configuration arguments.

◆ lappendCP()

CTCPanel::CTCPanel::lappendCP ( cp  ,
slot  ,
what   
)
protected

Method to lappend something to a slot in a control point's data.

Should only be called from object constructors.

Parameters
cpThe control point to update.
slotThe slot to update.
whatThe object to add to the slot.

◆ lremoveCP()

CTCPanel::CTCPanel::lremoveCP ( cp  ,
slot  ,
what   
)
protected

Method to remove something from a slot in a control point's data.

Should only be called from object destructors.

Parameters
cpThe control point to update.
slotThe slot to update.
whatThe object to remove from the slot.

◆ move()

CTCPanel::CTCPanel::move ( name  ,
,
 
)

Move a named object.

Parameters
nameThe name of the object to be moved.
xThe amount of the x movement.
yThe amount of the y movement.

◆ objectlist()

CTCPanel::CTCPanel::objectlist ( cp  = "",
class  = "" 
)

Method to return the list of objects.

Parameters
cp(optional) The name of control point to return the object of. If cp is the empty string, return all objects.
class(optional) The class of objects to return. If class is the empty string, return all classes of objects.

◆ print()

CTCPanel::CTCPanel::print ( name  ,
fp   
)

Method to print the named object to the specificied file channel.

Parameters
nameThe object to print.
fpThe file channel to print to.

◆ schematic_crosshair()

CTCPanel::CTCPanel::schematic_crosshair (   ...)

Display crosshairs on the schematic canvas.

Parameters
...Options:
  • -xvar Global variable to receive the X result.
  • -yvar Global variable to receive the Y result.

◆ seti()

CTCPanel::CTCPanel::seti ( name  ,
ind  ,
value   
)

Method to set the indicator state of an object.

Parameters
nameThe name of the object whose indicator state is to be set.
indThe indicator to update. See the individual element descriptions for valid indicator names.
valueThe new indicator value, generally on or off.

◆ setv()

CTCPanel::CTCPanel::setv ( name  ,
value   
)

Method to set the value (or state) of an object.

Parameters
nameThe name of the object to update.
valueThe value to set it to. See the individual element descriptions for valid values.

◆ setZoom()

CTCPanel::CTCPanel::setZoom ( zoomFactor  )

Method to set the zoom factor to a specific factor.

Parameters
zoomFactorThe zoom factor.

◆ updateAndSyncCP()

CTCPanel::CTCPanel::updateAndSyncCP ( cp  )
protected

Method to update and syncronize a control point.

Should only be called from object methods.

Parameters
cpThe name of the control point.

◆ updateSR()

CTCPanel::CTCPanel::updateSR ( canvas  ,
newheight  ,
newwidth   
)

Method to update one of the canvases scroll region.

Bound to the Configure event of each of the canvases.

Parameters
canvasThe canvas to update.
newheightThe new height.
newwidthThe new width.

◆ zoomBy()

CTCPanel::CTCPanel::zoomBy ( zoomFactor  )

Method to zoom the display by a zoom factor.

Parameters
zoomFactorThe zoom factor.

Member Data Documentation

◆ _ch_oldfocus

CTCPanel::CTCPanel::_ch_oldfocus
private

Used save the old focus.

◆ _ch_oldgrab

CTCPanel::CTCPanel::_ch_oldgrab
private

Used save the old grab.

◆ controls

CTCPanel::CTCPanel::controls
private

The controls component.

◆ controlsYscroll

CTCPanel::CTCPanel::controlsYscroll
private

The controls y scroll bar component.

◆ CPData

CTCPanel::CTCPanel::CPData
private

The Control point data array.

◆ CPList

CTCPanel::CTCPanel::CPList
private

The list of control points.

◆ Objects

CTCPanel::CTCPanel::Objects
private

The object array.

◆ scale

CTCPanel::CTCPanel::scale
private

The current scale value.

◆ schematic

CTCPanel::CTCPanel::schematic
private

The schematic component.

◆ schematicYscroll

CTCPanel::CTCPanel::schematicYscroll
private

The schematic y scroll bar component.

◆ xscroll

CTCPanel::CTCPanel::xscroll
private

The shared x scroll bar component.