Graphics primitive arrangement method, device, readable storage medium and graphical programming system

Through the method of automatic arrangement and connection of primitives, the problems of inconvenient manual connection operation and high error rate in the prior art are solved, and efficient and reliable topological structure drawing is achieved.

CN115755747BActive Publication Date: 2025-04-25SUZHOU GAOCHUANG MOTION CONTROL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211366040.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2025-04-25
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

In the prior art, the organization of primitives in the topology depends on manual connection, resulting in inconvenient operation, high time cost and high error rate.

Method used

A method of layout of primitives is provided. By obtaining the dimension information of the initial primitives and the subsequent primitive information of the primitives to be arranged, the primitive connection relationship is determined, and the automatic arrangement and connection of primitives is realized through the sorting and placement position determination.

Benefits of technology

It improves the drawing efficiency of topological structure, reduces the error rate, enhances the reliability of the structure, and reduces the user's manual operation needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115755747B_ABST
    Figure CN115755747B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, readable storage medium and graphical programming system for arranging graphic elements, wherein the method for arranging graphic elements includes: obtaining an initial graphic element and at least two graphic elements to be arranged, each of the initial graphic element and the at least two graphic elements to be arranged having: size information and subsequent graphic element information; determining a graphic element connection relationship according to the initial graphic element, at least two graphic elements to be arranged and corresponding subsequent graphic element information; sorting the initial graphic element and the at least two graphic elements to be arranged according to the graphic element connection relationship to obtain all paths for graphic element arrangement; determining the placement positions of the initial graphic element and the at least two graphic elements to be arranged according to all paths, the size information of the initial graphic element and the size information of the at least two graphic elements to be arranged; and connecting the initial graphic element and the at least two graphic elements to be arranged at the placement positions according to the graphic element connection relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of control technology, and in particular to a method and device for arranging graphic elements, a readable storage medium and a graphical programming system. Background Art

[0002] Programmable logic controllers are widely used in the field of industrial control. Currently, the programming languages ​​of programmable logic controllers include: Sequential Function Chart (SFC), Ladder Diagram (LD), Function Block Diagram (FBD), Instruction List (IL), and Structured Text (ST).

[0003] Among them, the three graphical programming languages, Sequential Function Chart (SFC), Ladder Diagram (LD), and Function Block Diagram (FBD), require certain organization of each programming element to form a topological structure.

[0004] In the related technical solutions, the organization of the above topological structure relies on manual connection. Although the manual connection has a higher degree of freedom, the operation is not convenient enough. For example, the time cost of manual connection is relatively high. At the same time, the probability of error in manual connection is relatively high. Summary of the invention

[0005] The present invention aims to solve at least one of the technical problems existing in the prior art or related art.

[0006] To this end, a first aspect of the present invention is to provide a method for arranging graphic elements.

[0007] A second aspect of the present invention is to provide a device for arranging graphic elements.

[0008] A third aspect of the present invention provides a readable storage medium.

[0009] A fourth aspect of the present invention is to provide a graphical programming system.

[0010] In view of this, according to a first aspect of the present invention, the present invention provides a method for arranging graphic elements, including: obtaining an initial graphic element and at least two graphic elements to be arranged, each of the initial graphic element and the at least two graphic elements to be arranged having: size information and subsequent graphic element information; determining a graphic element connection relationship according to the initial graphic element, the at least two graphic elements to be arranged and the corresponding subsequent graphic element information; sorting the initial graphic element and the at least two graphic elements to be arranged according to the graphic element connection relationship to obtain all paths for graphic element arrangement; determining the placement positions of the initial graphic element and the at least two graphic elements to be arranged according to all paths, the size information of the initial graphic element and the size information of the at least two graphic elements to be arranged; and connecting the initial graphic element and the at least two graphic elements to be arranged at the placement positions according to the graphic element connection relationship.

[0011] The technical solution of the present application proposes a primitive arrangement method, by running the primitive arrangement method, primitives can be automatically arranged and automatically connected to form a topological structure. In this process, there is no need for the user to manually connect different primitives, which improves the efficiency of drawing the topological structure. At the same time, the above technical solution does not require manual participation, reduces the probability of errors when connecting primitives together to form a topological structure, and improves the reliability of the topological structure.

[0012] In the above technical solution, the graphic elements in this application can be understood as graphic blocks for implementing graphical programming. Specifically, in the ladder diagram (Ladder Diagram, LD) language, the graphic elements include: power rails, contacts, coils, function blocks; in the function block diagram (Function Block Diagram, FBD), the graphic elements include: function blocks, AND / OR function blocks, outputs; in the sequential function chart (Sequential Function Chart, SFC), the graphic elements include: steps, transfers, branches, jumps, etc.

[0013] In one of the technical solutions, the subsequent primitive information can be understood as the next primitive connected to the current primitive under the current primitive, and the connection relationship between the primitives can be known based on the subsequent primitive.

[0014] In one of the technical solutions, the initial primitive is the first primitive used when programming using primitives, which can be understood as the starting step of programming. Specifically, in a sequential function chart (SFC), the initial primitive is the initial step; in a ladder diagram (LD) language, the initial primitive is the left power rail; in a function block diagram (FBD), the initial primitive is the initial line.

