CN115830186A - User-friendly QT two-dimensional drawing method and engine - Google Patents

User-friendly QT two-dimensional drawing method and engine Download PDF

Info

Publication number
CN115830186A
CN115830186A CN202211591792.5A CN202211591792A CN115830186A CN 115830186 A CN115830186 A CN 115830186A CN 202211591792 A CN202211591792 A CN 202211591792A CN 115830186 A CN115830186 A CN 115830186A
Authority
CN
China
Prior art keywords
variable
canvas
time
value
graph
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211591792.5A
Other languages
Chinese (zh)
Inventor
彭延国
李云鹏
黄麓源
刘洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xidian University
Original Assignee
Xidian University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xidian University filed Critical Xidian University
Priority to CN202211591792.5A priority Critical patent/CN115830186A/en
Publication of CN115830186A publication Critical patent/CN115830186A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a user-friendly QT two-dimensional drawing method and an engine, and the method comprises the following steps: displaying a drawing page; acquiring data to be drawn when a data input signal of a user for a drawing page is received, and determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable; drawing and displaying a current graph in a canvas according to an initial drawing starting point, an initial zooming multiple and data to be drawn; when the first control signal is acquired, processing the current graph and displaying the processed graph; when the second control signal is acquired, controlling the opening or closing of the corresponding virtual auxiliary tool on the canvas; when the third control signal is obtained, obtaining an input parameter corresponding to the third control signal, and obtaining a current value of a preset variable; and regenerating the canvas and redrawing the graph based on the input parameter, the current value of the preset variable, the preset configuration parameter and the data to be painted which correspond to the third control signal, and displaying the regenerated canvas and the redrawing graph.

Description

