A user-friendly QT two-dimensional drawing method and engine

Through the QT two-dimensional drawing method, virtual function keys and preset variables are used to control the drawing starting point and zoom factor, combined with virtual auxiliary tools, the problems of user friendliness and scalability in QT development tools are solved, and the interactivity and display effects are improved.

CN115830186BActive Publication Date: 2025-09-16XIDIAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211591792.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-12
Publication Date
2025-09-16
Estimated Expiration
2042-12-12

AI Technical Summary

Technical Problem

How to create a user-friendly, highly interactive, intuitive, and easily extensible 2D drawing engine using QT development tools to meet the visualization needs of individuals and enterprises while controlling costs.

Method used

This paper provides a user-friendly QT two-dimensional drawing method. By displaying multiple virtual function keys, obtaining user input signals, using preset variables to control the drawing starting point and zoom factor, and combining virtual auxiliary tools, it realizes the drawing, processing and display of graphics, and regenerates the canvas and graphics according to user control signals.

Benefits of technology

User interactivity is improved, the graphics drawing effect meets user expectations, function expansion is convenient, and the needs of user friendliness and visual display are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115830186B_ABST
    Figure CN115830186B_ABST
Patent Text Reader

Abstract

The present invention discloses a user-friendly QT two-dimensional drawing method and engine, which comprises the following steps: displaying a drawing page; acquiring data to be drawn upon receiving a data input signal from a user for the drawing page, and determining an initial drawing starting point and an initial zoom factor according to preset values ​​of preset variables; drawing and displaying a current graphic on a canvas according to the initial drawing starting point, the initial zoom factor, and the data to be drawn; processing the current graphic upon receiving a first control signal, and displaying the processed graphic; controlling the opening or closing of a corresponding virtual auxiliary tool on the canvas upon receiving a second control signal; acquiring an input parameter corresponding to the third control signal, and acquiring the current value of the preset variable upon receiving a third control signal; regenerating the canvas based on the input parameter corresponding to the third control signal, the current value of the preset variable, the preset configuration parameter, and the data to be drawn, redrawing the graphic, and displaying the regenerated canvas and the redrawn graphic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of drawing technology, and in particular relates to a user-friendly QT two-dimensional drawing method and engine. Background Art

[0002] With the increasing popularity of graphical interfaces, more and more individuals, businesses, and organizations are turning to graphically displaying their data. Whether it's using statistical charts to view parameters, reporting data trends, or using 2D diagrams to illustrate the final product parameters, these graphical data formats are more consistent with human cognition and easier for users to read and retrieve data.

[0003] Qt is a classic cross-platform C++ graphical user interface application development framework. It can be used to develop both GUI programs and non-GUI programs, such as console tools and servers. Qt is an object-oriented framework that uses a special code generation extension (called the Meta Object Compiler (MOC)) and macros to make it easily extensible and allow true component-based programming.

[0004] Whether for individual users or small, medium, or large businesses and organizations, QT is a stable and balanced development tool choice, balancing the need for data visualization with manageable costs. The key challenge is to use QT to create a graphics engine that is highly interactive, intuitive, user-friendly, and easily extensible. Summary of the Invention

[0005] In order to solve the above problems existing in the related art, the present invention provides a user-friendly QT two-dimensional drawing method and engine. The technical problem to be solved by the present invention is achieved by the following technical solutions:

[0006] The present invention provides a user-friendly QT two-dimensional drawing method, comprising:

[0007] Displaying a drawing page containing multiple virtual function buttons;

[0008] When receiving a data input signal from the user for the drawing page, obtaining data to be drawn;

[0009] Upon receiving a drawing signal from a user, determining an initial drawing starting point and an initial zoom factor according to preset values ​​of preset variables; the preset variables include: a first variable for controlling the distance between the drawing starting point and the left border of the canvas when drawing on the canvas; a second variable for controlling the distance between the drawing starting point and the upper border of the canvas when drawing on the canvas; and a third variable for controlling the zoom factor of graphic drawing when drawing on the canvas;

[0010] Taking the initial drawing starting point as the drawing starting point and the initial zoom factor as the initial zoom factor of the graphic, drawing the current graphic on the canvas of the drawing page where the virtual auxiliary tool is displayed according to the data to be drawn, and displaying the current graphic;

[0011] When a first control signal from the user for the first virtual function key is obtained, processing the current graphic and displaying the processed graphic;

[0012] When a second control signal from the user for the second virtual function button is obtained, controlling the opening or closing of the corresponding virtual assistive tool on the canvas;

[0013] When a third control signal from the user for the canvas and the current graphic is obtained, an input parameter corresponding to the third control signal is obtained, and a current value of the preset variable is obtained;

[0014] Based on the input parameters corresponding to the third control signal, the current values ​​of the preset variables, the preset configuration parameters and the data to be drawn, the canvas is regenerated, and the graphics are redrawn, and the regenerated canvas and the redrawn graphics are displayed.

[0015] The present invention has the following beneficial technical effects:

[0016] The drawing method provided by the present invention not only provides users with rich functions when drawing graphics, but also, through clever design, concentrates some complex functions on changing the values ​​of three variables without introducing other cumbersome processes. On the one hand, the drawing effect can be quickly changed according to the user's control signal, thereby improving the interactivity with the user. On the other hand, the drawing effect can be displayed according to the user's control signal, which is consistent with the user's expected effect, which is more in line with the user's intuition. On the other hand, when it is necessary to expand new functions for the drawing engine, it can be quickly implemented by changing the values ​​of these three variables, thereby facilitating the expansion of functions.

[0017] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 An optional flowchart of a user-friendly QT two-dimensional drawing method provided by an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of a portion of a canvas showing a grid of dotted lines, an upper coordinate ruler, a left coordinate ruler, and a partially drawn graphic, provided by an embodiment of the present invention;

[0020] Figure 3A schematic diagram of an exemplary cross-shaped auxiliary ruler at a position of a mouse provided by an embodiment of the present invention;

[0021] Figure 4A A schematic diagram of a canvas, a coordinate ruler displayed on the canvas, and a graphic before starting to move the graphic on the canvas, provided as an example in an embodiment of the present invention;

[0022] Figure 4B A schematic diagram of the canvas, the coordinate ruler displayed on the canvas, and the graphic at a moment in the process of moving a graphic on the canvas provided by an exemplary embodiment of the present invention;

[0023] Figure 4C A schematic diagram of a canvas, a coordinate ruler displayed on the canvas, and a graphic after a graphic is moved on the canvas according to an exemplary embodiment of the present invention;

[0024] Figure 5 A flow chart illustrating a principle of zooming in and out of a graphic at a specific point, provided as an example in an embodiment of the present invention;

[0025] Figure 6A A schematic diagram of an exemplary fixed point corresponding to a position of a mouse on a canvas before zooming in provided by an embodiment of the present invention;

[0026] Figure 6B A schematic diagram of an enlarged fixed point corresponding to a position of a mouse on a canvas provided by an exemplary embodiment of the present invention;

[0027] Figure 7 A schematic diagram of an exemplary drawing page provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The present invention will be further described in detail below with reference to specific examples, but the embodiments of the present invention are not limited thereto.

[0029] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, "plurality" means two or more, unless otherwise specifically defined.

[0030] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification.

[0031] Although the present invention is described herein in conjunction with various embodiments, in the process of implementing the claimed invention, those skilled in the art can understand and implement other variations of the disclosed embodiments by reviewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude multiple situations. A single processor or other unit can implement several functions listed in the claims. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0032] Figure 1 This is an optional flow chart of a user-friendly QT two-dimensional drawing method provided by an embodiment of the present invention. The drawing method can be applied to a QT two-dimensional drawing engine, such as Figure 1 As shown, the method includes the following steps:

[0033] S101: Display a drawing page including a plurality of virtual function buttons.

[0034] Here, when the QT two-dimensional drawing engine receives the user's operation instruction, it can display a drawing page, which can include multiple virtual function buttons, such as a cross reading auxiliary ruler button, a grid background button, and the like.