[0015] Since the diagram of the initial primitive is different from that of other primitives, the initial primitive can be determined from the primitives before arranging the primitives. Since each primitive contains the information of the subsequent primitive, that is, the initial primitive contains a subsequent primitive information, and each primitive to be arranged also contains a subsequent primitive information, therefore, the subsequent primitive information in different primitives can be used to know the connection relationship of all primitives, that is, the primitive connection relationship mentioned above.

[0016] In the technical solution of the present application, the primitive connection relationship is used to characterize the connection relationship between different primitives, and the primitive connection relationship is used to sort at least two primitives to be arranged and the initial primitive to obtain all paths. In this process, since the path is constructed based on the primitive connection relationship, the obtained path conforms to the logic of data processing.

[0017] In the process of determining the placement position, the connection relationship of the graphic elements is referred to, so that the obtained placement position conforms to the above-mentioned connection relationship of the graphic elements, ensuring that the position relationship between the graphic elements is logical. At the same time, it also reduces the complexity of the connection between the graphic elements when connecting different graphic elements. At the same time, the size information of the graphic elements is referred to in the process of determining the placement position, reducing the probability of overlap between different graphic elements, so that the arranged topological structure is clear and unambiguous.

[0018] In the above technical solution, the size information includes: a width value and a height value. By limiting the size information to include the width value and the height value, the above size information can be used to represent the primitive in a two-dimensional graphic so that the user can perform visual operations.

[0019] In addition, the graphic element arrangement method proposed in this application also has the following additional technical features.

[0020] In the above technical solution, the placement positions of the initial primitive and at least two primitives to be arranged are determined according to all paths, the size information of the initial primitive and the size information of at least two primitives to be arranged, specifically including: obtaining the primitives on the first path; determining the placement positions of the primitives on the first path according to the size information corresponding to the primitives on the first path and the primitive connection relationship; obtaining the primitives on the second path; determining the placement positions of the primitives on the second path according to the size information corresponding to the primitives on the first path, the placement positions of the primitives on the first path, the size information of the primitives on the second path and the primitive connection relationship; wherein the second path is any path among all paths except the first path.

[0021] In this technical solution, the placement positions of the graphics elements are determined one by one according to the paths. At the same time, when determining the placement positions of the graphics elements on the second path, the size information corresponding to the graphics elements on the first path and the placement positions of the graphics elements on the first path are referred to, thereby reducing the probability of overlapping graphics elements when the graphics elements on the two paths are placed, so that the arranged topological structure is clear and unambiguous.

[0022] In the above technical solution, the placement position includes: a coordinate value in a first direction and a coordinate value in a second direction, the first direction and the second direction are perpendicular; according to the size information corresponding to the graphic element on the first path and the graphic element connection relationship, the placement position of the graphic element on the first path is determined, specifically including: obtaining a first coordinate value in the first direction and a second coordinate value in the second direction of the initial graphic element; determining the coordinate value of the graphic element on the first path in the first direction according to the graphic element connection relationship, the first coordinate value and the size information corresponding to the graphic element on the first path; using the second coordinate value as the coordinate value of the graphic element on the first path in the second direction, and calibrating the graphic element on the first path; according to The placement position of the graphics elements on the second path is determined based on the size information corresponding to the graphics elements on the first path, the placement position of the graphics elements on the first path, the size information of the graphics elements on the second path and the graphics element connection relationship, specifically including: obtaining the first type of graphics elements, which are calibrated graphics elements; determining the second type of graphics elements on the second path, which are uncalibrated graphics elements; determining the coordinate value of the second type of graphics elements in the first direction based on the graphics element connection relationship, the placement position of the first type of graphics elements and the size information of the first type of graphics elements in the first direction; determining the size information of the first type of graphics elements in the second direction based on the coordinate value in the first direction, and determining the coordinate value of the second type of graphics elements in the second direction.

[0023] In this technical solution, it is specifically defined how the placement position of each graphic element is determined.

[0024] Specifically, as mentioned above, the initial primitive is the first primitive used when programming with primitives. It can be understood that the initial primitive is the first primitive in each arrangement order. Therefore, the coordinate value of the initial primitive can be obtained before the primitives are arranged. Usually, the initial primitive is located at the origin of the coordinate axis, that is, the first coordinate value in the first direction and the second coordinate value in the second direction. Usually, the first coordinate value and the second coordinate value are both zero.

[0025] After determining the placement position of the initial graphic element, the placement position of each graphic element in the arrangement order can be determined based on the arrangement order. Specifically, for the first path, the graphic elements on the first path have the same coordinates in the second direction. At this time, the second coordinate value in the second direction is used as the coordinate value of the graphic element on the first path in the second direction, thereby forming an effect that any graphic element on the first path is arranged in the same straight line distribution, so as to improve the regularity of the arrangement.

[0026] Specifically, after the first coordinate value of the initial primitive in the first direction is known, the size information of the initial primitive is added to the first coordinate value in the first direction to obtain the coordinate value of the subsequent primitive in the first direction of the initial primitive. Based on this, the coordinate value of the primitive on the first path in the first direction can be determined.

[0027] When there are multiple graphic elements on the first path, the coordinate value of the graphic element with the later order in the first direction of two adjacent graphic elements can be determined based on the coordinate value of the graphic element with the earlier order in the first direction and the size information of the graphic element with the earlier order.

[0028] For each second path except the first path in all arrangement orders, find out the unmarked graphics elements, that is, the second type of graphics elements mentioned above, and combine the placement position of the first type of graphics elements and the size information of the first type of graphics elements in the first direction to determine the coordinate value of the second type of graphics elements in the first direction.

