A method, device and electronic equipment for adjusting graphic position
By monitoring and automatically adjusting the position of graphics, it solves the tedious and inaccurate problem of manually adjusting a circle to a tangent state, and realizes the function of automatically adjusting two graphics to a tangent state, improving operating efficiency and accuracy.
Patent Information
- Application Number
- CN201910236431.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-03-27
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2039-03-27
AI Technical Summary
When using office software or drawing software, adjusting two circles to a tangent state requires manual operation, which is cumbersome and time-consuming, and the accuracy of human judgment is not high.
By monitoring the graphic selection event, it is determined that the currently selected graphic is a circle, its position coordinates are determined, and the position of the currently selected graphic is automatically adjusted based on the position coordinates and radius of the target circle so that it is tangent to the target circle.
It simplifies manual adjustment operations, improves the accuracy and efficiency of graphic position adjustment, and realizes the function of automatically adjusting two graphics to a tangent state.
Smart Images

Figure CN111752646B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of position adjustment, and in particular to a method, device and electronic equipment for adjusting the position of a graphic. Background Art
[0002] Currently, when using office software such as Microsoft Office or WPS and drawing software, when moving a circle to fit closely to the edge of another circle, that is, adjusting the two circles to be tangent, the user needs to manually adjust the position of the circle and manually determine whether the position to which the circle is adjusted is the final position to make the circle tangent to the other circle; based on the manual determination result and operation, the circle is adjusted to the final state.
[0003] During the above adjustment process, the user manually adjusts the position of the circle, which is cumbersome and time-consuming. In addition, the user manually determines whether the position to which the circle is adjusted is the final position where the circle is tangent to another circle, which is not accurate. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a method, device and electronic device for adjusting the position of a graphic, so as to automatically adjust the position of the graphic to a position where the graphic is tangent to another graphic, simplify the manual adjustment operation and improve the accuracy. The specific technical solution is as follows:
[0005] In one aspect, an embodiment of the present invention provides a method for adjusting a position of a graphic, the method comprising:
[0006] If it is detected that a graphic selection event is triggered, determining whether the currently selected graphic corresponding to the graphic selection event is a circle;
[0007] If it is determined that the currently selected graphic is a circle, monitoring a moving operation on the currently selected graphic, and determining the current position coordinates of the currently selected graphic according to the moving operation;
[0008] Based on the current position coordinates and the position coordinates of other graphics, determine from the other graphics a target circle whose distance from the currently selected graphic is within a preset distance range;
[0009] Obtaining the radius of the currently selected graphic and the radius of the target circle;
[0010] Based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, the position of the currently selected graphic is adjusted to the target position, wherein the target position is: a position where the currently selected graphic and the target circle are in a tangent state.
[0011] Optionally, before the step of determining whether the currently selected graphic corresponding to the graphic selection event is a circle, the method further includes:
[0012] Determine whether the preset replacement button is in a non-trigger state;
[0013] If it is determined whether the preset replacement button is in a non-trigger state, the step of determining whether the currently selected graphic corresponding to the graphic selection event is a circle is performed.
[0014] Optionally, the step of determining, from the other graphics, a target circle whose distance from the currently selected graphic is within a preset distance range based on the current position coordinates and the position coordinates of the other graphics, comprises:
[0015] From other figures, a circle is determined as an alternative circle;
[0016] Based on the current position coordinates and the position coordinates of the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range is determined from the candidate circles.
[0017] Optionally, the step of determining, from the candidate circles, a target circle whose distance to the currently selected graphic is within a preset distance range based on the current position coordinates and the position coordinates of the candidate circles comprises:
[0018] Based on the current position coordinates and the position coordinates of the candidate circles, calculating the center distance between the center of the currently selected graphic and the center of each candidate circle;
[0019] Obtaining the radius of the currently selected graphic and the radius of each candidate circle;
[0020] For each candidate circle, the sum of the radius of the candidate circle and the radius of the currently selected figure is calculated as a first sum; and the difference between the center distance of the candidate circle and the first sum is calculated as the distance between the candidate circle and the currently selected figure;
[0021] For each candidate circle, determining whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range;
[0022] If it is determined that the distance between the candidate circle and the currently selected graphic is within the preset distance range, the candidate circle is determined to be the first candidate circle;
[0023] From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
[0024] Optionally, the current position coordinates include: a first horizontal axis coordinate value of the center of the currently selected figure under a preset horizontal axis and a first vertical axis coordinate value under a preset vertical axis; the position coordinates of the target circle include: a second horizontal axis coordinate value of the center of the target circle under the preset horizontal axis and a second vertical axis coordinate value under the preset vertical axis;
[0025] The step of adjusting the position of the currently selected graphic to the target position based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle comprises:
[0026] Determine a center relative angle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value;
[0027] Determine the target circle center longitudinal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the circle center relative angle, and the second longitudinal axis coordinate value;
[0028] Determine the target circle center horizontal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the center relative angle and the second horizontal axis coordinate value;
[0029] Based on the target circle center longitudinal axis coordinate value, the target circle center transverse axis coordinate value and the radius of the currently selected graphic, the position of the currently selected graphic is adjusted to the target position.
[0030] Optionally, the step of determining the relative angle of the center of the circle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value adopts the formula:
[0031]
[0032] Wherein, D represents the relative angle of the center of the circle, and x 1 represents the first horizontal axis coordinate value, the x 2 represents the second horizontal axis coordinate value, the y 1 represents the first vertical axis coordinate value, the y 2 represents the second vertical axis coordinate value;
[0033] The step of determining the target circle center longitudinal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the center relative angle and the second longitudinal axis coordinate value adopts the formula:
[0034] y 目标 =(r 1 +r2 )*inD+y 2
[0035] Among them, the y 目标 represents the vertical axis coordinate value of the target circle center, and the r 1 Indicates the radius of the currently selected graphic, the r 2 represents the radius of the target circle;
[0036] The step of determining the horizontal axis coordinate value of the target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value adopts the formula:
[0037] x 目标 =(r 1 +r 2 )*osD+x 2
[0038] Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
[0039] On the other hand, an embodiment of the present invention provides a graphic position adjustment device, the device comprising:
[0040] A first judgment module is used to judge whether the currently selected graphic corresponding to the graphic selection event is a circle if a graphic selection event is detected to be triggered;
[0041] A monitoring and determining module, for monitoring a moving operation on the currently selected graphic if it is determined that the currently selected graphic is a circle, and determining the current position coordinates of the currently selected graphic according to the moving operation;
[0042] A determination module, configured to determine, based on the current position coordinates and the position coordinates of other graphics, a target circle whose distance from the currently selected graphic is within a preset distance range from the other graphics;
[0043] An acquisition module, used to obtain the radius of the currently selected graphic and the radius of the target circle;
[0044] An adjustment module is used to adjust the position of the currently selected graphic to a target position based on the current position coordinates and the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, wherein the target position is a position where the currently selected graphic is in a tangent state with the target circle.
[0045] Optionally, the device further comprises:
[0046] A second judgment module is used to judge whether the preset replacement button is in a non-trigger state before judging whether the currently selected graphic corresponding to the graphic selection event is a circle;
[0047] If it is determined whether the preset replacement button is in a non-trigger state, the first determination module is triggered.
[0048] Optionally, the determining module includes:
[0049] The first determination unit, the user determines a circle from other graphics as an alternative circle
[0050] The second determining unit is used to determine, from the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range based on the current position coordinates and the position coordinates of the candidate circles.
[0051] Optionally, the second determining unit is specifically configured to:
[0052] Based on the current position coordinates and the position coordinates of the candidate circles, calculating the center distance between the center of the currently selected graphic and the center of each candidate circle;
[0053] Obtaining the radius of the currently selected graphic and the radius of each candidate circle;
[0054] For each candidate circle, the sum of the radius of the candidate circle and the radius of the currently selected figure is calculated as a first sum; and the difference between the center distance of the candidate circle and the first sum is calculated as the distance between the candidate circle and the currently selected figure;
[0055] For each candidate circle, determining whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range;
[0056] If it is determined that the distance between the candidate circle and the currently selected graphic is within the preset distance range, the candidate circle is determined to be the first candidate circle;
[0057] From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
[0058] Optionally, the current position coordinates include: a first horizontal axis coordinate value of the center of the currently selected figure under a preset horizontal axis and a first vertical axis coordinate value under a preset vertical axis; the position coordinates of the target circle include: a second horizontal axis coordinate value of the center of the target circle under the preset horizontal axis and a second vertical axis coordinate value under the preset vertical axis;
[0059] The adjustment module comprises:
[0060] a third determining unit, configured to determine a center relative angle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value;
[0061] a fourth determining unit, configured to determine a vertical axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second vertical axis coordinate value;
[0062] a fifth determining unit, configured to determine a horizontal axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value;
[0063] The adjustment unit is used to adjust the position of the currently selected graphic to the target position based on the vertical axis coordinate value of the target circle center, the horizontal axis coordinate value of the target circle center and the radius of the currently selected graphic.
[0064] Optionally, the third determining unit adopts the formula:
[0065]
[0066] Wherein, D represents the relative angle of the center of the circle, and x 1 represents the first horizontal axis coordinate value, the x 2 represents the second horizontal axis coordinate value, the y 1 represents the first vertical axis coordinate value, the y 2 represents the second vertical axis coordinate value;
[0067] The fourth determination unit adopts the formula:
[0068] y 目标 =(r 1 +r 2 )*sinD+y 2
[0069] Among them, the y 目标 represents the vertical axis coordinate value of the target circle center, and the r 1 Indicates the radius of the currently selected graphic, the r 2 represents the radius of the target circle;
[0070] The fifth determination unit adopts the formula:
[0071] x 目标 =(r 1 +r 2 )*cosD+x 2
[0072] Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
[0073] On the other hand, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0074] Memory, used to store computer programs;
[0075] The processor is used to implement any of the above-mentioned steps of the graphic position adjustment method provided by the embodiment of the present invention when executing the computer program stored in the memory.
[0076] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned steps of the method for adjusting the position of the graphics provided by the embodiment of the present invention is implemented.
[0077] The technical solution provided by the embodiment of the present invention is as follows: if it is monitored that a graphic selection event is triggered, it is determined whether the currently selected graphic corresponding to the graphic selection event is a circle; if it is determined that the currently selected graphic is a circle, the moving operation on the currently selected graphic is monitored, and according to the moving operation, the current position coordinates of the currently selected graphic are determined; the radius of the currently selected graphic and the radius of the target circle are obtained; based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, a target circle whose distance from the currently selected graphic is within a preset distance range is determined from other graphics, wherein the other graphics are graphics other than the currently selected graphic contained in the current page; based on the current position coordinates and the position coordinates of the target circle, the position of the currently selected graphic is adjusted to the target position, wherein the target position is a position that makes the currently selected graphic and the target circle in a tangent state.
[0078] In an embodiment of the present invention, when it is detected that a graphic selection event is triggered and it is determined that the currently selected graphic corresponding to the graphic selection event is a circle, the target circle can be automatically matched based on the current position coordinates of the currently selected graphic and the position coordinates of other graphics in the current page, and the position of the currently selected graphic is automatically adjusted to the target position where the currently selected graphic and the target circle are in a tangent state based on the current position coordinates of the currently selected graphic, the position coordinates of the target circle, the radius of the currently selected graphic, and the radius of the target circle, so as to automatically adjust the graphic position to a position where the graphic is in a tangent state with another graphic, simplify the manual adjustment operation, improve the accuracy, and improve the adjustment efficiency of adjusting the graphic to be in a tangent state with another graphic. Of course, any product or method implementing the present invention does not necessarily need to achieve all the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0079] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0080] Figure 1A A schematic diagram of a flow chart of a method for adjusting a graphic position provided by an embodiment of the present invention;
[0081] Figure 1B A schematic diagram of the positions of preset calibration points corresponding to the circle;
[0082] Figure 2 Another schematic diagram of a flow chart of a method for adjusting a graphic position provided by an embodiment of the present invention;
[0083] Figure 3 is a flow chart of an implementation method of S105 shown in FIG1 ;
[0084] Figure 4 A schematic diagram of the structure of a graphic position adjustment device provided by an embodiment of the present invention;
[0085] Figure 5 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0086] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0087] The embodiments of the present invention provide a method, device and electronic device for adjusting the position of a graphic, so as to automatically adjust the position of the graphic to a position where the graphic is tangent to another graphic, simplify the manual adjustment operation and improve the accuracy.
[0088] like Figure 1A As shown, an embodiment of the present invention provides a method for adjusting a graphic position, which may include the following steps:
[0089] S101: If it is detected that a graphic selection event is triggered, determine whether the currently selected graphic corresponding to the graphic selection event is a circle;
[0090] It is understandable that the graphic position adjustment method provided in the embodiment of the present invention can be applied to any type of electronic device, which can be a computer, a smart phone, etc. In one case, the functional software for implementing the graphic position adjustment method provided in the embodiment of the present invention can exist in the form of a dedicated client software, or in the form of a plug-in of currently existing client software, for example, it can be: client software with a drawing function or a graphic inserting function, and such client software with a drawing function or a graphic inserting function can include but is not limited to office software such as Microsoft Office and WPS and dedicated drawing software.
[0091] In an embodiment of the present invention, the electronic device can monitor in real time whether a graphic selection event is triggered. If it is detected that the graphic selection event is triggered, it determines whether the currently selected graphic corresponding to the graphic selection event is a circle. If it is a circle, the subsequent graphic position adjustment process is executed.
[0092] In one case, the way in which an electronic device monitors whether a graphic selection event is triggered may be: the electronic device detects whether an object selection event is triggered, wherein the object selection event corresponds to parameter information of a selected object, and the parameter information is information used to describe the object, and the parameter information includes information such as object identification, object type, and object size; the electronic device determines whether the object is a graphic based on the parameter information of the selected object corresponding to the object selection event, and if it is determined that the object is a graphic, it is determined that the graphic selection event is monitored to be triggered.
[0093] Among them, the above process of judging whether the object is a graphic based on the parameter information of the selected object carried by the object selection event may be to judge whether the object type of the selected object carried by the object selection event is a preset graphic type; if so, the object is judged to be a graphic.
[0094] In the above process of determining whether the currently selected graphic corresponding to the graphic selection event is a circle, one case may be: the parameter information of the selected object corresponding to the object selection event may also carry the shape information of the graphic, and the electronic device may determine whether the currently selected graphic corresponding to the graphic selection event is a circle based on the shape information of the graphic. Another case may be: determining whether the currently selected graphic is a circle by using the Hough transform circle detection algorithm.
[0095] In one implementation, the way in which an object selection event is triggered may include: a user performs a predetermined operation on the current page of the electronic device through a mouse, stylus, or finger, and after the electronic device detects the predetermined operation, it determines that the object selection event is triggered, wherein the predetermined operation may include but is not limited to long pressing, clicking, or sliding.
[0096] S102: If it is determined that the currently selected graphic is a circle, monitoring a moving operation on the currently selected graphic, and determining the current position coordinates of the currently selected graphic according to the moving operation;
[0097] In one implementation, a user can select the currently selected graphic with a mouse, stylus or finger, and control the previously selected graphic to move. If the electronic device determines that the currently selected graphic is a circle, it can monitor the movement operation on the currently selected graphic in real time, and determine the current position coordinates of the currently selected graphic based on the movement operation in real time; it can also monitor the movement operation on the currently selected graphic in real time, and when it is detected that the position of the currently selected graphic has not changed within a predetermined time period, determine the current position coordinates of the currently selected graphic based on the movement operation. At this time, only the position coordinates of the currently selected graphic when it has not changed within the predetermined time period can be determined.
[0098] In one case, when the user selects the currently selected graphic with the mouse and controls the movement of the currently selected graphic by controlling the movement of the mouse. After the electronic device determines that the currently selected graphic is a circle, it can monitor the movement operation of the currently selected graphic by monitoring the mouse movement event. It can be understood that the movement operation can characterize the movement trajectory of the currently selected graphic, and then the electronic device can determine the current position coordinates of the currently selected graphic through the movement trajectory of the currently selected graphic represented by the movement operation. Among them, the electronic device can monitor the movement operation of the currently selected graphic in real time, and determine the current position coordinates of the currently selected graphic based on the movement operation in real time; it can also be that the electronic device monitors the movement operation of the currently selected graphic in real time, and when it is detected that the position of the currently selected graphic has not changed within a predetermined time length, it determines the current position coordinates of the currently selected graphic based on the movement operation, and at this time, only the position coordinates of the currently selected graphic that has not changed within the predetermined time length can be determined.
[0099] In one case, the current position coordinates of the center of the currently selected graphic can be used to represent the current position coordinates of the currently selected graphic. In one implementation, when determining the current position coordinates of the currently selected graphic, the position coordinates of a preset calibration point corresponding to the currently selected graphic can be first obtained, and then based on the position coordinates of the preset calibration point and the radius of the currently selected graphic, the current position coordinates of the center of the currently selected graphic are determined.
[0100] The preset calibration point may be: the intersection of the left vertical tangent and the upper vertical tangent of the currently selected graphic, such as Figure 1B As shown; or it can be: the intersection of the left vertical tangent and the lower vertical tangent of the currently selected figure; or it can be: the intersection of the right vertical tangent and the lower vertical tangent of the currently selected figure; or it can be: the intersection of the right vertical tangent and the upper vertical tangent of the currently selected figure.
[0101] Correspondingly, when the preset calibration point is: the intersection of the left vertical tangent and the upper vertical tangent of the currently selected figure, the first horizontal axis coordinate value in the current position coordinate of the currently selected figure = the horizontal axis coordinate value of the preset calibration point + the radius of the currently selected figure; the first vertical axis coordinate value in the current position coordinate of the currently selected figure = the horizontal axis coordinate value of the preset calibration point + the radius of the currently selected figure. When the preset calibration point is: the intersection of the left vertical tangent and the lower vertical tangent of the currently selected figure, the first horizontal axis coordinate value in the current position coordinate of the currently selected figure = the horizontal axis coordinate value of the preset calibration point + the radius of the currently selected figure; the first vertical axis coordinate value in the current position coordinate of the currently selected figure = the horizontal axis coordinate value of the preset calibration point - the radius of the currently selected figure. When the preset calibration point is: the intersection of the right vertical tangent and the lower vertical tangent of the currently selected figure, the first horizontal axis coordinate value in the current position coordinates of the currently selected figure = the horizontal axis coordinate value of the preset calibration point - the radius of the currently selected figure; the first vertical axis coordinate value in the current position coordinates of the currently selected figure = the horizontal axis coordinate value of the preset calibration point - the radius of the currently selected figure. When the preset calibration point is: the intersection of the right vertical tangent and the upper vertical tangent of the currently selected figure, the first horizontal axis coordinate value in the current position coordinates of the currently selected figure = the horizontal axis coordinate value of the preset calibration point - the radius of the currently selected figure; the first vertical axis coordinate value in the current position coordinates of the currently selected figure = the horizontal axis coordinate value of the preset calibration point + the radius of the currently selected figure.
[0102] In another case, the current position coordinates of the currently selected graphic may be represented by the position coordinates of the preset calibration point corresponding to the currently selected graphic, which is also possible.
[0103] S103: Based on the current position coordinates and the position coordinates of other graphics, determine from other graphics a target circle whose distance from the currently selected graphic is within a preset distance range;
[0104] Among them, the other graphics are: the graphics contained in the current page except the currently selected graphics; the current page can refer to the current display page of the electronic device, or a drawing page created by drawing software, or a page in an open text document, or all pages in an open text document, all of which are possible.
[0105] It is understandable that when the user adjusts the position of the graphics, there may be a need to adjust the positional relationship between the graphics. In one case, there may be one or more other graphics in the current page where the currently selected graphic is located. The other graphics are: graphics contained in the current page other than the currently selected graphic. When the user adjusts the positional relationship between the graphics, the currently selected graphic can first be moved to a position near another graphic whose positional relationship between the graphics needs to be adjusted. Then, the electronic device can determine the target circle corresponding to the currently selected graphic from the other graphics based on the distance between each other graphic and the currently selected graphic. In view of this, the electronic device can first obtain the position coordinates of other graphics, and then calculate the distance between the currently selected graphic and other graphics based on the current position coordinates and the position coordinates of other graphics. Then, based on the calculated distance, from other graphics, determine the target circle whose distance to the currently selected graphic is within the preset distance range, that is, determine the target circle corresponding to the currently selected graphic, and the target circle is: the graphic whose positional relationship with the currently selected graphic is adjusted.
[0106] Among them, it is inevitable that there are multiple other graphics whose distances to the currently selected graphic are within the preset distance range. For this situation, one implementation is that the electronic device randomly selects one other graphic as the target circle from the multiple other graphics whose distances to the currently selected graphic are within the preset distance range. Another implementation is that, considering the user's operating habits, the currently selected graphic is generally moved to a position where the distance to the desired graphic is closer to other graphics. In order to ensure the user's experience and to improve the accuracy of the target circle of the currently selected graphic to a certain extent, the electronic device determines the other graphics closest to the currently selected graphic from the multiple other graphics whose distances to the currently selected graphic are within the preset distance range as the target circle. Among them, the above-mentioned desired graphic is: the other graphic other than the currently selected graphic among the two graphics whose positional relationship between the graphics needs to be adjusted by the user.
[0107] In one case, the electronic device may first determine the other graphics before obtaining the position coordinates of the other graphics. The process of determining the other graphics may be: the electronic device traverses each graphic in the current page, and then, for each graphic, determines whether the graphic is not the currently selected graphic. When it is determined that the graphic is not the currently selected graphic, it is determined that the graphic is other graphics.
[0108] Subsequently, after determining other graphics, the position coordinates of the other graphics are obtained, wherein the position coordinates of each graphic in the current page are pre-stored in a local or connected storage device of the electronic device. After determining other graphics, the electronic device can directly obtain the position coordinates of the other graphics from the corresponding storage location in the local or connected storage device.
[0109] S104: Obtain the radius of the currently selected graphic and the radius of the target circle;
[0110] It is understandable that the width or height of the currently selected graphic and the width or height of the target circle can be stored in the local or connected storage device of the electronic device, wherein the currently selected graphic is a circle, the width and height of the currently selected graphic are equal, and the width and height of the target circle are equal. The process of the electronic device obtaining the radius of the currently selected graphic and the radius of the target circle can be: the electronic device obtains the width or height of the currently selected graphic, and uses half of the width or height of the currently selected graphic as the radius of the currently selected graphic; and obtains the width or height of the target circle, and uses half of the width or height of the target circle as the radius of the target circle.
[0111] S105: adjusting the position of the currently selected graphic to the target position based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic, and the radius of the target circle;
[0112] The target position is the position where the currently selected graphic is tangent to the target circle.
[0113] In this step, the current position relationship between the currently selected graphic and the target circle can be determined through the current position coordinates of the currently selected graphic and the position coordinates of the target circle. Then, based on the current position relationship, the radius of the currently selected graphic, the radius of the target circle and the position coordinates of the target circle, the position at which the currently selected graphic and the target circle are in a tangent state can be directly determined as the target position. Then, the electronic device can directly adjust the currently selected graphic from the position represented by the current position coordinates to the target position.
[0114] In an embodiment of the present invention, when it is monitored that a graphic selection event is triggered and it is determined that the currently selected graphic corresponding to the graphic selection event is a circle, the target circle can be automatically matched based on the current position coordinates of the currently selected graphic and the position coordinates of other graphics, and the position of the currently selected graphic can be automatically adjusted to the target position where the currently selected graphic and the target circle are in a tangent state based on the current position coordinates of the currently selected graphic, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, thereby automatically adjusting the graphic position to a position where the graphic is in a tangent state with another graphic, simplifying manual adjustment operations, improving accuracy, and improving the adjustment efficiency of adjusting the graphic to be in a tangent state with another graphic.
[0115] Considering the user's usage habits, a function switch can be set for the graphic position adjustment process. When the user has a need, the function switch corresponding to the graphic position adjustment process can be turned on. Then, when the electronic device detects that the function switch is turned on, the graphic position adjustment process provided by the embodiment of the present invention can be executed; when the user has no need, the function switch corresponding to the graphic position adjustment process can be turned off. When the electronic device detects that the function switch is not turned on, the graphic position adjustment process provided by the embodiment of the present invention is not executed. In one implementation, Figure 2 As shown, the method may include the following steps:
[0116] S201: If it is detected that the graphic selection event is triggered, determine whether the preset replacement button is in a non-triggered state; if it is determined that the preset replacement button is in a non-triggered state, execute S202;
[0117] S202: Determine whether the currently selected graphic corresponding to the graphic selection event is a circle;
[0118] S203: If it is determined that the currently selected graphic is a circle, monitoring a moving operation on the currently selected graphic, and determining the current position coordinates of the currently selected graphic according to the moving operation;
[0119] S204: Based on the current position coordinates and the position coordinates of other graphics, determine from other graphics a target circle whose distance from the currently selected graphic is within a preset distance range;
[0120] The other graphics are: graphics contained in the current page except the currently selected graphics;
[0121] S205: Obtain the radius of the currently selected graphic and the radius of the target circle;
[0122] S206: Based on the current position coordinates and the position coordinates of the target circle, the position of the currently selected graphic is adjusted to the target position;
[0123] The target position is the position where the currently selected graphic is tangent to the target circle.
[0124] Among them, the S201 is the same as S101 shown in FIG. 1 , the S203 is the same as S102 shown in FIG. 1 , the S204 is the same as S103 shown in FIG. 1 , the S205 is the same as S104 shown in FIG. 1 , and S206 is the same as S105 described in FIG. 1 .
[0125] In this implementation, if the electronic device detects that a graphic selection event is triggered, it can first determine whether the preset replacement button is in a non-triggered state, that is, determine whether the preset replacement button is in a non-pressed state. If the preset replacement button is in a non-pressed state, that is, it is determined that the preset replacement button is in a non-triggered state, it is determined that the user has a need to use it, and then the subsequent process of adjusting the graphic position provided by the embodiment of the present invention is executed, that is, S202-S206 is executed. The currently selected graphic is automatically adhered to the target circle, so that the currently selected graphic and the target circle are in a tangent state.
[0126] In one case, in order to meet the user's usage habits, the preset replacement key can be an ALT key. When the ALT key is not pressed, the sticking function is turned on, that is, the subsequent process of the graphic position adjustment provided by the embodiment of the present invention can be continued; when the ALT key is pressed, the sticking function is turned off, that is, the subsequent process of the graphic position adjustment provided by the embodiment of the present invention is not continued.
[0127] The user may need to adjust the two circles to be in a tangent state. If the user manually adjusts the position of the two circles so that the two circles are in a tangent state, it not only takes the user's adjustment time, but also the user manually determines whether the two circles are in a tangent state, and the final adjustment result is not accurate. At this time, in order to improve the adjustment efficiency of the user's adjustment of the two circles to be in a tangent state, simplify the user's manual adjustment operation, and improve the accuracy of the adjustment result of adjusting the two circles to be in a tangent state. In one implementation, the electronic device can first determine the circle from other graphics, and determine the target circle from the determined circles, and then adjust the position of the currently selected graphic to the target position based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic, and the radius of the target circle. Wherein, the step of determining the target circle whose distance from the currently selected graphic is within a preset distance range from other graphics based on the current position coordinates and the position coordinates of other graphics can include:
[0128] From other figures, a circle is determined as an alternative circle;
[0129] Based on the current position coordinates and the position coordinates of the candidate circles, a target circle whose distance to the currently selected graphic is within a preset distance range is determined from the candidate circles.
[0130] Among them, the electronic device determines a circle from other graphics as a candidate circle, and then directly obtains the position coordinates of the candidate circle. Then, based on the current position coordinates and the position coordinates of the candidate circle, it determines from the candidate circles a target circle whose distance from the currently selected graphic is within a preset distance range.
[0131] In one implementation, parameter information of each other graphic is stored locally in the electronic device or in a connected storage device, wherein the parameter information of each other graphic includes information characterizing whether the graphic is a circle. The electronic device can first obtain the parameter information of each other graphic, and then, based on the parameter information of each other graphic, determine a circle from the other graphics as an alternative circle.
[0132] Subsequently, based on the current position coordinates and the position coordinates of the candidate circles, a target circle whose distance from the currently selected graphic is within a preset distance range can be determined from the candidate circles, which can reduce the computational burden of the electronic device to a certain extent. In one implementation, based on the current position coordinates and the position coordinates of the candidate circles, the step of determining, from the candidate circles, a target circle whose distance from the currently selected graphic is within a preset distance range can include:
[0133] Based on the current position coordinates and the position coordinates of the candidate circles, the center distance between the center of the currently selected figure and the center of each candidate circle is calculated;
[0134] Get the radius of the currently selected shape and the radius of each alternative circle;
[0135] For each candidate circle, the sum of the radius of the candidate circle and the radius of the currently selected figure is calculated as the first sum; and the difference between the center distance of the candidate circle and the first sum is calculated as the distance between the candidate circle and the currently selected figure;
[0136] For each candidate circle, determine whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range;
[0137] If it is determined that the distance between the candidate circle and the currently selected figure is within the preset distance range, the candidate circle is determined to be the first candidate circle;
[0138] From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
[0139] In this implementation, in order to ensure the accuracy of the determined target circle and avoid interference of the radius of the candidate circle and the currently selected figure on the determination result of the target circle, the distance between the candidate circle and the currently selected figure is calculated as: the distance between the edge of the candidate circle and the edge of the currently selected figure. The preset distance range can be: a range for limiting the distance between the edges of the figure and the figure. The preset distance range can be set manually or automatically by the electronic device, which is possible.
[0140] Among them, the process of calculating the distance between the edge of the alternative circle and the edge of the currently selected figure can be: calculating the distance between the center of the alternative circle and the center of the currently selected figure, that is, the center-to-center distance; and calculating the sum of the radius of the alternative circle and the radius of the currently selected figure as the sum of the radii corresponding to the alternative circle, and then; taking the difference between the center-to-center distance and the sum of the radii corresponding to the alternative circle as the distance between the edge of the alternative circle and the edge of the currently selected figure.
[0141] Subsequently, it is determined whether the distance between the edge of each candidate circle and the edge of the currently selected graphic belongs to the preset distance range, that is, whether the distance between the edge of each candidate circle and the edge of the currently selected graphic is not greater than the upper limit of the preset distance range, and not less than the lower limit of the preset distance range; if it is determined that the distance between the edge of the candidate circle and the edge of the currently selected graphic is not greater than the upper limit of the preset distance range, and not less than the lower limit of the preset distance range, then it is determined that the distance between the edge of the candidate circle and the edge of the currently selected graphic belongs to the preset distance range. If the electronic device determines that the distance between the edge of the candidate circle and the edge of the currently selected graphic belongs to the preset distance range, it determines that the candidate circle is the first candidate circle. Then, from the first candidate circles, the first candidate circle with the closest distance to the currently selected graphic is determined as the target circle.
[0142] In one case, the above-mentioned current position coordinates are the position coordinates of the center of the currently selected figure, including the center longitudinal axis coordinate value and the center transverse axis coordinate value of the center of the currently selected figure, wherein the center longitudinal axis coordinate value of the center of the currently selected figure is the first longitudinal axis coordinate value mentioned later, and the center transverse axis coordinate value of the center of the currently selected figure is the first transverse axis coordinate value mentioned later. The position coordinates of the alternative circle are the position coordinates of the center of the alternative circle, including the center longitudinal axis coordinate value and the center transverse axis coordinate value of the center of the alternative circle, wherein the center longitudinal axis coordinate value of the center of the alternative circle is the second longitudinal axis coordinate value mentioned later, and the center transverse axis coordinate value of the center of the alternative circle is the second transverse axis coordinate value mentioned later. In view of this, the above-mentioned formula for calculating the center distance between the center of the currently selected figure and the center of each alternative circle based on the current position coordinates and the position coordinates of the alternative circles can be:
[0143] Center distance = (center vertical axis coordinate value of the currently selected figure - center vertical axis coordinate value of the alternative circle) / sin (center relative angle); or,
[0144] Center distance = (the horizontal axis coordinate value of the center of the currently selected figure - the horizontal axis coordinate value of the center of the alternative circle) / cos (the relative angle of the center);
[0145] Among them, the relative angle of the center of the circle = acrtan((the vertical axis coordinate value of the center of the currently selected figure - the vertical axis coordinate value of the center of the alternative circle) / (the horizontal axis coordinate value of the center of the currently selected figure - the horizontal axis coordinate value of the center of the alternative circle)).
[0146] The distance between the centers of the two circles is Figure 1B shown.
[0147] In another case, the above current position coordinates are the position coordinates of the preset calibration point corresponding to the currently selected graphic, including the ordinate coordinate value and the abscissa coordinate value of the preset calibration point corresponding to the currently selected graphic. The position coordinates of the alternative circle are the position coordinates of the preset calibration point corresponding to the alternative circle, including the ordinate coordinate value and the abscissa coordinate value of the preset calibration point corresponding to the alternative circle. In view of this, the above formula used to calculate the center distance between the center of the currently selected graphic and the center of each alternative circle based on the current position coordinates and the position coordinates of the alternative circles can be:
[0148] Take the preset calibration point corresponding to the currently selected figure as the intersection of the left vertical tangent and the upper vertical tangent of the currently selected figure, and the preset calibration point corresponding to the candidate circle as the intersection of the left vertical tangent and the upper vertical tangent of the candidate circle as an example for explanation:
[0149] Center distance = ((vertical axis coordinate value of the preset calibration point corresponding to the currently selected figure + radius of the currently selected figure) - (vertical axis coordinate value of the preset calibration point corresponding to the alternative circle + radius of the alternative circle)) / sin (relative angle of the center of the circle); or,
[0150] Center distance = ((horizontal axis coordinate value of the preset calibration point corresponding to the currently selected figure + radius of the currently selected figure) - (horizontal axis coordinate value of the preset calibration point corresponding to the alternative circle + radius of the alternative circle)) / cos (relative angle of the center of the circle);
[0151] Among them, the relative angle of the center of the circle = acrtan((the vertical axis coordinate value of the preset calibration point corresponding to the currently selected figure + the radius of the currently selected figure)-(the vertical axis coordinate value of the preset calibration point corresponding to the alternative circle + the radius of the alternative circle)) / ((the horizontal axis coordinate value of the preset calibration point corresponding to the currently selected figure + the radius of the currently selected figure)-(the horizontal axis coordinate value of the preset calibration point corresponding to the alternative circle + the radius of the alternative circle)).
[0152] In another implementation, after all the circles included in the current page are determined, the radius of the circles included in the current page is determined, and the electronic device can set the preset distance range based on the radius of each circle included in the current page, that is, the preset distance range can be: the range used to limit the distance between the graphic and the center of the graphic.
[0153] In view of this situation, the center distance between the center of the currently selected figure and the center of each alternative circle can be calculated directly based on the current position coordinates and the position coordinates of the alternative circles, and then, it is determined whether each center distance belongs to the preset distance range, that is, whether each center distance is not greater than the upper limit value of the preset distance range, and not less than the lower limit value of the preset distance range; if the center distance is not greater than the upper limit value of the preset distance range, and not less than the lower limit value of the preset distance range, then it is determined that the center distance belongs to the preset distance range, and the alternative circle corresponding to the center distance is determined as the first alternative circle; then, the electronic device determines the first alternative circle with the smallest corresponding center distance from the first alternative circles as the target circle.
[0154] After the electronic device determines the target circle, it can determine the target position that makes the currently selected graphic and the target circle tangent based on the current position coordinates and radius of the currently selected graphic and the position coordinates and radius of the target circle, and then adjust the position of the currently selected graphic to the target position.
[0155] In one implementation, the current position coordinates include: a first horizontal axis coordinate value of the center of the currently selected graphic under a preset horizontal axis and a first vertical axis coordinate value under a preset vertical axis; the position coordinates of the target circle include: a second horizontal axis coordinate value of the center of the target circle under a preset horizontal axis and a second vertical axis coordinate value under a preset vertical axis;
[0156] like Figure 3 As shown, the step of adjusting the position of the currently selected graphic to the target position based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle may include:
[0157] S301: determining a center relative angle based on a first horizontal axis coordinate value, a second horizontal axis coordinate value, a first vertical axis coordinate value, and a second vertical axis coordinate value;
[0158] S302: Determine the vertical axis coordinate value of the target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second vertical axis coordinate value;
[0159] S303: Determine the horizontal axis coordinate value of the target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value;
[0160] S304: Based on the target circle center vertical axis coordinate value, the target circle center horizontal axis coordinate value, and the radius of the currently selected graphic, adjust the position of the currently selected graphic to the target position.
[0161] Among them, when determining the target position, the positional relationship between the currently selected graphic and the target circle, that is, the relative angle of the center of the circle, can be determined first based on the current position coordinates of the currently selected graphic and the position coordinates of the target circle. Then, based on the relative angle of the center of the circle, the radius of the currently selected graphic, the radius of the target circle, and the position coordinates of the target circle, the final position to which the center of the currently selected graphic needs to be moved is determined, that is, the vertical axis coordinate value of the center of the target circle and the horizontal axis coordinate value of the center of the target circle are determined respectively. Then, based on the vertical axis coordinate value of the center of the target circle, the horizontal axis coordinate value of the center of the target circle, and the radius of the currently selected graphic, the target position of the currently selected graphic is determined, and then the position of the currently selected graphic is adjusted to the target position.
[0162] Among them, the target position of the currently selected figure is determined based on the target circle center longitudinal axis coordinate value, the target circle center transverse axis coordinate value and the radius of the currently selected figure, which can be: based on the target circle center longitudinal axis coordinate value, the target circle center transverse axis coordinate value and the radius of the currently selected figure, the target longitudinal axis coordinate value and the target transverse axis coordinate value of the preset calibration point corresponding to the currently selected figure are determined. In one case, the preset calibration point corresponding to the currently selected figure is: the intersection of the left vertical tangent and the upper vertical tangent of the currently selected figure as an example, the target longitudinal axis coordinate value of the preset calibration point corresponding to the currently selected figure = the target circle center longitudinal axis coordinate value - the radius of the currently selected figure; the target transverse axis coordinate value of the preset calibration point corresponding to the currently selected figure = the target circle center transverse axis coordinate value - the radius of the currently selected figure.
[0163] Subsequently, after determining the target vertical axis coordinate value and the target horizontal axis coordinate value of the preset calibration point corresponding to the currently selected graphic, the center of the currently selected graphic is adjusted to the position represented by the target vertical axis coordinate value and the target horizontal axis coordinate value, that is, the target position.
[0164] In one implementation, the step of determining the relative angle of the center of the circle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value may use the formula:
[0165]
[0166] Among them, D represents the relative angle of the center of the circle, and x 1 Indicates the first horizontal axis coordinate value, that is, the horizontal axis coordinate value of the center of the currently selected figure. 2 Represents the second horizontal axis coordinate value, that is, the horizontal axis coordinate value of the center of the alternative circle. 1Indicates the first vertical axis coordinate value, that is, the vertical axis coordinate value of the center of the currently selected figure. 2 represents the second vertical axis coordinate value, that is, the vertical axis coordinate value of the center of the alternative circle;
[0167] The step of determining the target circle center vertical axis coordinate value of the currently selected figure based on the radius of the currently selected figure, the radius of the target circle, the relative angle of the circle center, and the second vertical axis coordinate value may adopt the formula:
[0168] y 目标 =(r 1 +r 2 )*sinD+y 2
[0169] Among them, the y 目标 Represents the vertical axis coordinate value of the target circle center. 1 Indicates the radius of the currently selected graphic. 2 Indicates the radius of the target circle;
[0170] The step of determining the horizontal axis coordinate value of the target circle center of the currently selected figure based on the radius of the currently selected figure, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value may adopt the formula:
[0171] x 目标 =(r 1 +r 2 )*cosD+x 2
[0172] Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
[0173] In another implementation, when the current position coordinates of the currently selected graphic are identified by the position coordinates of the preset calibration point corresponding to the currently selected graphic, and the position coordinates of other graphics are identified by the position coordinates of the preset calibration points corresponding to other graphics; that is, the current position coordinates include: the horizontal axis coordinate value of the preset calibration point corresponding to the currently selected graphic under the preset horizontal axis and the vertical axis coordinate value under the preset vertical axis; the position coordinates of the target circle include: the horizontal axis coordinate value of the preset calibration point corresponding to the target circle under the preset horizontal axis and the vertical axis coordinate value under the preset vertical axis;
[0174] The electronic device may first determine the horizontal axis coordinate value and the vertical axis coordinate value of the center of the circle of the currently selected graphic based on the horizontal axis coordinate value and the vertical axis coordinate value of the preset calibration point corresponding to the currently selected graphic and the radius of the currently selected graphic. And determine the horizontal axis coordinate value and the vertical axis coordinate value of the center of the target circle based on the horizontal axis coordinate value and the vertical axis coordinate value of the preset calibration point corresponding to the target circle and the radius of the target circle.
[0175] Specifically, taking the preset calibration point corresponding to the currently selected figure as the intersection of the left vertical tangent and the upper vertical tangent of the currently selected figure, and the preset calibration point corresponding to the target circle as the intersection of the left vertical tangent and the upper vertical tangent of the target circle as an example, the horizontal axis coordinate value of the center of the circle of the currently selected figure = the horizontal axis coordinate value of the preset calibration point corresponding to the currently selected figure + the radius of the currently selected figure; the vertical axis coordinate value of the center of the circle of the currently selected figure = the vertical axis coordinate value of the preset calibration point corresponding to the currently selected figure + the radius of the currently selected figure. The horizontal axis coordinate value of the center of the target circle = the horizontal axis coordinate value of the preset calibration point corresponding to the target circle + the radius of the target circle; the vertical axis coordinate value of the center of the target circle = the vertical axis coordinate value of the preset calibration point corresponding to the target circle + the radius of the target circle.
[0176] Then, based on the horizontal axis coordinate value and the vertical axis coordinate value of the center of the currently selected figure, and the horizontal axis coordinate value and the vertical axis coordinate value of the center of the target circle, determine the relative angle of the center; based on the radius of the currently selected figure, the radius of the target circle, the relative angle of the center, and the vertical axis coordinate value of the center of the target circle, determine the vertical axis coordinate value of the target center of the currently selected figure; based on the radius of the currently selected figure, the radius of the target circle, the relative angle of the center, and the horizontal axis coordinate value of the center of the target circle, determine the horizontal axis coordinate value of the target center of the currently selected figure; based on the vertical axis coordinate value, the horizontal axis coordinate value of the target center, and the radius of the currently selected figure, determine the target position, that is, the final position of the preset calibration point corresponding to the currently selected figure; adjust the position of the preset calibration point corresponding to the currently selected figure to the target position.
[0177] Corresponding to the above method embodiment, the embodiment of the present invention provides a graphic position adjustment device, such as Figure 4 As shown, the device comprises:
[0178] The first judgment module 410 is used to judge whether the currently selected graphic corresponding to the graphic selection event is a circle if a graphic selection event is detected to be triggered;
[0179] A monitoring and determining module 420 is used to monitor a moving operation on the currently selected graphic if it is determined that the currently selected graphic is a circle, and determine the current position coordinates of the currently selected graphic according to the moving operation;
[0180] A determination module 430 is used to determine, based on the current position coordinates and the position coordinates of other graphics, a target circle whose distance from the currently selected graphic is within a preset distance range from the other graphics;
[0181] An acquisition module 440 is used to obtain the radius of the currently selected graphic and the radius of the target circle;
[0182] The adjustment module 450 is used to adjust the position of the currently selected graphic to the target position based on the current position coordinates and the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, wherein the target position is: a position where the currently selected graphic and the target circle are in a tangent state.
[0183] In an embodiment of the present invention, when it is monitored that a graphic selection event is triggered and it is determined that the currently selected graphic corresponding to the graphic selection event is a circle, the target circle can be automatically matched based on the current position coordinates of the currently selected graphic and the position coordinates of other graphics, and the position of the currently selected graphic can be automatically adjusted to the target position where the currently selected graphic and the target circle are in a tangent state based on the current position coordinates of the currently selected graphic, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, thereby automatically adjusting the graphic position to a position where the graphic is in a tangent state with another graphic, simplifying manual adjustment operations, improving accuracy, and improving the adjustment efficiency of adjusting the graphic to be in a tangent state with another graphic.
[0184] In one implementation, the device further includes:
[0185] A second judgment module is used to judge whether the preset replacement button is in a non-trigger state before judging whether the currently selected graphic corresponding to the graphic selection event is a circle;
[0186] If it is determined whether the preset replacement button is in a non-trigger state, the first determination module 410 is triggered.
[0187] In one implementation, the determining module 430 includes:
[0188] The first determination unit, the user determines a circle from other graphics as an alternative circle
[0189] The second determining unit is used to determine, from the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range based on the current position coordinates and the position coordinates of the candidate circles.
[0190] In one implementation, the second determining unit is specifically configured to:
[0191] Based on the current position coordinates and the position coordinates of the candidate circles, calculating the center distance between the center of the currently selected graphic and the center of each candidate circle;
[0192] Obtaining the radius of the currently selected graphic and the radius of each candidate circle;
[0193] For each candidate circle, the sum of the radius of the candidate circle and the radius of the currently selected figure is calculated as a first sum; and the difference between the center distance of the candidate circle and the first sum is calculated as the distance between the candidate circle and the currently selected figure;
[0194] For each candidate circle, determining whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range;
[0195] If it is determined that the distance between the candidate circle and the currently selected graphic is within the preset distance range, the candidate circle is determined to be the first candidate circle;
[0196] From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
[0197] In one implementation, the current position coordinates include: a first horizontal axis coordinate value of the center of the currently selected graphic under a preset horizontal axis and a first vertical axis coordinate value under a preset vertical axis; the position coordinates of the target circle include: a second horizontal axis coordinate value of the center of the target circle under the preset horizontal axis and a second vertical axis coordinate value under the preset vertical axis;
[0198] The adjustment module 450 includes:
[0199] a third determining unit, configured to determine a center relative angle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value;
[0200] An obtaining unit, used to obtain the radius of the currently selected graphic and the radius of the target circle;
[0201] a fourth determining unit, configured to determine a vertical axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second vertical axis coordinate value;
[0202] a fifth determining unit, configured to determine a horizontal axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value;
[0203] The adjustment unit is used to adjust the position of the currently selected graphic to the target position based on the vertical axis coordinate value of the target circle center, the horizontal axis coordinate value of the target circle center and the radius of the currently selected graphic.
[0204] In one implementation, the third determination unit uses the following formula:
[0205]
[0206] Wherein, D represents the relative angle of the center of the circle, and x 1 represents the first horizontal axis coordinate value, the x 2 represents the second horizontal axis coordinate value, the y 1 represents the first vertical axis coordinate value, the y 2 represents the second vertical axis coordinate value;
[0207] The fourth determination unit adopts the formula:
[0208] y 目标 =(r 1 +r 2 )*sinD+y 2
[0209] Among them, the y 目标 represents the vertical axis coordinate value of the target circle center, and the r 1 Indicates the radius of the currently selected graphic, the r 2 represents the radius of the target circle;
[0210] The fifth determination unit adopts the formula:
[0211] x 目标 =(r 1 +r 2 )*cosD+x 2
[0212] Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
[0213] Corresponding to the above method embodiment, the embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540.
[0214] Memory 530, for storing computer programs;
[0215] The processor 510 is used to implement any of the above-mentioned steps of the graphic position adjustment method provided by the embodiment of the present invention when executing the computer program stored in the memory 530.
[0216] In an embodiment of the present invention, when it is monitored that a graphic selection event is triggered and it is determined that the currently selected graphic corresponding to the graphic selection event is a circle, the target circle can be automatically matched based on the current position coordinates of the currently selected graphic and the position coordinates of other graphics, and the position of the currently selected graphic can be automatically adjusted to the target position where the currently selected graphic and the target circle are in a tangent state based on the current position coordinates of the currently selected graphic, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, thereby automatically adjusting the graphic position to a position where the graphic is in a tangent state with another graphic, simplifying manual adjustment operations, improving accuracy, and improving the adjustment efficiency of adjusting the graphic to be in a tangent state with another graphic.
[0217] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0218] The communication interface is used for communication between the above electronic device and other devices.
[0219] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0220] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0221] Corresponding to the above method embodiments, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned steps of the graphic position adjustment method provided by the embodiment of the present invention is implemented.
[0222] In the embodiment of the present invention, when it is detected that a graphic selection event is triggered and it is determined that the currently selected graphic corresponding to the graphic selection event is a circle, the target circle can be automatically matched based on the current position coordinates of the currently selected graphic and the position coordinates of other graphics in the current page, and the position of the currently selected graphic can be automatically adjusted to the target position where the currently selected graphic and the target circle are in a tangent state based on the current position coordinates of the currently selected graphic and the position coordinates of the target circle, so as to achieve automatic adjustment of the graphic position to a position where the graphic is in a tangent state with another graphic, simplify the manual adjustment operation, and improve the accuracy. And it can also achieve the improvement of the adjustment efficiency of adjusting the graphic to be in a tangent state with another graphic.
[0223] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0224] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0225] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for adjusting the position of a graphic, It is characterized in that Applied to electronic equipment, the method comprises: If it is detected that a graphic selection event is triggered, determining whether the currently selected graphic corresponding to the graphic selection event is a circle includes: Detecting whether an object selection event is triggered, wherein the object selection event corresponds to parameter information of the selected object, and the parameter information includes the object type; Determine whether the object type of the selected object carried by the object selection event is a preset graphic type, and if so, determine that the object is a graphic, and determine that the graphic selection event is detected to be triggered; The parameter information of the selected object corresponding to the object selection event also carries the shape information of the graphic, and based on the shape information of the graphic, it is determined whether the currently selected graphic corresponding to the graphic selection event is a circle; or, by using the Hough transform circle detection algorithm, it is determined whether the currently selected graphic is a circle; If it is determined that the currently selected graphic is a circle, a moving operation on the currently selected graphic is monitored, and according to the moving operation, the current position coordinates of the currently selected graphic are determined; wherein the current position coordinates of the center of the currently selected graphic are used to represent the current position coordinates of the currently selected graphic; Based on the current position coordinates and the position coordinates of other graphics, determine from the other graphics a target circle whose distance from the currently selected graphic is within a preset distance range; Obtaining the radius of the currently selected graphic and the radius of the target circle; Based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, adjusting the position of the currently selected graphic to the target position, wherein the target position is: a position where the currently selected graphic and the target circle are in a tangent state; The current position coordinates include: the first horizontal axis coordinate value of the center of the currently selected figure under the preset horizontal axis and the first vertical axis coordinate value under the preset vertical axis; the position coordinates of the target circle include: the second horizontal axis coordinate value of the center of the target circle under the preset horizontal axis and the second vertical axis coordinate value under the preset vertical axis; The step of adjusting the position of the currently selected graphic to the target position based on the current position coordinates, the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle comprises: Determine a center relative angle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value; Determine the target circle center longitudinal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the circle center relative angle, and the second longitudinal axis coordinate value; Determine the target circle center horizontal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the center relative angle and the second horizontal axis coordinate value; Based on the target circle center longitudinal axis coordinate value, the target circle center transverse axis coordinate value and the radius of the currently selected graphic, the position of the currently selected graphic is adjusted to the target position.
2. The method according to claim 1, It is characterized in that Before the step of determining whether the currently selected graphic corresponding to the graphic selection event is a circle, the method further includes: Determine whether the preset replacement button is in a non-trigger state; If it is determined that the preset replacement button is in a non-trigger state, the step of determining whether the currently selected graphic corresponding to the graphic selection event is a circle is performed.
3. The method according to claim 1, It is characterized in that The step of determining, based on the current position coordinates and the position coordinates of other graphics, from the other graphics, a target circle whose distance from the currently selected graphic is within a preset distance range, comprises: From other figures, a circle is determined as an alternative circle; Based on the current position coordinates and the position coordinates of the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range is determined from the candidate circles.
4. The method according to claim 3, It is characterized in that The step of determining, from the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range based on the current position coordinates and the position coordinates of the candidate circles comprises: Based on the current position coordinates and the position coordinates of the candidate circles, calculating the center distance between the center of the currently selected graphic and the center of each candidate circle; Obtaining the radius of the currently selected graphic and the radius of each candidate circle; For each candidate circle, the sum of the radius of the candidate circle and the radius of the currently selected figure is calculated as a first sum; and the difference between the center distance of the candidate circle and the first sum is calculated as the distance between the candidate circle and the currently selected figure; For each candidate circle, determining whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range; If it is determined that the distance between the candidate circle and the currently selected graphic is within the preset distance range, the candidate circle is determined to be the first candidate circle; From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
5. The method according to claim 1, It is characterized in that The step of determining the relative angle of the center of the circle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value adopts the formula: Wherein, D represents the relative angle of the center of the circle, and x 1 represents the first horizontal axis coordinate value, the x 2 represents the second horizontal axis coordinate value, the y 1 represents the first vertical axis coordinate value, the y 2 represents the second vertical axis coordinate value; The step of determining the target circle center longitudinal axis coordinate value of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the center relative angle and the second longitudinal axis coordinate value adopts the formula: y 目标 =(r 1 +r 2 )*sinD+y 2 Among them, the y 目标 represents the vertical axis coordinate value of the target circle center, and the r 1 Indicates the radius of the currently selected graphic, the r 2 represents the radius of the target circle; The step of determining the horizontal axis coordinate value of the target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value adopts the formula: x 目标 =(r 1 +r 2 )*cosD+x 2 Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
6. A graphic position adjustment device, It is characterized in that Applied to electronic equipment, the device comprises: The first judgment module is used to judge whether the currently selected graphic corresponding to the graphic selection event is a circle if a graphic selection event is detected to be triggered, including: detecting whether an object selection event is triggered, wherein the object selection event corresponds to parameter information of a selected object, and the parameter information includes an object type; judging whether the object type of the selected object carried by the object selection event is a preset graphic type, and if so, determining that the object is a graphic, and determining that the graphic selection event is detected to be triggered; the parameter information of the selected object corresponding to the object selection event also carries shape information of the graphic, and based on the shape information of the graphic, determining whether the currently selected graphic corresponding to the graphic selection event is a circle; or, judging whether the currently selected graphic is a circle by using a Hough transform circle detection algorithm; A monitoring and determining module, for monitoring a moving operation on the currently selected graphic if it is determined that the currently selected graphic is a circle, and determining the current position coordinates of the currently selected graphic according to the moving operation; wherein the current position coordinates of the center of the currently selected graphic are used to represent the current position coordinates of the currently selected graphic; A determination module, configured to determine, based on the current position coordinates and the position coordinates of other graphics, a target circle whose distance from the currently selected graphic is within a preset distance range from the other graphics; An acquisition module, used to obtain the radius of the currently selected graphic and the radius of the target circle; an adjustment module, configured to adjust the position of the currently selected graphic to a target position based on the current position coordinates and the position coordinates of the target circle, the radius of the currently selected graphic and the radius of the target circle, wherein the target position is a position where the currently selected graphic is in a tangent state with the target circle; The current position coordinates include: the first horizontal axis coordinate value of the center of the currently selected figure under the preset horizontal axis and the first vertical axis coordinate value under the preset vertical axis; the position coordinates of the target circle include: the second horizontal axis coordinate value of the center of the target circle under the preset horizontal axis and the second vertical axis coordinate value under the preset vertical axis; The adjustment module comprises: a third determining unit, configured to determine a center relative angle based on the first horizontal axis coordinate value, the second horizontal axis coordinate value, the first vertical axis coordinate value, and the second vertical axis coordinate value; a fourth determining unit, configured to determine a vertical axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second vertical axis coordinate value; a fifth determining unit, configured to determine a horizontal axis coordinate value of a target circle center of the currently selected graphic based on the radius of the currently selected graphic, the radius of the target circle, the relative angle of the circle center, and the second horizontal axis coordinate value; The adjustment unit is used to adjust the position of the currently selected graphic to the target position based on the vertical axis coordinate value of the target circle center, the horizontal axis coordinate value of the target circle center and the radius of the currently selected graphic.
7. The device according to claim 6, It is characterized in that The device also includes: A second judgment module is used to judge whether the preset replacement button is in a non-trigger state before judging whether the currently selected graphic corresponding to the graphic selection event is a circle; If it is determined that the preset replacement button is in a non-trigger state, the first determination module is triggered.
8. The device according to claim 6, It is characterized in that The determining module comprises: The first determining unit, in which the user determines a circle from other graphics as a candidate circle; The second determining unit is used to determine, from the candidate circles, a target circle whose distance to the currently selected figure is within a preset distance range based on the current position coordinates and the position coordinates of the candidate circles.
9. The device according to claim 8, It is characterized in that The second determining unit is specifically configured to: Based on the current position coordinates and the position coordinates of the candidate circles, calculating the center distance between the center of the currently selected graphic and the center of each candidate circle; Obtaining the radius of the currently selected graphic and the radius of each candidate circle; For each candidate circle, calculate the sum of the radius of the candidate circle and the radius of the currently selected graphic as a first sum; and calculating the difference between the center distance of the candidate circle and the first sum as the distance between the candidate circle and the currently selected figure; For each candidate circle, determining whether the distance between the candidate circle and the currently selected graphic falls within a preset distance range; If it is determined that the distance between the candidate circle and the currently selected graphic is within the preset distance range, the candidate circle is determined to be the first candidate circle; From the determined first candidate circles, a first candidate circle that is closest to the currently selected graphic is determined as the target circle.
10. The device according to claim 6, It is characterized in that The third determination unit adopts the formula: Wherein, D represents the relative angle of the center of the circle, and x 1 represents the first horizontal axis coordinate value, the x 2 represents the second horizontal axis coordinate value, the y 1 represents the first vertical axis coordinate value, the y 2 represents the second vertical axis coordinate value; The fourth determination unit adopts the formula: y 目标 =(r 1 +r 2 )*sinD+y 2 Among them, the y 目标 represents the vertical axis coordinate value of the target circle center, and the r 1 Indicates the radius of the currently selected graphic, the r 2 represents the radius of the target circle; The fifth determination unit adopts the formula: x 目标 =(r 1 +r 2 )*cosD+x 2 Among them, the x 目标 Indicates the horizontal axis coordinate value of the target circle center.
11. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the graphic position adjustment method described in any one of claims 1-5 when executing the computer program stored in the memory.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the graphic position adjustment method according to any one of claims 1 to 5 are implemented.