[0035] S102 : upon receiving a data input signal from the user for a drawing page, obtaining data to be drawn.

[0036] Here, a data input box may also be displayed on the drawing page, and the user may input data to the QT two-dimensional drawing engine through the data input box. When the QT two-dimensional drawing engine receives the data input by the user, it obtains the data to be drawn.

[0037] Here, the user may input data by uploading a file or directly inputting data, which is not limited in the embodiment of the present invention.

[0038] Here, the data to be drawn may be appearance data and internal structure data of a product, size data of a graphic, or data for drawing a histogram, a curve graph, etc., which is not limited in the embodiment of the present invention.

[0039] S103. Upon receiving a drawing signal from the user, determining an initial drawing starting point and an initial zoom factor based on preset values ​​of preset variables; the preset variables include: a first variable for controlling the distance between the drawing starting point and the left edge of the canvas when drawing on the canvas; a second variable for controlling the distance between the drawing starting point and the upper edge of the canvas when drawing on the canvas; and a third variable for controlling the zoom factor of graphic drawing when drawing on the canvas.

[0040] Here, the first and third variables together control the horizontal coordinate of the drawing starting point when drawing on the canvas; the second and third variables together control the vertical coordinate of the drawing starting point when drawing on the canvas. For example, the first variable can be draw_start_point, the second variable can be draw_start_point_y, and the third variable can be pic_size_times. In addition, draw_start_point and draw_start_point_y are of type int, and pic_size_times is of type double. Draw_start_point * pic_size_times is the horizontal coordinate of the drawing starting point, and draw_start_point_y * pic_size_times is the vertical coordinate of the drawing starting point.

[0041] S104 , using the initial drawing starting point as the drawing starting point and the initial zoom factor as the initial zoom factor of the graphic, draw the current graphic on the canvas of the drawing page displaying the virtual auxiliary tool according to the data to be drawn, and display it.

[0042] Here, the virtual assistive tool may include: a grid dotted line, an upper coordinate ruler displayed at the upper boundary of the canvas, and a left coordinate ruler displayed at the left boundary of the canvas. Figure 2 A diagram showing a portion of the canvas with dotted grid lines, a top ruler, a left ruler, and a partially drawn graphic.

[0043] Here, when drawing graphics, a drawing function can be used to draw graphics.

[0044] S105 : When a first control signal from the user for the first virtual function key is obtained, the current graphic is processed and the processed graphic is displayed.

[0045] Here, the first virtual function key is a mirror function key. When a user touch operation on the virtual function key is detected, a first control signal is obtained. When the first control signal is obtained, a mirror function is called to draw a mirror image of the current image on the current canvas, thereby obtaining a graphic composed of the current image and the mirror image.

[0046] S106: When a second control signal from the user for the second virtual function button is obtained, control the opening or closing of the corresponding virtual auxiliary tool on the canvas.

[0047] In the embodiment of the present invention, the second virtual function button is a cross reading auxiliary ruler button or a grid background button.

[0048] In some embodiments, when the second virtual function key is a cross-reading auxiliary ruler key and a user's touch signal on the cross-reading auxiliary ruler key is detected, a second control signal is obtained, the horizontal coordinate and vertical coordinate of the user's current click position are obtained, a vertical line is drawn according to the horizontal coordinate and the canvas height of the canvas, and a horizontal line is drawn according to the vertical coordinate and the canvas width of the canvas, and a cross-reading auxiliary ruler with the current click position as the center point is obtained.

[0049] For example, a mouseDoubleClickEvent event can be defined in the drawing window. This event only handles one logic, that is, when the user double-clicks or clicks, the switch variable (bool type) for drawing the cross reading auxiliary ruler is inverted to achieve the on / off effect. If the switch is on, the horizontal and vertical coordinates of the current mouse are tracked, and the two coordinate values ​​are used as parameters to continuously call the update method to update the drawing in real time in the interface. The logic of the Update method is: receive the horizontal coordinate x of the current mouse position, the vertical coordinate y of the current mouse position, and when the current drawing window width is width and the length is length. Two solid straight lines are drawn, from (x, 0) to (x, height) and from (0, y) to (width, y). At this time, there are two horizontal and vertical lines centered on the current mouse position. Since update is called every time the mouse moves, the cross ruler will be continuously updated as the mouse moves, and the performance effect is that it follows the user's mouse movement. For example, Figure 3 A schematic diagram of a cross-reading auxiliary ruler at a certain position of the mouse.

[0050] In some embodiments, when the second virtual function key is a grid background key and a user touch signal of the grid background key is detected, a second control signal is obtained, the display status of the grid dotted lines on the current canvas is obtained, and when the display status is displayed, the grid dotted lines are hidden; when the display status is not displayed, the value of the third variable at the current moment is obtained, and the grid dotted lines are drawn and displayed based on the value of the third variable, the canvas width, the canvas height, and the pixel distance between adjacent grid dotted lines.

[0051] For example, the control of displaying or not the dotted lines of the grid can also be achieved by defining a mouseDoubleClickEvent event and a bool variable.

[0052] S107 : When a third control signal from the user for the canvas and the current graphic is obtained, an input parameter corresponding to the third control signal is obtained, and a current value of a preset variable is obtained.

[0053] In an embodiment of the present invention, multiple virtual function keys include: a center key; the third control signal can be obtained by the following method: acquiring the user's touch operation in real time; when the touch operation is a zoom-in operation or a zoom-out operation on the current graphic, determining that the third control signal is acquired; or, when the touch operation is a zoom-in operation or a zoom-out operation on the current graphic at the touch position, determining that the third control signal is acquired; or, when the touch operation is a drag operation on the current graphic, determining that the third control signal is acquired; or, when the touch operation is a double-click operation on any position on the canvas, determining that the third control signal is acquired; or, when the touch operation is a selection operation on the center key, determining that the third control signal is acquired.

[0054] S108 , based on the input parameters corresponding to the third control signal, the current values ​​of the preset variables, the preset configuration parameters and the data to be drawn, regenerate the canvas and redraw the graphics, and display the regenerated canvas and the redrawn graphics.

[0055] In some embodiments, the third control signal is obtained based on a user's zoom operation on the current graphic. Accordingly, the input parameter corresponding to the third control signal is: the duration of the zoom operation; the preset configuration parameters include: a preset interval value, a preset maximum value, and canvas parameters. That is, when the user zooms in on the current graphic only by controlling the mouse wheel, the above S108 can be implemented by the following steps:

[0056] S1081. When the zoom-in operation starts, the current value of the third variable is increased by a preset interval value to obtain the Nth third variable; N is 1.

[0057] Here, the preset interval value may be 0.5 or other values, which is not limited.

[0058] S1082. When the third variable updated for the Nth time is less than a preset maximum value, an Nth canvas is generated based on the Nth third variable, the current value of the first variable, the current value of the second variable, and the canvas parameters, and an Nth drawing starting point is obtained using the Nth third variable, the current value of the first variable, and the current value of the second variable. The Nth drawing starting point is used as the starting drawing point, and the Nth third variable is used as the scaling factor of the graphic. The graphic is redrawn according to the data to be drawn to obtain the Nth graphic.

[0059] S1083: Increase the third variable of the Nth time by a preset interval value to obtain the third variable of the N+1th time.

[0060] S1084. When the third variable of the N+1th time is less than a preset maximum value, an N+1th canvas is generated based on the third variable of the N+1th time, the current value of the first variable, the current value of the second variable, and the canvas parameters, and an N+1th drawing starting point is obtained using the third variable of the N+1th time, the current value of the first variable, and the current value of the second variable. The drawing starting point of the N+1th time is used as the starting point for drawing, and the third variable of the N+1th time is used as the zoom factor of the graph. The graph is redrawn according to the data to be drawn to obtain the N+1th graph, until the N+mth canvas and graph are obtained at the end of the zoom time; m is an integer greater than or equal to 1.