[0029] After determining the coordinate values ​​of the second type of graphics elements in the first direction, it is necessary to determine the coordinate values ​​of the second type of graphics elements in the second direction. In this process, the size information of the first type of graphics elements in the second direction can be referred to to determine the coordinate values, thereby reducing the probability of overlap between different graphics elements and improving the aesthetics of the graphics element arrangement.

[0030] In one of the technical solutions, the size information of the first type of graphic element in the second direction is selected as the largest size in the second direction, such as selecting the maximum height value.

[0031] In one of the technical solutions, each graphic element has identification information. After the placement position of the graphic element is calibrated, the identification information is set to 1, otherwise it is set to 0. Therefore, by checking the identification information, it can be determined whether the placement position of the graphic element has been determined.

[0032] In any of the above technical solutions, when the number of first-category graphic elements is at least one, the first-category graphic elements include a first graphic element, and the first graphic element is the last graphic element in the first-category graphic element, and the arrangement method also includes: when the second graphic element has been calibrated, obtaining the coordinate value of the second graphic element in the first direction, the second graphic element is the successor graphic element corresponding to the first graphic element; obtaining the coordinate value of the second graphic element in the first direction; when the coordinate value of the second graphic element in the first direction is less than or equal to the coordinate value of the first graphic element in the first direction, determining the movement value of the second graphic element; and updating the coordinate value of the second graphic element in the first direction according to the movement value.

[0033] In this technical solution, the number of the first type of graphic elements may be one or more.

[0034] In the above technical solution, the coordinate value of the second graphic element in the first direction is compared with the coordinate value of the first graphic element in the first direction to determine whether there is position overlap between the graphic elements. If, in the first direction, it is detected that the coordinate value of the later arrangement order is smaller than the coordinate value of the front arrangement order, it is considered that graphic element overlap has occurred. At this time, the position of the graphic element needs to be adjusted to eliminate the overlap mentioned above, thereby providing the user with a beautiful layout. At the same time, it also improves the convenience of graphic element operation and reduces the increased difficulty of visualization operation caused by graphic element overlap.

[0035] In this technical solution, the last graphic element in the first category is selected as the object for comparison with the second graphic element so as to achieve overall translation of multiple continuous graphic elements through one translation, thereby reducing the number of translations and the amount of data processing.

[0036] In the above technical solution, the coordinate value of the second graphic element in the first direction is updated so as to realize the translation of the second graphic element.

[0037] In one of the technical solutions, when the second primitive includes subsequent primitive information, when it is detected that the coordinate value of the second primitive in the first direction is updated, the coordinate value of the subsequent primitive in the first direction is synchronously updated according to the movement value.

[0038] In any of the above technical solutions, it also includes: determining the sum of the coordinate value of the first primitive in the first direction and the size information of the first primitive; determining the difference between the sum and the coordinate value of the second primitive in the first direction, and using the difference as the movement value.

[0039] In this technical scheme, the method for determining the movement value is specifically defined. In the above technical scheme, the sum of the coordinate value of the first primitive in the first direction and the size information of the first primitive is calculated to obtain the actual coordinate value of the second primitive in the first direction, and the difference between the actual coordinate value and the current coordinate value (that is, the coordinate value of the second primitive in the first direction mentioned above) is calculated to obtain the movement amount required for the second primitive.

[0040] In the above technical solution, the probability of overlap between different graphic elements is reduced, thereby improving the aesthetics of graphic element arrangement.

[0041] In any of the above technical solutions, it also includes: updating the initial primitive and at least two primitives to be arranged when one or more of the following updates are detected: the number of at least two primitives to be arranged, the size information of any one of at least two primitives to be arranged, the initial primitive, and the subsequent primitive information of at least two primitives to be arranged.

[0042] In this technical solution, when a change in the number of graphic elements is detected, it is considered that the arranged graphic elements have been deleted or added. By updating at least two graphic elements to be arranged and the initial graphic element, the automatic update of the topological structure is achieved. In this process, user participation is reduced and the efficiency of graphic element arrangement is improved.

[0043] In the above technical solution, when the size information of a primitive is updated, if the topological structure is not updated, there is a possibility of overlap between primitives. In order to eliminate the above possibility, at least two primitives to be arranged and the initial primitive are updated to achieve automatic updating of the topological structure.

[0044] In the above technical solution, when the subsequent primitive information is adjusted, the logic between the primitives will inevitably change, and the automatic update of the topological structure is achieved by updating at least two primitives to be arranged and the initial primitive.

[0045] In the above technical solution, by updating at least two graphics elements to be arranged and the initial graphics element, the user is prevented from redrawing the graphics elements and connecting them, thereby reducing the user's workload.

[0046] In any of the above technical solutions, the initial primitives and at least two primitives to be arranged are sorted according to the primitive connection relationship to obtain all paths for primitive arrangement, specifically including: using a depth-first search algorithm to search the initial primitives and at least two primitives to be arranged to obtain all paths.

[0047] In the above technical solution, the depth-first search algorithm, also known as depth-first search, is a method that is used more often in the early stages of crawler development, and its purpose is to reach the leaf nodes of the searched structure. Taking Hypertext Markup Language as an example, in an Hypertext Markup Language file, when a hyperlink is selected, the linked Hypertext Markup Language file will perform a depth-first search, that is, a single link must be completely searched before searching the rest of the hyperlink results.

