Previous Page Next Page Contents

plot::Group -- a group of graphical primitives

Introduction

plot::Group(object1, object2...) groups the graphical primitives object1, object2... into a single graphical primitives.

Creating Elements

plot::Group(object1 <, object2...> <, option1, option2...>)

Parameters

object1, object2 - either two- or three-dimensional graphical primitives, i.e., objects of type "graphprim" of the same dimension
option1, option2, ... - plot option(s) of the form OptionName = value

Related Domains

plot::Scene, RGB

Related Functions

plot, plot2d, plot3d, plot::copy

Details

Operands

The operands of an object of plot::Group are the parameters object1, object2... (in that order).

Important Operations

Operands of a group primitive can be accessed either using the system function op, the index operator [ ], or using the attribute objects described above. For example, if group is such an object, then the calls op(group,1), group[1] and group::objects[1] return the first graphical object object1 of the group.

Via group[i] := g or group::objects[i] := g, the ith object of the group is replaced by the graphical primitive g (which must be an object of type "graphprim").

See the methods "op", "_index", "set_index" and "slot" below.

Use the slot operator :: to get or set plot options of the grouped graphical primitives. For example, if group is such an object, then group::Color := RGB::Red changes the color of each graphical primitive of group to red.

Result of Evaluation

Evaluating an object of type plot::Group returns itself.

Function Call

Calling an object of plot::Group as a function yields the object itself, regardless of the arguments. The arguments are not evaluated.

Method _index: indexed access to the operands of a group primitive

Method dimension: dimension of a group primitive

Method getPlotdata: create the plot data of a group primitive

Method nops: number of operands of a group primitive

Method op: extract operands of a group primitive

Method set_index: set operands of a group primitive

Method slot: read attributes, and write attributes and plot options

Method copy: create a copy of a group primitive

Method expose: expose the definition of a group

Method modify: modify a copy of a group primitive

Method print: printing a group primitive

Example 1

We create a group consisting of a graph of function and two vertical dashed lines from some points on the x-axis to the corresponding points on the graph:

>> g := plot::Group(
     plot::Function2d(4 - x^2, x = -2..2),
     plot::line([-1, 0], [-1, 3], LineStyle = DashedLines),
     plot::line([1, 0], [1, 3], LineStyle = DashedLines)
   )
                               plot::Group()

To plot the object in a graphical scene, enter:

>> plot(g)

Plot options can either be specified as additional arguments to the call plot::Group(...), or set via the slot operator :: as follows:

>> g::Color := RGB::Blue: plot(g)

If a plot option is invalid for some primitives of the group, then a warning message is issued. For example, the plot option Grid only exists for graphs of functions but not for polygons (the two lines here), and thus specifying this option only has an effect on the first primitive of the group g:

>> g::Grid := [200]:
      Warning: unknown option name 'Grid'; assignment ignored [plot:\
      :Polygon::slot]
      Warning: unknown option name 'Grid'; assignment ignored [plot:\
      :Polygon::slot]

Example 2

This example illustrates how primitives of the group can be extracted and manipulated seperately. We take the group of the previous example:

>> g := plot::Group(
     plot::Function2d(4 - x^2, x = -2..2),
     plot::line([-1, 0], [-1, 3], LineStyle = DashedLines),
     plot::line([1, 0], [1, 3], LineStyle = DashedLines)
   )
                               plot::Group()

With expose one can see the definition of the group g and the definition of its graphical primitives:

>> expose(g)
                                      2
      plot::Group(plot::Function2d(- x  + 4, x = -2..2),
      
         plot::Polygon(plot::Point(-1, 0), plot::Point(-1, 3)),
      
         plot::Polygon(plot::Point(1, 0), plot::Point(1, 3)))

In order to change the color of the graph, which is the first graphical primitive of the group into blue, we enter:

>> (g[1])::Color := RGB::Blue: plot(g)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000