User-friendly QT two-dimensional drawing method and engine
Technical Field
The invention belongs to the technical field of drawing, and particularly relates to a user-friendly QT two-dimensional drawing method and engine.
Background
With the popularization of graphical interfaces, more and more individuals, enterprises and organizations tend to show data held by themselves to users in a graphical manner. Whether the data trend of the parameters and the report forms is viewed in the form of a statistical chart or the final shaping of the product parameters is displayed in the form of a two-dimensional schematic diagram. The graphical data are more in line with the cognition of people, and the users can read and search the data more conveniently.
QT is as a classic cross-platform C + + graphical user interface application development framework. It can be used to develop both GUI and non-GUI programs, such as console tools and servers. QT is an Object-oriented framework that is easily extended using special code generation extensions called Meta Object Compiler (MOC) and some macros, and allows true component programming.
QT is a stable and balanced development tool choice between the visual presentation demand and controllable cost of data, both for individual users and for large, medium and small enterprises and organizations. How to use the QT to create a drawing engine for the user, which has strong interactivity, is intuitive for the user, has good experience, and has easily expandable functions, is a problem to be considered and solved.
Disclosure of Invention
In order to solve the above problems 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 invention is realized by the following technical scheme:
the invention provides a user-friendly QT two-dimensional drawing method, which comprises the following steps:
displaying a drawing page comprising a plurality of virtual function keys;
when a data input signal of a user aiming at the drawing page is received, acquiring data to be drawn;
when a drawing signal of a user is received, determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable; the preset variables include: a first variable for controlling a distance of a drawing start point from a left boundary of a canvas when drawing in the canvas; a second variable for controlling a distance of a drawing start point from an upper boundary of the canvas when drawing in the canvas; a third variable for controlling a zoom factor of the drawing of the graphic when drawing in the canvas;
drawing a current graph in a canvas of the drawing page, which is displayed with a virtual auxiliary tool, according to the data to be drawn by taking the initial drawing starting point as a drawing starting point and the initial zooming times as the initial zooming times of the graph, and displaying the current graph;
when a first control signal of a user for a first virtual function key is acquired, processing the current graph, and displaying the processed graph;
when a second control signal of the user for a second virtual function key is acquired, controlling the opening or closing of a corresponding virtual auxiliary tool on the canvas;
when a third control signal of a user for the canvas and the current graph is acquired, acquiring an input parameter corresponding to the third control signal and acquiring a current value of the preset variable;
and regenerating the canvas and redrawing the graph 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 painted, and displaying the regenerated canvas and the redrawing graph.
The invention has the following beneficial technical effects:
according to the drawing method provided by the invention, not only are rich functions provided for a user during drawing of the graph, but also some complex functions are concentrated on changing values of three variables through ingenious design without introducing other complicated processes, on one hand, the drawing effect can be quickly changed according to a control signal of the user, the interactivity between the drawing method and the user is improved, on the other hand, the drawing effect consistent with the effect expected by the user can be displayed according to the control signal of the user, the drawing method is more in line with the intuition of the user, on the other hand, when a new function needs to be expanded for a drawing engine, the values of the three variables can be quickly changed, and the expansion of the function is facilitated.
The present invention will be described in further detail with reference to the accompanying drawings and examples.
Drawings
FIG. 1 is an alternative flow chart of a user-friendly QT two-dimensional mapping method provided by an embodiment of the invention;
FIG. 2 is a schematic diagram of an exemplary canvas displaying a grid dotted line, an upper coordinatometer, a left coordinatometer and a partially rendered graphic, according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an exemplary cross-reading auxiliary scale at a position where a mouse is located according to an embodiment of the present invention;
FIG. 4A is a diagram illustrating a canvas, a coordinatometer displayed on the canvas, and a graphic, prior to starting to move the graphic on the canvas, according to an exemplary embodiment of the present invention;
fig. 4B is a schematic diagram of a canvas, a coordinatometer displayed on the canvas, and a graphic at a time in an exemplary process of moving the graphic on the canvas according to an embodiment of the present invention;
FIG. 4C is a diagram illustrating a canvas, a coordinatometer displayed on the canvas, and a graphic after the graphic has been moved across the canvas, according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart illustrating an exemplary fixed-point zooming in and out on a graphic according to an embodiment of the present invention;
fig. 6A is a schematic diagram of a position on an exemplary canvas where a mouse is located before a fixed point is enlarged according to an embodiment of the present invention;
fig. 6B is a schematic diagram of an enlarged fixed point corresponding to a position on the canvas where the mouse is located according to the embodiment of the present invention;
fig. 7 is a schematic diagram of an exemplary drawing page according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to specific examples, but the embodiments of the present invention are not limited thereto.
In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples described in this specification can be combined and combined by those skilled in the art.
While the invention has been described in connection with various embodiments, other variations to the disclosed embodiments can be understood and effected by those skilled in the art in practicing the claimed invention, from a review of the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other elements or steps, and the word "a" or "an" does not exclude a plurality. A single processor or other unit may fulfill the functions of several items recited in the claims. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
Fig. 1 is an optional flowchart of a user-friendly QT two-dimensional drawing method provided in an embodiment of the present invention, which can be applied to a QT two-dimensional drawing engine, as shown in fig. 1, and the method includes the following steps:
s101, displaying a drawing page comprising a plurality of virtual function keys.
Here, when the QT two-dimensional drawing engine receives an operation instruction from a user, a drawing page may be displayed, and the page may include a plurality of virtual function keys, for example, a cross reading auxiliary ruler key, a grid background key, and the like.
S102, acquiring data to be drawn when a data input signal of a user for a drawing page is received.
Here, a data input box can also be displayed on the drawing page, a user can input data to the QT two-dimensional drawing engine through the data input box, and when the QT two-dimensional drawing engine receives the data input by the user, the data to be drawn is obtained.
Here, the user may input data by uploading a file, or may input data by directly inputting data, which is not limited in the embodiment of the present invention.
Here, the data to be drawn may be appearance data and internal structure data of the product, size data of the graph, data for drawing a histogram, a graph, or the like, and the like, which is not limited in the embodiment of the present invention.
S103, when a drawing signal of a user is received, determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable; the preset variables include: a first variable for controlling a distance of a drawing start point from a left boundary of a canvas when drawing in the canvas; a second variable for controlling a distance of the drawing start point from an upper boundary of the canvas when drawing in the canvas; and a third variable for controlling the zoom factor of the graphic drawing when drawing in the canvas.
Here, the first variable and the third variable together control the abscissa of the drawing start point when drawing in the canvas; the second variable and the third variable together control the ordinate of the drawing starting point when drawing in the canvas. For example, the first variable may be draw _ start _ point, the second variable may be draw _ start _ point _ y, the third variable may be pic _ size _ times, and draw _ start _ point _ y are int type, pic _ size _ times are double type; the draw _ start _ point _ pic _ size _ times is the abscissa of the drawing start point, and the draw _ start _ point _ y _ pic _ size _ times is the ordinate of the drawing start point.
And S104, drawing the current graph in the canvas of the drawing page on which the virtual auxiliary tool is displayed according to the data to be drawn by taking the initial drawing starting point as the starting drawing point and the initial scaling factor as the initial scaling factor of the graph, and displaying.
Here, the virtual assistant tool may include: a grid dotted line, an upper coordinatometer displayed at an upper boundary of the canvas, and a left coordinatometer displayed at a left boundary of the canvas. Illustratively, FIG. 2 is a schematic diagram of a portion of a canvas showing a grid dotted line, an upper coordinatometer, a left coordinatometer and a partially drawn graphic.
Here, when the graphic drawing is performed, the graphic drawing may be performed by using a drawing function.
And S105, processing the current graph and displaying the processed graph when the first control signal of the user for the first virtual function key is acquired.
Here, the first virtual function key is a mirror function key. And when the touch operation of the user on the virtual function key is detected, obtaining a first control signal, and when the first control signal is obtained, calling a mirror function to draw a mirror image graph of the current graph on the current canvas to obtain a graph consisting of the current graph and the mirror image graph.
And S106, when a second control signal of the user for the second virtual function key is acquired, controlling the opening or closing of the corresponding virtual auxiliary tool on the canvas.
In the embodiment of the invention, the second virtual function key is a cross reading auxiliary ruler key or a grid background key.
In some embodiments, when the second virtual function key is a cross reading auxiliary scale key and a touch signal of the user to the cross reading auxiliary scale key is detected, a second control signal is obtained, an abscissa and an ordinate of a current click position of the user are obtained, a vertical line is drawn according to the abscissa and a canvas height of a canvas, a horizontal line is drawn according to the ordinate and the canvas width of the canvas, and the cross reading auxiliary scale using the current click position as a center point is obtained.
For example, a mousedoubtleclickEvent event may be defined in the drawing window, which only handles one logic, that is, when the user double-clicks or single-clicks, the on/off effect is achieved by negating the on/off variable (type of bool) of the drawing cross reading auxiliary scale. If the switch is turned on, continuously calling an Update method to Update the drawing in real time in the interface by tracking the horizontal and vertical coordinates of the current mouse and taking the two coordinate values as parameters, wherein the logic of the Update method is as follows: and receiving the abscissa x of the current mouse position and the ordinate y of the current mouse position, and when the width of the current drawing window 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), which are then the two vertical and horizontal lines centered on the current mouse position. Since update is invoked with each mouse movement, the cross bar will be updated continuously with the mouse movement, and the rendering effect follows the mouse movement of the user. For example, fig. 3 is a schematic diagram of a cross reading auxiliary scale at a certain position of a mouse.
In some embodiments, when the second virtual function key is a grid background key and a touch signal of a user to the grid background key is detected, obtaining a second control signal, obtaining a display state of a grid dotted line on a current canvas, and hiding the grid dotted line when the display state is displayed; and when the display state is not displayed, obtaining the value of a third variable at the current moment, and drawing and displaying the grid dotted lines according to the value of the third variable, the width of the canvas, the height of the canvas and the pixel distance between adjacent grid dotted lines.
Illustratively, control of whether grid dotted lines are displayed or not may also be achieved by defining a mousedouubleclickevent event and a pool variable.
S107, when a third control signal of the user for the canvas and the current graph is obtained, obtaining an input parameter corresponding to the third control signal, and obtaining a current value of a preset variable.
In an embodiment of the present invention, the plurality of virtual function keys include: a centering key; the third control signal may be obtained by: acquiring touch operation of a user in real time; when the touch operation is an amplifying operation or a reducing operation on the current graph, determining to acquire a third control signal; or when the touch operation is an enlarging operation or a reducing operation on the current graph at the touch position, determining to acquire a third control signal; or when the touch operation is a drag operation on the current graph, determining to acquire a third control signal; or when the touch operation is a double-click operation on any position on the canvas, determining to acquire a third control signal; or when the touch operation is the selection operation of the centering key, determining to acquire the third control signal.
And S108, regenerating the canvas and redrawing the graph 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, and displaying the regenerated canvas and the redrawing graph.
In some embodiments, the third control signal is derived from a user's zoom-in operation on the current graphic; correspondingly, the input parameters corresponding to the third control signal are: the duration of the amplification operation; the preset configuration parameters include: presetting an interval value, a maximum value and a canvas parameter; that is, when the user enlarges the current graphic only by controlling the wheel of the mouse, the above S108 may be implemented by:
s1081, when amplification operation starts, increasing a current value of a third variable by a preset interval value to obtain an Nth time of the third variable; n is 1.
Here, the preset interval value may be 0.5, or may be other values, which is not limited thereto.
S1082, when the third variable updated for the Nth time is smaller than the preset maximum value, generating the canvas for the Nth time 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 parameters, obtaining the drawing starting point for the Nth time by adopting the third variable for the Nth time, the current value of the first variable and the current value of the second variable, and redrawing the graph according to the data to be drawn by taking the drawing starting point for the Nth time as a drawing starting point and the third variable for the Nth time as a scaling multiple of the graph to obtain the graph for the Nth time.
S1083, increasing the nth third variable by a preset interval value to obtain the (N + 1) th third variable.
S1084, when the third variable of the (N + 1) th time is smaller than a preset maximum value, generating the canvas of the (N + 1) th time based on the third variable of the (N + 1) th time, the current value of the first variable, the current value of the second variable and the canvas parameters, obtaining the drawing starting point of the (N + 1) th time by adopting the third variable of the (N + 1) th time, the current value of the first variable and the current value of the second variable, re-drawing the graph by taking the drawing starting point of the (N + 1) th time as a starting drawing point and the third variable of the (N + 1) th time as a scaling factor of the graph according to data to be drawn, obtaining the graph of the (N + 1) th time, and obtaining the canvas and the graph of the (N + m) th time until the amplification time is finished; m is an integer greater than or equal to 1.
S1085, when the third variable of the (N + 1) th time is larger than or equal to the preset maximum value, generating the canvas of the (N + 1) th time based on the preset maximum value, the current value of the first variable, the current value of the second variable and the canvas parameters, obtaining the drawing starting point of the (N + 1) th time by adopting the preset maximum value, the current value of the first variable and the current value of the second variable, and redrawing the graph according to the data to be drawn by taking the drawing starting point of the (N + 1) th time as a drawing starting point and the preset maximum value as a zooming multiple of the graph to obtain the graph of the (N + 1) th time, taking the canvas of the (N + 1) th time as the canvas corresponding to the remaining duration of the zooming operation, and taking the graph of the (N + 1) th time as the drawing graph corresponding to the remaining duration.
For example, when the user starts to scroll the mouse wheel upwards, if the current pic _ size _ times is less than 10, then in the process of scrolling the mouse wheel upwards by the user, 0.5 is sequentially added to the pic _ size _ times, and until the pic _ size _ times is greater than or equal to the maximum value of 10, the pic _ size _ times is maintained to be 10; and calling a redrawing function to draw the current graph according to the current pic _ size _ times, the current draw _ start _ point _ y, the current draw _ start _ point and the data to be drawn after the pic _ size _ times are increased by 0.5 each time.
Here, when the third control signal is obtained according to a zoom-out operation of the user on the current graphic; correspondingly, the input parameters corresponding to the third control signal are: reducing the duration of the operation; the preset configuration parameters include: presetting an interval value, a minimum value and a canvas parameter; that is, when the user reduces the current graphic only by controlling the wheel of the mouse, the specific implementation principle of S108 is the same as that of S1081 to S1085.
In some embodiments, the canvas parameters include: canvas width, canvas height, pixel distance between adjacent mesh dotted lines; the virtual auxiliary tool is a grid dotted line; based on this, the step of generating the canvas for the nth time in S1082 may be implemented as the following steps:
s201, determining a coordinate interval value according to the pixel distance and the Nth time third variable.
S202, setting a first cycle, wherein in the first cycle, the initial value of the drawing times i is 0, and when the ith drawing is carried out, the vertical grid line coordinate of the ith time is determined according to the value of i, the coordinate interval value and the height of the canvas.
S203, when the absolute value of the horizontal coordinate of the ith vertical grid line coordinate is smaller than the width of the canvas, drawing a vertical grid line according to the ith vertical grid line coordinate, updating i to i +1, determining the ith +1 vertical grid line coordinate, and ending the first cycle until the absolute value of the horizontal coordinate of the ith + a vertical grid line coordinate is larger than the width of the canvas; a is an integer greater than 1.
And S204, setting a second cycle, wherein the initial value of the drawing time j in the second cycle is 0, and determining the transverse grid line coordinate of the jth time according to the value of j, the coordinate interval value and the canvas width when the jth time is drawn.
S205, when the absolute value of the ordinate of the jth horizontal grid line coordinate is smaller than the height of the canvas, drawing a horizontal grid line according to the jth horizontal grid line coordinate, updating j to j +1, determining the jth +1 horizontal grid line coordinate, and ending the second cycle until the absolute value of the ordinate of the jth + b horizontal grid line coordinate is larger than the height of the canvas; b is an integer greater than 1.
S206, generating the Nth canvas for displaying the grid dotted lines according to the drawn vertical grid lines and the drawn horizontal grid lines.
Illustratively, assuming that the window width is height, a loop is set to draw a dashed straight line from (x, 0) to (x, height), and x is successively increased by 10.0 × pic size times until x is greater than the window width, so that a vertical grid line can be drawn. Assuming that the window height sets a loop for width, drawing a virtual straight line from (0, y) to (width, y), and gradually increasing y by 10.0% pic size times until y is greater than the window height, thus, a horizontal grid line can be drawn; and 10 is the pixel distance between adjacent grid dotted lines, the window width is the canvas width, and the window height is the canvas height.
In some embodiments, the canvas parameters may include: presetting length, canvas width and canvas height; the virtual auxiliary tool is a coordinatometer displayed on the upper boundary or the left boundary of the canvas; based on this, the step of generating the canvas for the nth time in S1082 may be implemented as the following steps:
s207, setting a third cycle, setting an initial value of drawing times i as 0 in the third cycle, and when the ith drawing is performed and the coordinatometer is displayed on the upper boundary of the canvas, determining a first coordinate point of the ith drawing according to the value of i, the current value of the first variable, the third variable of the Nth drawing and a preset length; and when the coordinatometer is displayed on the left boundary of the canvas, determining the second coordinate point of the ith time according to the value of i, the current value of the second variable, the third variable of the Nth time and the preset length.
S208, when the absolute value of the abscissa of the ith first coordinate point is smaller than the boundary value of the Nth right cycle, drawing an ith vertical coordinate line according to the ith first coordinate point, then updating i to i +1, drawing the (i + 1) th time, and ending the third cycle until the absolute value of the abscissa of the (i + c) th first coordinate point is larger than the boundary value of the Nth right cycle; c is an integer greater than 1; the boundary value of the Nth right circulation time is determined according to the difference value between the width of the canvas and the boundary value of the Nth left circulation time and the Nth third variable; the boundary value of the Nth left circulation time is the current value of the first variable; when the absolute value of the ordinate of the ith second coordinate point is smaller than the boundary value of the Nth lower cycle time, drawing an ith abscissa line according to the ith second coordinate point; then, updating i to i +1, drawing for the (i + 1) th time, and ending the third cycle until the absolute value of the ordinate of the first coordinate point of the (i + h) th time is larger than the boundary value of the next cycle time of the Nth time; the boundary value of the Nth lower circulation time is determined according to the difference value between the height of the canvas and the boundary value of the Nth upper circulation time and the Nth third variable; the nth upper loop time boundary value is the current value of the second variable.
S209, setting a fourth cycle, setting an initial value of drawing times j as 0 in the fourth cycle, and when the jth drawing is performed and the coordinatometer is displayed on the upper boundary of the canvas, determining a first coordinate point of the jth time according to the value of j, the current value of the first variable, the third variable of the nth time and the preset length; and when the coordinatometer is displayed on the left boundary of the canvas, determining a second coordinate point of the jth time according to the value of j, the current value of the second variable, the third variable of the nth time and the preset length.
S210, when the absolute value of the abscissa of the jth first coordinate point is smaller than the Nth left cycle boundary value, drawing a jth vertical coordinate line according to the jth first coordinate point, then updating j to j +1, drawing for the j +1 th time, and ending the fourth cycle until the absolute value of the abscissa of the jth first coordinate point is larger than the Nth left cycle boundary value canvas width; when the absolute value of the ordinate of the jth second coordinate point is smaller than the boundary value of the Nth upper cycle number, drawing a jth abscissa line according to the jth second coordinate point; and then updating j to j +1, and drawing for the (j + 1) th time until the absolute value of the ordinate of the second coordinate point of the (j + c) th time is larger than the boundary value of the upper cycle time of the Nth time, and ending the fourth cycle.
Illustratively, the upper coordinatometer is taken as an example, and the drawing method of the upper coordinatometer is as follows:
1) The prescribed coordinatometer value increases to the right, and the zero point of the upper coordinatometer corresponds to the abscissa of the drawing start point.
2) And setting a right cycle for drawing a zero point and a vertical coordinate line to the right of the zero point. In the loop, i starts to count from 0, and the loop is accumulated, and a vertical coordinate line is correspondingly drawn after i is accumulated once. These vertical coordinate lines are all vertical, with the abscissa of each coordinate line being x, and the length of the coordinate line being length. Then the drawing is started from (x, 0) to (x, length), i.e. a line in the vertical direction with length. In order to embody the characteristics of the coordinatometer, in this loop, when i is 0 or an integer multiple of 10, the length of the line is set to be the longest, i.e., 25. When i is an integer multiple of 5, the length of the line is the next longest, i.e., 20. When i is otherwise the length of the line is the shortest, i.e. 10.
3) In each cycle of the right loop, x is set to (i + draw _ start _ point) × pic _ size _ times, and when i is accumulated to be greater than (width-draw _ start _ point × (pic _ size _ times)/pic _ size _ times, the right loop is stopped, draw _ start _ point and pic _ size _ times are both values in the current case, and width is the width of the canvas.
4) At the same time, a left loop is set to plot the vertical line to the left of the zero. In the loop, j starts counting from 1, and the loop is accumulated, and a vertical coordinate line is correspondingly drawn after j is accumulated once. These coordinate lines are all vertical, with the abscissa of each vertical coordinate line being x, and the length of the coordinate line being length. Then the drawing is started from (x, 0) to (x, length), i.e. a line in the vertical direction with length. In order to embody the characteristics of the coordinatometer, in this cycle, when j is 0 or an integer multiple of 10, the length of the line is set to be the longest, i.e., 25. When j is an integer multiple of 5, the length of the line is the next longest, i.e., 20. When j is otherwise the length of the line is the shortest, i.e. 10.
5) In each cycle of the left cycle, x is set to (draw _ start _ point-j) × pic _ size _ times, and the left cycle is stopped when j accumulates to be greater than draw _ start _ point.
6) In order to improve the interactive experience of the user, pic _ size _ times of each time can be judged when the coordinatometer is drawn. If pic _ size _ times is smaller than the set threshold, the coordinate values below the coordinatometer are not displayed any more, and if pic _ size _ times is larger than the set threshold, the coordinate values below the coordinatometer are only displayed in integral multiples of 0 and 10. When the magnification factor is increased continuously, the distance between adjacent coordinate lines is pulled to be wider, and the coordinate values below the coordinatometer at the moment display integral multiples of 0, 5 and 10; therefore, the feedback of the user in zooming can be given, and the picture can be more harmonious visually.
Illustratively, when the coordinators are left coordinators, the third cycle is a lower cycle, the fourth cycle is an upper cycle, and one abscissa line is formed each time drawing is started from (0, y) to (length, y), and y is set to (draw _ start _ point _ y-i) × pic _ size _ time at each cycle of the lower cycle, and when i is added to be greater than (height-draw _ start _ point _ y | -pic _ size _ time)/pic _ size _ time, the lower cycle is stopped, height is a canvas height; at each cycle of the upper cycle, y is set to (draw _ start _ point _ y-j) × pic _ size _ times, and when j is accumulated to be larger than draw _ start _ point _ y, the upper cycle is stopped; the other principles are the same as the right and left cycles described above.
Here, by the coordinate scale drawing method provided by the invention, the effect that the coordinate scale displayed on the canvas moves along with the movement of the graph when the graph in the canvas moves can be realized, so that a user feels that the coordinate scale displayed on the canvas and the canvas is infinite.
By way of example, fig. 4A, 4B, and 4C respectively show schematic diagrams of changes of the canvas, the coordinatometer displayed on the canvas, and the graphic in three states before the graphic starts to move on the canvas, during the graphic moves, and after the graphic moves.
In some embodiments, the third control signal is derived from a user zooming in on the current graphic at a touch location; the input parameters corresponding to the third control signal are: coordinates of the touch position and duration of the amplification operation; the preset configuration parameters include: presetting an interval value, a maximum value and a canvas parameter; that is, when the current mouse position of the user is used as the zoom center to zoom in the drawing image, the step S108 may be implemented by:
and S1086, when the coordinates of the touch position are obtained, determining the coordinates of the current drawing starting point according to the current value of the first variable, the current value of the second variable and the current value of the third variable.
S1087, determining a transverse distance data difference and a longitudinal distance data difference according to the coordinate of the touch position, the coordinate of the current drawing starting point and the current value of the third variable.
S1088, when the amplification operation starts, increasing a current value of a third variable by a preset interval value to obtain an Mth time third variable, and when an Nth time updated third variable is smaller than a preset maximum value, generating an Mth time canvas based on the Mth time third variable, the current value of a first variable, the current value of a second variable and canvas parameters; m is 1.
S1089, determining a drawing starting point of the Mth time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the Mth time third variable, and redrawing the graph according to the data to be drawn by taking the Mth time drawing starting point as a drawing starting point and the Mth time third variable as a scaling multiple of the graph to obtain the Mth time graph.
And S1090, increasing the M +1 th time third variable by a preset interval value to obtain an M +1 th time third variable, and generating the M +1 th time canvas based on the M +1 th time third variable, the current value of the first variable, the current value of the second variable and the canvas parameter when the M +1 th time third variable is smaller than a preset maximum value.
S1091, determining a drawing starting point of the M +1 th time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the third variable of the M +1 th time, re-drawing the graph according to the data to be drawn by taking the drawing starting point of the M +1 th time as a drawing starting point and the third variable of the M +1 th time as a scaling multiple of the graph to obtain the graph of the M +1 th time until the enlargement time is finished, and obtaining the canvas and the graph of the M + n th time; n is an integer greater than or equal to 1.
S1092, when the third variable of the M +1 th time is larger than or equal to the preset maximum value, generating the canvas of the M +1 th time based on the preset maximum value, the current value of the first variable, the current value of the second variable and the canvas parameters.
S1093, determining a drawing starting point of the M +1 th time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the preset maximum value, redrawing the graph according to the data to be drawn by taking the drawing starting point of the M +1 th time as a drawing starting point and the preset maximum value as a zooming multiple of the graph to obtain the graph of the M +1 th time, taking the canvas of the M +1 th time as a canvas corresponding to the remaining duration of the amplification operation, and taking the graph of the M +1 th time as a drawing graph corresponding to the remaining duration.
Illustratively, as shown in fig. 5, the principle of zooming in and out the graphics at fixed points is as follows:
1) A while event (function) is defined in the drawing window, and whether the current position of the mouse of the user is in a drawing area (canvas, which may also be called a drawing board) is judged through the event. If yes, executing the subsequent steps, otherwise, not performing any processing.
2) Recording the coordinate position of the current mouse as (X _ new, Y _ new), and calculating the drawing starting point (X0, Y0) in the current drawing state, namely the drawing origin, according to the current draw _ start _ point, pic _ size _ times and draw _ start _ point _ Y.
3) And calculating the pixel distance between the coordinates of the current mouse and the drawing origin in the current drawing state, wherein the transverse distance is X _ new-X0, and the longitudinal distance is Y _ new-Y0. After the pixel distances are reduced to the difference of the data to be drawn, the data difference X _ distance of the transverse distance is (X _ new-X0)/pic _ size _ times, and the data difference Y _ distance of the longitudinal distance is (Y _ new-Y0)/pic _ size _ times.
4) When the user rolls the mouse wheel upwards, if the pic _ size _ times is smaller than 10 (preset maximum value), sequentially adding 0.5 to the pic _ size _ times, otherwise, keeping the pic _ size _ times at 10. (maximum magnification)
5) When the user rolls the mouse wheel down, if pic _ size _ times is greater than 2 (preset minimum), then sequentially decreasing pic _ size _ times by 0.5, otherwise, maintaining pic _ size _ times at 2.
6) When a current pic _ size _ time is obtained each time, calculating a new pixel distance between the mouse position and the drawing origin under the current pic _ size _ time, wherein the new pixel distance represented by the obtained X _ distance on the canvas is pic _ size _ time X _ distance, the new pixel distance represented by the obtained Y _ distance on the canvas is pic _ size _ time Y _ distance, and the obtained new drawing origin is (X _ new-pic _ size _ time X _ distance, Y _ new-pic _ size _ time Y _ distance) according to the new pixel distance represented by the X _ distance and the Y _ distance on the canvas.
7) And respectively drawing the current graph and the current canvas according to the new drawing origin, the new pic _ size _ times, the current draw _ start _ point _ y and the data to be drawn, wherein the drawing origin, the new pic _ size _ times, the current draw _ start _ point _ y and the data to be drawn are obtained each time, and the process is circulated until the mouse wheel does not roll any more.
Here, the principle of fixed point scaling is that the engine takes (pic _ size _ times × draw _ start _ point, pic _ size _ times × draw _ start _ point _ y) as a logical drawing start point. When the data to be drawn is 10 (e.g., a line representing 10 centimeters), starting at the drawing start point, an image of 10 × pic _size _timespixel 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 10 to be drawn in the drawing effect is enlarged or reduced, so that the zooming effect is formed, and since the coordinate lines and grid lines of the coordinatometer are processed at the zooming ratio of pic _ size _ times, the same changes are reflected in the distance between the adjacent grid lines and the distance between the adjacent grid lines, so that the reading is still 10 for the user reading, and is still for the user. For example, fig. 6A and 6B are schematic diagrams before and after zooming in a fixed point corresponding to a certain position on a canvas where a mouse is located.
In some embodiments, the third control signal is obtained according to a drag operation of the user on the current graphic; the input parameters corresponding to the third control signal are: coordinates of a dragging start point and coordinates of each dragging point in the dragging process; the preset configuration parameters include: canvas parameters; that is, when the user drags and moves the graphic on the canvas by pressing the mouse for a long time, the above S108 may be implemented by the following steps:
s1094, in the dragging process, obtaining the dragging direction of the ith point according to the coordinate of the ith dragging point and the coordinate of the dragging starting point; i is 1.
S1095, obtaining the ith variable and the ith 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 coordinate of the ith dragging point and the coordinate of the dragging starting point.
S1096, determining a drawing starting point and a scaling factor of the ith time according to the current values of the first variable, the second variable and the third variable of the ith time.
S1097, generating the canvas of the ith time based on the first variable of the ith time, the second variable of the ith time, the current value of the third variable and the canvas parameters.
S1098, taking the drawing starting point of the ith drawing as a starting drawing point, taking the zoom factor as the zoom factor of the drawing, and generating the drawing of the ith drawing according to the data to be drawn.
S1099, obtaining the dragging direction of the (i + 1) th point according to the coordinates of the (i + 1) th dragging point and the coordinates of the ith dragging point.
S1100, when the dragging direction of the (i + 1) th point is the same as that of the ith point, obtaining a first variable of the (i + 1) th time and a second variable of the (i + 1) th time according to a first variable of the ith time, a second variable of the ith time, a current value of a third variable, coordinates of the (i + 1) th dragging point and coordinates of a dragging starting point; and when the dragging direction of the (i + 1) th point is opposite to the dragging direction of the (i) th point, obtaining the (i + 1) th first variable and the (i + 1) th second variable according to the (i) th first variable, the (i) th second variable, the current value of the third variable, the coordinates of the (i + 1) th dragging point and the coordinates of the (i + 1) th dragging point.
S1101, respectively generating the canvas of the (i + 1) th time and the drawing graph of the (i + 1) th time based on the obtained current values of the first variable of the (i + 1) th time, the second variable of the (i + 1) th time and the third variable.
S1102, obtaining the dragging direction of the (i + 2) th point according to the coordinates of the (i + 2) th dragging point and the coordinates of the (i + 1) th dragging point until a canvas and a drawing graph corresponding to the last dragging point in the dragging process are generated.
Illustratively, the principle of the zooming operation of the graph according to the dragging operation of the user is as follows:
1) A mousePressEvent event is defined on the canvas and is used to process mouse button events. In this event, it is first determined whether the user has pressed the left button or not, and whether the user has clicked the left button on the drawing area (canvas). If both conditions are met, step 2) is executed, otherwise no response is made.
2) And saving the mouse position of the user at the clicking time, recording two abscissa of the mouse position, wherein the abscissa is Start _ x and Endx _ c respectively, and the ordinate is Start _ y and Endy _ c respectively.
3) A mousenovoveevent event is defined on the canvas and is used to handle events of mouse movement. In the event, it is determined whether the user has pressed the left key during the movement and whether the user has moved in the drawing area. If both of the above conditions are satisfied, step 4) is performed. Otherwise, no response is made.
4) The mouse position of the current user is captured, and horizontal and vertical coordinates of the current user are recorded as Endx and Endy. In the process of processing the user drag, firstly, it needs to be determined whether the user drag is always towards a certain direction, or the user has a reverse situation in the process of dragging. The reverse direction is, for example, the user initially drags to the right and then turns to move to the left without releasing the mouse, and the specific process is as shown in step 5).
5) Take the abscissa as an example. Judging whether the current (Endx-Endx _ c) (Endx-Start _ x) is less than 0 or not; if less than 0, it proves that the user has done the reverse operation in the transverse direction at this time. In this case Start _ x = Endx _ c needs to be changed; while the current draw _ start _ point is saved using a variable draw _ start _ point _ c.
6) After step 5) is performed, regardless of whether the user performs a reverse operation, the end _ c = end is updated.
7) After the step 6) is executed, no matter whether the user performs the reverse operation, the result is draw _ start _ point = draw _ start _ point _ c + (end-start)/(pic _ size _ times).
8) The ordinate is similar to the abscissa, and the steps 5) to 7) are sequentially executed according to the corresponding variable of the ordinate;
9) And calling a redrawing function to draw a new graph by using the current draw _ start _ point, draw _ start _ point _ y and pic _ size _ time.
10 Define a mouseReleaseEvent event on the canvas, handle a mouse-up event. And judging whether the released mouse key is a left key or not in the event, if so, executing the step 11), and otherwise, not responding.
11 Record the current mouse position (x, y), update Endx = x, endy = y; obtaining draw _ start _ point _ c = draw _ start _ point; and get draw _ start _ point _ y _ c = draw _ start _ point _ y.
12 Call redraw function to draw the new graphics and the new canvas with the current draw _ start _ point, draw _ start _ point _ y, pic _ size _ times.
In some embodiments, the plurality of virtual function keys comprises: a centering key; the third control signal is obtained according to double-click operation of the user on any position on the canvas or selection operation of a centering key; the input parameters corresponding to the third control signal include: coordinates of the operating position; the preset configuration parameters include: the parameter of the canvas, 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; that is, when the user wants to quickly restore the image to the best presentation state (the scaling is proper and the image is located in the center area of the whole canvas), the above S108 can be implemented by the following steps.
S1103, when the coordinates of the operation position belong to a preset coordinate range, acquiring 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.
And S1104, 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 parameter.
S1105, determining a matched drawing starting point and a matched 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.
And S1106, generating a drawing graph according to the data to be drawn by taking the matched drawing starting point as a drawing starting point and the matched scaling factor as the scaling factor of the graph.
Two different principles for quickly restoring a graphic to an optimal presentation state are, for example:
1) And connecting the click signal of the 'centered' button by using a slot function, changing three core parameters of draw _ start _ point, draw _ start _ point _ y and pic _ size _ time in the slot function into a numerical value (preset matching value) which is most matched with the size of the current canvas, and calling a redrawing function to redraw the graph and the canvas.
2) A mousePressEvent event is defined in the canvas. In this event, it is determined whether the user has clicked the right mouse button on the drawing area. If so, changing three core parameters of draw _ start _ point, draw _ start _ point _ y and pic _ size _ time into a numerical value which is most matched with the size of the current canvas, and then calling a redrawing function to redraw the graph and the canvas.
Here, with the "fast centering" function, the image size and position of the original image may have changed after the user has performed a series of drag and zoom operations, and when the user wishes to quickly restore the image to the optimal presentation state (with the proper zoom ratio and the image in the center area of the entire canvas), this effect may be achieved by clicking the "centering" function button, clicking the right mouse button, or double clicking the mouse.
In some embodiments, when the data to be plotted includes multiple sets of data, and the multiple sets of data may be used to plot multiple graphs, each graph corresponding to a graph name, four independent drawing areas may be displayed at a time in a window (drawing page), one graph may be displayed in each drawing area, and four pull-down selection boxes may be simultaneously displayed in the drawing page, the four pull-down selection boxes corresponding to the four independent drawing areas one to one, and when a user selects a graph name through the pull-down selection box corresponding to one drawing area, the QT engine may read a set of data corresponding to the graph name and call a redraw function to plot and display the graph corresponding to the selected graph name in the drawing area; for example, the drawing page is shown in fig. 7.
In some embodiments, when the drawn graph is a curved graph and a fourth control signal of the user for the drawn graph is acquired, the input parameter corresponding to the fourth control signal may be acquired, the drawing area coordinate system where the drawn graph is located may be acquired, and the coordinate data corresponding to the input parameter may be displayed according to the input parameter and the drawing area coordinate system corresponding to the fourth control signal.
Here, when a hovering operation of an input cursor (e.g., a cursor corresponding to a mouse) of the user on the drawn curve graph is acquired, the fourth control signal is acquired, so that an input parameter corresponding to the fourth control signal may be a coordinate of a hovering position of the input cursor of the user, and correspondingly, coordinate data corresponding to the input parameter may be coordinate data on a curve on the drawn curve graph; in this way, a function of selecting a point on the drawn curve graph by the cursor can be realized.
For example, four independent drawing areas may be defined in the window, user data may be read from the user data, loaded into DrawSeries to wait for drawing, coordinate points may be drawn according to the read user data, a coordinate system may be set, and then an optimal curve may be fitted through a fitting algorithm. The four independent drawing areas are respectively controlled by four pull-down selection boxes, a user can select the current DrawIndex through the pull-down selection boxes, whether the DrawIndex is changed or not is judged, if the DrawIndex is changed, user data corresponding to the new DrawIndex is loaded into DrawSeries, and a redrawing function is automatically called to draw a graph; after the graph is drawn, when a user mouse is suspended, the position of the mouse is automatically detected, the absolute position of the mouse is converted into a coordinate system of a drawing area, whether the mouse is suspended on a curve in the drawn graph or not is judged according to the converted coordinate, and if the mouse is suspended on the curve, the coordinates (DrawX and DrawY) of the position of the curve at the suspension position under the coordinate system of the drawing area are displayed.
In some embodiments, an animation key is further displayed on the drawing page, when a user clicks the animation key, a plurality of graphics and a plurality of canvases corresponding to the graphics in a one-to-one correspondence manner can be correspondingly drawn according to data to be drawn and a plurality of groups of preset variable values, where each group 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 plurality of graphics and the corresponding canvases are drawn, the plurality of graphics and the corresponding canvases can be sequentially displayed at preset time intervals, and a graphic and the corresponding canvases are simultaneously displayed each time, so that animation playing of the graphics can be formed.
That is, since one graphics drawing state is controlled by three core variables draw _ start _ point, draw _ start _ point _ y, pic _ size _ time. Therefore, only the three parameters and the data to be drawn need to be provided, so that the drawing of a two-dimensional graph can be completed, and the animation function can be realized by playing the graphs at a fixed frequency, wherein the specific steps are as follows:
1) A timer is defined by using Qtimer, and the starting time and the interval time of the timer are set.
2) And binding the timeout event with the timeout signal timeout of the Qtimer, retransmitting three variables of drawing and drawing data in the timeout function, realizing redrawing of the graphs and the canvas, and executing the step 3) when all graphs are drawn and displayed.
3) The Qtimer timer is stopped.
The invention also provides a user-friendly QT two-dimensional drawing engine, comprising:
the display module is used for displaying a drawing page comprising a plurality of virtual function keys;
the acquisition module is used for acquiring data to be drawn when a data input signal of a user for the drawing page is received;
the drawing module is used for determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable when a drawing signal of a user is received; drawing a current graph in a canvas with a virtual auxiliary tool displayed according to the data to be drawn by taking the initial drawing starting point as a drawing starting point and the initial zooming times as the initial zooming times of the graph, and displaying the current graph;
the first processing module is used for processing the current graph and displaying the processed graph when a first control signal of a user for a first virtual function key is acquired;
the second processing module is used for controlling the opening or closing of the corresponding virtual auxiliary tool on the canvas when a second control signal of the user for a second virtual function key is acquired;
the third processing module is used for acquiring an input parameter corresponding to a third control signal aiming at the canvas and the current graph of a user and acquiring a current value of the preset variable; and regenerating the canvas and redrawing the graph 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 painted, and displaying the regenerated canvas and the redrawing graph.
The invention can lead the functions to be logically unified, and in the actual operation effect, no matter how to drag and zoom, the corresponding relation between the image value and the final image expression effect is kept consistent all the time; the drawing effect is more convenient and faster to change, and the drawing effect can be changed only by modifying and organizing the three core variables according to the drawing logic of the invention; moreover, the method is more convenient when a new function is expanded, and safe and correct function expansion can be realized as long as the correct organization form of the three core parameters is ensured. That is to say, through the drawing method provided by the invention, not only rich functions are provided for users during drawing of the graph, but also some complex functions are concentrated on changing values of three variables through ingenious design without introducing other complicated processes, on one hand, the drawing effect can be changed quickly according to the control signal of the user, the interactivity with the users is improved, on the other hand, the drawing effect consistent with the effect expected by the user can be displayed according to the control signal of the user, the method is more consistent with the intuition of the user, on the other hand, when a new function needs to be expanded for a drawing engine, the method can be realized quickly by changing the values of the three variables, and the expansion of the function is facilitated.
The foregoing is a more detailed description of the invention in connection with specific preferred embodiments and it is not intended that the invention be limited to these specific details. For those skilled in the art to which the invention pertains, numerous simple deductions or substitutions may be made without departing from the spirit of the invention, which shall be deemed to belong to the scope of the invention.