[0061] S1085. When the third variable of the N+1th time is greater than or equal to the preset maximum value, an N+1th canvas is generated based on the preset maximum value, the current value of the first variable, the current value of the second variable, and the canvas parameters. The preset maximum value, the current value of the first variable, and the current value of the second variable are used to obtain the N+1th drawing starting point. The N+1th drawing starting point is used as the starting point for drawing. The preset maximum value is used as the zoom factor of the graphic. The graphic is redrawn according to the data to be drawn to obtain the N+1th graphic. The N+1th canvas is used as the canvas corresponding to the remaining duration of the zoom-in operation, and the N+1th graphic is used as the drawing graphic corresponding to the remaining duration.

[0062] For example, when the user starts to scroll the mouse wheel upward, if the current pic_size_times is less than 10, pic_size_times will be increased by 0.5 in sequence while the user scrolls the mouse wheel upward until pic_size_times is greater than or equal to the maximum value of 10, and pic_size_times will be maintained at 10; each time pic_size_times increases by 0.5, the redraw function is called to draw the current graphics according to the current pic_size_times, the current draw_start_point_y, the current draw_start_point and the data to be drawn.

[0063] Here, when the third control signal is obtained based on the user's zoom-out operation on the current graphic; correspondingly, the input parameter corresponding to the third control signal is: the duration of the zoom-out operation; the preset configuration parameters include: a preset interval value, a preset minimum value and a canvas parameter; that is, when the user only zooms out the current graphic by controlling the mouse wheel, the specific implementation principle of the above S108 is the same as the above S1081 to S1085.

[0064] In some embodiments, the canvas parameters include: canvas width, canvas height, and pixel distance between adjacent grid dashed lines; the virtual assistive tool is a grid dashed line; based on this, the step of generating the Nth canvas in S1082 above can be implemented as the following steps:

[0065] S201: Determine a coordinate interval value according to the pixel distance and the Nth third variable.

[0066] S202 , setting a first loop. In the first loop, the initial value of the drawing times i is 0. When the i-th drawing is performed, the i-th vertical grid line coordinates are determined according to the value of i, the coordinate interval value, and the canvas height.

[0067] S203. When the absolute value of the horizontal coordinate of the i-th vertical grid line coordinate is less than the canvas width, draw the vertical grid line according to the i-th vertical grid line coordinate, update i to i+1, determine the i+1-th vertical grid line coordinate, and end the first loop until the absolute value of the horizontal coordinate of the i+a-th vertical grid line coordinate is greater than the canvas width; a is an integer greater than 1.

[0068] S204. Set a second loop. In the second loop, the initial value of the drawing times j is 0. When the j-th drawing is performed, the j-th horizontal grid line coordinates are determined according to the value of j, the coordinate interval value and the canvas width.

[0069] S205. When the absolute value of the vertical coordinate of the j-th horizontal grid line coordinate is less than the canvas height, draw the horizontal grid line according to the j-th horizontal grid line coordinate, update j to j+1, determine the j+1-th horizontal grid line coordinate, and end the second loop until the absolute value of the vertical coordinate of the j+b-th horizontal grid line coordinate is greater than the canvas height; b is an integer greater than 1.

[0070] S206 : Generate an N-th canvas displaying grid dotted lines according to the drawn vertical grid lines and horizontal grid lines.

[0071] For example, assuming the window width is height, set up a loop to draw a dashed line from (x, 0) to (x, height), with x increasing by 10.0*pic_size_times until x is greater than the window width, width, so that vertical grid lines can be drawn. Assuming the window height is width, set up a loop to draw a dashed line from (0, y) to (width, y), with y increasing by 10.0*pic_size_times until y is greater than the window height, height, so that horizontal grid lines can be drawn; 10 is the pixel distance between adjacent dashed grid lines, the window width is the canvas width, and the window height is the canvas height.

[0072] In some embodiments, the canvas parameters may include: a preset length, a canvas width, and a canvas height; the virtual auxiliary tool is a coordinate ruler displayed on the upper or left border of the canvas; based on this, the step of generating the Nth canvas in S1082 above may be implemented as the following steps:

[0073] S207. Set a third loop. In the third loop, set the initial value of the number of drawing times i to 0. When drawing for the i-th time, when the coordinate ruler is displayed at the upper boundary of the canvas, the i-th first coordinate point is determined according to the value of i, the current value of the first variable, the N-th third variable and the preset length; when the coordinate ruler is displayed at the left boundary of the canvas, the i-th second coordinate point is determined according to the value of i, the current value of the second variable, the N-th third variable and the preset length.

[0074] S208. When the absolute value of the horizontal coordinate of the first coordinate point of the i-th time is less than the right cycle number boundary value of the N-th time, draw the i-th vertical coordinate line according to the first coordinate point of the i-th time, then update i to i+1, and draw the i+1-th time, until the absolute value of the horizontal coordinate of the first coordinate point of the i+c-th time is greater than the right cycle number boundary value of the N-th time, then end the third loop; c is an integer greater than 1; the right cycle number boundary value of the N-th time is determined according to the difference between the canvas width and the left cycle number boundary value of the N-th time, and the third variable of the N-th time; the left cycle number boundary value of the N-th time is the first The current value of the variable; when the absolute value of the ordinate of the second coordinate point of the i-th time is less than the boundary value of the lower loop count of the N-th time, draw the i-th horizontal coordinate line according to the second coordinate point of the i-th time; then, update i to i+1, and perform the i+1-th drawing, until the absolute value of the ordinate of the first coordinate point of the i+h-th time is greater than the boundary value of the lower loop count of the N-th time, then end the third loop; the boundary value of the lower loop count of the N-th time is determined according to the difference between the canvas height and the boundary value of the upper loop count of the N-th time, and the third variable of the N-th time; the boundary value of the upper loop count of the N-th time is the current value of the second variable.

[0075] S209. Set a fourth loop. In the fourth loop, set the initial value of the number of drawing times j to 0. When drawing for the jth time, when the coordinate ruler is displayed at the upper boundary of the canvas, the first coordinate point of the jth time is determined according to the value of j, the current value of the first variable, the third variable of the Nth time, and the preset length; when the coordinate ruler is displayed at the left boundary of the canvas, the second coordinate point of the jth time is determined according to the value of j, the current value of the second variable, the third variable of the Nth time, and the preset length.

[0076] S210. When the absolute value of the horizontal coordinate of the j-th first coordinate point is less than the N-th left loop number boundary value, draw the j-th vertical coordinate line according to the j-th first coordinate point, and then update j to j+1, and perform the j+1-th drawing, until the absolute value of the horizontal coordinate of the j+h-th first coordinate point is greater than the N-th left loop number boundary value canvas width, and end the fourth loop; when the absolute value of the vertical coordinate of the j-th second coordinate point is less than the N-th upper loop number boundary value, draw the j-th horizontal coordinate line according to the j-th second coordinate point; and then update j to j+1, and perform the j+1-th drawing, until the absolute value of the vertical coordinate of the j+c-th second coordinate point is greater than the N-th upper loop number boundary value, and end the fourth loop.

[0077] For example, taking the upper coordinate ruler as an example, the method for drawing the upper coordinate ruler is as follows:

[0078] 1) The coordinate scale values ​​increase to the right, and the zero point of the upper coordinate scale corresponds to the horizontal coordinate of the starting point of the drawing.

[0079] 2) Set up a right loop to draw the zero point and the vertical coordinate line to the right of the zero point. In this loop, i starts counting from 0 and accumulates in a loop. Each time i is accumulated, a vertical coordinate line is drawn. These vertical coordinate lines are all vertical, and the horizontal coordinate of each coordinate line is x, and the length of the coordinate line is length. Then, starting from (x, 0) and drawing to (x, length), it is a vertical line with a length of length. In order to reflect the characteristics of the coordinate ruler, in this loop, when i is 0 or an integer multiple of 10, the length of the line is set to the longest, that is, 25. When i is an integer multiple of 5, the length of the line is the second longest, that is, 20. When i is other cases, the length of the line is the shortest, that is, 10.

