plot::Group -- a group of
graphical primitives
Introductionplot::Group(object1, object2...) groups
the graphical primitives object1, object2...
into a single graphical primitives.
Creating
Elementsplot::Group(object1 <, object2...> <, option1,
option2...>)
Parametersobject1, 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
Related
Functionsplot, plot2d, plot3d, plot::copy
Detailsplot::Group represent groups of
graphical primitives that can be displayed via the call
plot(...), or used with other graphical primitives of the
plot library.plot::Group(object1)
returns an object of the domain plot::Group, i.e., a group
can consists of only one graphical primitive.plot::Group has type
"graphprim", i.e., if o is such an object,
then the result of type(o) is the string
"graphprim".option1, option2... must
be valid plot options for two- and three-dimensional graphical
primitives, respectively. Available options and their default values
can be found on the corresponding help pages for the objects
object1, object2....
The plot options option1,
option2... are passed to each graphical primitive
object_i. This means, a plot option should be a valid plot
option for every given graphical primitive
object_i! If an invalid option is given for some
primitives of the group, then a warning message is issued, and the
setting of this option has no effect on the corresponding graphical
primitives.
::.
Each attribute has the property ``read'', i.e., the value of an
attribute attr of a graphical primitive o can
be read with o::attr. If the attribute also has the
``write'' property, then the value of the attribute can be changed with
o::attr := new_value.
The following attributes are available for a group of graphical objects:
| attribute | values | properties |
dimension |
The dimension of the group, that is the dimension of
the graphical primitives object1, object2...
where the dimension of object1, object2...
must be equal.
This attribute exists in order to have an efficient access to the
dimension of a group primitive. Because not every graphical primitive
has this attribute, one should call the method |
read |
objects |
A list of the graphical primitives of the group. A
graphical primitive is an object of type "graphprim". The
initial value is the list [object1, object2...] of the
parameters object1, object2... |
read/write |
plotdata |
List of the plot data of the group primitive in a
plot2d and plot3d conforming syntax,
respectively. The value of this attribute can be read if the method
"getPlotdata" (see below) was called before. The initial
value is the empty list []. |
read |
plot::Scene about working with
attributes.The operands of an object of plot::Group are the
parameters object1, object2... (in that
order).
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.
Evaluating an object of type plot::Group returns
itself.
Calling an object of plot::Group as a function yields
the object itself, regardless of the arguments. The arguments are
not evaluated.
_index(dom group, positive integer i)ith graphical primitive of
group. If i is greater than the number of
graphical primitive of group, then FAIL is
returned._index, i.e., one may use it in the
form function[i], or in functional notation
_index(group, i).dimension(dom group)dimension, i.e.,
the integer 2 or 3 (see the table of attributes
above).getPlotdata(dom group)group in a
plot2d and plot3d conforming syntax,
respectively, i.e., an inner list has the form [Mode = ...,
...].
For example, with s := plot::Group::getPlotdata(group)
the call plot2d(op(s)) and plot3d(op(s)),
respectively, gives a plot of group.
plotdata of group.plot::Scene to build the plot data of
the graphical scene.nops(dom group)group.nops, i.e., one may use it in the form
nops(group).op(dom group, positive
integer i)ith graphical primitive of
group. If i is greater than the number of
graphical primitives of group, then FAIL is
returned.op, i.e., one may use it in the form
op(group, i).set_index(dom group, positive integer i, graphprim
object)ith graphical primitive of
group by the graphical primitive object.i is greater than the number of graphical
primitives of group, or if object is not of
type "graphprim", then a warning message is issued. In
this case the call of this method has no effect on the object
group.slot(dom group, string slotname)slotname of
group. slotname must be the name of an
attribute of a group primitive (see the table of attributes above),
otherwise an error message is issued.slot, i.e., one may use it in the form
group::slotname_id (here, slotname_id must be
the identifier corresponding to the string slotname), or
in functional notation slot(group, slotname).slot(dom group, string slotname, any val)slotname is an attribute of a group primitive, then
this method changes the value of this attribute to val
(see the table above for the attributes of a group primitive).
Otherwise the slot slotname of each primitive of the
group is changed to the value val. If
slotname is an invalid attribute or plot option of some
primitives of the group, then a warning message is issued that the
change is ignored for the corresponding primitive.
slot, i.e., one may use it in the form
group::slotname_id := val (here, slotname_id
must be the identifier corresponding to the string
slotname), or in functional notation slot(group,
slotname, val).copy(dom group)group.plot::copy. See its help page for
details.expose(dom group)group.expose, i.e., one may use it in the
form expose(group).modify(dom group, equation(s) Name1 = value1...)group and changes the
slots Name1... of this copy to the new values
value1...Name1... must be names of attributes
of a group primitive or plot options of graphical primitives of
group. Otherwise a warning message is issued, and the slot
remains unchanged. Also, if one of the values value1... is
not an admissible value for the corresponding attribute or plot option,
respectively, the change of the slot is ignored.
See the tables of available attributes above.
plot::modify.print(dom group)plot::Group(). It is used to print objects of
plot::Group to the screen.expose(group)
to expose the graphical primitives of the group.print for details.
Example
1We 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
2This 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)