Functions | |
void | Define_Line_Style (const char *name, const char *definition) |
void | UnDefine_Line_Style (const char *name) |
void Define_Line_Style | ( | const char * | name, | |
const char * | definition | |||
) |
Allows the user to create a custom line style using a combination of lines, blanks, glyphs, and attributes.
name | Name of the custom line style. | |
definition | Line style definition described below. |
definition = "[ Parallel ] [, Parallel ] [, Parallel ] [, Transformed ]"
The definition string, or line style definition, is a comma-separated list of "parallels" that have optional parameters and/or modifiers, as follows:
Parallel = [Caps-n-Arrows] [+/-ddd gsu [fixed] offset,] [+ddd gsu [fixed] weight,] [fit,] [segmented,] [,absolute[weight|length]] [join,] [Element] [,Element]...
In the examples above, "dash" is an Element that is modified by the properties of the parallel. Elements consist of a shape (line or glyph) with a modifier (length or size), as follows:
Element = [+ddd gsu] dash or [+ddd gsu] blank or [+ddd gsu] contrast or [+ddd gsu] glyph_name [,inline|inset] [,mirror] [,rotation=x] [fixed]
"inline" - The line pattern is resumed after leaving space for the glyph "inset" - The line pattern is snipped to the glyph's nominal radius "mirror" - Flips the glyph about its X-axis before applying any rotation element. "rotation = x" - The additional angle in degrees the glyph is rotated about the line vector. "fixed" - The angle of rotation of the glyph will not be affected by the line vector.
The endpoints of custom linestyles may be controlled with a number of settings that come first in the definition of a parallel. Individual parallels in a definition can have unique cap and arrow settings. See the examples in the NOTES section for usage.
By default, user-defined line styles are screen-oriented (2D space). If the "transformed" key word is used in the style definition, HOOPS will draw the pattern in 3d space. Users can set the orientation vectors for the pattern via the "orientation" setting of Set_Geometry_Options(). The "transformed" setting can only be used on polyline primitives. See example #7 below for usage.
Please note that since line patterns are projected on an arbitrary plane, transformed line patterns can lead to some surprises. For one, segments of polylines will have non-uniform dash/blank lengths if they are at different angles to the projection plane. This is most noticeable when a blank eats up an entire segment. This is also true for glyph spacing.
HC_Define_Line_Style ( "solid_line", "2 pixel weight," "dash" );
Note that the example does not use the world 'parallel' as the first directive in the definition. This is because 'parallel' is implicit at the beginning of a definition.
Example 2: The double-line version of the above example, with a 20 pixel separation, would look like this:
HC_Define_Line_Style ( "double_solid_line", "2 pixel weight," "dash," "parallel, 20 pixel offset, 2 pixel weight," "dash" );
Note that in this example, the second instance of "dash" (the second parallel) must be preceded by "parallel" to identify the beginning of a new parallel, whereas in the first instance this is implied.
Example 3: The following example creates and sets a scalable line pattern that alternates between a line segment, a blank, and a line segment in the segment's contrast line color:
HC_Define_Line_Style ( "myLineStyle", "0.1 oru dash," "0.1 oru blank," "0.1 oru contrast" ); HC_Set_Color ( "lines=red, line contrast=blue"); HC_Set_Line_Pattern("myLineStyle");
Example 4: Another example creates a line which has arrow heads at either end:
const char Arrow[] = { 10, 0, 0, -1, 4, -10, 0, 0, 10, 10, 0, -10, 0, -3, 0 }; HC_Define_Glyph ( "triangle", sizeof(Arrow), Arrow ); HC_Define_Line_Style ( "myLineStyle", "arrows = 0.1 oru triangle," "dash" ); HC_Set_Line_Pattern("myLineStyle");
Example 5: Using parallels, it is very easy to create a triple-line style:
HC_Define_Line_Style ( "myLineStyle", "dash," "parallel, 0.05 oru offset," "contrast," "parallel, -0.05 oru offset," "contrast" ); HC_Set_Color("lines=red, line contrast=blue"); HC_Set_Line_Pattern("myLineStyle");
Example 6: This example uses the "fixed" setting to force one of the parallels to be always 5 pixels from the center-line, while the other will be affected by the local line weight and consequently be 10 pixels from the center-line.
HC_Define_Line_Style ( "myLineStyle", "dash," "parallel, 5 pixel fixed offset," "contrast," "parallel, -5 pixel offset," "contrast" ); HC_Set_Color("lines=red, line contrast=blue"); HC_Set_Line_Pattern("myLineStyle"); HC_Set_Line_Weight(2.0);
Example 7: The following example defines a simple pattern that consists of 2 dashed polylines with an offset in 3D space such that both lines lie on a plane defined in Set_Geometry_Options():
HC_Define_Line_Style("3d_parallel", "dash, parallel, 5 pixel offset, dash, transformed");
void UnDefine_Line_Style | ( | const char * | name | ) |
Removes a custom line style established by a previous call to Define_Line_Style().
name | Name of the custom line style. |