[0080] 3) In each iteration of the right loop, x is set to (i + draw_start_point) * pic_size_times, and when i accumulates to be greater than (width - draw_start_point * pic_size_times) / pic_size_times, the right loop stops, draw_start_point and pic_size_times are both the current values, and width is the canvas width.

[0081] 4) At the same time, set a left loop to draw the vertical coordinate line to the left of the zero point. In this loop, j starts counting from 1 and accumulates in a loop. Each time j is accumulated, a vertical coordinate line is drawn. These coordinate lines are all vertical, and the horizontal coordinate of each vertical coordinate line is x, and the length of the coordinate line is length. Then, starting from (x, 0) and drawing to (x, length), a line in the vertical direction with a length of length is drawn. In order to reflect the characteristics of the coordinate ruler, in this loop, when j is 0 or an integer multiple of 10, the length of the line is set to the longest, that is, 25. When j is an integer multiple of 5, the length of the line is the second longest, that is, 20. When j is other cases, the length of the line is the shortest, that is, 10.

[0082] 5) In each cycle of the left loop, x is set to (draw_start_point-j)*pic_size_times, and when j accumulates to be greater than draw_start_point, the left loop stops.

[0083] 6) To enhance the user's interactive experience, the pic_size_times can be checked each time the coordinate ruler is drawn. If pic_size_times is less than the set threshold, the coordinate values ​​below the ruler are no longer displayed. When pic_size_times is greater than the set threshold, the coordinate values ​​below the ruler only display integer multiples of 0 and 10. As the magnification continues to increase, the spacing between adjacent coordinate lines will be wider, and the coordinate values ​​below the ruler will display integer multiples of 0, 5, and 10. This not only provides feedback to the user when zooming in and out, but also makes the image appear more harmonious visually.

[0084] Exemplarily, when the coordinate ruler is the left coordinate ruler, the third loop is the lower loop and the fourth loop is the upper loop, and each time it starts drawing from (0, y) to (length, y) to form a horizontal coordinate line, and in each loop of the lower loop, y is set to (draw_start_point_y-i)*pic_size_times, when i accumulates to be greater than (height-draw_start_point_y*pic_size_times) / pic_size_times, the lower loop is stopped, and height is the canvas height; in each loop of the upper loop, y is set to (draw_start_point_y-j)*pic_size_times, when j accumulates to be greater than draw_start_point_y, the upper loop is stopped; other principles are the same as the above right and left loops.

[0085] Here, through the coordinate ruler drawing method provided by the present invention, it is possible to achieve the effect that when the graphics in the canvas move, the coordinate ruler displayed on the canvas also moves with the movement of the graphics, thereby allowing the user to feel that the canvas and the coordinate ruler displayed on the canvas are infinite.

[0086] For example, Figure 4A 、 Figure 4B and Figure 4C The diagram shows the changes of the canvas, the coordinate ruler displayed on the canvas, and the graphics in three states: before the graphics start to be moved on the canvas, during the movement of the graphics, and after the movement of the graphics. Obviously, the coordinate ruler displayed on the canvas moves infinitely with the movement of the graphics, thus showing a feeling that the canvas and the coordinate ruler displayed on the canvas are infinite.

[0087] In some embodiments, the third control signal is obtained based on a user's zoom operation on the current graphic at a touch position; the input parameters corresponding to the third control signal are: the coordinates of the touch position and the duration of the zoom operation; the preset configuration parameters include: a preset interval value, a preset maximum value, and canvas parameters; that is, when zooming in on the drawn graphic with the user's current mouse position as the zoom center, the above S108 can be implemented by the following steps:

[0088] S1086 : When the coordinates of the touch position are acquired, the coordinates of the current drawing starting point are determined according to the current value of the first variable, the current value of the second variable, and the current value of the third variable.

[0089] S1087 : Determine a horizontal distance data difference and a vertical distance data difference according to the coordinates of the touch position, the coordinates of the current drawing starting point, and the current value of the third variable.

[0090] S1088. When the zoom-in operation starts, the current value of the third variable is increased by a preset interval value to obtain the Mth third variable, and when the third variable updated for the Nth time is less than a preset maximum value, the Mth canvas is generated based on the Mth third variable, the current value of the first variable, the current value of the second variable and the canvas parameters; M is 1.

[0091] S1089. Determine the Mth drawing starting point based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the Mth third variable. Use the Mth drawing starting point as the starting point for drawing, use the Mth third variable as the scaling factor for the graph, and redraw the graph based on the data to be drawn to obtain the Mth graph.

[0092] S1090. Increase the Mth third variable by a preset interval value to obtain the M+1th third variable. When the M+1th third variable is less than a preset maximum value, generate the M+1th canvas based on the M+1th third variable, the current value of the first variable, the current value of the second variable, and the canvas parameters.

[0093] S1091. Determine the M+1th drawing starting point based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the M+1th third variable. Use the M+1th drawing starting point as the drawing start point, use the M+1th third variable as the zoom factor for the graph, and redraw the graph based on the data to be drawn to obtain the M+1th graph. This continues until the M+nth canvas and graph are obtained at the end of the zoom time, where n is an integer greater than or equal to 1.

[0094] S1092: When the third variable of the M+1th time is greater than or equal to the preset maximum value, generate the M+1th canvas based on the preset maximum value, the current value of the first variable, the current value of the second variable, and the canvas parameters.

[0095] S1093. Determine the M+1th drawing starting point based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the preset maximum value. Use the M+1th drawing starting point as the drawing start point, use the preset maximum value as the zoom factor of the graphic, and redraw the graphic based on the data to be drawn to obtain the M+1th graphic. Use the M+1th canvas as the canvas corresponding to the remaining duration of the zoom-in operation, and use the M+1th graphic as the drawing graphic corresponding to the remaining duration.

[0096] For example, Figure 5 As shown in the figure, the principle of fixed-point zooming in and out of the graphics is as follows:

[0097] 1) Define the wheelEvent event (function) in the drawing window. Use this event to determine whether the current user's mouse position is in the drawing area (canvas, also known as the drawing board). If so, execute the subsequent steps; otherwise, do nothing.

[0098] 2) Record the current mouse coordinate position as (X_new, Y_new), and calculate the drawing starting point (X0, Y0) in the current drawing state based on the current draw_start_point, pic_size_times, and draw_start_point_y, that is, the drawing origin.

[0099] 3) Calculate the pixel distance between the current mouse coordinates and the drawing origin in the current drawing state. The horizontal distance is X_new - X0, and the vertical distance is Y_new - Y0. After converting these pixel distances to the gap in the data to be drawn, the horizontal distance difference X_distance is (X_new - X0) / pic_size_times, and the vertical distance difference Y_distance is (Y_new - Y0) / pic_size_times.

[0100] 4) When the user scrolls the mouse wheel upward, if pic_size_times is less than 10 (the preset maximum value), pic_size_times is incremented by 0.5, otherwise pic_size_times remains at 10. (maximum magnification)

[0101] 5) When the user scrolls the mouse wheel downward, if pic_size_times is greater than 2 (the preset minimum value), pic_size_times is reduced by 0.5 in sequence, otherwise pic_size_times is maintained at 2.

[0102] 6) Each time a current pic_size_times is obtained, the new pixel distance between the mouse position and the drawing origin is calculated under the current pic_size_times. The new pixel distance represented by the obtained X_distance on the canvas is pic_size_times*X_distance, and the new pixel distance represented by the obtained Y_distance on the canvas is pic_size_times*Y_distance. According to the new pixel distances represented by X_distance and Y_distance on the canvas, the new drawing origin is (X_new-pic_size_times*X_distance, Y_new-pic_size_times*Y_distance).

[0103] 7) Draw the current graphic and the current canvas according to the new drawing origin, new pic_size_times, current draw_start_point, draw_start_point_y, and data to be drawn each time, and repeat this cycle until the mouse wheel stops rolling.