[0048] According to a second aspect of the present invention, the present invention provides a device for arranging graphic elements, comprising: a processor and a memory, the memory storing programs or instructions that can be run on the processor, and the programs or instructions, when executed by the processor, implement the steps of any of the methods described above.

[0049] According to a third aspect of the present invention, the present invention provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of any of the above methods are implemented.

[0050] According to a fourth aspect of the present invention, the present invention provides a graphical programming system, comprising: a graphic element arrangement device as described in any one of the above items; and / or a readable storage medium as described above.

[0051] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0053] Figure 1 A schematic diagram showing a flow chart of a method for arranging graphic elements in some embodiments of the present invention;

[0054] Figure 2 A topological schematic diagram of the graph elements before the two graph elements X14 and MUL in the ladder diagram (LD) language in an embodiment of the present invention is shown;

[0055] Figure 3 A topological diagram of the graphic elements after the two graphic elements X14 and MUL in the ladder diagram (LD) language in an embodiment of the present invention is shown;

[0056] Figure 4 A topological schematic diagram of a graphic element before a MOD graphic element is shown in a function block diagram (FBD) in an embodiment of the present invention;

[0057] Figure 5 A topological schematic diagram of a MOD primitive in a function block diagram (FBD) in an embodiment of the present invention is shown;

[0058] Figure 6 A topological schematic diagram showing a sequential function chart (SFC) in an embodiment of the present invention, excluding the primitives before the step2 primitive;

[0059] Figure 7 A topological diagram of a step2 primitive in a sequential function chart (SFC) in an embodiment of the present invention is shown;

[0060] Figure 8 A schematic diagram showing a flow chart of a method for arranging graphic elements in some embodiments of the present invention;

[0061] Fig. 9 A detailed schematic diagram of a method for arranging graphic elements in an embodiment of the present invention is shown;

[0062] Fig.10 A schematic block diagram of an arrangement device of graphic elements in some embodiments of the present invention is shown. DETAILED DESCRIPTION

[0063] In order to more clearly understand the above aspects, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0064] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0065] According to one embodiment of the present invention, Figure 1 As shown, a method for arranging graphic elements is provided, including:

[0066] Step 102, obtaining an initial primitive and at least two primitives to be arranged, wherein each of the initial primitive and the at least two primitives to be arranged has: size information and subsequent primitive information;

[0067] Step 104, determining a primitive connection relationship according to the initial primitive, at least two primitives to be arranged, and corresponding subsequent primitive information;

[0068] Step 106, sorting the initial primitive and at least two primitives to be arranged according to the primitive connection relationship to obtain all paths for primitive arrangement;

[0069] Step 108, determining placement positions of the initial primitive and at least two primitives to be arranged according to all paths, size information of the initial primitive and size information of at least two primitives to be arranged;

[0070] Step 110 , connecting the initial graphic element at the placement position and at least two graphic elements to be arranged according to the graphic element connection relationship.

[0071] The embodiment of the present application proposes a primitive arrangement method, by running the primitive arrangement method, primitives can be automatically arranged and automatically connected to form a topological structure. In this process, there is no need for the user to manually connect different primitives, which improves the efficiency of drawing the topological structure. At the same time, the above embodiment does not require manual participation, reduces the probability of errors when connecting primitives together to form a topological structure, and improves the reliability of the topological structure.

[0072] In the above embodiments, the graphic elements in the present application can be understood as graphic blocks for implementing graphical programming. Specifically, in the ladder diagram (LD) language, the graphic elements include: power rails, contacts, coils, function blocks; in the function block diagram (FBD), the graphic elements include: function blocks, AND / OR function blocks, outputs; in the sequential function chart (SFC), the graphic elements include: steps, transfers, branches, jumps, etc.

[0073] In one of the embodiments, the subsequent primitive information can be understood as the next primitive connected to the current primitive under the current primitive, and the connection relationship between primitives can be known based on the subsequent primitive.

[0074] In one of the embodiments, the initial primitive is the first primitive used when programming using primitives, which can be understood as the starting step of programming. Specifically, in a sequential function chart (SFC), the initial primitive is the initial step; in a ladder diagram (LD) language, the initial primitive is the left power rail; in a function block diagram (FBD), the initial primitive is the initial line.

[0075] Since the diagram of the initial primitive is different from that of other primitives, the initial primitive can be determined from the primitives before arranging the primitives. Since each primitive contains the information of the subsequent primitive, that is, the initial primitive contains a subsequent primitive information, and each primitive to be arranged also contains a subsequent primitive information, therefore, the subsequent primitive information in different primitives can be used to know the connection relationship of all primitives, that is, the primitive connection relationship mentioned above.

[0076] In an embodiment of the present application, the primitive connection relationship is used to characterize the connection relationship between different primitives, and the primitive connection relationship is used to sort at least two primitives to be arranged and the initial primitive to obtain all paths. In this process, since the path is constructed based on the primitive connection relationship, the obtained path conforms to the logic of data processing.

[0077] In the process of determining the placement position, the connection relationship of the graphic elements is referred to, so that the obtained placement position conforms to the above-mentioned connection relationship of the graphic elements, ensuring that the position relationship between the graphic elements is logical. At the same time, it also reduces the complexity of the connection between the graphic elements when connecting different graphic elements. At the same time, the size information of the graphic elements is referred to in the process of determining the placement position, reducing the probability of overlap between different graphic elements, so that the arranged topological structure is clear and unambiguous.

