Implementation of an industrial control pipe control with various intersecting shapes

Source: Internet
Author: User

Introduced

In the process of programming industrial control system, the pipe control is a very important and useful control in the environment system such as simulation field. Many industrial configuration software can use his graphics library to produce a very beautiful three-dimensional scene, so that the program injected a lot of life. And in the personal writing of the industrial program, because there is no graphics library and other support, then the display appears very monotonous. If we can add support for this type of control, it will make our programs more professional.

Body

Now a portion of the network also provides a way to programmatically control the pipeline, but basically they are rough, not ideal, and in the pipeline entities often have a variety of intersecting shapes, and the network can hardly find the kind of support for various shapes of the pipe control (generally provides the horizontal and vertical two shapes support). Using these controls to complete the interface, when the complex corners and other areas will appear very awkward. On the basis of analyzing and collecting this information, I have developed some control for pipeline, etc., and have completed various corners and other cross shapes. I hope that my experience will be helpful to those who are involved in this area or who are looking for relevant information.

The first is the implementation of the pipe control. The pipe is a kind of circular equipment, from the outward appearance we can see basically is a kind of process that darkens the middle to both sides. In my other article, "The implementation of an industrial control pipeline flow Control", a gradient method is used to achieve the rendering of the entity. That is suitable for a simple pipe implementation. such as horizontal and vertical. But in a complex control implementation, this approach to the implementation of the corner is very troublesome, so we do not adopt this approach.

We can do this experiment in the Windows Paint program, we use different colors to draw some different colors of the line, when our color with a color to another color gradient will produce a visual "bump" effect. Because the pipe is generally black-and-white color, we can use the rough and white gradient color to draw, show the effect see below: Can be seen roughly, with this different color to do some area of the drawing can form that visual effect on the pipeline drawing.

As shown above, we can get a way to draw a control similar to a horizontal pipe, so that we can get the drawing method of the control of the longitudinal pipe. At that time in the corner of the implementation, we have to do some other processing. A lot of times we see some master in the physical connection, when the pipe corner, the need to two pipe at the interface of the shoe 45 degrees of cutting, and then realize the intersection of different pipelines. We can do this by crossing the handle on it. I believe you can see the following code implementation.

Through the analysis of the pipeline, generally can get some general shape of the pipe, about 11 kinds of conditions in the atmosphere, the corner on the left, the corner on the right, the lower right corner, the lower left corner, vertical, horizontal, central intersection, the left cross, the top side cross, the upper cross, the bottom cross. Draw work on different shapes by setting the properties of the control. We can do a rough abstraction of the shape here.//管道的形状
typedef enum _PipeFace
{
  PF_CORNER_LEFT_TOP   = 0,     //左上的拐角
  PF_CORNER_RIGHT_TOP    = 2,   //右上的拐角
  PF_CORNER_RIGHT_BOTTOM = 3,     //右下的拐角
  PF_CORNER_LEFT_BOTTOM = 4,     //左下的拐角
  PF_VERTICAL        = 5,     //竖向
  PF_HORIZONTAL      = 6,     //横向
  PF_CROSS_CENTER    = 7,   //中央交叉
  PF_CROSS_LEFT     = 8,   //左边交叉
  PF_CROSS_TOP      = 9,   //顶边交叉
  PF_CROSS_RIGHT     = 10,   //上边交叉
  PF_CROSS_BOTTOM    = 11   //底边交叉
}PIPEFACE;
The following is our pipeline drawing work, triggering WM_PAINT messages to complete the drawing work.void Cpipectrl::onpaint ()
{
CPAINTDC DC (this);

RECT rcclient;
GetClientRect (&rcclient);
Switch (m_enumface)
{
Case Pf_horizontal:
Drawhorizontal (&DC, rcclient);
Break
Case Pf_vertical:
Drawvertical (&DC, rcclient);
Break
Case Pf_corner_left_top:
Drawcornerlefttop (&DC, rcclient);
Break
Case Pf_corner_right_top:
Drawcornerrighttop (&DC, rcclient);
Break
Case Pf_corner_right_bottom:
Drawcornerrightbottom (&DC, rcclient);
Break
Case Pf_corner_left_bottom:
Drawcornerleftbottom (&DC, rcclient);
Break
Case Pf_cross_center:
Drawcrosscenter (&DC, rcclient);
Break
Case Pf_cross_top:
Drawcrosstop (&DC, rcclient);
Break
Case Pf_cross_right:
Drawcrossright (&DC, rcclient);
Break
Case Pf_cross_bottom:
Drawcrossbottom (&DC, rcclient);
Break
Case Pf_cross_left:
Drawcrossleft (&DC, rcclient);
Break
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.