Claims (10)

1. A user-friendly QT two-dimensional mapping method is characterized by comprising the following steps:
displaying a drawing page comprising a plurality of virtual function keys;
when a data input signal of a user aiming at the drawing page is received, acquiring data to be drawn;
when a drawing signal of a user is received, determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable; the preset variables include: a first variable for controlling a distance of a drawing start point from a left boundary of a canvas when drawing in the canvas; a second variable for controlling a distance of a drawing start point from an upper boundary of the canvas when drawing in the canvas; a third variable for controlling a zoom factor of the drawing of the graphic when drawing in the canvas;
drawing a current graph in a canvas of the drawing page, which is displayed with a virtual auxiliary tool, according to the data to be drawn by taking the initial drawing starting point as a drawing starting point and the initial zooming times as the initial zooming times of the graph, and displaying the current graph;
when a first control signal of a user for a first virtual function key is acquired, processing the current graph, and displaying the processed graph;
when a second control signal of the user for a second virtual function key is acquired, controlling the opening or closing of a corresponding virtual auxiliary tool on the canvas;
when a third control signal of a user for the canvas and the current graph is acquired, acquiring an input parameter corresponding to the third control signal and acquiring a current value of the preset variable;
and regenerating the canvas and redrawing the graph 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 painted, and displaying the regenerated canvas and the redrawing graph.
2. The user-friendly QT two-dimensional drawing method according to claim 1, characterized in that said third control signal is obtained according to a user's enlargement operation of said current graph; the input parameters corresponding to the third control signal are: the duration of the amplification operation; the preset configuration parameters include: presetting an interval value, a maximum value and a canvas parameter;
the regenerating the canvas and redrawing the graph 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 painted includes:
when the amplification operation starts, increasing the current value of the third variable by a preset interval value to obtain an Nth time of third variable; n is 1;
when the updated third variable of the nth time is smaller than a preset maximum value, generating a canvas of the nth time based on the updated third variable of the nth time, the current value of the first variable, the current value of the second variable and the canvas parameter, obtaining a drawing starting point of the nth time by adopting the updated third variable of the nth time, the current value of the first variable and the current value of the second variable, and redrawing the graph according to the data to be drawn by taking the drawing starting point of the nth time as a drawing starting point and the updated third variable of the nth time as a scaling multiple of the graph to obtain the graph of the nth time;
increasing the preset interval value for the nth third variable to obtain an N +1 th third variable;
when the third variable of the (N + 1) th time is smaller than the preset maximum value, generating a canvas of the (N + 1) th time based on the third variable of the (N + 1) th time, the current value of the first variable, the current value of the second variable and the canvas parameters, obtaining a drawing starting point of the (N + 1) th time by adopting the third variable of the (N + 1) th time, the current value of the first variable and the current value of the second variable, re-drawing the graph according to the data to be drawn by taking the drawing starting point of the (N + 1) th time as a starting drawing point and the third variable of the (N + 1) th time as a scaling factor of the graph, and obtaining the graph of the (N + 1) th time until the canvas and the graph of the (N + m) th time are obtained when the amplification time is over; m is an integer greater than or equal to 1;
when the third variable of the (N + 1) th time is larger than or equal to the preset maximum value, generating the canvas of the (N + 1) th time based on the preset maximum value, the current value of the first variable, the current value of the second variable and the canvas parameter, obtaining the drawing starting point of the (N + 1) th time by adopting the preset maximum value, the current value of the first variable and the current value of the second variable, re-drawing the graphic according to the data to be drawn by taking the drawing starting point of the (N + 1) th time as a drawing starting point and taking the preset maximum value as a scaling multiple of the graphic, obtaining the graphic of the (N + 1) th time, taking the canvas of the (N + 1) th time as the canvas corresponding to the remaining duration of the amplification operation, and taking the graphic of the (N + 1) th time as the drawing graphic corresponding to the remaining duration.
3. The user-friendly QT two-dimensional drawing method in accordance with claim 2, wherein the canvas parameters include: canvas width, canvas height, pixel distance between adjacent mesh dotted lines; the virtual auxiliary tool is a grid dotted line; generating the canvas for the Nth time 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 parameters, comprising:
determining a coordinate interval value according to the pixel distance and the Nth time third variable;
setting a first cycle, wherein the initial value of the drawing times i in the first cycle is 0, and determining the vertical grid line coordinate of the ith time according to the value of i, the coordinate interval value and the canvas height when the ith drawing is performed;
when the absolute value of the abscissa of the ith vertical grid line coordinate is smaller than the canvas width, drawing a vertical grid line according to the ith vertical grid line coordinate, updating i to i +1, determining the ith +1 vertical grid line coordinate, and ending the first cycle until the absolute value of the abscissa of the ith + a vertical grid line coordinate is larger than the canvas width; a is an integer greater than 1;
setting a second cycle, wherein the initial value of the drawing time j in the second cycle is 0, and determining the transverse grid line coordinate of the jth time according to the value of j, the coordinate interval value and the canvas width when the jth time is drawn;
when the absolute value of the ordinate of the jth horizontal grid line coordinate is smaller than the height of the canvas, drawing a horizontal grid line according to the jth horizontal grid line coordinate, updating j to j +1, determining the jth +1 horizontal grid line coordinate, and ending the second cycle until the absolute value of the ordinate of the jth + b horizontal grid line coordinate is larger than the height of the canvas; b is an integer greater than 1;
and generating the canvas for displaying the Nth time of the grid dotted line according to the drawn vertical grid line and the drawn horizontal grid line.
4. The user-friendly QT two-dimensional drawing method in accordance with claim 2, wherein the canvas parameters include: presetting length, canvas width and canvas height; the virtual auxiliary tool is a coordinatometer displayed on the upper boundary or the left boundary of the canvas; generating the canvas for the Nth time 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 parameters, comprising:
setting a third cycle, wherein an initial value of drawing times i is set to be 0, and when the ith drawing is performed, when the coordinatometer is displayed on the upper boundary of the canvas, determining a first coordinate point of the ith drawing according to the value of i, the current value of the first variable, the third variable of the Nth drawing and the preset length; when the coordinatometer is displayed on the left boundary of the canvas, determining an ith second coordinate point according to the value of i, the current value of the second variable, the Nth third variable and the preset length;
when the absolute value of the abscissa of the ith first coordinate point is smaller than the boundary value of the Nth right cycle, drawing an ith vertical coordinate line according to the ith first coordinate point, then updating i to i +1, drawing the (i + 1) th time, and ending the third cycle until the absolute value of the abscissa of the (i + c) th first coordinate point is larger than the boundary value of the Nth right cycle; c is an integer greater than 1; the boundary value of the Nth right cycle time is determined according to the difference value between the canvas width and the boundary value of the Nth left cycle time and the Nth third variable; the Nth left cycle time boundary value is the current value of the first variable; when the absolute value of the ordinate of the ith second coordinate point is smaller than the boundary value of the Nth lower cycle time, drawing an ith abscissa line according to the ith second coordinate point; then, updating i to i +1, and drawing for the (i + 1) th time 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 next cycle time of the Nth time, and ending the third cycle; the boundary value of the Nth lower cycle time is determined according to the difference value between the canvas height and the boundary value of the Nth upper cycle time and the Nth third variable; the boundary value of the Nth upper cycle time is the current value of the second variable;
setting a fourth cycle, setting an initial value of drawing times j as 0 in the fourth cycle, and when the jth drawing is performed, and when the coordinatometer is displayed on the upper boundary of the canvas, determining a first coordinate point of the jth time 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 coordinatometer is displayed on the left boundary of the canvas, determining a second coordinate point of the jth time according to the value of j, the current value of the second variable, the third variable of the Nth time and the preset length;
when the absolute value of the abscissa of the jth first coordinate point is smaller than the Nth left cycle boundary value, drawing a jth vertical coordinate line according to the jth first coordinate point, then updating j to j +1, and drawing the jth +1 time until the absolute value of the abscissa of the jth first coordinate point is larger than the Nth left cycle boundary value, and ending the fourth cycle; when the absolute value of the ordinate of the jth second coordinate point is smaller than the boundary value of the Nth upper cycle number, drawing a jth abscissa line according to the jth second coordinate point; and then updating j to j +1, and drawing for the (j + 1) th time until the absolute value of the ordinate of the second coordinate point of the (j + c) th time is greater than the boundary value of the upper cycle time of the Nth time, and ending the fourth cycle.
5. The user-friendly QT two-dimensional mapping method of claim 2, wherein the third control signal is derived from a user's zoom-in operation on the current graph at a touch location; the input parameters corresponding to the third control signal are: coordinates of the touch position and duration of the amplification operation; the preset configuration parameters include: presetting an interval value, a maximum value and a canvas parameter;
the regenerating the canvas and redrawing the graph 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 painted includes:
when the coordinates of the touch position are obtained, determining the coordinates of the current drawing starting point 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 transverse distance data difference and a longitudinal distance data difference according to the coordinate of the touch position, the coordinate of the current drawing starting point and the current value of the third variable;
when the amplification operation starts, increasing a preset interval value to the current value of the third variable to obtain an Mth time third variable, and when the Nth time updated third variable is smaller than the preset maximum value, generating an Mth time canvas based on the Mth time third variable, the current value of the first variable, the current value of the second variable and the canvas parameter; m is 1;
determining a drawing starting point of the Mth time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the third variable of the Mth time, and redrawing the graph according to the data to be drawn by taking the drawing starting point of the Mth time as a drawing starting point and the third variable of the Mth time as a scaling multiple of the graph to obtain the graph of the Mth time;
increasing the preset interval value for the Mth time third variable to obtain an M +1 th time third variable, and generating an M +1 th time canvas based on the M +1 th time third variable, the current value of the first variable, the current value of the second variable and the canvas parameter when the M +1 th time third variable is smaller than the preset maximum value;
determining a drawing starting point of the M +1 th time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the third variable of the M +1 th time, and redrawing the graph according to the data to be drawn by taking the drawing starting point of the M +1 th time as a drawing starting point and the third variable of the M +1 th time as a scaling multiple of the graph to obtain the graph of the M +1 th time until the enlargement time is finished to obtain the canvas and the graph of the M + n th time; n is an integer greater than or equal to 1;
when the third variable of the M +1 th time is larger than or equal to the preset maximum value, generating the canvas of the M +1 th time based on the preset maximum value, the current value of the first variable, the current value of the second variable and the canvas parameter;
determining a drawing starting point of the M +1 th time according to the coordinate of the touch position, the transverse distance data difference, the longitudinal distance data difference and the preset maximum value, redrawing the graph according to the data to be drawn by taking the drawing starting point of the M +1 th time as a drawing starting point and the preset maximum value as a zooming multiple of the graph, obtaining the graph of the M +1 th time, taking the canvas of the M +1 th time as a canvas corresponding to the remaining duration of the amplification operation, and taking the graph of the M +1 th time as a drawing graph corresponding to the remaining duration.
6. The user-friendly QT two-dimensional mapping method of claim 1, wherein the third control signal is derived from a drag operation of the user on the current graph; the input parameters corresponding to the third control signal are: coordinates of a dragging start point and coordinates of each dragging point in the dragging process; the preset configuration parameters include: canvas parameters;
the regenerating the canvas and redrawing the graph 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 painted includes:
in the dragging process, obtaining the dragging direction of the ith point according to the coordinate of the ith dragging point and the coordinate of the dragging starting point; i is 1;
obtaining the ith variable and the ith 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 coordinate of the ith dragging point and the coordinate of the dragging starting point;
determining a drawing starting point and a scaling factor of the ith time according to the current values of the first variable, the second variable and the third variable of the ith time;
generating the canvas of the ith time based on the first variable of the ith time, the second variable of the ith time, the current value of the third variable and the canvas parameters;
generating an ith drawing graph according to the data to be drawn by taking the drawing starting point of the ith drawing as a starting drawing point and taking the scaling factor as the scaling factor of the graph;
obtaining the dragging direction of the (i + 1) th point according to the coordinates of the (i + 1) th dragging point and the coordinates of the (i) th dragging point;
when the dragging direction of the (i + 1) th point is the same as that of the ith point, obtaining a first variable of the (i + 1) th time and a second variable of the (i + 1) th time according to the first variable of the ith time, the second variable of the ith time, the current value of the third variable, the coordinate of the (i + 1) th dragging point and the coordinate of the dragging starting point; when the dragging direction of the (i + 1) th point is opposite to that of the ith point, obtaining a first variable of the (i + 1) th time and a second variable of the (i + 1) th time according to the first variable of the ith time, the second variable of the ith time, the current value of the third variable, the coordinate of the (i + 1) th dragging point and the coordinate of the ith dragging point;
respectively generating a canvas of the (i + 1) th time and a drawing graph of the (i + 1) th time based on the obtained current values of the first variable of the (i + 1) th time, the second variable of the (i + 1) th time and the third variable;
and obtaining the dragging direction of the (i + 2) th point according to the coordinates of the (i + 2) th dragging point and the coordinates of the (i + 1) th dragging point until generating a canvas and a drawing graph corresponding to the last dragging point in the dragging process.
7. The user-friendly QT two-dimensional drawing method according to claim 1, wherein the plurality of virtual function keys comprise: a centering key; the third control signal is obtained according to the clicking operation of a user on any position on the canvas or the selection operation of the centering key; the input parameters corresponding to the third control signal include: coordinates of the operating position; the preset configuration parameters include: the canvas parameter, 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;
the regenerating the canvas and redrawing the graph 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 belong to a preset coordinate range, acquiring 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 parameter;
determining a matched drawing starting point and a matched zooming multiple 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;
and generating a drawing graph according to the data to be drawn by taking the matched drawing starting point as a drawing starting point and the matched scaling times as the scaling times of the graph.
8. The user-friendly QT two-dimensional mapping method of claim 1, wherein the second virtual function key is a cross-reading auxiliary ruler key or a grid background key; when a second control signal of the user for the second virtual function key is acquired, controlling the corresponding virtual auxiliary tool to be opened or closed includes:
when the second virtual function key is a cross reading auxiliary ruler key and the second control signal is obtained, acquiring the abscissa and the ordinate of the current click position of the user;
drawing a vertical line according to the abscissa and the height of the canvas, and drawing a horizontal line according to the ordinate and the width of the canvas to obtain a cross reading auxiliary ruler taking the current click position as a central point;
when the second virtual function key is a grid background key and the second control signal is acquired, acquiring the display state of a grid dotted line on the current canvas, and hiding the grid dotted line when the display state is displayed; and when the display state is not displayed, obtaining the value of a third variable at the current moment, and drawing and displaying the grid dotted lines according to the value of the third variable, the width of the canvas, the height of the canvas and the pixel distance between adjacent grid dotted lines.
9. The user-friendly QT two-dimensional mapping method according to claim 1, characterized in that said method further comprises:
when a fourth control signal of a user for a drawn graph is acquired, acquiring an input parameter corresponding to the fourth control signal, and acquiring a drawing area coordinate system where the drawn graph is located;
and displaying coordinate data corresponding to the input parameters according to the input parameters corresponding to the fourth control signals and the drawing area coordinate system.
10. A user-friendly QT two-dimensional drawing engine, comprising:
the display module is used for displaying a drawing page comprising a plurality of virtual function keys;
the acquisition module is used for acquiring data to be drawn when a data input signal aiming at the drawing page by a user is received;
the drawing module is used for determining an initial drawing starting point and an initial zooming multiple according to a preset value of a preset variable when a drawing signal of a user is received; drawing a current graph in a canvas of the drawing page, which is displayed with a virtual auxiliary tool, according to the data to be drawn by taking the initial drawing starting point as a drawing starting point and the initial zooming times as the initial zooming times of the graph, and displaying the current graph;
the first processing module is used for processing the current graph and displaying the processed graph when a first control signal of a user for a first virtual function key is acquired;
the second processing module is used for controlling the opening or closing of the corresponding virtual auxiliary tool on the canvas when a second control signal of the user for a second virtual function key is acquired;
the third processing module is used for acquiring an input parameter corresponding to a third control signal aiming at the canvas and the current graph of a user and acquiring a current value of the preset variable; and regenerating the canvas and redrawing the graph 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 painted, and displaying the regenerated canvas and the redrawing graph.
CN202211591792.5A 2022-12-12 2022-12-12 User-friendly QT two-dimensional drawing method and engine Pending CN115830186A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211591792.5A CN115830186A (en) 2022-12-12 2022-12-12 User-friendly QT two-dimensional drawing method and engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211591792.5A CN115830186A (en) 2022-12-12 2022-12-12 User-friendly QT two-dimensional drawing method and engine

