OptionMap Statement

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

OptionMap Statement Syntax

The Fractal Science Kit fractal generator optionMap statement is 1 of the statements used in the properties section of the program instructions to define the program's Properties.

The optionMap statement is used to create named sets of related options that can be set by selecting the name from a combobox. When an optionMap item is selected, all the component options are updated with the value specified in the optionMap statement. The user can accept the set of values as is, or change one or more of the component values. This provides the user with a set of example parameter sets while still allowing the user to try new parameter sets not specified in the optionMap statement.

The syntax of the optionMap statement is:

optionMap <OptionMapName> (<Opt>, <Opt>, ...) {
  <ItemName>, <ItemLabel>, <OptValue>, <OptValue>, ...
  <ItemName>, <ItemLabel>, <OptValue>, <OptValue>, ...
  ...
}

The <OptionMapName> names the option map and must be a valid identifier. The <OptionMapName> is used in combination with an Option Statement (whose type field is set to the <OptionMapName> name) to generate a set of selectable items presented in a combobox control the user can use to select the example parameter set. The options (<Opt>, <Opt>, ...) above are a comma separated list of option names enclosed in parentheses. The options do not need to be defined before the optionMap statement and in fact are usually given following the optionMap statement. Each of the options in the set must be on the same page as the option that represents the option map however, or a compiler error will result. Option types not permitted as part of an option map include: ColorSet Options, IndexedEnum Options, SamplePointValue Options, or Option Map Options.

Each row of the optionMap statement must contain an <ItemName> which must be a valid identifier, an <ItemLabel> which must be a quoted string, and an <OptValue> entry for each of the given options in the set. <ItemName> names the set defined in that row and can be referenced using the form <OptionMapName>.<ItemName>. <ItemLabel> is the string presented to the user in the combobox. Each of the <OptValue> entries must be values appropriate for the type (and range, if applicable) of the associated option.

When the user selects an item from the combobox, each of the options in the set are updated with the associated value. If the user changes one or more of the associated options such that it no longer matches any of the items in the option map, the combobox is set to the 1st entry which is usually given the name <Custom>.

Example:

optionMap Examples(A, B) {
  Custom,            "<Custom>",                  0,   0
  CirclePacking6x6,  "Circle Packing: 6 x 6",     6,   6
  CirclePacking6x9,  "Circle Packing: 6 x 9",     6,   9
  CirclePacking9x6,  "Circle Packing: 9 x 6",     9,   6
  CirclePacking9x9,  "Circle Packing: 6 x 6",     9,   9
  CirclePacking12x4, "Circle Packing: 12 x 4",   12,   4
  CirclePacking12x5, "Circle Packing: 12 x 5",   12,   5
  CirclePacking12x6, "Circle Packing: 12 x 6",   12,   6
  CirclePacking12x9, "Circle Packing: 12 x 9",   12,   9
  CirclePacking4x12, "Circle Packing: 4 x 12",    4,  12
  CirclePacking5x12, "Circle Packing: 5 x 12",    5,  12
  CirclePacking6x12, "Circle Packing: 6 x 12",    6,  12
  CirclePacking9x12, "Circle Packing: 9 x 12",    9,  12
  JordanCurve1,      "Jordan Curve 1",          256i,  8+4i
  JordanCurve2,      "Jordan Curve 2",          256i,  8+2i
  JordanCurve3,      "Jordan Curve 3",          256i,  8+1.8i
  JordanCurve4,      "Jordan Curve 4",         16-4i, 16+4i
}
option Example {
  type = Examples
  caption = "Example"
  default = Examples.CirclePacking6x6
}
option A {
  type = Complex
  caption = "A"
  details = "Trace A = 2 * Cos(Math.PI / A)"
  default = 6
}
option B {
  type = Complex
  caption = "B"
  details = "Trace B = 2 * Cos(Math.PI / B)"
  default = 6
}

This example defines an optionMap called Examples which has 2 member options: A and B. A and B follow the optionMap statement. Next an option named Example is created to display the option map combobox selector. Finally, options A and B are defined. This arrangement allows users to select one of the given example parameter sets or to specify their own values for options A and B. If the values the user enters do no match any of the listed parameter sets, the combobox will display the text "<Custom>" to indicate the current values are not one of the sets listed. Here is the resulting properties page:

OptionMap Option Example

 

Copyright © 2004-2016 Hilbert, LLC
All rights reserved