![]() | ![]() | DiaCanvas2 Reference Manual | ![]() |
---|
Table of Contents
DiaCanvas is a GNOME widget tailored to applications that draw a diagram, in the wider sense of the word. DiaCanvas has a Visio like appearance and supports the GNOME anti-alias canvas as well as the original X canvas.
DiaCanvas2 uses the model/view/controller paradigm to make it possible to create multiple views of one object and to separate visualization data from the (more simple) data model. DiaCanvas is the base class for the canvas model. A canvas contains a set of DiaCanvasItems. The DiaCanvasView class is the visual counterpart of DiaCanvas. Likewise is the DiaCanvasViewItem the visual counterpart of the DiaCanvasItem, the object that contains information about an object on the canvas.
A programmer should not need to worry about the views of the canvas. All the programmer needs to do is inherit from DiaCanvasItem to create a object that has more specialized functionality. The view will request the DiaShape objects that describe the appearance. A shape is the most simple representation of a drawing primitive. For a line is would be a list of points, the line width, end point type and the color.
DiaCanvasItems are stateless. You can not rely on the status flags with regards to selected, focused and grabbed except in the event handler. Shapes that only need to be drawn if the view item is in a selected state can set their visibility flag.
Objects can be transformed in a generic way. This can be done by using an transformation matrix. If you have programmed with the GnomeCanvas this probably sounds familiar. For example if an object needs to be rotated, the matrix is assigned values to make the transformation possible. The object itself, however does not need to know that it is transformed, it creates its shapes the same way it would have done when the object was not rotated.
The interface DiaCanvasGroupable has a special meaning. Groupable objects have the ability to contain child objects visible to the view. The views use this interface to access those child objects. Objects exposed via the DiaCanvasGroupable interface can recieve events and can therefore be selected individually. The DiaCanvasGroup class realizes this interface. Items can be assembled by using multiple composite items.
An object usually has a bunch of handles. A handle (DiaHandle) is an object used to manipulate the DiaCanvasItem. For a line the handles can be used to move the different points on the line (every point is represented by a handle). A rectangle might have a handle on every corner, this makes it easy to resize the rectangle.
DiaHandle objects are always drawn on top of the objects. This way you can guess where an object is, even if it is hidden by another object.
Like all diagrams an item can be connected to another. In DiaCanvas2 those relations are held true by means of a linear constraint solver. If a line connects to a rectangle object (e.g. a box), an equation is created that will position the line's handle on the side of the rectangle. If the rectangle is moved, the line also moves (or at least the line's handle). Please read the chapter about the constraint solver for more information.
<< DiaCanvas2 Reference Manual | DiaCanvas >> |