Publications (1)

Publication Number Publication Date
CN115830186A true CN115830186A (en) 2023-03-21

Family

ID=85546616

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211591792.5A Pending CN115830186A (en) 2022-12-12 2022-12-12 User-friendly QT two-dimensional drawing method and engine

Country Status (1)

Country Link
CN (1) CN115830186A (en)

Similar Documents

Publication Publication Date Title
EP1958056B1 (en) A method of tracking data objects using related thumbnails in a palette window
US6590577B1 (en) System and method for controlling a dynamic display of data relationships between static charts
EP0635808B1 (en) Method and apparatus for operating on the model data structure on an image to produce human perceptible output in the context of the image
EP2990924B1 (en) Gesture-based on-chart data filtering
US4686522A (en) Method of editing graphic objects in an interactive draw graphic system using implicit editing actions
US6157381A (en) Computer system, user interface component and method utilizing non-linear scroll bar
KR101794373B1 (en) Temporary formatting and charting of selected data
US10983695B2 (en) Focus management system
EP0636971A2 (en) Method and apparatus for producing a composite second image in the spatial context of a first image
US11061529B2 (en) Generating contextual guides
JP2501293B2 (en) Method and system for displaying pressure on input device
WO2020042378A1 (en) Control bar display method, apparatus and device for electronic whiteboard, and storage medium
JP3705826B2 (en) Virtual three-dimensional window display control method
US20050179705A1 (en) Navigation within a large computer file
JP2011128962A (en) Information processing apparatus and method, and computer program
KR100246862B1 (en) Method and editing system for setting tool button
Perlin et al. Nested user interface components
WO2022144649A1 (en) Time lapse video generation by re-executing user instructions in a graphics vector application
US6404434B1 (en) Curve generating apparatus and method, storage medium storing curve generating program, and method of setting associate points
US20030222925A1 (en) Field control method and system
JP3369734B2 (en) Three-dimensional computer-aided design apparatus and method
CN110286827B (en) Element scaling control method, device, equipment and storage medium
CN115830186A (en) User-friendly QT two-dimensional drawing method and engine
US6469702B1 (en) Method and system for editing function curves in two dimensions
JPH0652278A (en) Data processing system and value selecting method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination