The PowerAppBase class should control the general look and feel of the apps and provide the basic methods needed to build a PowerApp. The variables and method are described below.
The variables contained in the PowerAppBase class mainly deal with the app size, colors and progress indicator. There are also variables for making color map swatches. Below are all of the PowerAppBase variables and their descriptions.
###############################
### Class Variables
###############################
# Embedded Viewer
variable eviewer
# Standalone
variable win
# The width and height of the left frame, or the processing frame.
# This will be used when attaching or detaching the frame.
variable process_width
variable process_height
# The width and height of the Viewer window. This is used when
# configuring the window size when frames are attached or detached.
variable viewer_width
variable viewer_height
# The width and height of the right frame, or the visualization
# frame. This will be used when attaching or detaching the frame.
variable vis_width
variable vis_height
# The width and height of the current screen so that the app can
# come up in the center
variable screen_width
variable screen_height
# Indicates whether the processing frame is attached or detached.
# Applications should be initialized as attached
variable IsPAttached
# Pointers to the attached and detached frames
variable detachedPFr
variable attachedPFr
# Indicates whether the visualization frame is attached or detached.
# Applications should be initialized as attached
variable IsVAttached
# Pointers to the attached and detached frames
variable detachedVFr
variable attachedVFr
# Flag to indicate whether entire gui has been built.
# This is usefull in functions called by scale widgets because they
# get called during initialization.
variable initialized
# Flag to indicate when app is loading and executing a saved session.
variable loading
# The id for the call to change_indicator which controls the progress
# bar.
variable indicatorID
# These point to the indicator canvas and are used to raise different
# canvases. One points to the attached frame and the other to the
# detached.
variable indicator1
variable indicator2
# These point to the progress indicator labels of the
# attached and detached frames
variable indicatorL1
variable indicatorL2
# Represents the state of the progress graph
# 0 = Reset the indicator
# 1 = Start executing spinner
# 2 = Stop executing spinner and indicate "Complete"
# 3 = Error state
variable indicate
# The progress spinner is just an image shifting upon each executing.
# The cyle variable keeps track of how many shifts the image has made.
variable cycle
# A counter of currently executing modules. If this is positive, the
# progress indicator should be spinning. Only when all modules are
# complete (and this variable is equal to 0) will the "Complete"
# state be reached.
variable executing_modules
# Width and height of the indicator
variable i_width
variable i_height
# Number of stripes on the spinner mode of the indicator
variable stripes
# Variables for positions when moving spinner image
variable i_move
variable i_back
# Stores name of first module to get an error and the indicator won't
# be cleared from the error state until this module clears it.
variable error_module
# Colors for execute and next buttons
variable next_color
variable execute_color
# Width and height and resolution of colormap canvases if needed
variable colormap_width
variable colormap_height
variable colormap_res
The PowerAppBase class provides methods for building the standard parts of an App such as the Menu, Viewer Options tab, Progress Indicator, and colormap canvases. It also provides some helper methods for loading and saving, and activating and disabling widgets. Below are the methods and their descriptions.
############################
### constructor
############################
# The PowerAppBase constructor will be called before the child's constructor.
# It will initialize variables regarding size, state, the progress indicator, tooltips, etc.
# The constructor also configures the scheme (color, fonts, etc)
constructor {}
############################
### destructor
#############################
destructor
#############################
### configure_scheme
#############################
# Configure the color scheme and look and feel to be the same.
# This includes the colors for the next and execute buttons.
method configure_scheme {}
###############################
### build_menu
###############################
# Build the standard menu in the specified frame.
# The menu contains the File->Load Session, File->Save Session, etc..
method build_menu { m }
#########################
### reset_app
#########################
# Method that should be called when loading a session.
# This just enables any disabled modules so that the
# loaded session can disable a fresh set of modules.
method reset_app {}
##########################
### save_module_variables
##########################
# This method saves out the variables of all of the modules to the
# specified file. It currently only saves out the variables for the
# modules that the application has included in the global mods array.
method save_module_variables { fileid }
##########################
### get_module_variable_name
##########################
# This method strips away the module name information and gets
# just the variable name (i.e. port-index from
# SCIRun_FieldsOther_ChooseField_0-port-index
method get_module_variable_name { var }
#########################
### save_disabled_modules
#########################
# Save out the call to disable all modules that are currently disabled
method save_disabled_modules { fileid }
#########################
### save_class_variables
#########################
# Save out all of the class variables
method save_class_variables { fileid }
#######################
### get_class_variable_name
#######################
# Remove the :: fromt the variable
method get_class_variable_name { var }
#############################
### exit_app
#############################
# Exit by a NiceQuit
method exit_app {}
#############################
### create_viewer_tab
#############################
# Build the Viewer tab. This is actually labeled the "Viewer Options"
method create_viewer_tab { vis }
########################
### display_module_error
########################
# If a module has received an error, and the
# user clicks on the red progress bar, this
# displays the module's log.
method display_module_error {}
###########################
### activate_widget
###########################
# This method activates a widget and changes the foreground color to be black.
# If it is a Next or Execute button, it changes the foreground color to be
# the appropriate color
method activate_widget {w}
##############################
### disable_widget
##############################
# This method disables a widget and sets the foreground to be grey64
method disable_widget {w}
############################
### construct_indicator
############################
# This intializes the canvases for the different
# indicate states (reset, error, executing, complete)
method construct_indicator { canvas }
#######################
### change_indicator
#######################
# Change the indicator bar. If indicate equals 0,
# reset, 1 equals start swirl, 2 equals complete,
# 3 equals error state. Each time this executes with
# indicate=1, the swirl canvas shifts. After 3 cyles
# it starts over. Only when indicate is a 1 does this
# function call itself again.
method change_indicator {}
###########################
### block_connection
###########################
# Blocks a module connection
method block_connection { modA portA modB portB }
###########################
### unblock_connection
###########################
# Unblocks a module connection
method unblock_connection { modA portA modB portB }
#############################
### draw_colormap
#############################
# This draws a small colormap specified by
# which on the canvas
method draw_colormap { which canvas }
######################
### set_color_map
######################
method set_color_map { map }
#######################
### make_new_map
#######################
method make_new_map { currentMap }
#####################
### modify
#####################
method modify { i range }
#######################
### addColorSelection
#######################
# This method creates a button and color swatch so the
# user can set a specific color
method addColorSelection {frame text color mod}
#######################
### raiseColor
#######################
# Raises the color swatch and allows the user to pick
method raiseColor {col color mod}
#########################
### setColor
#########################
# Set the appropriate color. This should probably be
# re-written by the child class to change the color
# for a specific ShowField.
method setColor {col color mode}