mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 07:42:33 +01:00
Extensive clarifying, including which type of "representation" is being discussed, relative point's "anchor" to the (0,0) point which was previously unclear, pointer-event propagation to figures, rotation and scaling propagation inside the relative point tree, and several other things.
Author:vwheeler Date:2014-04-30T18:51:42.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1359 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
[[Property:weight|7]]
|
||||
[[Property:uuid|c12fee6e-5e99-ae59-8ac5-f57abb4c1878]]
|
||||
The EiffelVision 2 figure cluster can be considered a high-level way of drawing on an [[ref:libraries/vision2/reference/ev_drawable_chart|EV_DRAWABLE]] descendant. Here are some advantages:
|
||||
* The model is separated from the representation by using projectors that take a world of figures and project it to any device, not just a drawing area.
|
||||
* Instead of drawing with static API's like draw_line, real figure objects are used that can move, change color or morph.
|
||||
* For projection devices that allow this, events may be caught and fired through the appropriate figure object.
|
||||
* The model (tree of figures) is separated from the graphical representation by using projectors that take a "world" (i.e. entire set) of figures and project it onto any device, not just a drawing area.
|
||||
* Instead of drawing with static API's like <code>draw_line</code>, real figure objects are used that remember their locations, rotation and scaling internally, and can later be moved, color changed, rotated and/or scaled without limit, individually, or as an entire relative branch in the tree of figures.
|
||||
* For projection devices that support it, (mouse) pointer events are propagated to the affected figures.
|
||||
|
||||
|
||||
==Figure Classes==
|
||||
|
||||
Every basic figure class inherits from [[ref:libraries/vision2/reference/ev_atomic_figure_chart|EV_ATOMIC_FIGURE]]. An atomic figure has the property of having its own graphical representation. [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] on the other hand does not have its own graphical representation, but is instead a collection of figures. Finally, [[ref:libraries/vision2/reference/ev_figure_chart|EV_FIGURE]] is the common ancestor to those two. Since [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] is a collection of EV_FIGUREs, it can contain subgroups.
|
||||
Every basic figure class inherits from [[ref:libraries/vision2/reference/ev_atomic_figure_chart|EV_ATOMIC_FIGURE]]. An atomic figure has the property of having its own graphical representation. [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] on the other hand is a collection of figures. Finally, [[ref:libraries/vision2/reference/ev_figure_chart|EV_FIGURE]] is the common ancestor to those two. Since [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] is a collection of EV_FIGUREs, it can contain both atomic figures and subgroups, thus forming a tree of figures.
|
||||
|
||||
As top-level group of a "world" of figures you must use [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]]. It inherits from [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] but adds some features for grid and background color.
|
||||
Any "branch" of that tree that wishes to be drawn (i.e. rendered to a device or file) (especially the top-level root) must be a figure group of type [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]]. It inherits from [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]], and adds some features for grid and background color, required for drawing.
|
||||
|
||||
===Figures===
|
||||
|
||||
@@ -35,7 +35,7 @@ As top-level group of a "world" of figures you must use [[ref:libraries/vision2/
|
||||
| [[ref:libraries/vision2/reference/ev_figure_ellipse_chart|EV_FIGURE_ELLIPSE]]
|
||||
| closed
|
||||
| 2
|
||||
| ellipse inside imaginary rectangle
|
||||
| an ellipse inside imaginary rectangle
|
||||
|-
|
||||
| [[ref:libraries/vision2/reference/ev_figure_equilateral_chart|EV_FIGURE_EQUILATERAL]]
|
||||
| closed
|
||||
@@ -70,7 +70,7 @@ As top-level group of a "world" of figures you must use [[ref:libraries/vision2/
|
||||
| [[ref:libraries/vision2/reference/ev_figure_rectangle_chart|EV_FIGURE_RECTANGLE]]
|
||||
| closed
|
||||
| 2
|
||||
| figure with four sides
|
||||
| a figure with four sides
|
||||
|-
|
||||
| [[ref:libraries/vision2/reference/ev_figure_star_chart|EV_FIGURE_STAR]]
|
||||
| open
|
||||
@@ -84,16 +84,16 @@ As top-level group of a "world" of figures you must use [[ref:libraries/vision2/
|
||||
|}
|
||||
|
||||
|
||||
A closed figure is a figure that has some area enclosed when drawn that can optionally be filled with a color. Closed figures inherit [[ref:libraries/vision2/reference/ev_closed_figure_chart|EV_CLOSED_FIGURE]] which gives them the property fill_color. Open figures inherit [[ref:libraries/vision2/reference/ev_atomic_figure_chart|EV_ATOMIC_FIGURE]] directly just as [[ref:libraries/vision2/reference/ev_closed_figure_chart|EV_CLOSED_FIGURE]].
|
||||
A closed figure is a figure that has some area enclosed when drawn that can optionally be filled with a color. Closed figures inherit [[ref:libraries/vision2/reference/ev_closed_figure_chart|EV_CLOSED_FIGURE]] which gives them the property <code>fill_color</code>. Open figures inherit [[ref:libraries/vision2/reference/ev_atomic_figure_chart|EV_ATOMIC_FIGURE]] directly, as does [[ref:libraries/vision2/reference/ev_closed_figure_chart|EV_CLOSED_FIGURE]].
|
||||
|
||||
===Points===
|
||||
|
||||
Central in the design of the figures are points. Figures are built up as much from points as possible. For example, an ellipse is not a center point with two radii, but the biggest fitting ellipse inside an imaginary rectangle, so of two points.
|
||||
Central in the design of the figures are points. Figures are built up as much from points as possible. For example, an ellipse is not a center point with two radii, but is instead the largest fitting ellipse inside an imaginary rectangle, so of two points.
|
||||
|
||||
As you can see in the table above, each figure has a certain number of points. These values can be 1, 2 or * (any number). For each value there is a class the figure inherits from. These classes are:
|
||||
* 1 (a figure has one point): [[ref:libraries/vision2/reference/ev_single_pointed_figure_chart|EV_SINGLE_POINTED_FIGURE]].
|
||||
* 2 (a figure has two points): [[ref:libraries/vision2/reference/ev_double_pointed_figure_chart|EV_DOUBLE_POINTED_FIGURE]].
|
||||
* * (a figure has zero or more points): [[ref:libraries/vision2/reference/ev_multi_pointed_figure_chart|EV_MULTI_POINTED_FIGURE]].
|
||||
As you can see in the table above, each figure has a certain number of points. These values can be 1, 2 or * (any number). For each value there is a class the figure inherits from. These are:
|
||||
* 1 (figure has one point): [[ref:libraries/vision2/reference/ev_single_pointed_figure_chart|EV_SINGLE_POINTED_FIGURE]].
|
||||
* 2 (figure has two points): [[ref:libraries/vision2/reference/ev_double_pointed_figure_chart|EV_DOUBLE_POINTED_FIGURE]].
|
||||
* * (figure has zero or more points): [[ref:libraries/vision2/reference/ev_multi_pointed_figure_chart|EV_MULTI_POINTED_FIGURE]].
|
||||
|
||||
These classes offer features to handle the given number of points. [[ref:libraries/vision2/reference/ev_single_pointed_figure_chart|EV_SINGLE_POINTED_FIGURE]] offers the feature:
|
||||
|
||||
@@ -102,40 +102,44 @@ These classes offer features to handle the given number of points. [[ref:librari
|
||||
</code>
|
||||
|
||||
[[ref:libraries/vision2/reference/ev_double_pointed_figure_chart|EV_DOUBLE_POINTED_FIGURE]] inherits [[ref:libraries/vision2/reference/ev_single_pointed_figure_chart|EV_SINGLE_POINTED_FIGURE]] for its first point, which is renamed to <eiffel>point_a</eiffel>. It adds <eiffel>point_b</eiffel>, so it has the features:
|
||||
|
||||
<code>
|
||||
point_a: EV_RELATIVE_POINT
|
||||
point_b: EV_RELATIVE_POINT
|
||||
</code>
|
||||
|
||||
[[ref:libraries/vision2/reference/ev_multi_pointed_figure_chart|EV_MULTI_POINTED_FIGURE]] internally holds an array of points. Its most important feature is:
|
||||
[[ref:libraries/vision2/reference/ev_multi_pointed_figure_chart|EV_MULTI_POINTED_FIGURE]] internally holds an array of points:
|
||||
|
||||
<code>
|
||||
i_th_point (i: INTEGER): EV_RELATIVE_POINT
|
||||
</code>
|
||||
|
||||
===Relative Point===
|
||||
|
||||
The points that the figures use are of type [[ref:libraries/vision2/reference/ev_relative_point_chart|EV_RELATIVE_POINT]] . Each point is relative to another point, which is also relative. Each point is a set of coordinates and a reference point. The absolute coordinates are calculated only when needed by adding the absolute coordinates of the reference point to the relative coordinates.
|
||||
The points that the figures use are of type [[ref:libraries/vision2/reference/ev_relative_point_chart|EV_RELATIVE_POINT]]. Each point is relative to the location of the parent figure group (<code>point</code>), which is relative to the location of its parent figure group, and so on up to the top-level (world) figure group. Each point is a set of relative coordinates and a reference point (<code>origin</code>). If the reference point is not attached (as may be the case for immediate children of the top-level group, when it has no point object), the subordinate relative points are relative to point (0,0). The absolute coordinates are calculated only when needed by adding the absolute coordinates of the reference point to the relative coordinates.
|
||||
|
||||
{{note|Even the top-level (world) figure group can be "moved" by calling its <code>set_point</code> feature, passing a new relative point. However, if this is done, then THAT relative point is relative to point (0,0). If you do this, do so before <code>extend</code>-ing it with figures and sub-groups so that they receive the point in question as their reference point.}}
|
||||
|
||||
|
||||
==Figure Worlds==
|
||||
|
||||
In order to put the figures you want to display in a context, you have to insert them in a figure world object, an instance of [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]]. This is a descendant of [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] and hence works in the same way. This figure world is later associated with one or more projectors. [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]] adds a number of features to [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]]. These extra features are needed for the representation by a projector. One is the background color. This feature will be used to erase the canvas for a graphical projector in the specified color. The other features are to manage the grid.
|
||||
In order to put the figures you want to display in a context, you insert them (or the figure groups that contain them) into a top-level a "figure world" object: an instance of [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]]. This is a descendant of [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]] and hence works in the same way. This figure world is later associated with one or more projectors. [[ref:libraries/vision2/reference/ev_figure_world_chart|EV_FIGURE_WORLD]], as previously mentioned, adds a number of features to [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]]. These extra features are needed for graphical representation by a projector. One is the background color. This feature is used to erase the canvas for a graphical projector in the specified color. The other features are to manage the grid.
|
||||
|
||||
|
||||
==Projectors==
|
||||
|
||||
A projector is an object that knows what a figure world should look like. The figure world itself is not more than a hint towards its representation. For example, if a line is "20" long, this unit might mean pixels, miles, centimeters or whatever. It is up to the projector to interpret units. Also, color might be interpreted as gray scale. Typically, a projector will do the best possible job projecting the world to its device.
|
||||
A projector is an object that knows what a figure world should look like. The figure world itself is only a hint of its representation. For example, if a line is "20" long, this might mean 20 pixels, miles, centimeters or whatever. It is up to the projector to interpret units. Also, color might be interpreted as gray scale. Typically, a projector will do the best possible job projecting the "world" of figures onto its device.
|
||||
|
||||
With EiffelVision come these projectors:
|
||||
* [[ref:libraries/vision2/reference/ev_postscript_projector_chart|EV_POSTSCRIPT_PROJECTOR]]
|
||||
* [[ref:libraries/vision2/reference/ev_drawing_area_projector_chart|EV_DRAWING_AREA_PROJECTOR]]
|
||||
* [[ref:libraries/vision2/reference/ev_pixmap_projector_chart|EV_PIXMAP_PROJECTOR]]
|
||||
The first one maps figure worlds to a postscript file. The other two are descendants of [[ref:libraries/vision2/reference/ev_widget_projector_chart|EV_WIDGET_PROJECTOR]], and can project on widgets that inherit [[ref:libraries/vision2/reference/ev_drawable_chart|EV_DRAWABLE]]: [[ref:libraries/vision2/reference/ev_drawing_area_chart|EV_DRAWING_AREA]] and [[ref:libraries/vision2/reference/ev_pixmap_chart|EV_PIXMAP]], eventually using double-buffering, which results in a more smooth animation but requires fast copying from memory to the video buffer (can be slow for a remote display).
|
||||
The first one maps figure worlds to a postscript file. The other two are descendants of [[ref:libraries/vision2/reference/ev_widget_projector_chart|EV_WIDGET_PROJECTOR]], and can project on widgets that inherit from [[ref:libraries/vision2/reference/ev_drawable_chart|EV_DRAWABLE]], two of which are [[ref:libraries/vision2/reference/ev_drawing_area_chart|EV_DRAWING_AREA]] and [[ref:libraries/vision2/reference/ev_pixmap_chart|EV_PIXMAP]], eventually using double-buffering, which normally results in a smoother animation but requires fast copying from memory to the video buffer (and thus can be slow if the display is remote).
|
||||
|
||||
|
||||
==Events==
|
||||
|
||||
The other features of drawing area and widget is that they generate pointer events. These events can be translated by projectors to map the figure world. These projectors send the event to the appropriate figure. Every figure has all common pointer action sequences:
|
||||
The other features of drawing area and widget is that they generate pointer events. These events are translated by projectors to the map of the figure world. These projectors send the event to the appropriate figure. Every figure is set up to receive all the common pointer events, including Pick-and-Drop events:
|
||||
* <eiffel>pointer_motion_actions</eiffel>
|
||||
* <eiffel>pointer_button_press_actions</eiffel>
|
||||
* <eiffel>pointer_double_press_actions</eiffel>
|
||||
@@ -145,15 +149,15 @@ The other features of drawing area and widget is that they generate pointer even
|
||||
* <eiffel>pick_actions</eiffel>
|
||||
* <eiffel>conforming_pick_actions</eiffel>
|
||||
* <eiffel>drop_actions</eiffel>
|
||||
There are no events for keyboard focus and no key press events. In case you wish to use these events, use the ones of the pixmap or drawing area.
|
||||
There are no events for keyboard focus and no key press events. If you need to use these events, use them from pixmap or drawing area.
|
||||
|
||||
When using events, keep the z-order in mind. This is the order in which the figures are stacked in the world. The first item of a figure group is the figure that is the farthest away. This means that the figure is obscured by any figures which are in front of it, and events will also not be propagated to this figure in that case.
|
||||
When using events, keep the z-order in mind. This is the order in which the figures are stacked in the "figure world". The first item of a figure group is the figure that is the farthest away. Any figure can be obscured by (visible) figures in front of it. Events are only received by a figure when the (mouse) pointer is over its exposed areas, i.e. areas not obscured by (visible) figures in front of it. If a figure is fully obscured by visible figures in front of it, then it will receive no pointer events.
|
||||
|
||||
|
||||
==Rotation and Scaling==
|
||||
|
||||
The relative points also support rotation and scaling. These factors work just like coordinates, except scaling, which is multiplied instead of added in the chain of points. This means that when a relative point which is the root of a tree of several points is moved, the entire tree is moved, when it is scaled the entire tree is scaled and same for rotation.
|
||||
Relative Points also support rotation and scaling. Both rotation and scaling can be entered at any point in the tree of relative points. One of the most useful of these points is the <code>point</code> of an [[ref:libraries/vision2/reference/ev_figure_group_chart|EV_FIGURE_GROUP]], which rotation and/or scaling will then propagate down the tree to all the contained figures and sub-groups. Rotation is in radians progressing counter-clockwise from the positive X axis. Scaling is multiplied into the chain of relative points. This means that when a relative point which is the root of a tree of several points is moved, the entire tree is moved. When it is scaled the entire tree is scaled, and the same for rotation.
|
||||
|
||||
The scaling factor is divided into a horizontal and vertical component. If the factor is 0.5, everything is displayed at half its size. The rotation factor is in radians.
|
||||
The scaling factor has two components: horizontal (x) and vertical (y), which can be set separately or together. If the x/y scaling factor is 0.5, everything at that point and below in the tree is displayed at half its normal size.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user