[0104] Here, the principle of fixed-point scaling is that the engine uses (pic_size_times*draw_start_point, pic_size_times*draw_start_point_y) as the logical drawing starting point. When the data to be drawn is 10 (for example, representing a 10-centimeter line), starting from the drawing starting point, an image with a length of 10*pic_size_times pixel values ​​is drawn on the canvas to represent the data to be drawn 10 under the current pic_size_times. According to this principle, when pic_size_times is enlarged or reduced, the actual pixel value occupied by the same data to be drawn 10 in the drawing effect will be enlarged or reduced, thereby forming a scaling effect, and since the coordinate lines and grid lines of the coordinate ruler are processed at the scaling ratio of pic_size_times, the same changes will also be reflected in the distance between adjacent grid lines and the distance between adjacent coordinate lines. Therefore, for the user reading, the reading remains 10 and remains unchanged, and for the user. For example, Figure 6A and Figure 6B Diagram showing the zoomed-in view of a point on the canvas corresponding to the mouse position.

[0105] In some embodiments, the third control signal is obtained based on the user's dragging operation on the current graphic. The input parameters corresponding to the third control signal are: the coordinates of the drag starting point and the coordinates of each drag point during the dragging process. The preset configuration parameters include: canvas parameters. That is, when the user long-presses the mouse to drag and move the graphic on the canvas, the above S108 can be implemented by the following steps:

[0106] S1094. During the dragging process, obtain the dragging direction of the i-th point according to the coordinates of the i-th dragging point and the coordinates of the dragging starting point; i is 1.

[0107] S1095. Obtain the i-th first variable and the i-th second variable according to the current value of the first variable, the current value of the second variable, the current value of the third variable, the coordinates of the i-th drag point, and the coordinates of the drag starting point.

[0108] S1096: Determine the i-th drawing starting point and zoom factor according to the current values ​​of the i-th first variable, the i-th second variable, and the third variable.

[0109] S1097 : Generate an i-th canvas based on the i-th first variable, the i-th second variable, the current values ​​of the third variable, and the canvas parameters.

[0110] S1098 , using the i-th drawing starting point as the starting drawing point and the zoom factor as the zoom factor of the graphic, generating the i-th drawing graphic according to the data to be drawn.

[0111] S1099: Obtain the drag direction of the (i+1)th point according to the coordinates of the (i+1)th drag point and the coordinates of the (i)th drag point.

[0112] S1100. When the dragging direction of the i+1th point is the same as the dragging direction of the i-th point, the i+1th first variable and the i+1th second variable are obtained based on the i-th first variable, the i-th second variable, the current value of the third variable, the coordinates of the i+1th drag point, and the coordinates of the drag starting point; when the dragging direction of the i+1th point is opposite to the dragging direction of the i-th point, the i+1th first variable and the i+1th second variable are obtained based on the i-th first variable, the i-th second variable, the current value of the third variable, the coordinates of the i+1th drag point, and the coordinates of the i-th drag point.

[0113] S1101 , based on the obtained current values ​​of the (i+1)th first variable, the (i+1)th second variable, and the third variable, respectively generate the (i+1)th canvas and the (i+1)th drawing graphic.

[0114] S1102 : Obtain the drag direction of the (i+2)th drag point according to the coordinates of the (i+2)th drag point and the (i+1)th drag point, until a canvas and a drawing graphic corresponding to the last drag point in the dragging process are generated.

[0115] For example, the principle of performing a scaling operation on a graphic according to a user's drag operation is as follows:

[0116] 1) Define a mousePressEvent event on the canvas to handle mouse button events. First, determine whether the user pressed the left button and whether the user clicked the left button in the drawing area (canvas). If both conditions are met, proceed to step 2); otherwise, do nothing.

[0117] 2) Save the mouse position at the moment the user clicks. The horizontal coordinate of the mouse position is recorded twice, with the horizontal coordinates being Start_x and Endx_c, and the vertical coordinates being Start_y and Endy_c.

[0118] 3) Define a mouseMoveEvent event on the canvas to handle mouse movement events. In this event, determine whether the user has pressed the left mouse button during movement and whether the user is moving within the drawing area. If both conditions are met, proceed to step 4). Otherwise, do nothing.

[0119] 4) Capture the current user's mouse position and record its horizontal and vertical coordinates as Endx and Endy. When handling the user's drag, first determine whether the user's drag is always in a certain direction, or whether the user has reversed direction during the drag. Reversing direction means, for example, that the user initially drags to the right and then turns to the left without releasing the mouse. The specific process is shown in step 5).

[0120] 5) Using the horizontal axis as an example, determine whether the current value (Endx - Endx_c) * (Endx - Start_x) is less than 0. If so, the user has reversed the horizontal direction. In this case, change Start_x to Endx_c and use a variable called draw_start_point_c to store the current draw_start_point.

[0121] 6) After executing step 5), regardless of whether the user performs a reverse operation, Endx_c=Endx is updated.

[0122] 7) After executing step 6), regardless of whether the user performs a reverse operation, draw_start_point=draw_start_point_c+(Endx-Startx) / (pic_size_times) is obtained.

[0123] 8) The vertical coordinate is similar to the horizontal coordinate. According to the corresponding variables of the vertical coordinate, execute steps 5) to 7) in sequence to update draw_start_point_y;

[0124] 9) Call the redraw function to draw a new graphic with the current draw_start_point, draw_start_point_y, and pic_size_times.

[0125] 10) Define the mouseReleaseEvent event on the canvas to handle the mouse release event. In this event, determine whether the released mouse button is the left button. If so, execute step 11), otherwise do nothing.

[0126] 11) Record the current mouse position (x, y), update Endx = x, Endy = y; obtain draw_start_point_c = draw_start_point; and obtain draw_start_point_y_c = draw_start_point_y.

[0127] 12) Call the redraw function to draw new graphics and a new canvas with the current draw_start_point, draw_start_point_y, and pic_size_times.

[0128] In some embodiments, multiple virtual function buttons include: a center button; the third control signal is obtained based on a user's double-click operation on any position on the canvas or a selection operation on the center button; the input parameters corresponding to the third control signal include: the coordinates of the operation position; the preset configuration parameters include: canvas parameters, a preset matching value of the first variable, a preset matching value of the second variable, and a preset matching value of the third variable; that is, when the user wants to quickly restore the graphics to the optimal display state (the zoom ratio is appropriate and the image is located in the center area of ​​the entire canvas), the above S108 can be achieved through the following steps.

[0129] S1103 . When the coordinates of the operation position belong to a preset coordinate range, obtain a preset matching value of the first variable, a preset matching value of the second variable, and a preset matching value of the third variable.

[0130] S1104 : Generate a matching canvas based on the preset matching value of the first variable, the preset matching value of the second variable, the preset matching value of the third variable, and canvas parameters.

[0131] S1105 : Determine a matching drawing starting point and a matching zoom factor according to the preset matching value of the first variable, the preset matching value of the second variable, and the preset matching value of the third variable.

[0132] S1106 , using the matched drawing starting point as the drawing starting point and the matched zoom factor as the zoom factor of the graphic, and generating a drawing graphic according to the data to be drawn.

[0133] Exemplarily, two different principles for quickly restoring graphics to an optimal display state are as follows:

[0134] 1) Use a slot function to connect the click signal of the "Center" button. In the slot function, by changing the three core parameters of draw_start_point, draw_start_point_y, and pic_size_times to the values ​​that best match the current canvas size (preset matching values), and then calling the redraw function, the graphics and canvas can be redrawn.

[0135] 2) Define a mousePressEvent event in the canvas. In this event, determine whether the user right-clicks the mouse in the drawing area. If so, change the three core parameters (draw_start_point, draw_start_point_y, and pic_size_times) to values ​​that best match the current canvas size. Then, call the redraw function to redraw the shape and canvas.

[0136] Here, through the "Quick Center" function, when the user performs a series of dragging and scaling operations, the image size and position of the original image may have changed, and when the user wants to quickly restore the image to the best display state (the scaling ratio is appropriate and the image is located in the center area of ​​the entire canvas), this effect can be achieved by clicking the "Center" function button, right-clicking the mouse, or double-clicking the mouse.

