<<<<<<<<<<<<<<<<<

Scalar_bar(modeller) Model Scalar_bar(modeller)

NAME

scalar_bar - segmented rectangle colored with lookup_table entries

DESCRIPTION

The scalar_bar class produces a rectangle divided into a specified number of horizontal segments (e.g., quadrilateral polygons). Each segment is colored by the corresponding entry in scalar_bar's display object lookup_table (by default the class "lookup_table). Hence the number of segments is intimitely tied to the state of the lookup table.

SUPERCLASS

new_modeller

INSTANCE VARIABLES

width the width of the scalar bar.

height the height of the scalar bar.

MESSAGES

width= Set the width of the scalar bar.

height= Set the height of the scalar bar.

EXAMPLES

The following LYMB script automatically builds a scalar bar with titles and labels. The variables indicated at the top of the script specify the title of the scalar bar, the range of values for the labels, the number of segments, and the bar's height and width.

/* * Define some parameters */ string new: `scalar_bar_title'="Title"; scalar new: `scalar_bar_height'=1.0; scalar new: `scalar_bar_width'=0.25; vector new: `scalar_bar_range'=(0,1); scalar new: `scalar_bar_title_spacing'=10;

scalar new: `tmp_scl'; scalar new: `tmp_scl2'; string new: `tmp_str'; string new: `tmp_str2';

/*

* the hershey_text models */ hershey_text new: ht_title_model text=scalar_bar_title font="futura.m" ; hershey_text new: ht_label_model font="futura.l" ;

/* * compute the labels */ loop new: label_loop duration=scalar_bar_title_spacing resolution=1 start_actions=` tmp_str =""; tmp_str2 float_format=`0.00'; tmp_scl = [scalar_bar_range @ 2 ?] - [scalar_bar_range @ 1 ?]; tmp_scl / scalar_bar_title_spacing;' tick_actions=` tmp_scl2 = tmp_scl * [label_loop time?] + [scalar_bar_range @ 1 ?]; tmp_str2 = tmp_scl2; tmp_str + tmp_str2 + `\n';' end_actions=`tmp_str chop! chop!;' ; label_loop start!;

ht_label_model text=tmp_str ;

/* * now the scalar bar */ scalar_bar new: scalar_bar_model height=scalar_bar_height width=scalar_bar_width ;

actor new: the_scalar_bar_title modeller=ht_title_model; the_scalar_bar_title position=(0,scalar_bar_height,0); tmp_scl = scalar_bar_height * 0.1; the_scalar_bar_title scale=(tmp_scl, tmp_scl, 1.0);

actor new: the_scalar_bar_label modeller=ht_label_model; tmp_scl = scalar_bar_width * 1.1; the_scalar_bar_label position=(tmp_scl,0,0); tmp_scl = scalar_bar_height / scalar_bar_title_spacing; the_scalar_bar_label scale=(tmp_scl, tmp_scl, 1.0);

actor new: the_scalar_bar modeller=scalar_bar_model ;

camera new: acam position=(0,0,1) range=[scalar_bar_model bounds?] default! on! ; renderer new: aren actors= (the_scalar_bar, [actor instances?]) cameras= acam render! ;

SEE ALSO

actor, modeller, lookup_table, hershey_text


Please send comments and suggestions to
consult@rpi.edu