[0078] In the above embodiment, the size information includes: a width value and a height value. By limiting the size information to include the width value and the height value, the above size information can be used to represent the graphic element in a two-dimensional graphic so that the user can perform visual operations.

[0079] In the above technical solution, the placement positions of the initial primitive and at least two primitives to be arranged are determined according to all paths, the size information of the initial primitive and the size information of at least two primitives to be arranged, specifically including: obtaining the primitives on the first path; determining the placement positions of the primitives on the first path according to the size information corresponding to the primitives on the first path and the primitive connection relationship; obtaining the primitives on the second path; determining the placement positions of the primitives on the second path according to the size information corresponding to the primitives on the first path, the placement positions of the primitives on the first path, the size information of the primitives on the second path and the primitive connection relationship; wherein the second path is any path among all paths except the first path.

[0080] In this technical solution, the placement positions of the graphics elements are determined one by one according to the paths. At the same time, when determining the placement positions of the graphics elements on the second path, the size information corresponding to the graphics elements on the first path and the placement positions of the graphics elements on the first path are referred to, thereby reducing the probability of overlapping graphics elements when the graphics elements on the two paths are placed, so that the arranged topological structure is clear and unambiguous.

[0081] In the above embodiment, the placement position includes: a coordinate value in a first direction and a coordinate value in a second direction, the first direction and the second direction being perpendicular; determining the placement position of the graphic element on the first path according to the size information corresponding to the graphic element on the first path and the graphic element connection relationship, specifically including: obtaining a first coordinate value in the first direction and a second coordinate value in the second direction of the initial graphic element; determining the coordinate value of the graphic element on the first path in the first direction according to the graphic element connection relationship, the first coordinate value and the size information corresponding to the graphic element on the first path; using the second coordinate value as the coordinate value of the graphic element on the first path in the second direction, and calibrating the graphic element on the first path; according to The placement position of the graphics elements on the second path is determined based on the size information corresponding to the graphics elements on the first path, the placement position of the graphics elements on the first path, the size information of the graphics elements on the second path and the graphics element connection relationship, specifically including: obtaining the first type of graphics elements, which are calibrated graphics elements; determining the second type of graphics elements on the second path, which are uncalibrated graphics elements; determining the coordinate value of the second type of graphics elements in the first direction based on the graphics element connection relationship, the placement position of the first type of graphics elements and the size information of the first type of graphics elements in the first direction; determining the size information of the first type of graphics elements in the second direction based on the coordinate value in the first direction, and determining the coordinate value of the second type of graphics elements in the second direction.

[0082] In this embodiment, how to determine the placement position of each graphic element is specifically defined.

[0083] Specifically, Figure 2 As shown, the first path includes x1-x2-ADD-x6; the second path is x1-x2-x7-SUB-x11, wherein the coordinate value of x7 in the first direction is determined by x2, and the coordinate value of x7 in the second direction is determined by ADD. Specifically, the coordinate value of x7 in the first direction is the same as the coordinate value of ADD in the first direction, and the coordinate value of x7 in the second direction is determined by the coordinate value of ADD in the second direction and the size of ADD in the second direction.

[0084] In one of the embodiments, in the LD language and the FBD language, the abscissa is defined as the horizontal direction and the ordinate is defined as the vertical direction, and in the SFC language, the abscissa is defined as the vertical direction and the ordinate is defined as the horizontal direction.

[0085] In one of the technical solutions, different languages ​​use different coordinates. Since SFC has no concept of segmentation, the graphics elements use absolute coordinates. In LD and FBD, the graphics elements use relative coordinates, such as Figure 2 and Figure 3As shown, the segmentation line uses absolute coordinates, and the graphics element stores relative coordinates relative to the segmentation line. In the automatic sorting of LD and FBD, only the graphics elements in the current segment are sorted after the addition, deletion and modification operations, and the subsequent segments only modify the coordinates of the segmentation line. When the graphics element needs to be displayed, the absolute coordinates are obtained based on the segmentation line and the relative coordinates for display.

[0086] Specifically, as mentioned above, the initial primitive is the first primitive used when programming with primitives. It can be understood that the initial primitive is the first primitive in each arrangement order. Therefore, the coordinate value of the initial primitive can be obtained before the primitives are arranged, the first horizontal first coordinate value in the first direction and the second first vertical coordinate value in the second direction. Usually, the first coordinate value and the second coordinate value are both zero.

[0087] After determining the placement position of the initial graphic element, the placement position of each graphic element in the arrangement order can be determined based on the arrangement order. Specifically, for the first path, the graphic elements on the first path have the same coordinates in the second direction. At this time, the second coordinate value in the second direction is used as the coordinate value of the graphic element on the first path in the second direction, thereby forming an effect that any graphic element on the first path is arranged in the same straight line distribution, so as to improve the regularity of the arrangement.

[0088] Specifically, after the first coordinate value of the initial primitive in the first direction is known, the size information of the initial primitive is added to the first coordinate value in the first direction to obtain the coordinate value of the subsequent primitive in the first direction of the initial primitive. Based on this, the coordinate value of the primitive on the first path in the first direction can be determined.

[0089] When there are multiple graphic elements on the first path, the coordinate value of the graphic element with the later order in the first direction of two adjacent graphic elements can be determined based on the coordinate value of the graphic element with the earlier order in the first direction and the size information of the graphic element with the earlier order.

[0090] For each second path except the first path in all arrangement orders, find out the unmarked graphics elements, that is, the second type of graphics elements mentioned above, and combine the placement position of the first type of graphics elements and the size information of the first type of graphics elements in the first direction to determine the coordinate value of the second type of graphics elements in the first direction.

[0091] After determining the coordinate values ​​of the second type of graphics elements in the first direction, it is necessary to determine the coordinate values ​​of the second type of graphics elements in the second direction. In this process, the size information of the first type of graphics elements in the second direction can be referred to to determine the coordinate values, thereby reducing the probability of overlap between different graphics elements and improving the aesthetics of the graphics element arrangement.

[0092] In one of the technical solutions, the size information of the first type of graphic element in the second direction is selected as the largest size in the second direction, such as selecting the maximum height value.

[0093] In one of the embodiments, each graphic element has identification information. After the placement position of the graphic element is calibrated, the identification information is set to 1, otherwise it is set to 0. Therefore, it is possible to determine whether the placement position of the graphic element has been determined by checking the identification information.

[0094] In any of the above technical solutions, when the number of first-category graphic elements is at least one, the first-category graphic elements include a first graphic element, and the first graphic element is the last graphic element in the first-category graphic element, and the arrangement method also includes: when the second graphic element has been calibrated, obtaining the coordinate value of the second graphic element in the first direction, the second graphic element is the successor graphic element corresponding to the first graphic element; obtaining the coordinate value of the second graphic element in the first direction; when the coordinate value of the second graphic element in the first direction is less than or equal to the coordinate value of the first graphic element in the first direction, determining the movement value of the second graphic element; and updating the coordinate value of the second graphic element in the first direction according to the movement value.

[0095] In this technical solution, the number of the first type of graphic elements may be one or more.

[0096] In the above technical solution, the coordinate value of the second graphic element in the first direction is compared with the coordinate value of the first graphic element in the first direction to determine whether there is position overlap between the graphic elements. If, in the first direction, it is detected that the coordinate value of the later arrangement order is smaller than the coordinate value of the front arrangement order, it is considered that graphic element overlap has occurred. At this time, the position of the graphic element needs to be adjusted to eliminate the overlap mentioned above, thereby providing the user with a beautiful layout. At the same time, it also improves the convenience of graphic element operation and reduces the increased difficulty of visualization operation caused by graphic element overlap.

[0097] In this technical solution, the last graphic element in the first category is selected as the object for comparison with the second graphic element so as to achieve overall translation of multiple continuous graphic elements through one translation, thereby reducing the number of translations and the amount of data processing.

[0098] In the above technical solution, the coordinate value of the second graphic element in the first direction is updated so as to realize the translation of the second graphic element.

[0099] In one of the technical solutions, when the second primitive includes subsequent primitive information, when it is detected that the coordinate value of the second primitive in the first direction is updated, the coordinate value of the subsequent primitive in the first direction is synchronously updated according to the movement value.

[0100] In any of the above technical solutions, it also includes: determining the sum of the coordinate value of the first primitive in the first direction and the size information of the first primitive; determining the difference between the sum and the coordinate value of the second primitive in the first direction, and using the difference as the movement value.

[0101] In this technical scheme, the method for determining the movement value is specifically defined. In the above technical scheme, the sum of the coordinate value of the first primitive in the first direction and the size information of the first primitive is calculated to obtain the actual coordinate value of the second primitive in the first direction, and the difference between the actual coordinate value and the current coordinate value (that is, the coordinate value of the second primitive in the first direction mentioned above) is calculated to obtain the movement amount required for the second primitive.

[0102] In the above embodiment, the probability of overlap between different graphic elements is reduced, thereby improving the aesthetics of graphic element arrangement.

[0103] In any of the above embodiments, it also includes: updating the initial primitive and at least two primitives to be arranged when one or more of the following updates are detected: the number of at least two primitives to be arranged, the size information of any one of the at least two primitives to be arranged, the initial primitive, and the subsequent primitive information of at least two primitives to be arranged.

[0104] In this embodiment, when a change in the number of graphic elements is detected, it is considered that the arranged graphic elements have been deleted or added, and at least two graphic elements to be arranged and the initial graphic element are updated to achieve automatic updating of the topological structure. In this process, user participation is reduced and the efficiency of graphic element arrangement is improved.

[0105] In the above embodiment, when the size information of a primitive is updated, if the topological structure is not updated, there is a possibility of overlap between primitives. In order to eliminate the above possibility, at least two primitives to be arranged and the initial primitive are updated to achieve automatic updating of the topological structure.

[0106] In the above embodiment, when the subsequent primitive information is adjusted, the logic between the primitives will inevitably change, and the automatic update of the topological structure is achieved by updating at least two primitives to be arranged and the initial primitive.

[0107] In the above embodiment, by updating at least two graphics elements to be arranged and the initial graphics element, the user is prevented from redrawing and connecting the graphics elements, thereby reducing the user's workload.

[0108] In one embodiment, if Figure 2 As shown in the ladder diagram (LD) language, the topology diagram of the graphic elements before the two graphic elements X14 and MUL is not included, such as Figure 3As shown, in the ladder diagram (Ladder Diagram, LD) language, the topology diagram includes the graphic elements after the two graphic elements X14 and MUL. It can be seen from the above that the topology diagram can be automatically updated.