[0137] In some embodiments, when the data to be drawn contains multiple groups of data, and the multiple groups of data can be used to draw multiple curve graphs, each curve graph corresponds to a graphic name, four independent drawing areas can be displayed in the window (drawing page) at a time, and each drawing area can display a curve graph. In addition, four drop-down selection boxes can also be displayed in the drawing page at the same time. These four drop-down selection boxes correspond to the four independent drawing areas one by one. When the user selects a graphic name through the drop-down selection box corresponding to a drawing area, the QT engine can read a group of data corresponding to the graphic name, and call the redraw function to draw and display the curve graph corresponding to the selected graphic name in the drawing area; for example, the drawing page is as follows: Figure 7 shown.

[0138] In some embodiments, when the drawn graphic is a curve graphic and a fourth control signal is obtained from the user for the drawn graphic, the input parameters corresponding to the fourth control signal can be obtained, and the drawing area coordinate system where the drawn graphic is located can be obtained. According to the input parameters corresponding to the fourth control signal and the drawing area coordinate system, the coordinate data corresponding to the input parameters are displayed.

[0139] Here, when the user's input cursor (for example, the cursor corresponding to the mouse) is obtained to hover over the drawn curve graph, a fourth control signal is obtained, so that the input parameter corresponding to the fourth control signal can be the coordinates of the hover position of the user's input cursor, and correspondingly, the coordinate data corresponding to the input parameter can be the coordinate data on the curve on the drawn curve graph; in this way, the function of selecting a point on the drawn curve graph through the cursor can be realized.

[0140] For example, four independent drawing areas can be defined in a window. User data can be read from the user's data data, loaded into DrawSeries and wait for drawing. Coordinate points are drawn according to the read user data and the coordinate system is set. After that, the optimal curve is fitted by the fitting algorithm. The four independent drawing areas are controlled by four drop-down selection boxes. The user can select the current DrawIndex through the drop-down selection box to determine whether the DrawIndex has changed. If it has changed, the user data corresponding to the new DrawIndex is loaded into DrawSeries, and the redraw function is automatically called to draw the graphics. After the graphics are drawn, when the user hovers the mouse, the mouse position is automatically detected, the absolute position of the mouse is converted into the coordinate system of the drawing area, and the converted coordinates are used to determine whether the mouse is hovering over the curve in the drawn graphics. If it is on the curve, the coordinates of the curve position where the mouse is hovering in the coordinate system of the drawing area (DrawX, DrawY) are displayed.

[0141] In some embodiments, an animation button is also displayed on the drawing page. When the user clicks the animation button, multiple graphics and multiple canvases corresponding to the multiple graphics can be drawn according to the data to be drawn and multiple sets of preset variable values, wherein each set of preset variable values ​​includes a preset value of draw_start_point, a preset value of draw_start_point_y and a preset value of pic_size_times, and when the multiple graphics and the corresponding multiple canvases are drawn, the multiple graphics and the corresponding multiple canvases can be displayed in sequence at preset time intervals, and one graphic and the canvas corresponding to the graphic are displayed at the same time. In this way, a playback animation of the graphics can be formed.

[0142] In other words, since the drawing state of a graphic is controlled by three core variables: draw_start_point, draw_start_point_y, and pic_size_times, you only need to provide these three parameters and the data to be drawn to complete the drawing of a two-dimensional graphic. Playing these graphics at a fixed frequency can realize the animation function. For example, the specific steps are as follows:

[0143] 1) Use Qtimer to define a timer and set the timer's start time and interval time.

[0144] 2) Bind the timeout event to the Qtimer's timeout signal timeout. In the timeout function, retransmit the three drawing variables and drawing data to achieve redrawing of the graphics and canvas. When all graphics are drawn and displayed, execute step 3).

[0145] 3) Stop the Qtimer timer.

[0146] The present invention also provides a user-friendly QT two-dimensional drawing engine, comprising:

[0147] A display module, used for displaying a drawing page including a plurality of virtual function buttons;

[0148] An acquisition module, configured to acquire data to be drawn upon receiving a data input signal from a user for the drawing page;

[0149] a drawing module configured to, upon receiving a drawing signal from a user, determine an initial drawing starting point and an initial zoom factor based on preset values ​​of preset variables; draw a current graphic on a canvas displaying a virtual auxiliary tool based on the data to be drawn, using the initial drawing starting point as the drawing start point and the initial zoom factor as the initial zoom factor of the graphic, and display the current graphic;

[0150] a first processing module, configured to process the current graphic and display the processed graphic when a first control signal from the user for the first virtual function key is obtained;

[0151] a second processing module, configured to control the opening or closing of the corresponding virtual assistive tool on the canvas when a second control signal from the user for the second virtual function button is obtained;

[0152] The third processing module is used to obtain the input parameters corresponding to the third control signal and the current value of the preset variable when obtaining the third control signal from the user for the canvas and the current graphic; regenerate the canvas and redraw the graphic based on the input parameters corresponding to the third control signal, the current value of the preset variable, the preset configuration parameters and the data to be drawn, and display the regenerated canvas and the redrawn graphic.

[0153] The present invention can unify the logic between functions, and in actual operation, no matter how the image is dragged or scaled, the corresponding relationship between the image's numerical value and the image's final display effect always remains consistent. Changing the drawing effect is more convenient and quick, and the drawing effect can be changed by simply modifying and organizing the three core variables according to the drawing logic of the present invention. Moreover, it is more convenient to expand new functions, and as long as the correct organization of the three core parameters is ensured, safe and correct function expansion can be achieved. In other words, the drawing method provided by the present invention not only provides users with rich functions when drawing graphics, but also, through ingenious design, concentrates some complex functions on changing the values ​​of the three variables without introducing other cumbersome processes. On the one hand, the drawing effect can be quickly changed according to the user's control signal, improving the interactivity with the user. On the other hand, the drawing effect can be displayed according to the user's control signal in accordance with the user's expected effect, which is more in line with the user's intuition. On the other hand, when it is necessary to expand new functions for the drawing engine, it can be quickly implemented by changing the values ​​of the three variables, facilitating the expansion of functions.

[0154] The above is a further detailed description of the present invention in conjunction with specific preferred embodiments, and the specific implementation of the present invention should not be considered to be limited to these descriptions. For those skilled in the art to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the scope of protection of the present invention.

Claims

1. A user-friendly QT two-dimensional drawing method, characterized in that, include: Displaying a drawing page containing multiple virtual function buttons; When receiving a data input signal from the user for the drawing page, obtaining data to be drawn; Upon receiving a drawing signal from the user, determining an initial drawing starting point and an initial zoom factor according to preset values ​​of preset variables; The preset variables include: a first variable for controlling the distance between the drawing starting point and the left border of the canvas when drawing on the canvas; a second variable for controlling the distance between the drawing starting point and the upper border of the canvas when drawing on the canvas; and a third variable for controlling the zoom factor of the graphic drawing when drawing on the canvas; Taking the initial drawing starting point as the drawing starting point and the initial zoom factor as the initial zoom factor of the graphic, drawing the current graphic on the canvas of the drawing page where the virtual auxiliary tool is displayed according to the data to be drawn, and displaying the current graphic; When a first control signal from the user for the first virtual function key is obtained, processing the current graphic and displaying the processed graphic; When a second control signal from the user for the second virtual function button is obtained, controlling the opening or closing of the corresponding virtual assistive tool on the canvas; When a third control signal from the user for the canvas and the current graphic is obtained, an input parameter corresponding to the third control signal is obtained, and a current value of the preset variable is obtained; Based on the input parameters corresponding to the third control signal, the current values ​​of the preset variables, the preset configuration parameters and the data to be drawn, the canvas is regenerated, and the graphics are redrawn, and the regenerated canvas and the redrawn graphics are displayed.

2. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that The third control signal is obtained according to a user's zoom operation on the current graphic; The input parameters corresponding to the third control signal are: the duration of the amplification operation; The preset configuration parameters include: a preset interval value, a preset maximum value and canvas parameters; The regenerating the canvas and redrawing the graphics based on the input parameter corresponding to the third control signal, the current value of the preset variable, the preset configuration parameter, and the data to be drawn includes: When the amplification operation starts, the current value of the third variable is increased by a preset interval value to obtain the Nth third variable; N is 1; When the third variable updated for the Nth time is less than a preset maximum value, generating an Nth canvas based on the third variable for the Nth time, the current value of the first variable, the current value of the second variable, and the canvas parameter, obtaining an Nth drawing starting point using the third variable for the Nth time, the current value of the first variable, and the current value of the second variable, and redrawing a graph according to the data to be drawn using the Nth drawing starting point as a drawing start point and the third variable for the Nth time as a scaling factor of the graph, to obtain an Nth graph; Increasing the third variable of the Nth time by the preset interval value to obtain the third variable of the N+1th time; When the third variable of the N+1th time is less than the preset maximum value, based on the third variable of the N+1th time, the current value of the first variable, the current value of the second variable and the canvas parameter, an N+1th canvas is generated, and the third variable of the N+1th time, the current value of the first variable and the current value of the second variable are used to obtain an N+1th drawing starting point, and the drawing starting point of the N+1th time is used as the starting point for drawing, the third variable of the N+1th time is used as the zoom factor of the graph, and the graph is redrawn according to the data to be drawn to obtain an N+1th graph, until the duration of the zoom-in operation ends, and an N+mth canvas and graph are obtained; m is an integer greater than or equal to 1; When the third variable of the N+1th time is greater than or equal to the preset maximum value, an N+1th canvas is generated based on the preset maximum value, the current value of the first variable, the current value of the second variable and the canvas parameter, and an N+1th drawing starting point is obtained by using the preset maximum value, the current value of the first variable and the current value of the second variable. The N+1th drawing starting point is used as the starting drawing point, and the preset maximum value is used as the zoom factor of the graphic. The graphic is redrawn according to the data to be drawn to obtain the N+1th graphic, and the N+1th canvas is used as the canvas corresponding to the remaining duration of the zoom-in operation, and the N+1th graphic is used as the drawing graphic corresponding to the remaining duration.

3. The user-friendly QT two-dimensional drawing method according to claim 2, characterized in that: The canvas parameters include: canvas width, canvas height, and pixel distance between adjacent grid dashed lines; the virtual auxiliary tool is a grid dashed line; generating the Nth canvas based on the Nth third variable, the current value of the first variable, the current value of the second variable, and the canvas parameters, includes: Determining a coordinate interval value according to the pixel distance and the Nth third variable; Setting a first loop, in which the initial value of the drawing number i is 0, and when performing the i-th drawing, determining the i-th vertical grid line coordinates according to the value of i, the coordinate interval value, and the canvas height; When the absolute value of the horizontal coordinate of the i-th vertical grid line coordinate is less than the canvas width, draw a vertical grid line according to the i-th vertical grid line coordinate, update i to i+1, determine the i+1-th vertical grid line coordinate, and terminate the first loop when the absolute value of the horizontal coordinate of the i+a-th vertical grid line coordinate is greater than the canvas width; a is an integer greater than 1; Setting a second loop, in which the initial value of the drawing times j is 0, and when performing the j-th drawing, determining the j-th horizontal grid line coordinates according to the value of j, the coordinate interval value, and the canvas width; When the absolute value of the ordinate of the j-th horizontal grid line coordinate is less than the canvas height, draw a horizontal grid line based on the j-th horizontal grid line coordinate, update j to j+1, determine the j+1-th horizontal grid line coordinate, and terminate the second loop when the absolute value of the ordinate of the j+b-th horizontal grid line coordinate is greater than the canvas height; b is an integer greater than 1; According to the drawn vertical grid lines and horizontal grid lines, an N-th canvas for displaying the grid dotted lines is generated.

4. The user-friendly QT two-dimensional drawing method according to claim 2, characterized in that: The canvas parameters include: a preset length, a canvas width, and a canvas height; the virtual auxiliary tool is a coordinate ruler displayed on the upper boundary or the left boundary of the canvas; and generating the Nth canvas based on the Nth third variable, the current value of the first variable, the current value of the second variable, and the canvas parameters includes: A third loop is set, in which an initial value of the number of drawing times i is set to 0. When drawing for the i-th time, when the coordinate ruler is displayed at the upper boundary of the canvas, a first coordinate point for the i-th time is determined based on the value of i, the current value of the first variable, the third variable for the N-th time, and the preset length; when the coordinate ruler is displayed at the left boundary of the canvas, a second coordinate point for the i-th time is determined based on the value of i, the current value of the second variable, the third variable for the N-th time, and the preset length; When the absolute value of the horizontal coordinate of the first coordinate point of the i-th time is less than the right cycle number boundary value of the N-th time, the i-th vertical coordinate line is drawn according to the first coordinate point of the i-th time, and then i is updated to i+1, and the i+1-th drawing is performed until the absolute value of the horizontal coordinate of the first coordinate point of the i+c-th time is greater than the right cycle number boundary value of the N-th time, and the third loop is ended; c is an integer greater than 1; the right cycle number boundary value of the N-th time is determined according to the difference between the canvas width and the left cycle number boundary value of the N-th time, and the third variable of the N-th time; the left cycle number boundary value of the N-th time is the first variable the current value of the ordinate of the i-th second coordinate point; when the absolute value of the ordinate of the i-th second coordinate point is less than the N-th lower cycle number boundary value, draw the i-th horizontal coordinate line according to the i-th second coordinate point; thereafter, update i to i+1, and perform the i+1-th drawing, until the absolute value of the ordinate of the i+h-th first coordinate point is greater than the N-th lower cycle number boundary value, then end the third loop; the N-th lower cycle number boundary value is determined according to the difference between the canvas height and the N-th upper cycle number boundary value, and the N-th third variable; the N-th upper cycle number boundary value is the current value of the second variable; A fourth loop is set, in which an initial value of the number of drawing times j is set to 0. When drawing for the jth time, when the coordinate ruler is displayed at the upper boundary of the canvas, a first coordinate point for the jth time is determined based on the value of j, the current value of the first variable, the third variable for the Nth time, and the preset length; and when the coordinate ruler is displayed at the left boundary of the canvas, a second coordinate point for the jth time is determined based on the value of j, the current value of the second variable, the third variable for the Nth time, and the preset length. When the absolute value of the horizontal coordinate of the j-th first coordinate point is less than the N-th left cycle number boundary value, the j-th vertical coordinate line is drawn according to the j-th first coordinate point, and then j is updated to j+1, and the j+1-th drawing is performed until the absolute value of the horizontal coordinate of the j+h-th first coordinate point is greater than the N-th left cycle number boundary value, and the fourth loop is terminated; when the absolute value of the vertical coordinate of the j-th second coordinate point is less than the N-th upper cycle number boundary value, the j-th horizontal coordinate line is drawn according to the j-th second coordinate point; and then j is updated to j+1, and the j+1-th drawing is performed until the absolute value of the vertical coordinate of the j+c-th second coordinate point is greater than the N-th upper cycle number boundary value, and the fourth loop is terminated.

