From graduation to now has a relatively long period of time, in these work, the preparation of industrial control software has been my main occupation. Because at that time is a cautious company, mainly responsible for the power industry monitoring system, while opening up some industrial-related business, such as water, gates, rubber dams and other systems. This kind of system a notable characteristic is the system integration degree is high, requests to the field control request to understand more, then uses the plc+ IPC the mode to be possible. There are many kinds of PLC, and the technology is very mature, can be stable operation, and the PLC manufacturers have provided the programming software, can be rapid development, and in the host computer (industrial computer software) part of the configuration of software providers, more well-known such as Kingview, Visual Graph, Ifix and so on. However, many of these configuration software are based on the project authorization, that is, a project to be sent to get one of his authorization. As a cautious company, the company's leaders feel that since they have their own software development engineers if the use of configuration software to achieve the words is a very good thing, so the company's claim is to develop their own monitoring software.
An important part of the development of industrial control software is the graphics system. Many configuration systems provide a wealth of graphical configuration functions, can be provided through their graphics library to complete a variety of complex graphics development, and the effect is very good. such as symbol, LED, trend, flow control, etc. And their own development is a lot more monotonous. There are now a number of control providers, such as the century flying, to provide a series of control development packages, but in a word, they are all about rice. As a lot of developers are reluctant to go out of the money, but search the network of such controls, but rarely find a few. Some time ago a friend received a project, a pump plant monitoring system, the implementation of the system requires a lot of pipeline and pipeline internal trend chart, can reflect the direction of the flow of water real-time. Since private development could not afford to buy those controls, I was asked to give him a pipe control that could be used to reflect the flow of the project.
Thanks to the wealth of information on the Web, "If I succeed it is because I stand on the shoulders of giants", by considering, we can use the combination of pipeline and flow to implement our control
The first is the pipe, the simple consideration is horizontal and vertical two kinds (as for you have time to consider those 7788 turn situation), then we can define the pipeline in two modes
typedef enum _FlowPattern
{
FP_HORIZONTAL = 0,
FP_VERTICAL = 1
}FLOWPATTERN;
Then there is the flow direction of the inner flow, the horizontal can be from left to right and from right to left, vertical can be divided by the top down and right up, so that we can abstract the flow direction inside:typedef enum _DirectionType
{
LEFT_TO_RIGHT = 0,
RIGHT_TO_LEFT = 1,
TOP_TO_BOTTOM = 2,
BOTTOM_TO_TOP = 3
}DIRECTIONTYPE;
The following is the drawing of the pipe, how to draw to achieve the visual effect of the pipeline. If a planar rectangle is a pipe that does not look visually effective. After referring to some of the gradient on the network processing methods found that in fact, our pipeline can be implemented in this way. If the side and center of the pipe are in two different colors, the two colors are a color-approximate value, a deep, shallow one. When the color processing is drawn from the edge to the central method: shallow-deep-shallow, so that we can produce a visual effect of the pipe concave surface, which in turn can produce the convex surface of the pipe. There are a lot of ways to do gradient drawing on the network now, this is no problem.
And then there's the design of the flow that we're going to consider. In some of the mobile controls we normally see (charging control) the flow of the shape can be a variety of rectangles, some small triangles and so on. And the flow of performance is in the middle of the pipeline to draw some of our above examples of small graphics. In this way, we design a functional class for these individual small graphs, and then in the middle of the class to achieve a different single small slider to draw, if our pipeline has n such small slider composition, if we do the dynamic drawing of small slider, then will not produce visual sliding.
Principles such as the above, we design a timer in the sliding control, using the timer driver, and then filling the pipe with a shape to dynamically populate a slider queue, each dynamic calculation of the position of each slider, by dynamically refreshing the pipe background and slider position (erase the original old slider position) can produce sliding effect , the principle of pipe flow control is basically the case.
Here is the hands-on implementation, we first create an inherited CStatic Flow class Cflowctrl through ClassWizard, and then map the WM_PAINT message, because the pipe and slider drawing is done here. If our timer time is very small, refresh rate quickly, there will be a very serious flicker, here we use double buffering, in the middle of memory to make complex graphics, and then "paste" (BITBTN) to the interface can not flicker. To enhance the readability of the program, we have two classes (Cflowimpl, Cpipeimpl) for piping drawing and slider drawing.