[0109] In one embodiment, if Figure 4 As shown in the Function Block Diagram (FBD), the topological diagram of the graphic element before the MOD graphic element is not included, such as Figure 5 As shown, in the function block diagram (Function Block Diagram, FBD), a topology diagram of MOD graphics elements is included. It can be seen from the above that the topology diagram can be automatically updated.

[0110] In one embodiment, if Figure 6 As shown in the Sequential Function Chart (SFC), the topological diagram of the graphics element before step2 is not included, such as Figure 7 As shown, in the sequential function chart (SFC), the topology diagram includes the step2 diagram element. It can be seen from the above that the topology diagram can be automatically updated.

[0111] In any of the above embodiments, the initial primitives and at least two primitives to be arranged are sorted according to the primitive connection relationship to obtain all paths for primitive arrangement, specifically including: using a depth-first search algorithm to search the initial primitives and at least two primitives to be arranged to obtain all paths.

[0112] In the above embodiments, the depth-first search algorithm, also known as depth-first search, is a method that is used more often in the early stages of crawler development, and its purpose is to reach the leaf nodes of the searched structure. Taking Hypertext Markup Language as an example, in an Hypertext Markup Language file, when a hyperlink is selected, the linked Hypertext Markup Language file will perform a depth-first search, that is, a single link must be completely searched before searching the rest of the hyperlink results. In one embodiment, Figure 8 As shown, the arrangement method of the primitives includes:

[0113] Step 802, determining the connection relationship between the initial primitive and the primitives.

[0114] Specifically, the initial primitive is the initial step in SFC, the left power rail in LD, and the initial line in FBD. Each primitive stores the subsequent primitives, and all primitives can be found based on the initial primitive and the subsequent primitives to obtain the connection relationship.

[0115] Step 804, starting from the initial primitive, use a depth-first search algorithm to search for all possible paths of the primitive.

[0116] Step 806, determining the position of the graphic element according to all possible paths obtained.

[0117] Step 808, determine when the graphics elements are added, deleted, or modified and need to be reordered. If the judgment result is yes, execute step 802, if the judgment result is no, end.

[0118] In one embodiment, for the convenience of description, in LD and FBD, the horizontal coordinate is defined as the A coordinate and the vertical coordinate is defined as the B coordinate, and in SFC, the horizontal coordinate is defined as the B coordinate and the vertical coordinate is defined as the A coordinate. Fig. 9 As shown, step 806 includes:

[0119] Step 902, taking out the first path from all possible paths, and determining the positions of all the graphic elements on the first path according to the specified order and the initial value of the B coordinate (0).

[0120] For the convenience of subsequent description, the order is specified from left to right in LD and FBD, and from top to bottom in SFC. The A coordinate value of the first element is the initial value 0, and the A coordinates of subsequent elements increase in sequence according to the placement order and the size of the previous element. The two coordinate values ​​of the element are determined, that is, the positions of all elements on the first path are determined and marked as determined.

[0121] Step 904, take out the next path, find out all the graphic elements with undetermined positions in the path, and determine the A coordinate values ​​of these graphic elements.

[0122] Among them, the first primitive with an undetermined position is found, the previous primitive of the primitive is obtained according to the path, and the A coordinate value of the primitive with an undetermined position is determined in sequence according to the A coordinate value of the previous primitive and the primitive size.

[0123] Step 906, processing the last primitive whose position is not determined in the path of step 904, and finding the primitive whose successor has been determined.

[0124] If the A coordinate of this primitive is smaller than or equal to the A coordinate of the last primitive whose position is not determined, it needs to be moved. The value of the move is the A coordinate value of the last primitive whose position is not determined plus its size minus the A coordinate value of the successor primitive. All primitives whose positions have been determined after the last primitive whose position is not determined are found through the breadth-first search algorithm, and the A coordinate values ​​are moved in sequence.

[0125] Step 908, calculate the B coordinate of the graphic element that was not placed in step 904, and determine the final position according to the A and B coordinates.

[0126] Among them, according to the A coordinate value determined in step 904, all the graphics elements whose positions have been determined in the range from the A coordinate value of the first graphics element with an undetermined position to the A coordinate value of the last graphics element with an undetermined position are searched, and their B coordinate values ​​are calculated plus their sizes. The maximum value obtained is the B coordinate value of the unplaced graphics element. According to the A coordinate value determined in step 904 and the B coordinate value determined in step 908, the position of the graphics element is finally obtained, and the graphics element is marked as a determined position.

[0127] Step 910, repeating steps 904 to 908 until all paths are placed. Draw all connection lines according to the final positions of the primitives and the connection relationships of the primitives.

[0128] In one embodiment, if Fig.10 As shown, the present invention provides a graphic element arrangement device 1000, including: a controller 1002 and a memory 1004, wherein the memory 1004 stores programs or instructions, and the controller 1002 implements the steps of any of the above methods when executing the programs or instructions in the memory 1004.

[0129] Among them, the memory 1004 can be used to store software programs and various data. The memory 1004 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instruction required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1004 may include a volatile memory or a non-volatile memory, or the memory 1004 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1004 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0130] In one embodiment, the present invention provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of any of the above methods are implemented.

[0131] In one embodiment, the present invention provides a graphical programming system, including: a graphic element arrangement device as described in any one of the above; and / or a readable storage medium as described above.