5. The user-friendly QT two-dimensional drawing method according to claim 2, characterized in that: The third control signal is obtained according to a user's zooming operation on the current graphic at the touch position; The input parameters corresponding to the third control signal are: coordinates of the touch position and duration of the zoom operation; The preset configuration parameters include: a preset interval value, a preset maximum value and canvas parameters; The regenerating the canvas and redrawing the graphics based on the input parameter corresponding to the third control signal, the current value of the preset variable, the preset configuration parameter, and the data to be drawn includes: When the coordinates of the touch position are acquired, the coordinates of the current drawing starting point are determined according to the current value of the first variable, the current value of the second variable, and the current value of the third variable; determining a horizontal distance data difference and a vertical distance data difference according to the coordinates of the touch position, the coordinates of the current drawing starting point, and the current value of the third variable; When the zoom-in operation starts, the current value of the third variable is increased by a preset interval value to obtain the Mth third variable, and when the third variable updated for the Nth time is less than the preset maximum value, the Mth canvas is generated based on the Mth third variable, the current value of the first variable, the current value of the second variable, and the canvas parameter; M is 1; Determining an Mth drawing starting point based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the Mth third variable, and redrawing a graph based on the data to be drawn using the Mth drawing starting point as a drawing start point and the Mth third variable as a graph scaling factor to obtain an Mth graph; Increasing the Mth third variable by the preset interval value to obtain an M+1th third variable, and when the M+1th third variable is less than the preset maximum value, generating an M+1th canvas based on the M+1th third variable, the current value of the first variable, the current value of the second variable, and the canvas parameters; Determining an M+1th drawing starting point based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the M+1th third variable, and redrawing the graph based on the data to be drawn using the M+1th drawing starting point as the drawing start point and the M+1th third variable as the scaling factor of the graph to obtain the M+1th graph, until the M+nth canvas and graph are obtained at the end of the duration of the zoom-in operation; n is an integer greater than or equal to 1; When the (M+1)th third variable is greater than or equal to the preset maximum value, generating an (M+1)th canvas based on the preset maximum value, the current value of the first variable, the current value of the second variable, and the canvas parameters; An M+1th drawing starting point is determined based on the coordinates of the touch position, the horizontal distance data difference, the vertical distance data difference, and the preset maximum value. The M+1th drawing starting point is used as the drawing start point, the preset maximum value is used as the zoom factor of the graphic, and the graphic is redrawn according to the data to be drawn to obtain the M+1th graphic. The M+1th canvas is used as the canvas corresponding to the remaining duration of the zoom-in operation, and the M+1th graphic is used as the drawing graphic corresponding to the remaining duration.

6. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that: The third control signal is obtained according to the user's dragging operation on the current graphic; The input parameters corresponding to the third control signal are: the coordinates of the drag starting point and the coordinates of each drag point during the dragging process; The preset configuration parameters include: canvas parameters; The regenerating the canvas and redrawing the graphics based on the input parameter corresponding to the third control signal, the current value of the preset variable, the preset configuration parameter, and the data to be drawn includes: During the dragging process, the dragging direction of the i-th point is obtained according to the coordinates of the i-th dragging point and the coordinates of the dragging starting point; i is 1; Obtaining the i-th first variable and the i-th second variable according to the current value of the first variable, the current value of the second variable, the current value of the third variable, the coordinates of the i-th drag point, and the coordinates of the drag starting point; Determine the i-th drawing starting point and zoom factor according to the current values ​​of the i-th first variable, the i-th second variable, and the third variable; Generate an i-th canvas based on the i-th first variable, the i-th second variable, the current value of the third variable and the canvas parameter; Taking the i-th drawing starting point as the starting drawing point and the zoom factor as the zoom factor of the graphic, generating the i-th drawing graphic according to the data to be drawn; Obtain the drag direction of the i+1th point according to the coordinates of the i+1th drag point and the coordinates of the i-th drag point; When the drag direction of the i+1th point is the same as the drag direction of the i-th point, the i+1th first variable and the i+1th second variable are obtained based on the i-th first variable, the i-th second variable, the current value of the third variable, the coordinates of the i+1th drag point, and the coordinates of the drag starting point; when the drag direction of the i+1th point is opposite to the drag direction of the i-th point, the i+1th first variable and the i+1th second variable are obtained based on the i-th first variable, the i-th second variable, the current value of the third variable, the coordinates of the i+1th drag point, and the coordinates of the i-th drag point; Generate an i+1th canvas and an i+1th drawing graphic based on the obtained current values ​​of the i+1th first variable, the i+1th second variable, and the third variable; The drag direction of the i+2th point is obtained according to the coordinates of the i+2th drag point and the coordinates of the i+1th drag point, until the canvas and drawing graphics corresponding to the last drag point in the dragging process are generated.

7. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that: The multiple virtual function keys include a center key; the third control signal is obtained based on a user single-clicking operation on any position on the canvas or selecting the center key; the input parameters corresponding to the third control signal include the coordinates of the operation position; the preset configuration parameters include canvas parameters, a preset matching value of the first variable, a preset matching value of the second variable, and a preset matching value of the third variable; The regenerating the canvas and redrawing the graphics based on the input parameter corresponding to the third control signal, the current value of the preset variable, and the preset configuration parameter, includes: When the coordinates of the operation position fall within a preset coordinate range, obtaining a preset matching value of the first variable, a preset matching value of the second variable, and a preset matching value of the third variable; generating a matching canvas based on the preset matching value of the first variable, the preset matching value of the second variable, the preset matching value of the third variable, and the canvas parameters; Determining a matching drawing starting point and a matching zoom factor according to a preset matching value of the first variable, a preset matching value of the second variable, and a preset matching value of the third variable; The matched drawing starting point is used as the drawing starting point, the matched zoom factor is used as the zoom factor of the graphic, and a drawing graphic is generated according to the data to be drawn.

8. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that: The second virtual function button is a cross reading auxiliary ruler button or a grid background button; when a second control signal from the user for the second virtual function button is obtained, controlling the opening or closing of the corresponding virtual auxiliary tool includes: When the second virtual function button is a cross-shaped reading auxiliary ruler button, and when the second control signal is obtained, the horizontal coordinate and the vertical coordinate of the user's current click position are obtained; Draw a vertical line according to the horizontal coordinate and the height of the canvas, and draw a horizontal line according to the vertical coordinate and the width of the canvas, to obtain a cross reading auxiliary ruler with the current click position as the center point; When the second virtual function button is a grid background button and when the second control signal is obtained, the display status of the grid dotted lines on the current canvas is obtained, and when the display status is displayed, the grid dotted lines are hidden; when the display status is not displayed, the value of the third variable at the current moment is obtained, and the grid dotted lines are drawn and displayed according to the value of the third variable, the canvas width, the canvas height, and the pixel distance between adjacent grid dotted lines.

9. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that: The method further comprises: When a fourth control signal for the drawn graphic is obtained from the user, an input parameter corresponding to the fourth control signal is obtained, and a coordinate system of a drawing area where the drawn graphic is located is obtained; According to the input parameter corresponding to the fourth control signal and the drawing area coordinate system, coordinate data corresponding to the input parameter is displayed.

10. A user-friendly QT two-dimensional drawing engine, characterized in that, include: A display module, used for displaying a drawing page including a plurality of virtual function buttons; An acquisition module, configured to acquire data to be drawn upon receiving a data input signal from a user for the drawing page; A drawing module, configured to determine an initial drawing starting point and an initial zoom factor according to preset values ​​of preset variables upon receiving a drawing signal from a user; Taking the initial drawing starting point as the drawing starting point and the initial zoom factor as the initial zoom factor of the graphic, drawing the current graphic on the canvas of the drawing page where the virtual auxiliary tool is displayed according to the data to be drawn, and displaying the current graphic; a first processing module, configured to process the current graphic and display the processed graphic when a first control signal from the user for the first virtual function key is obtained; a second processing module, configured to control the opening or closing of the corresponding virtual assistive tool on the canvas when a second control signal from the user for the second virtual function button is obtained; a third processing module, configured to, upon receiving a third control signal from the user for the canvas and the current graphic, obtain input parameters corresponding to the third control signal and obtain a current value of the preset variable; Based on the input parameters corresponding to the third control signal, the current values ​​of the preset variables, the preset configuration parameters and the data to be drawn, the canvas is regenerated, and the graphics are redrawn, and the regenerated canvas and the redrawn graphics are displayed.

Citation Information

Patent Citations

  • Remote headnote moving and scaling synchronization method and system

    CN105573702A

  • A method of scaling and translating bitmap by using a two-dimensional mouse

    CN109358797A