A method and system for generating a graphic adsorption line, an electronic device and a storage medium
By classifying the characteristic lines of graphic snap lines by direction and type and sorting their coordinate values, and by setting auxiliary lines, the problem of low generation efficiency in existing technologies is solved. This achieves more efficient generation of graphic snap lines and optimized snap line selection, thereby improving the performance of editing tools and user experience.
Patent Information
- Application Number
- CN202111629615.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2041-12-28
AI Technical Summary
Existing technologies are inefficient in generating snap lines, especially when there are many bounding boxes and they are densely arranged in the editing interface. This results in a large amount of computation, causing operation lag and poor snap line generation.
By querying the feature lines of the target bounding box, the bounding box feature lines within the drawing editing area are divided into multiple sets according to the direction and type of the feature lines, and sorted based on coordinate values. Other bounding box feature lines that meet the constraints are set as auxiliary lines, thereby determining and displaying the drawing snap lines.
The computational load for generating snap lines has been reduced, increasing generation efficiency. The selection of snap lines has been optimized, improving the relevance of operations and the editing experience.
Smart Images

Figure CN114332294B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image editing technology, and in particular to a method, system, electronic device, and storage medium for generating graphic snap lines. Background Technology
[0002] When drawing flowcharts, topology diagrams, or architecture diagrams, it is often necessary to display snap lines in the editing interface to help the editor determine the bounding boxes that need to be aligned. When the bounding box being edited is close to the snap line, the snap line provides a certain snapping effect, reducing the precision requirements of the alignment operation.
[0003] In related technologies, graphic snap lines are usually generated based on the principle of proximity. However, when there are many bounding boxes in the editing interface and they are densely arranged, the process of generating graphic snap lines requires a lot of comparison and calculation, resulting in low efficiency in generating graphic snap lines.
[0004] Therefore, how to improve the generation efficiency of patterned adsorption lines is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide a method, system, electronic device, and storage medium for generating patterned adsorption lines, which can improve the generation efficiency of patterned adsorption lines.
[0006] To solve the above-mentioned technical problems, this application provides a method for generating a patterned adsorption line, the method comprising:
[0007] Query the currently selected target bounding box and determine the feature lines of the target bounding box; wherein, the type of the feature lines includes boundary lines and / or boundary perpendicular lines;
[0008] According to the direction and type of the feature lines, the feature lines of all bounding boxes within the image editing area are divided into multiple feature line sets, and the feature lines in the feature line sets are sorted according to the coordinate values of the feature lines.
[0009] The feature lines of other bounding boxes within the feature line set that meet the constraint conditions are set as auxiliary lines; wherein, the constraint condition is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range;
[0010] The graphic snap line corresponding to the target bounding box is determined from the auxiliary lines, and the graphic snap line is displayed in the graphic editing area.
[0011] Optionally, feature lines of other bounding boxes within the feature line set that meet the constraints are set as auxiliary lines, including:
[0012] Generate a corresponding coordinate value array by sorting the feature lines in the feature line set;
[0013] Set the coordinate values in the coordinate value array that correspond to the feature lines of the target bounding box as the target coordinate values;
[0014] The difference between the target coordinate value and the coordinate value of each coordinate value on the left is calculated in order from near to far until the difference of the coordinate values is no longer within the preset range.
[0015] The difference between the target coordinate value and each coordinate value on the right is calculated in order from near to far until the difference between the coordinate values is no longer within the preset range.
[0016] The feature line corresponding to the coordinate values within the preset interval where the difference of the coordinate values is located is set as the auxiliary line.
[0017] Optionally, after dividing the feature lines of all bounding boxes within the graph editing area into multiple feature line sets according to the direction and type of the feature lines, the method further includes:
[0018] Determine whether the position of the target bounding box in the image editing area has changed;
[0019] If so, the feature line set is updated according to the current position of the target bounding box.
[0020] Optionally, determining the graphic snap line corresponding to the target bounding box from the auxiliary lines includes:
[0021] If the number of auxiliary lines is 1, then the auxiliary line is set as the graphic snapping line corresponding to the target bounding box;
[0022] If the number of auxiliary lines is greater than 1, then the graphic snap line corresponding to the target bounding box is determined from the auxiliary lines according to the preset screening principle.
[0023] Optionally, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines according to a preset screening principle, including:
[0024] Query the current movement direction of the target bounding box;
[0025] Set the auxiliary line in the current movement direction of the target bounding box as the graphic snap line corresponding to the target bounding box.
[0026] Optionally, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines according to a preset screening principle, including:
[0027] Calculate the distance between the bounding box containing each of the auxiliary lines and the target bounding box;
[0028] Set the auxiliary line of the bounding box closest to the target bounding box as the graphic snap line corresponding to the target bounding box.
[0029] Optionally, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines according to a preset screening principle, including:
[0030] Query the number of times each of the aforementioned auxiliary lines was set as a graphic snap line and not selected by the user for snapping;
[0031] The auxiliary line whose frequency exceeds a preset value is set as an interference auxiliary line;
[0032] All auxiliary lines except the interference auxiliary lines are set as the graphic snapping lines corresponding to the target bounding box.
[0033] This application also provides a system for generating patterned adsorption lines, the system comprising:
[0034] The feature line determination module is used to query the currently selected target bounding box and determine the feature lines of the target bounding box; wherein, the type of the feature lines includes boundary lines and / or boundary perpendicular lines;
[0035] The set partitioning module is used to divide the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, and to sort the feature lines in the feature line sets according to the coordinate values of the feature lines.
[0036] The auxiliary line setting module is used to set the feature lines of other bounding boxes that meet the constraints within the feature line set as auxiliary lines; wherein, the constraint is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range;
[0037] The adsorption line generation module is used to determine the graphic adsorption line corresponding to the target bounding box from the auxiliary lines and display the graphic adsorption line in the graphic editing area.
[0038] This application also provides a storage medium storing a computer program thereon, which, when executed, implements the steps of the above-described method for generating graphic adsorption lines.
[0039] This application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor, when calling the computer program in the memory, implements the steps of the above-described method for generating graphic adsorption lines.
[0040] This application provides a method for generating graphic snap lines, comprising: querying a currently selected target bounding box and determining the feature lines of the target bounding box; wherein the type of the feature lines includes boundary lines and / or perpendicular bisectors of boundaries; dividing the feature lines of all bounding boxes within the drawing editing area into multiple feature line sets according to the direction and type of the feature lines, and sorting the feature lines in the feature line sets according to the coordinate values of the feature lines; setting the feature lines of other bounding boxes within the feature line sets that meet the constraint conditions as auxiliary lines; wherein the constraint condition is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range; determining the graphic snap line corresponding to the target bounding box from the auxiliary lines, and displaying the graphic snap line within the drawing editing area.
[0041] This application queries the feature lines of the currently selected target bounding box, divides the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, and sorts the feature lines based on their coordinate values. The feature lines in each feature line set are arranged in order of their coordinate values. This application uses the difference in coordinate values between the feature lines of other bounding boxes and the feature lines of the target bounding box as a reference to determine whether preset conditions are met. That is, the feature lines of other bounding boxes within the feature line set that meet the constraints are set as auxiliary lines, and then the graphic snapping line corresponding to the target bounding box is determined and displayed from the auxiliary lines. This application determines the graphic snapping line from the feature line set based on the difference in coordinate values, and the feature lines in the feature line set are arranged in order of their coordinate values, which can reduce the computational load in the process of determining the graphic snapping line and improve the generation efficiency of the graphic snapping line. This application also provides a graphic snapping line generation system, a storage medium, and an electronic device, which have the above-mentioned beneficial effects, and will not be elaborated further here. Attached Figure Description
[0042] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating a method for generating graphic adsorption lines provided in an embodiment of this application;
[0044] Figure 2 This is a schematic diagram of a rectangular bounding box provided in an embodiment of this application;
[0045] Figure 3 A schematic diagram of a cuboid enclosure box provided in an embodiment of this application;
[0046] Figure 4 This is a schematic diagram of a bounding box arrangement provided in an embodiment of this application;
[0047] Figure 5 This is a schematic diagram of an adsorption line determination method provided in an embodiment of this application;
[0048] Figure 6 This is a schematic diagram of the structure of a graphic adsorption line generation system provided in an embodiment of this application. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0050] Please see below. Figure 1 , Figure 1 This is a flowchart illustrating a method for generating graphic adsorption lines provided in an embodiment of this application.
[0051] Specific steps may include:
[0052] S101: Query the currently selected target bounding box and determine the feature lines of the target bounding box;
[0053] This embodiment can be applied to graph editing software, where users can draw editable flowcharts, topology diagrams, or architecture diagrams. The editing process may involve operations such as node arrangement and connection. The graph editing software can draw two-dimensional or three-dimensional nodes (i.e., the drawing result) on the canvas. The software can generate corresponding bounding boxes for the above models. A bounding box is a model used to describe the position of a node on the canvas, describing the position and size of the node in the graph editing area (i.e., the canvas). The bounding box corresponding to a two-dimensional node is the smallest rectangle that can enclose the node, and the bounding box corresponding to a three-dimensional node is the smallest cuboid that can enclose the node. The sides of the bounding box can be parallel or perpendicular to the X-axis and Y-axis (or X-axis, Y-axis, and Z-axis) of the graph editing area.
[0054] Each bounding box has one or more feature lines, which can be boundary lines, perpendicular bisectors, or both. Please refer to [link to relevant documentation]. Figure 2 , Figure 2 This is a schematic diagram of a rectangular bounding box provided in an embodiment of this application. Figure 2Points A, B, C, and D are the vertices of the rectangular bounding box. Point E is the midpoint of line segment AB, point F is the midpoint of line segment BC, point G is the midpoint of line segment CD, and point H is the midpoint of line segment AD. Figure 2 The rectangular bounding box shown is located in a Cartesian coordinate system. The characteristic lines of the bounding box include AB, BC, CD, AD, EG, and HF. Please refer to [link / reference needed]. Figure 3 , Figure 3 This is a schematic diagram of a cuboid bounding box provided in an embodiment of this application. The cuboid bounding box is located in a spatial rectangular coordinate system. Points I, J, K, L, I', J', K', and L' are the vertices of the cuboid bounding box. Point M is the midpoint of line segment IJ, point N is the midpoint of line segment JK, point P is the midpoint of line segment KL, and point Q is the midpoint of line segment IL. The feature lines in the cuboid bounding box include the line segments corresponding to the 12 edges of the cuboid, and may also include the perpendicular bisectors MP and QN of each face.
[0055] S102: Divide the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, and sort the feature lines in the feature line sets according to the coordinate values of the feature lines;
[0056] For a rectangular bounding box, the direction of the feature lines includes directions parallel to the X-axis and parallel to the Y-axis; for a cuboid bounding box, the direction of the feature lines includes directions parallel to the X-axis, parallel to the Y-axis, and parallel to the Z-axis. Therefore, for a rectangular bounding box, the following four sets of feature lines can be obtained: (1) boundary lines parallel to the X-axis; (2) boundary lines parallel to the Y-axis; (3) perpendicular bisectors of the boundary parallel to the X-axis; (4) perpendicular bisectors of the boundary parallel to the Y-axis. For a cuboid bounding box, the following six sets of feature lines can be obtained: (1) boundary lines parallel to the X-axis; (2) boundary lines parallel to the Y-axis; (3) boundary lines parallel to the Z-axis; (4) perpendicular bisectors of the boundary parallel to the X-axis; (5) perpendicular bisectors of the boundary parallel to the Y-axis; (6) perpendicular bisectors of the boundary parallel to the Z-axis.
[0057] For a rectangular bounding box, the coordinates of the feature lines are the values of the intersections of the feature lines with the X-axis or Y-axis, such as... Figure 2 As shown, the coordinates of feature line AB are the X-axis coordinates of the intersection of the extension of AB and the X-axis, and the coordinates of feature line AD are the Y-axis coordinates of the intersection of the extension of AF and the Y-axis. For a cuboid bounding box, the projection of each face of the cuboid bounding box into a rectangular coordinate system can be considered as a rectangular bounding box, and the coordinate values of each feature line can be determined using the above-described scheme for determining the coordinate values of the feature lines of the rectangular bounding box. When the same feature line has coordinate values on multiple axes, only the coordinate value of one axis can be used for calculation; the same axis is selected within the same set of feature lines. For example... Figure 3The coordinate value of IJ can be 10 corresponding to the Z-axis or 5 corresponding to the X-axis. You can choose one, but you must ensure that the axis used for IJ, LK, I'J', and L'K' is the same (e.g., all of them choose the X-axis).
[0058] After dividing the feature line set, the feature lines in the set can be sorted according to their coordinate values. For feature lines within the same bounding box with the same coordinate values, a deduplication operation can be performed. Figure 3 For example, only one of the characteristic lines IJ and I'J' can be retained.
[0059] S103: Set the feature lines of other bounding boxes that meet the constraints within the feature line set as auxiliary lines;
[0060] In this embodiment, auxiliary lines are lines that may be selected as graphic snapping lines. This embodiment can determine whether a line is an auxiliary line based on the difference in coordinate values within each feature line set. For example, if the difference in coordinate values between AB and CD is 5, and the difference in coordinate values between AB and EF is 30, then CD is more likely to be a graphic snapping line. This embodiment can set the following constraint: the difference in coordinate values between the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range; this step can set the feature lines of other bounding boxes that meet the above constraints as auxiliary lines.
[0061] Since the feature lines within the feature line set are sorted according to their coordinate values, the feature lines of other bounding boxes can be used to determine whether they meet the constraints by following the order of their distance from the target bounding box. Because the greater the difference in the sorting order within the feature line set, the greater the difference in coordinate values between the feature lines of other bounding boxes and the feature lines of the target bounding box, the evaluation process can stop when it is detected that the feature lines of other bounding boxes do not meet the constraints.
[0062] Specifically, in this embodiment, the auxiliary line can be set as follows: A corresponding coordinate value array is generated based on the sorting of the feature lines in the feature line set; the coordinate values corresponding to the feature lines of the target bounding box in the coordinate value array are set as target coordinate values; the difference between the target coordinate value and the coordinate values of each left coordinate value is calculated in order from near to far until the difference is not within the preset interval; the difference between the target coordinate value and the coordinate values of each right coordinate value is calculated in order from near to far until the difference is not within the preset interval; the feature line corresponding to the coordinate value whose difference is within the preset interval is set as the auxiliary line. To illustrate the above process, the feature lines in the feature line set are sorted in descending order of coordinate values as follows: a, b, c, d, e, f, g. The coordinate value of a is 2, the coordinate value of b is 5, the coordinate value of c is 7, the coordinate value of d is 12, the coordinate value of e is 13, the coordinate value of f is 19, and the coordinate value of g is 20. The feature line of the target bounding box is d, and the preset interval corresponding to the constraint condition is (-3, 3). At this time, the operation of calculating the difference of coordinate values needs to be performed, including dc, de, and df, and e is used as an auxiliary line. The above process does not require the calculation of db, da, and de, so the amount of calculation in the comparison process between feature lines can be reduced.
[0063] S104: Determine the graphic snap line corresponding to the target bounding box from the auxiliary lines, and display the graphic snap line in the drawing editing area.
[0064] During the editing process, vertical or horizontal snap lines appear when the content is moved or resized to remind the editor to align with another node at that position. A snapping effect is provided when editing close to the snap lines, meaning even minor edits are moved to the position aligned with the guide lines, improving alignment accuracy. After determining the guide lines, this embodiment can determine the graphic snap line corresponding to the target bounding box based on the number and position of the guide lines. This graphic snap line can be a straight line or a line segment of a preset length, and its length can differ from the guide lines. After displaying the snap lines, it can be determined whether the distance between the target feature line of the target bounding box and the graphic snap line is less than the snapping distance. If so, the target bounding box can be moved to the position of the graphic snap line. The guide lines corresponding to the target feature line and the graphic snap line have the same direction and type, such as perpendicular bisectors of the boundary parallel to the X-axis.
[0065] This embodiment queries the feature lines of the currently selected target bounding box, divides the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to their direction and type, and sorts the feature lines based on their coordinate values. The feature lines in each set are arranged in ascending order of their coordinate values. This embodiment uses the difference in coordinate values between the feature lines of other bounding boxes and the feature lines of the target bounding box as a reference to determine whether preset conditions are met. That is, the feature lines of other bounding boxes within the feature line set that meet the constraints are set as auxiliary lines, and then the graphic snapping line corresponding to the target bounding box is determined and displayed from the auxiliary lines. This embodiment determines the graphic snapping line from the feature line set based on the difference in coordinate values, and the feature lines in the feature line set are arranged in ascending order of their coordinate values, which reduces the computational load in determining the graphic snapping line and improves the generation efficiency of the graphic snapping line.
[0066] As a feasible implementation, after dividing the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, it can be determined whether the position of the target bounding box in the image editing area has changed; if so, the feature line set is updated according to the current position of the target bounding box. After updating the feature line set, the sorting of the feature lines in the feature line set can be adjusted according to the coordinate values, thereby redetermining the graphic snapping line.
[0067] As a feasible implementation method, Figure 1 The corresponding embodiment can determine the graphic snap line corresponding to the target bounding box from all the auxiliary lines in the following way: if the number of auxiliary lines is 1, then the auxiliary line is set as the graphic snap line corresponding to the target bounding box; if the number of auxiliary lines is greater than 1, then the graphic snap line corresponding to the target bounding box is determined from the auxiliary lines according to a preset screening principle.
[0068] The specific preset filtering principles mentioned above include: movement direction filtering principle, bounding box distance filtering principle, and user operation habit filtering principle.
[0069] The process of determining the graphic snapping line according to the movement direction filtering principle is as follows: query the current movement direction of the target bounding box; set the auxiliary line in the current movement direction of the target bounding box as the graphic snapping line corresponding to the target bounding box.
[0070] When the movement direction filtering principle cannot determine the graphic snapping line, the bounding box distance filtering principle can be used to determine the graphic snapping line. The implementation process is as follows: calculate the distance between the bounding box where each auxiliary line is located and the target bounding box; set the auxiliary line of the bounding box that is closest to the target bounding box as the graphic snapping line corresponding to the target bounding box.
[0071] When the movement direction filtering principle and the bounding box distance filtering principle cannot determine the graphic snapping line, the user operation habit filtering principle can be used to determine the graphic snapping line. The implementation process is as follows: query the number of times each of the above auxiliary lines is set as a graphic snapping line and is not selected by the user; set the auxiliary lines with the number of times greater than a preset value as interference auxiliary lines; set all the auxiliary lines except the interference auxiliary lines as the graphic snapping lines corresponding to the target bounding box.
[0072] The process described in the above embodiments is illustrated below through examples in practical applications.
[0073] In daily work, diagrams such as flowcharts, topology diagrams, and architecture diagrams that require manual editing are very common. A neat and orderly arrangement of content is not only more aesthetically pleasing but also more appropriately describes the relationships or correspondences between similar or related content. However, visually determining alignment during direct manipulation is not simple, especially when content that needs alignment is not aligned. Therefore, many methods have provided editing guidelines to optimize this process. However, when dealing with complex content, the commonly used bounding box calculations and snapping line generation logic can degrade performance and produce poor results. The purpose of this embodiment is to improve this process and optimize the snapping line effect.
[0074] Currently, many editing tools have a snapping line design, and the process is often as follows: (1) All node content maintains a bounding box data structure, including position and width and height. This bounding box is the smallest rectangle that encloses the node content; (2) When the user operates the node, by moving or scaling the node by moving the mouse, the position of the current node's bounding box and its relationship with other bounding boxes are detected. If the four sides of the target bounding box are close to the edge of any rectangle, a snapping line is provided. This snapping line is on the same horizontal or vertical line as the edge of the nearby bounding box rectangle. (3) If the mouse operation makes a certain edge of the moved bounding box close to the snapping line, a snapping effect is provided. That is, when the position of this edge is within a certain range, the operation effect will be the same as moving to the snapping line position. Through the above steps, many editing tools can realize the function of snapping.
[0075] The above-mentioned process of generating adsorption lines has the following problems: since the adsorption process involves comparing bounding boxes, the computational cost of comparing bounding boxes is high when there are many nodes, which can easily cause operation lag; the logic of adsorption lines relies solely on the proximity principle. If there are enough nodes, multiple adsorption lines may appear around multiple edges of the moving target, which may interfere with the operation.
[0076] To address the above issues, this embodiment provides an improvement to the traditional bounding box method. The improved scheme has higher bounding box calculation efficiency and improved performance; it can also more intelligently select adsorption lines and improve the correlation between adsorption lines and operations.
[0077] This embodiment provides an improvement to the method of achieving neat content through snapping assistance during content editing in an image editor. Snapping lines typically manage bounding boxes. When moving or scaling content, nearby bounding box edges or center lines are detected, and snapping lines are displayed. This creates a snapping effect near the snapping lines, facilitating content alignment. This invention improves bounding box management and snapping line generation logic to enhance performance and optimize results. The improvements in this embodiment mainly consist of two parts: optimized auxiliary line calculation and optimized selection of snapping lines from auxiliary lines.
[0078] The following is an introduction to the optimization of auxiliary line calculation:
[0079] In existing methods for generating bounding lines, the first step is to compare the positional relationship between the bounding box of the moving target and the bounding box in the canvas space to determine if the two bounding boxes have an alignment tendency. Generally, the data structure of the bounding box is as follows: BoundingBox:{xmin:number,xmax:number,ymin:number,ymax:number};
[0080] The bounding box describes the four sides of the rectangle it represents using four values (i.e., the coordinates of the feature lines): xmin represents the left side, xmax represents the right side, ymin represents the top side, and ymax represents the bottom side. These four sides intersect, forming a bounding box, and each side also serves as the basis for the position of the subsequent graphic snapping line. Whenever the mouse moves, the bounding box of the moved target node updates its position. After each update, it needs to be compared with all bounding boxes in the content to determine the required graphic snapping line. In this embodiment, a threshold can be defined to control a range; when the distance (i.e., the difference in coordinate values) between the edge of the moving bounding box and the edges of other bounding boxes in the same direction in the canvas is less than the threshold, an auxiliary line will be displayed. Specifically, the following method can be used to determine whether a graphic snapping line needs to be generated:
[0081] For the moving bounding box B1: {xmin, xmax, ymin, ymax}, traverse each bounding box B2: {xmin, xmax, ymin, ymax} in the canvas other than the moving bounding box; for the left side xmin of the bounding box B1, query its size relationship with B2.xmin and B2.xmax. If abs(B1.xmin – B2.xmin) < threshold, it means that the position of B2.xmin needs to display an auxiliary line, and the same calculation needs to be performed once for B2.xmax. Such a set of calculations needs to be performed for each side. If center alignment is also required, it is also necessary to calculate abs((B1.xmin + B1.xmax) – (B2.xmin + B2.xmax)) < threshold * 2 once, and the same also needs to be done for the vertical direction. The abs function is used to calculate the absolute value of a numerical value. Then it can be seen that in order to determine the number of times the auxiliary line needs to appear, more than 8N comparison calculations need to be performed on the other N bounding boxes in the canvas. In addition, since the mouse movement updates each time, this will cause the calculation and judgment of the bounding box to be recalculated, which is related to the frequency. In this calculation process, a large amount of calculations are wasted, and many bounding boxes far from the target bounding box also need to be compared and calculated.针对这种大量且复杂的比对计算本实施例做出了优化。
[0082] To reduce the problem of the computational complexity in the process of determining the auxiliary line, this embodiment first needs to modify the data structure when using the bounding box.同样是由四条边描述包围盒,但是可以将数据根据分析维度分离存储,对于二维问题,包围盒会被拆分为2个比对维度,而对于三维问题,则是三个比对维度,这里使用二维的情况举例。原始数据结构中,使用如下方式去描述一个包围盒:BoundingBox: {xmin: number, xmax: number, ymin: number, ymax: number}。
[0083] However, when using the bounding box data, it is stored as two arrays:
[0084] Horizon: [ymin, ymax];
[0085] Vertical: [xmin, xmax]。
[0086] Through the above method, all the sides of the bounding boxes can be stored horizontally together and vertically together, respectively, in two sets of sides with the same direction. At the same time, these two arrays need to be sorted from small to large, and the node needs to record the serial number of any side in the corresponding array. Please refer to Figure 4 , Figure 4This is a schematic diagram of the arrangement of bounding boxes provided by an embodiment of the present application. In the figure, B1, B2, and B3 are bounding boxes, and the dotted lines are the characteristic lines of each bounding box in the vertical direction.
[0087] B1: {xmin: 105, xmax: 205};
[0088] B2: {xmin: 0, xmax: 100};
[0089] B3: {xmin: 170, xmax: 270}.
[0090] In the improved method of this embodiment, when moving the bounding box of B1 as the moving target, there is no longer a threshold detection with the edges of B2 and B3. This embodiment will record the edges in the same direction in an array Vertical: [0, 100, 105, 170, 205, 270].
[0091] The array Vertical aggregates the edges participating in the bounding box detection in the same direction, sorts them from smallest to largest, and in the data of the node itself, it is necessary to record its position in the corresponding array after sorting. For example, in the above example:
[0092] B1: {xmin: 2, xmax: 4};
[0093] B2: {xmin: 0, xmax: 1};
[0094] B3: {xmin: 3, xmax: 5}.
[0095] At this time, the solution of the bounding box of B1 will be simplified to a one-dimensional search for neighboring elements. For B1, its left side edge is the edge numbered 1, and this edge is 100. At this time, directly judge abs(105 - 100) < threshold; if the above judgment holds, through one left side solution and one right side solution, the left neighboring edge can be obtained. Of course, if there are multiple edges satisfying the condition within the threshold, it is necessary to continuously solve the inequality to the left until it does not satisfy the condition. Through such a process, it can be determined that the number of calculations is reduced from at least 8N to at least only 8 * 2 calculations to confirm the result. The method of the present invention may increase the amount of calculation according to special circumstances, but in the case of a large number of nodes, it will also be much lower than 8N calculation times, because in this data structure, the bounding boxes that are too far from the target bounding box are excluded from the calculation through sorting, thereby greatly reducing the number of calculations.
[0096] In addition, a cuboid bounding box can be described as follows: BoundingBox:{xmin:number, xmax:number, ymin:number, ymax:number, zmin:number, zmax:number}.
[0097] However, when using bounding box data, it is stored as three arrays:
[0098] Horizon: [ymin, ymax];
[0099] Vertical: [xmin, xmax];
[0100] Depth: [zmin, zmax].
[0101] The above calculation process will add a depth dimension, thereby achieving a more significant computational speedup than before.
[0102] The above describes the computational logic of the optimization method in a static time. However, as the mouse moves, the bounding box of the moving target changes, so the above data structure needs to be dynamically updated. This process mainly involves reordering. Each time the mouse moves, in the example above, the bounding box B1 needs to be updated. For example, if it is moved 10 pixels to the left, then Vertical should change to Vertical:[0,100,95,170,195,270]. The data is rearranged according to the positions of xmin and xmax of B1, and the size relationship of the corresponding positions is checked to see if it has changed. For example, for xmin, which is the position with index 2, it is necessary to check whether it is smaller than the left and larger than the right. The result here is that it is larger than the left, so the data order changes to Vertical:[0,95,100,170,195,270]. Through this data index marking method, it is not necessary to reorder the entire array, but only to perform a limited sorting and update the index changes involved in the sorting process.
[0103] B1:{xmin:1,xmax:4};
[0104] B2:{xmin:0,xmax:2};
[0105] B3:{xmin:3,xmax:5}.
[0106] This change effectively reflects the change in the bounding box after mouse movement and allows it to be incorporated into the next rapid calculation.
[0107] The following section describes the optimization of the auxiliary line generation logic:
[0108] A typical approach to generating auxiliary lines involves calculating the proximity of bounding boxes to identify potential auxiliary lines. A threshold is usually set; auxiliary lines detected within this threshold range become the final displayed snapping lines. This method is relatively simple to implement but introduces some issues, such as potentially generating more than one auxiliary line. Please refer to [link / reference]. Figure 5 , Figure 5 This is a schematic diagram of an adsorption line determination method provided in an embodiment of this application. C1, C2, and C3 are three bounding boxes, and the dashed lines are auxiliary lines for C1 and C2; as shown... Figure 5 As shown, the node represented by the C3 bounding box is being moved downwards, and it's difficult to determine the specific auxiliary line that needs to be aligned based on the bounding box detection logic. In typical solutions, the snapping line of the C3 bounding box is determined solely by the distance between the auxiliary line and the edge being detected.
[0109] The above-mentioned solution is insufficient to achieve the best effect when multiple auxiliary lines appear. Therefore, this embodiment lists some preset filtering conditions to obtain the possible best auxiliary lines. The earlier these preset filtering conditions appear, the higher their weight.
[0110] The user's direction of movement and the positional relationship between the edges and the auxiliary lines are very important pieces of information. For example... Figure 5 As shown, C3 is moving downwards, indicating that the target that C3 wants to align with is more likely to be below the detection edge. The auxiliary line generated by the bounding box of C1 is above the bottom edge of C3, while the bottom edge of C2 is below C3, consistent with the direction of movement. Therefore, regardless of which auxiliary line is closer to the bottom edge of C3, the auxiliary line of C2 can be set as the corresponding graphic snapping line of C3. Secondly, this embodiment can also detect the distance between the node providing the auxiliary line and the moved node. Generally, nodes align with nearby nodes rather than distant nodes, such as... Figure 5 For example, C3 should be aligned with C2 as much as possible, not C1. This embodiment can also determine, based on user operating habits, that the same guideline should not appear multiple times in consecutive operations. Consecutive operations refer to the process from pressing the mouse button to releasing it while the user is moving or changing the size. If, during consecutive operations, the user sees a certain snapping line but does not choose to snap to it, it often indicates that this guideline is not the snapping line the user needs, and therefore should not be displayed again as a snapping line in this consecutive operation. Through the above three preset filtering conditions, the desired snapping line can be displayed as often as possible in complex scenarios.
[0111] This embodiment optimizes the bounding box calculations involved in the display of snap lines during graphic editing, significantly reducing the required computation. Furthermore, this embodiment optimizes the display scheme for complex auxiliary lines by using preset filtering conditions, improving the editing experience and thus increasing efficiency.
[0112] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a graphic adsorption line generation system provided in an embodiment of this application;
[0113] The system may include:
[0114] The feature line determination module 601 is used to query the currently selected target bounding box and determine the feature lines of the target bounding box; wherein, the type of the feature lines includes boundary lines and / or boundary perpendicular lines;
[0115] The set partitioning module 602 is used to divide the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, and to sort the feature lines in the feature line sets according to the coordinate values of the feature lines.
[0116] The auxiliary line setting module 603 is used to set the feature lines of other bounding boxes that meet the constraint conditions within the feature line set as auxiliary lines; wherein, the constraint condition is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range;
[0117] The adsorption line generation module 604 is used to determine the graphic adsorption line corresponding to the target bounding box from the auxiliary lines and display the graphic adsorption line in the graphic editing area.
[0118] This embodiment queries the feature lines of the currently selected target bounding box, divides the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to their direction and type, and sorts the feature lines based on their coordinate values. The feature lines in each set are arranged in ascending order of their coordinate values. This embodiment uses the difference in coordinate values between the feature lines of other bounding boxes and the feature lines of the target bounding box as a reference to determine whether preset conditions are met. That is, the feature lines of other bounding boxes within the feature line set that meet the constraints are set as auxiliary lines, and then the graphic snapping line corresponding to the target bounding box is determined and displayed from the auxiliary lines. This embodiment determines the graphic snapping line from the feature line set based on the difference in coordinate values, and the feature lines in the feature line set are arranged in ascending order of their coordinate values, which reduces the computational load in determining the graphic snapping line and improves the generation efficiency of the graphic snapping line.
[0119] Furthermore, the auxiliary line setting module 603 is used to generate a corresponding coordinate value array according to the sorting of the feature lines in the feature line set; it is also used to set the coordinate values corresponding to the feature lines of the target bounding box in the coordinate value array as target coordinate values; it is also used to calculate the difference between the target coordinate value and the coordinate values of each left coordinate value in order from near to far, until the difference between the coordinate values is not within the preset interval; it is also used to calculate the difference between the target coordinate value and the coordinate values of each right coordinate value in order from near to far, until the difference between the coordinate values is not within the preset interval; and it is also used to set the feature lines corresponding to the coordinate values whose difference between the coordinate values is within the preset interval as the auxiliary lines.
[0120] Furthermore, it also includes:
[0121] The set update module is used to determine whether the position of the target bounding box in the graph editing area has changed after dividing the feature lines of all bounding boxes in the graph editing area into multiple feature line sets according to the direction and type of the feature lines; if so, the feature line set is updated according to the current position of the target bounding box.
[0122] Furthermore, the adsorption line generation module 604 is used to set the auxiliary line as the graphic adsorption line corresponding to the target bounding box if the number of auxiliary lines is 1; and is also used to determine the graphic adsorption line corresponding to the target bounding box from the auxiliary lines according to a preset screening principle if the number of auxiliary lines is greater than 1.
[0123] Furthermore, the adsorption line generation module 604 includes:
[0124] The first filtering unit is used to query the current movement direction of the target bounding box; it is also used to set the auxiliary line in the current movement direction of the target bounding box as the graphic snap line corresponding to the target bounding box.
[0125] And / or, the second filtering unit is used to calculate the distance between the bounding box containing each of the auxiliary lines and the target bounding box; and is also used to set the auxiliary line of the bounding box closest to the target bounding box as the graphic snap line corresponding to the target bounding box.
[0126] And / or, the third filtering unit is used to query the number of times each of the auxiliary lines is set as a graphic snap line and not selected by the user; it is also used to set auxiliary lines with a number greater than a preset value as interference auxiliary lines; and it is also used to set all auxiliary lines except the interference auxiliary lines as graphic snap lines corresponding to the target bounding box.
[0127] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, and they will not be repeated here.
[0128] This application also provides a storage medium on which a computer program is stored, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0129] This application also provides an electronic device that may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the electronic device may also include various network interfaces, power supplies, and other components.
[0130] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0131] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for generating patterned adsorption lines, characterized in that, include: Query the currently selected target bounding box and determine the feature lines of the target bounding box; wherein, the type of the feature lines includes boundary lines and / or boundary perpendicular lines; According to the direction and type of the feature lines, the feature lines of all bounding boxes within the image editing area are divided into multiple feature line sets, and the feature lines in the feature line sets are sorted according to the coordinate values of the feature lines. The feature lines of other bounding boxes within the feature line set that meet the constraint conditions are set as auxiliary lines; wherein, the constraint condition is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range; If the number of auxiliary lines is 1, then the auxiliary line is set as the graphic snapping line corresponding to the target bounding box; If the number of auxiliary lines is greater than 1, then the graphic snap line corresponding to the target bounding box is determined from the auxiliary lines according to the preset screening principle; The graphic snap line is displayed within the graphic editing area.
2. The method for generating patterned adsorption lines according to claim 1, characterized in that, Setting feature lines of other bounding boxes within the feature line set that meet the constraints as auxiliary lines includes: Generate a corresponding coordinate value array by sorting the feature lines in the feature line set; Set the coordinate values in the coordinate value array that correspond to the feature lines of the target bounding box as the target coordinate values; The difference between the target coordinate value and the coordinate value of each coordinate value on the left is calculated in order from near to far until the difference of the coordinate values is no longer within the preset range. The difference between the target coordinate value and each coordinate value on the right is calculated in order from near to far until the difference between the coordinate values is no longer within the preset range. The feature line corresponding to the coordinate values within the preset interval where the difference of the coordinate values is located is set as the auxiliary line.
3. The method for generating graphic adsorption lines according to claim 1, characterized in that, After dividing the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, the process further includes: Determine whether the position of the target bounding box in the image editing area has changed; If so, the feature line set is updated according to the current position of the target bounding box.
4. The method for generating patterned adsorption lines according to claim 1, characterized in that, The preset filtering principles include: movement direction filtering principle, bounding box distance filtering principle, and user operation habit filtering principle.
5. The method for generating patterned adsorption lines according to claim 4, characterized in that, According to preset screening principles, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines, including: Query the current movement direction of the target bounding box; Set the auxiliary line in the current movement direction of the target bounding box as the graphic snap line corresponding to the target bounding box.
6. The method for generating patterned adsorption lines according to claim 4, characterized in that, According to preset screening principles, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines, including: Calculate the distance between the bounding box containing each of the auxiliary lines and the target bounding box; Set the auxiliary line of the bounding box closest to the target bounding box as the graphic snap line corresponding to the target bounding box.
7. The method for generating patterned adsorption lines according to claim 4, characterized in that, According to preset screening principles, the graphic snapping line corresponding to the target bounding box is determined from the auxiliary lines, including: Query the number of times each of the aforementioned auxiliary lines was set as a graphic snap line and not selected by the user for snapping; The auxiliary line whose frequency exceeds a preset value is set as an interference auxiliary line; All auxiliary lines except the interference auxiliary lines are set as the graphic snapping lines corresponding to the target bounding box.
8. A system for generating patterned adsorption lines, characterized in that, include: The feature line determination module is used to query the currently selected target bounding box and determine the feature lines of the target bounding box; wherein, the type of the feature lines includes boundary lines and / or boundary perpendicular lines; The set partitioning module is used to divide the feature lines of all bounding boxes within the image editing area into multiple feature line sets according to the direction and type of the feature lines, and to sort the feature lines in the feature line sets according to the coordinate values of the feature lines. The auxiliary line setting module is used to set the feature lines of other bounding boxes that meet the constraints within the feature line set as auxiliary lines; wherein, the constraint is that the difference between the coordinate values of the feature lines of other bounding boxes and the feature lines of the target bounding box is within a preset range; The adsorption line generation module is used to set the auxiliary line as the graphic adsorption line corresponding to the target bounding box if the number of auxiliary lines is 1; if the number of auxiliary lines is greater than 1, the graphic adsorption line corresponding to the target bounding box is determined from the auxiliary lines according to a preset filtering principle, and the graphic adsorption line is displayed in the graphic editing area.
9. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor, when calling the computer program in the memory, implements the steps of the method for generating graphic adsorption lines as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the steps of the method for generating graphic adsorption lines as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method, related equipment and system for object editing in virtual reality
CN109697002A
Layout edition system, method and layout edition program as well as recording medium recording the same
JP2001281835A