Before the time to learn new things do not summarize the habit of the weekend to the previous research things upside down, a little summary.
Scxml is a state machine-based dialogue scripting language standard, the specific content can be Google to, here to describe their own development of a scxml into an interactive graphics program.
The source code is uploaded to git.
Https://github.com/su6838354/scxml_exec
The basic principle is to convert an XML language with a state machine relationship to a rectangle, a line between rectangles, and a child-parent relationship of a rectangle.
The entire module is divided into 5 parts from the bottom up
1.Scxml Script
2.Parser layer (dependent tinyxpath)
3.Model Layer
4.Layout layer (model converted to virtual drawing object)
5.View Graphics (MFC and GDI [Gdiplus::graphics] implementations)
Parser layer will parse Scxml script through tinyxpth and output modal object, and provide getstate,gettransitions,getfinals interface to upper layer, the parameter type between interfaces is the model layer definition;
The layout layer obtains all the state and transition, and then translates it into virtual graphical objects Scxmlrectangle and scxmlline, etc.;
The view layer is implemented by MFC to depict and render virtual drawing objects
Here is the package design diagram, UI from layout to get graphical information drawing, layout from igetscxmlobject to get analytic information,
The parser layer can read the elements in the Scxml file through Iread, Modelfactory convert the acquired elements to a custom object, providing Igetmodel to layout
Here is the use case diagram for the layout and parser layers,
Layout describes the process of automatic state machine layout, including getting objects from the Scxml_parser module, and calculating the entire layout of the graph based on the object contents
Rectangle Scxml for outputting the center point, width, height, line start point, etc. of the graphic
Getscxmlobject parsing scxml objects, generating rectangular and directed segments
Parser describes the process of parsing an object from the Scxml format, and the relationship to the external module,
Read Scxml is primarily used to read the contents of Scxml files as required, and it calls the Tinyxpath module to perform custom XPath syntax
Create model constructs the read content as an object
The class diagram for layout is as follows
Line lines, including starting and ending points
Rectangle Rectangle, containing center point, width, height
Scxmllayout contains all the rectangles and lines of data and has a way to calculate the entire layout of the graphic
Layout sequence diagram
According to Scxml object, execute layout algorithm, generate graph information
Call Scxml_parser module, get custom Scxml object, generate corresponding graphic content, execute layout algorithm, output graphic information
The Parser class diagram is as follows
Xtinyxpath calling the XPath language to find the Scxml element
Scxmlparser call Tinyxpath get element, encapsulated as Scxmlobject object
Parser Timing Diagram:
The Scxml file parsing process calls the Tinyxpath module, which implements the XPath language embedded in C + +, acquires scxml elements as required, transforms them into custom objects, and uses them for layout drawing
The results are shown below
The following is a relatively complex scxml that contains parallel, multi-layered nesting relationships
Scxml Image Viewer (based on the implementation of C + + MFC Tinyxpath)