While creating a strongly customized plot, developer may want to access and modify both “logical” and “physical” structure of the plot. Examples of need for logical structure modification are when developer says “I want a horizontal zero grid line to be drawn in a special way” or “I want those two plots to have the same grid but different vertical value labels”. Oppositely, the need to “make all vertical lines thinner” requires modification of shapes, i.e. “physical” structure of plot control.
Architecture of Exincs plot control is shown on the figure below.
Logical layer (or diagram elements layer) is a set of classes derived from DiagramElement. Each diagram element has its parent element and child elements. The plot control has the only element which is root of plot control elements tree. The explicit function plot control root element normally has children of type ExplicitFunctionPlotItem which represents a single explicit function plot. An instance of ExplicitFunctionPlotItem contains child elements representing plot line, grid and labels.
Whenever the entire diagram (containing set of plots) must be drawn, a set of shapes (lines, ovals, text labels, etc.) is generated. Those shapes constitute “physical” layer of the control. Any shape in Exincs library is derived from DiagramShape class. Each diagram element has references to the set of shapes it generated. By adding custom shapes, applied programmer can draw complex images on plot area in physical screen coordinates. Moreover, developer can change the appearance of auto-generated shapes. The correspondence between logical and physical elements gives the developer virtually infinite customization possibilities.
Shapes layer is updated every time the plot area is redrawn. This usually happens when Redraw() method is invoked, plot is reside etc. Developer may modify the shapes layer by subscribing to DiagramShapesPrepared event which occurs after shapes layer re-generation but before shapes are drawn to the screen.
Diagram Elements
Every diagram element (an element of plot logical structure) in Exincs library is derived from DiagramElement class. This base class unites features common for all diagram elements:- Parent and Children properties that support the tree structure of diagram elements set.
- Diagram property containing the reference to the diagram this element belongs to.
- ZOder and Visible properties that are common appearance properties for all diagram elements.
Diagram Shapes
DiagramShape is the base class for all shapes – bricks of the “physical” layer. The main method of diagram shapes is Draw() which renders the shape to the screen (actually to System.Drawing.Graphics object). The hierarchy of shapes is shown on the figure below.