[0132] In one embodiment, the graphical programming system is a graphical programming system for a programmable logic controller. The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for arranging graphic elements, applied to a graphical programming system, characterized in that: include: Acquire an initial primitive and at least two primitives to be arranged, wherein each of the initial primitive and the at least two primitives to be arranged has: size information and subsequent primitive information; Determine a primitive connection relationship according to the initial primitive, the at least two primitives to be arranged and corresponding subsequent primitive information; Sorting the initial graphic element and the at least two graphic elements to be arranged according to the graphic element connection relationship to obtain all paths for graphic element arrangement; Determining placement positions of the initial graphic element and the at least two graphic elements to be arranged according to all the paths, the size information of the initial graphic element and the size information of the at least two graphic elements to be arranged; According to the primitive connection relationship, connecting the initial primitive located at the placement position and the at least two primitives to be arranged; The graphic primitives are graphic blocks used to implement graphical programming. In ladder diagram language, the graphic primitives include power rails, contacts, coils, and function blocks. In function block diagrams, the graphic primitives include function blocks, which include AND / OR function blocks and output blocks. In sequential function diagrams, the graphic primitives include steps, transfers, branches, and jumps. The step of determining the placement positions of the initial graphic element and the at least two graphic elements to be arranged according to all the paths, the size information of the initial graphic element, and the size information of the at least two graphic elements to be arranged specifically includes: Get the primitives on the first path; Determine placement positions of the graphic elements on the first path according to size information corresponding to the graphic elements on the first path and connection relationships between the graphic elements; Get the primitives on the second path; Determine the placement position of the graphic element on the second path according to the size information corresponding to the graphic element on the first path, the placement position of the graphic element on the first path, the size information of the graphic element on the second path and the connection relationship of the graphic element; The second path is any path among all the paths except the first path; The placement position includes: a coordinate value in a first direction and a coordinate value in a second direction, the first direction and the second direction being perpendicular; The step of determining the placement position of the graphic element on the first path according to the size information corresponding to the graphic element on the first path and the connection relationship between the graphic elements specifically includes: Acquire a first coordinate value of the initial graphic element in the first direction and a second coordinate value of the initial graphic element in the second direction; Determine the coordinate value of the graphic element on the first path in the first direction according to the graphic element connection relationship, the first coordinate value and the size information corresponding to the graphic element on the first path; Using the second coordinate value as the coordinate value of the graphic element on the first path in the second direction, and calibrating the graphic element on the first path; The determining the placement position of the graphic element on the second path according to the size information corresponding to the graphic element on the first path, the placement position of the graphic element on the first path, the size information of the graphic element on the second path and the graphic element connection relationship specifically includes: Acquire a first type of primitive, where the first type of primitive is a calibrated primitive; Determine a second type of primitive on the second path, where the second type of primitive is an uncalibrated primitive; Determine the coordinate value of the second type of graphic element in the first direction according to the graphic element connection relationship, the placement position of the first type of graphic element and the size information of the first type of graphic element in the first direction; Determine the coordinate value of the second type of graphic element in the second direction according to the coordinate value in the first direction and the size information of the first type of graphic element in the second direction; In the case where the number of the first type of primitives is at least one, the first type of primitives includes a first primitive, and the first primitive is the last primitive in the first type of primitives, the arrangement method further includes: In the case where the second graphic element has been calibrated, obtaining a coordinate value of the second graphic element in the first direction, the second graphic element being a subsequent graphic element corresponding to the first graphic element; Obtaining the coordinate value of the second graphic element in the first direction; When the coordinate value of the second graphic element in the first direction is less than or equal to the coordinate value of the first graphic element in the first direction, determining the movement value of the second graphic element; The coordinate value of the second graphic element in the first direction is updated according to the movement value.

2. The method for arranging graphic elements according to claim 1, characterized in that: Also includes: Determine a sum of the coordinate value of the first graphic element in the first direction and the size information of the first graphic element; A difference between the sum value and the coordinate value of the second primitive in the first direction is determined, and the difference is used as the movement value.

3. The method for arranging graphic elements according to claim 1, characterized in that: In the ladder diagram language and the function block diagram language, the coordinate value in the first direction and the coordinate value in the second direction are relative coordinates; In the sequential function chart language, the coordinate value in the first direction and the coordinate value in the second direction are absolute coordinates.

4. The method for arranging graphic elements according to any one of claims 1 to 3, characterized in that: Also includes: When one or more of the following updates are detected, the initial primitive and the at least two primitives to be arranged are updated: The number of the at least two graphics elements to be arranged, the size information of any one of the at least two graphics elements to be arranged, the initial graphics element, and the subsequent graphics element information of the at least two graphics elements to be arranged.

5. The method for arranging graphic elements according to claim 4, characterized in that: The step of sorting the initial graphic element and the at least two graphic elements to be arranged according to the graphic element connection relationship to obtain all paths for arranging the graphic elements specifically includes: The initial primitive and the at least two primitives to be arranged are searched using a depth-first search algorithm to obtain all the paths.

6. A device for arranging graphic elements, characterized in that: include: A processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 5 are implemented.

7. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A graphical programming system, characterized in that: include: The device for arranging graphics elements as claimed in claim 6; and / or The readable storage medium as claimed in claim 7.

Citation Information

Patent Citations

  • Ladder diagram editing method and device, electronic equipment and storage medium

    CN113419722A

  • Graph layout method and device, electronic equipment and storage medium

    CN114047912A