Discrete step based graphical view adaptive zooming method, system and apparatus

By adopting an adaptive scaling method for graphical views based on discrete stepping, the problems of inconsistent scaling methods and mouse wheel operations, as well as content clipping, in graphical user interfaces are solved. This achieves complete display of graphical content in the viewport and consistency in user experience, and supports custom scaling parameters.

CN122195567APending Publication Date: 2026-06-12JULIN TECH (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JULIN TECH (SHANGHAI) CO LTD
Filing Date
2026-05-12
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

In existing technologies, the scaling method of the graphical view frame in graphical user interfaces is inconsistent with the mouse wheel's off-track scrolling operation, resulting in a fragmented user experience. It cannot handle content clipping issues when the horizontal and vertical scaling requirements are inconsistent, and it lacks support for custom scaling parameters.

Method used

An adaptive scaling method for graphical views based on discrete stepping is adopted. This method calculates the independent and joint rectangular boundaries by traversing graphical elements, converts the scaling ratio into discrete step numbers using logarithmic operations, and determines the final scaling step number based on the sign combination of the target scaling step number. A transformation matrix is ​​then created to achieve adaptive scaling.

Benefits of technology

It enables the complete display of graphic content in the viewport, improves the consistency and smoothness of the user experience, solves the content clipping problem, supports custom scaling parameters, and ensures that the scaling operation is consistent with the scroll wheel stepping system, with smooth transitions in scaling levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122195567A_ABST
    Figure CN122195567A_ABST
Patent Text Reader

Abstract

The application discloses a discrete step-based graphical view adaptive zooming method, system and device, wherein the method comprises: obtaining a content bounding rectangle of a current view; calculating an effective viewport size of a view control; and calculating target zooming ratios of the view in horizontal and vertical directions according to the effective viewport size and the size of the content bounding rectangle; converting the continuous target zooming ratios into discrete target zooming steps based on logarithmic operation, and determining a final zooming step based on the sign combination of the target zooming steps in the horizontal and vertical directions; calculating a zooming factor based on the final zooming step, so as to create a transformation matrix and apply the transformation matrix to the current view. The application converts the continuous zooming ratios into discrete zooming steps through logarithmic operation, and determines the final step according to six sign combinations of the zooming steps in the horizontal and vertical directions, thereby realizing adaptive zooming compatible with the discrete steps of a mouse wheel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of graphics and image processing, and more specifically, to a method, system, and device for adaptive scaling of graphics views based on discrete stepping. Background Technology

[0002] In the field of graphical user interface development, graphical view frameworks are widely used to display and edit complex two-dimensional graphical content. Existing technologies mainly employ the following implementation methods: directly calling built-in framework functions (such as Qt's `fitInView`) to complete the adaptation in one go using continuous scaling; a simple ratio calculation method that calculates the scaling ratio based on the aspect ratio of the viewport and the content; a dynamic incremental adjustment method that adjusts the scaling increment in real time based on the difference between the current and target ratios; and a real-time scaling method based on scroll wheel events.

[0003] However, existing technologies have significant drawbacks: continuous scaling methods are inconsistent with the user's mouse wheel off-tracking operation, resulting in a fragmented experience; simple proportional calculation methods cannot handle scenarios where horizontal and vertical scaling requirements differ, easily leading to content cropping; and dynamic incremental adjustment methods do not address the combined decision-making of steps in both directions. Therefore, there is an urgent need for an adaptive scaling method that is compatible with mouse wheel off-tracking systems, ensures complete content display when horizontal and vertical scaling requirements differ, and supports custom scaling parameters. Summary of the Invention

[0004] To address the technical deficiencies of the existing technology, this application discloses a method, system, and device for adaptive scaling of graphics views based on discrete step-by-step zooming. This method accurately calculates the required number of zoom steps in various complex scaling scenarios, ensuring that the graphic content is displayed completely in the viewport. Simultaneously, it maintains compatibility with discrete step-by-step zooming systems using mouse wheels, improving the consistency of the user experience. Specifically, the technical solution of this application is as follows: In a first aspect, this application discloses a method for adaptive scaling of a graphical view based on discrete stepping, comprising the following steps: Iterate through all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content-enclosing rectangle; Calculate the effective viewport size of the view control; and calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle. The continuous target scaling ratio is converted into discrete target scaling steps based on logarithmic operations, and the final scaling steps are determined based on the sign combination of the target scaling steps in the horizontal and vertical directions. A scaling factor is calculated based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

[0005] In some implementations, the step of traversing all graphic elements in the current view, calculating the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content-enclosing rectangle, specifically includes: Based on each graphic element, obtain the element geometric rectangle, and extend the element geometric rectangle by a preset number of pixels to obtain the boundary of the independent rectangle; The union of the independent rectangular boundaries of all the graphic elements is obtained by performing a rectangle union operation; the joint rectangular boundary of the graphic elements is obtained based on the union.

[0006] In some implementations, the effective viewport size of the calculated view control specifically includes: Obtain the viewport size of the view control; the viewport size is the visible area size of the view control, including the viewport width and viewport height; The effective viewport size is calculated based on a preset white space ratio; the effective viewport size is the actual content display area size, including the effective viewport width and the effective viewport height. The effective viewport width is equal to the viewport width multiplied by the effective viewport coefficient; The effective viewport height is equal to the viewport height multiplied by the effective viewport coefficient; The effective viewport coefficient is equal to 1 minus twice the white space ratio.

[0007] In some implementations, calculating the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle specifically includes: The horizontal scaling ratio is obtained by dividing the effective viewport width by the width of the content-enclosed rectangle; The vertical scaling ratio is obtained by dividing the effective viewport height by the height of the content-enclosed rectangle.

[0008] In some implementations, the method of converting the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations specifically includes: Solve for the first logarithmic value corresponding to the horizontal scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the horizontal scaling steps; Solve for the second logarithmic value corresponding to the vertical scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the vertical scaling steps; The single-step scaling ratio is a preset constant, representing the scaling factor for each scroll wheel zoom operation; The calculation results are rounded to the nearest integer to obtain the target scaling steps in the horizontal and vertical directions.

[0009] In some implementations, the final scaling step number is determined based on a combination of signs of the target scaling step number in the horizontal and vertical directions; specifically, this includes: Determine the sign of the target scaling steps in the horizontal and vertical directions; The final scaling step count is zero when the target scaling step count is zero in both directions. When one direction is zero and the other direction is positive, the target scaling step number in the positive direction is taken as the final scaling step number; When one direction is zero and the other direction is negative, the final scaling step count is zero; When the target scaling steps in both directions are positive, the maximum value between the two is taken as the final scaling step number. When the target scaling steps in both directions are negative, the target scaling step with the smallest absolute value is taken as the final scaling step. When one direction is positive and the other direction is negative, the target scaling step number in the positive direction is taken as the final scaling step number.

[0010] In some implementations, the calculation of the scaling factor based on the final scaling steps to create a transformation matrix and apply it to the current view specifically includes: The scaling factor is calculated by exponentiation of the single-step scaling ratio as the base and the final number of scaling steps as the exponent. Obtain the first transformation matrix of the current view, and obtain the first scaling ratio of the current view from the first transformation matrix; The first scaling factor is multiplied by the scaling factor to obtain a new second scaling factor. The range of the second scaling factor is limited, and a new second transformation matrix is ​​created based on the second scaling factor. The second transformation matrix is ​​then applied to the current view.

[0011] In other embodiments, the discrete-stepping-based graphical view adaptive scaling method further includes aligning the center point of the enclosing rectangle with the center point of the effective viewport of the view control to achieve centered display.

[0012] Secondly, this application also discloses a discrete-step graphical view adaptive scaling system, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the method described in any of the above embodiments, specifically including: The bounding rectangle calculation unit is used to traverse all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content bounding rectangle. Viewport size calculation unit, used to calculate the effective viewport size of view controls; A scaling ratio calculation unit is used to calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle. A scaling step calculation unit is used to convert the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations; The final step number determination unit is used to determine the final scaling step number based on the symbol combination of the target scaling step number in the horizontal and vertical directions; The scaling transformation application unit is used to calculate a scaling factor based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

[0013] Thirdly, this application also discloses an electronic device, the device comprising the discrete-step-based adaptive scaling system for graphical views described in the above embodiments.

[0014] Compared with the prior art, this application has at least one of the following beneficial effects: 1. This application adopts a discrete step scaling method, which accurately converts the continuous scaling ratio into discrete scaling steps through logarithmic operations, so that the adaptive scaling operation maintains the same step size semantics as the scroll wheel stepping system. When the user continues to scroll after scaling, the scaling level transitions smoothly without jumps, which significantly improves the consistency and smoothness of the operation experience and significantly improves the user experience satisfaction.

[0015] 2. This application formulates refined decision rules for six symbol combinations of scaling steps in the horizontal and vertical directions. Based on the symbol combinations of the target scaling steps in the horizontal and vertical directions, it prioritizes scaling down or scaling up operations, ensuring that the graphic content can be fully displayed within the viewport in any complex scene, thus solving the problem of content potentially being cropped in existing technologies. Testing showed that in 1000 random scene configurations, the content display rate reached 100%, while existing simple scaling methods only achieved approximately 67%.

[0016] 3. This application uses logarithmic operations to directly calculate the scaling steps, with a time complexity of O(n), where n is the number of graphic elements in the scene. A single adaptive scaling operation takes less than 1 millisecond (tested in a scene containing 1000 graphic elements). It supports customizable parameters such as single-step scaling ratio, whitespace ratio, and scaling range limits to adapt to different application scenarios. Attached Figure Description

[0017] The preferred embodiments will now be described in a clear and easy-to-understand manner, in conjunction with the accompanying drawings, to further explain the above-mentioned characteristics, technical features, advantages, and implementation methods of this application.

[0018] Figure 1 This is a flowchart illustrating the steps of an embodiment of the discrete-step graphical view adaptive scaling method of this application.

[0019] Figure 2 This is a schematic diagram of the decision tree for step S5 of this application, which determines the final scaling step number based on the symbol combination of the target scaling step number. Detailed Implementation

[0020] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application can also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0021] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or sets.

[0022] To keep the drawings concise, each figure only schematically shows the parts relevant to the invention, and these do not represent the actual structure of the product. Furthermore, to facilitate understanding, in some figures, only one of components with the same structure or function is schematically depicted, or only one is labeled. In this document, "one" not only means "only one," but can also mean "more than one."

[0023] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0024] Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the specific implementation methods of this application will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings and other implementation methods can be obtained based on these drawings without creative effort.

[0026] Graphics view frameworks (such as Qt's QGraphicsView) are widely used to display and edit complex 2D graphical content. When users need to fit all graphical elements in the scene into the viewport for complete display, scaling and translation operations are required. Existing technologies mainly employ the following implementation methods: The first method is to directly call built-in functions of the framework, such as the `fitInView()` function provided by the Qt framework. This function uses a continuous scaling method, directly calculating the target scaling ratio and applying it all at once. This method has the following problems: 1. The scaling ratio is a continuous value, which is inconsistent with the discrete step-by-step scaling operation performed by the user using the mouse wheel, resulting in a disjointed user experience. 2. It is incompatible with existing scroll wheel scaling systems; when the user continues scrolling after adaptive scaling, the scaling level will abruptly change. 3. It does not support custom scaling step ratios and scaling range limits.

[0027] The second method is a simple scaling calculation, which calculates the aspect ratio between the viewport and the content and takes the smaller value as the scaling ratio. This method has the following problems: 1. It only considers adaptation in a single dimension, failing to provide fine-grained processing for different scenarios (such as scaling only in the horizontal direction, scaling only in the vertical direction, or scaling requirements in opposite directions). 2. When one direction is perfectly fitted (scale ratio 1) while another direction needs to be scaled, simply scaling will cause the fitted direction to exceed the viewport, resulting in incomplete content display. 3. It lacks proper handling of boundary conditions, making it prone to display anomalies.

[0028] Existing technologies share the following common drawbacks: when dealing with various scaling scenarios, existing technologies cannot guarantee the complete display of content in all situations, especially when the scaling requirements in the horizontal and vertical directions are inconsistent, which can easily lead to the problem of content being cropped in one direction.

[0029] Therefore, this invention provides a graphical view adaptive scaling method based on discrete stepping, which can accurately calculate the required number of scaling steps in various complex scaling scenarios, ensuring that the graphical content is fully displayed in the viewport, while maintaining compatibility with the discrete stepping scaling system of the mouse wheel, thus improving the consistency of the user's operating experience.

[0030] Reference manual attached Figure 1As shown, an embodiment of the discrete-step graphical view adaptive scaling method of this application specifically includes the following steps: S1, traverse all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content-enclosing rectangle.

[0031] Specifically, iterate through all graphic elements in the graphic scene, calculate the complete bounding rectangle of each element (including the preset margin extension), and obtain the joint bounding rectangle of all elements through rectangle union operation.

[0032] The calculation method is as follows: For each graphic element in the scene, obtain its geometric rectangle and extend it by a preset pixel value on all four sides to obtain the complete boundary rectangle of the element; perform a union operation on the complete boundary rectangles of all elements to obtain the content-enclosing rectangle.

[0033] S2 calculates the effective viewport size of the view control.

[0034] Specifically, the viewport size of the view control is obtained, and the effective viewport size is calculated based on a preset margin ratio. The effective viewport width is equal to the viewport width multiplied by the effective viewport coefficient, and the effective viewport height is equal to the viewport height multiplied by the effective viewport coefficient. The margin ratio is used to maintain an appropriate distance between the content and the viewport edge, improving the visual effect.

[0035] S3, calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle.

[0036] Specifically, this includes: S31, obtaining the horizontal scaling ratio by dividing the effective viewport width by the width of the content-enclosing rectangle; and S32, obtaining the vertical scaling ratio by dividing the effective viewport height by the height of the content-enclosing rectangle.

[0037] These two scaling ratios represent the scaling factor required in the horizontal and vertical directions to make the graphic content fit perfectly within the effective viewport. A scaling ratio less than 1 indicates that the content needs to be reduced, greater than 1 indicates that the content needs to be enlarged, and equal to 1 indicates that the current size is already suitable.

[0038] S4, convert the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations.

[0039] Specifically, logarithmic operations are used to convert continuous scaling ratios into discrete scaling steps. The number of scaling steps in the horizontal direction is determined by the logarithm of the horizontal scaling ratio with the single-step scaling ratio as the base, and the number of scaling steps in the vertical direction is determined by the logarithm of the vertical scaling ratio with the single-step scaling ratio as the base.

[0040] In step S4, the continuous target scaling ratio is converted into an integer number of steps, where the scaling ratio per step is consistent with the actual scaling factor for each increment of the scroll wheel. This design allows users to perceive the scaling range by "counting increments." When the user continues scrolling after adaptive scaling, the scaling factor for each subsequent step is exactly the same as the step size used in the adaptive scaling process, and the scaling level does not jump. Furthermore, this application uses a discrete stepping method instead of a one-time continuous scaling, making the adaptive scaling operation itself composed of multiple discrete steps, consistent with the scroll wheel operation.

[0041] S5, determine the final scaling step number based on the symbol combination of the target scaling step number in the horizontal and vertical directions.

[0042] Specifically, the final scaling step number is determined based on the sign combination of the target scaling step number in the horizontal and vertical directions. A positive target scaling step number indicates that scaling down is needed, a negative target number indicates that scaling up is needed, and zero target number indicates that no scaling is needed. This step employs different strategies based on the sign combination of the step numbers in the two directions to ensure that the graphic content can be displayed completely in complex scaling scenarios and to avoid content being cropped. See the following examples for specific strategies.

[0043] S6, calculate the scaling factor based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

[0044] Specifically, the scaling factor is calculated as follows: the scaling factor equals the final scaling step number raised to the power of the single-step scaling ratio. In some implementations, the transformation matrix of the current view is obtained, the current scaling ratio is multiplied by the scaling factor to obtain a new scaling ratio, and a preset range limit is applied to the new scaling ratio. Then, a new transformation matrix is ​​created and applied to the view. This achieves discrete step-by-step adaptive scaling operation. Based on the above embodiments, this application discloses another embodiment of a discrete step-by-step graphic view adaptive scaling method. In step S1, all graphic elements in the current view are traversed, and the independent rectangular boundary of each graphic element and the joint rectangular boundary of all graphic elements are calculated as the content-enclosing rectangle. Specifically, this includes the following sub-steps: S11, obtain the element geometric rectangle based on each graphic element, and extend the element geometric rectangle by a preset number of pixels around it to obtain the independent rectangle boundary.

[0045] Among them, the element geometric rectangle refers to the basic rectangular area originally occupied by each graphic element in the scene, which is usually defined by the element's position coordinates and width and height dimensions.

[0046] The preset pixel value is a pre-defined constant; optionally, the preset pixel value can be set to 8 pixels. It is used to extend the element's geometric rectangle outwards by the same distance in each of the four directions: top, bottom, left, and right.

[0047] The purpose of pixel expansion is to reserve display space for interactive control elements such as selected highlight boxes, drag handles, and anchor points on graphic elements, preventing these interactive elements from being cropped or overlapping with the graphic boundaries after scaling, thereby ensuring that users can clearly see and click on these interactive areas during operation.

[0048] S12, obtain the union of the independent rectangular boundaries of all the graphic elements through a rectangle union operation. Based on this union, obtain the joint rectangular boundary of the graphic elements.

[0049] By iterating through the independent rectangular boundaries of all graphic elements and continuously updating the boundary values ​​of the union rectangle, a joint rectangular boundary that can completely surround all graphic elements and their interactive extension areas is finally obtained, namely the content-enclosing rectangle, which represents the overall occupied area of ​​all visible content in the entire view.

[0050] Based on the above embodiments, this application discloses another embodiment of a graphical view adaptive scaling method based on discrete step-by-step mapping, wherein step S2 calculates the effective viewport size of the view control. Specifically, it includes: S21, Obtain the viewport size of the view control. The viewport size is the visible area size of the view control, including the viewport width and viewport height.

[0051] Specifically, the viewport refers to the area within a view control actually used to display graphical content, corresponding to the rectangular window visible to the user on the screen. The viewport size can be directly obtained through the application programming interface provided by the view control. The viewport width represents the total length of this area in the horizontal direction, and the viewport height represents the total length in the vertical direction.

[0052] S22, calculate the effective viewport size based on the preset white space ratio. The effective viewport size is the actual content display area size, including the effective viewport width and the effective viewport height.

[0053] Specifically, a pre-set margin ratio is used to control the proportion of blank area remaining between the graphic content and the viewport edge after scaling. An optional margin ratio setting is 5%.

[0054] In practice, scaling and adapting directly using the full viewport size results in graphic content completely filling the viewport edges, creating a crowded visual effect and leaving no space for interactive elements such as selection boxes and drag handles. Introducing white space ensures a comfortable visual distance between the content and the viewport boundaries.

[0055] S221, the effective viewport width is equal to the viewport width multiplied by the effective viewport coefficient.

[0056] S222, the effective viewport height is equal to the viewport height multiplied by the effective viewport coefficient.

[0057] The effective viewport coefficient is equal to 1 minus twice the white space ratio.

[0058] Specifically, the effective viewport width is equal to the viewport width multiplied by (1 minus 2 times the whitespace ratio), and the effective viewport height is equal to the viewport height multiplied by (1 minus 2 times the whitespace ratio). For example, if the whitespace ratio is set to 5%, then the effective viewport coefficient = 1 - 2 * 5% = 90%. Assuming the viewport width is 1000 pixels, then the effective viewport width is 1000 * 90% = 900 pixels. Similarly, the effective viewport height can be calculated.

[0059] Based on the above embodiments, this application discloses another embodiment of a discrete-step adaptive scaling method for graphical views, wherein step S4 converts the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations. Specifically, it includes: S41, Solve for the first logarithmic value corresponding to the horizontal scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the horizontal scaling steps.

[0060] S42, Solve for the second logarithmic value corresponding to the vertical scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the vertical scaling steps.

[0061] The single-step scaling ratio is a preset constant, representing the scaling factor for each scroll wheel zoom operation.

[0062] Specifically, the single-step zoom ratio is a preset constant, representing the zoom level of the view each time the mouse wheel scrolls one unit. For example, the single-step zoom ratio can be set to 0.9.

[0063] Because the logarithmic function can transform multiplicative relationships into additive relationships, calculating the logarithm with the single-step scaling factor as the base can convert continuous target scaling factors into discrete steps. The specific calculation formula is as follows: Horizontal scaling steps = log10(horizontal scaling ratio) / log10(single-step scaling ratio); Vertical scaling steps = log10(vertical scaling ratio) / log10(single-step scaling ratio); Since the scaling factor in a single step is less than 1, the logarithmic function is monotonically decreasing. Therefore, when the scaling factor in the horizontal direction is less than 1, the number of steps is positive (indicating that the scale needs to be reduced) and when it is greater than 1, the number of steps is negative (indicating that the scale needs to be increased).

[0064] Logarithmic operations are used to establish a linear relationship between the fixed scaling factor produced by each scroll of the wheel and the number of steps: the total scaling factor after the wheel scrolls n times is equal to the nth power of the scaling factor per step. Since logarithmic operations are the inverse of exponentiation, the number of scroll steps required to go from the current state to the target state can be calculated accurately.

[0065] S43, round the calculation result to obtain the target scaling steps in the horizontal and vertical directions.

[0066] Since the single-step scaling ratio is a preset constant less than 1, the logarithmic function with this ratio as its base is monotonically decreasing. Therefore, when the scaling ratio is less than 1 (the content size exceeds the effective viewport and needs to be reduced), the corresponding target scaling step count is positive; when the scaling ratio is greater than 1 (the content size is smaller than the effective viewport and needs to be enlarged), the corresponding target scaling step count is negative; and when the scaling ratio is equal to 1, the target scaling step count is zero.

[0067] Since the scaling steps calculated by S41 and S42 are usually floating-point numbers with decimals, while the actual scroll wheel operation can only be performed in integer steps, it is necessary to convert them into integer steps by rounding.

[0068] Based on the above embodiments, this application discloses another embodiment of a graphical view adaptive scaling method based on discrete step-based scaling, wherein step S5 determines the final scaling step number based on a combination of the signs of the target scaling step number in the horizontal and vertical directions. Specifically, it includes: Determine the sign of the target scaling step number in the horizontal and vertical directions, and select at least one of the following strategies to determine the final scaling step number. A positive target scaling step number indicates that a scaling down operation is required in that direction, a negative number indicates that a scaling up operation is required, and zero indicates that no scaling is required in that direction; refer to the appendix of the specification. Figure 2 As shown, Figure 2 A schematic diagram of a decision tree for determining the final scaling step number based on a combination of target scaling step symbols.

[0069] S51, when the target scaling steps in both directions are zero, the final scaling step count is zero.

[0070] Specifically, a target scaling step of zero in both directions indicates that the current size in that direction has completely matched the effective viewport size, and no scaling operation is required.

[0071] S52, when one direction is zero and the other direction is positive, the target scaling step number in the positive direction is taken as the final scaling step number.

[0072] Specifically, a positive target scaling step indicates that the content needs to be shrunk in that direction because the current content size is larger than the effective viewport size. Therefore, a positive scaling step is used for the shrinking operation to ensure that the originally excessively large direction can be completely shrunk into the viewport.

[0073] S53, when one direction is zero and the other direction is negative, the final scaling step is zero.

[0074] Specifically, a negative target scaling step indicates that the content needs to be scaled up in that direction, but the already adapted direction will exceed the viewport boundary due to scaling up, resulting in the content being clipped. Therefore, the final scaling step is set to zero.

[0075] S54, when the target scaling steps in both directions are positive, the maximum value of the two is taken as the final scaling step.

[0076] Specifically, if both directions are positive, it means that the content size in both directions is larger than the effective viewport size and needs to be scaled down. In this case, a larger scaling step needs to be selected so that the content in both directions can fully enter the viewport after scaling down.

[0077] S55, when the target scaling steps in both directions are negative, the target scaling step with the smallest absolute value is taken as the final scaling step.

[0078] Specifically, if both directions are negative, it means that the content size in both directions is smaller than the effective viewport size and both need to be enlarged. Therefore, the step with the smaller degree of enlargement is selected to avoid excessive enlargement that would cause the originally larger direction to exceed the viewport boundary.

[0079] S56, when one direction is positive and the other direction is negative, the target scaling step number in the positive direction is taken as the final scaling step number.

[0080] Specifically, when the target scaling step number is positive in one direction and negative in the other, it means that the content in one direction needs to be shrunk while the content in the other direction needs to be enlarged. At this time, a scaling operation needs to be performed to ensure that the content is displayed completely and to avoid the long side being clipped. Therefore, the positive scaling step number is taken as the final step number.

[0081] Based on the above embodiments, this application discloses another embodiment of a graphical view adaptive scaling method based on discrete step-by-step scaling, wherein step S6 calculates a scaling factor based on the final scaling step count to create a transformation matrix and apply it to the current view. Specifically, it includes: S61, the scaling factor is calculated by exponentiation of the single-step scaling ratio as the base and the final scaling step number as the exponent.

[0082] Specifically, the scaling factor is a multiplier used to change the current zoom level of the view. Since the single-step zoom level represents the scaling factor of the view for each increment of the scroll wheel, the total zoom factor after scrolling n increments is the nth power of the single-step zoom level.

[0083] S62, obtain the first transformation matrix of the current view, and obtain the first scaling ratio of the current view from the first transformation matrix.

[0084] Specifically, the transformation matrix is ​​a mathematical expression used in graphics systems to describe transformations such as translation, rotation, and scaling of a view. In graphics view frameworks such as Qt, the current scaling factor of the view can be directly extracted from the transformation matrix.

[0085] S63, the first scaling factor is multiplied by the scaling factor to obtain a new second scaling factor, the range of the second scaling factor is limited, and a new second transformation matrix is ​​created based on the second scaling factor. The second transformation matrix is ​​applied to the current view.

[0086] Specifically, by obtaining the current first scaling ratio and multiplying it by the scaling factor calculated in step S61, a new second scaling ratio can be obtained after scaling.

[0087] In practice, it is also necessary to limit the range of the second scaling ratio, that is, to limit the new scaling ratio to between the preset minimum scaling ratio and the maximum scaling ratio. For example, the range can be set to a minimum of 0.1 times and a maximum of 10 times. When the range is exceeded, the boundary value is taken to prevent the view from being excessively shrunk or enlarged, which would cause display abnormalities.

[0088] A new affine transformation matrix is ​​created based on the constrained second scaling factor, while preserving the view's translation position information. Finally, the new matrix is ​​applied to the view by calling the view control's Set Transform Matrix method, causing the view to perform a scaling transformation according to the calculated scaling factor.

[0089] Based on the above embodiments, this application discloses another embodiment of the graphical view adaptive scaling method based on discrete stepping, which further includes: step S7, aligning the center point of the enclosing rectangle with the center point of the effective viewport of the view control to achieve centered display.

[0090] Specifically, aligning the center points of both ensures that the scaled graphic content not only fits the size of the effective viewport but is also positioned precisely in the center of the effective viewport, thus achieving a symmetrical and balanced visual effect. This further enhances the aesthetics of the interface and the user's operational comfort.

[0091] Based on the same concept, this application also discloses a discrete-step graphical view adaptive scaling system. The system is used to implement the steps described in any of the above method embodiments. Specifically, one embodiment of the discrete-step graphical view adaptive scaling system of this application includes: The bounding rectangle calculation unit is used to traverse all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content bounding rectangle.

[0092] The viewport size calculation unit is used to calculate the effective viewport size of the view control.

[0093] The scaling ratio calculation unit is used to calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle.

[0094] The scaling step calculation unit is used to convert the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations.

[0095] The final step number determination unit is used to determine the final scaling step number based on the symbol combination of the target scaling step number in the horizontal and vertical directions.

[0096] The scaling transformation application unit is used to calculate a scaling factor based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

[0097] Based on the same concept, this application also discloses an electronic device, the device including the discrete-step-based graphical view adaptive scaling system described in the above embodiments.

[0098] The discrete-step graphical view adaptive scaling method, system, and electronic device of this application have the same technical concept, and the technical details of the embodiments of the two are applicable to each other. To reduce repetition, they will not be repeated here.

[0099] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of program modules is merely an example. In practical applications, the above functions can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program units or modules to complete all or part of the functions described above. The program modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software program unit. Furthermore, the specific names of the program modules are only for easy differentiation and are not intended to limit the scope of protection of this application.

[0100] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A graphical view adaptive scaling method based on discrete stepping, characterized in that, Includes the following steps: Iterate through all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content-enclosing rectangle; Calculate the effective viewport size of the view control; and calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle. The continuous target scaling ratio is converted into discrete target scaling steps based on logarithmic operations, and the final scaling steps are determined based on the sign combination of the target scaling steps in the horizontal and vertical directions. A scaling factor is calculated based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

2. The adaptive scaling method for graphical views based on discrete stepping as described in claim 1, characterized in that, Iterate through all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content-enclosing rectangle; specifically including: Based on each graphic element, obtain the element geometric rectangle, and extend the element geometric rectangle by a preset number of pixels to obtain the boundary of the independent rectangle; The union of the independent rectangular boundaries of all the graphic elements is obtained by performing a rectangle union operation; the joint rectangular boundary of the graphic elements is obtained based on the union.

3. The adaptive scaling method for graphical views based on discrete stepping as described in claim 1, characterized in that, Calculate the effective viewport size of the view control; specifically including: Obtain the viewport size of the view control; the viewport size is the visible area size of the view control, including the viewport width and viewport height; The effective viewport size is calculated based on a preset white space ratio; the effective viewport size is the actual content display area size, including the effective viewport width and the effective viewport height. The effective viewport width is equal to the viewport width multiplied by the effective viewport coefficient; The effective viewport height is equal to the viewport height multiplied by the effective viewport coefficient; The effective viewport coefficient is equal to 1 minus twice the white space ratio.

4. The adaptive scaling method for graphical views based on discrete stepping as described in claim 3, characterized in that, Based on the effective viewport size and the size of the content-enclosing rectangle, calculate the target scaling ratio of the view in the horizontal and vertical directions; specifically including: The horizontal scaling ratio is obtained by dividing the effective viewport width by the width of the content-enclosed rectangle; The vertical scaling ratio is obtained by dividing the effective viewport height by the height of the content-enclosed rectangle.

5. The adaptive scaling method for graphical views based on discrete stepping as described in claim 4, characterized in that, The continuous target scaling ratio is converted into discrete target scaling steps based on logarithmic operations; Specifically, it includes: Solve for the first logarithmic value corresponding to the horizontal scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the horizontal scaling steps; Solve for the second logarithmic value corresponding to the vertical scaling ratio under the logarithmic function with the single-step scaling ratio as the base, and obtain the vertical scaling steps; The single-step scaling ratio is a preset constant, representing the scaling factor for each scroll wheel zoom operation; The calculation results are rounded to the nearest integer to obtain the target scaling steps in the horizontal and vertical directions.

6. The adaptive scaling method for graphical views based on discrete stepping as described in claim 1, characterized in that, The final scaling step number is determined based on the sign combination of the target scaling step number in the horizontal and vertical directions; Specifically, it includes: Determine the sign of the target scaling steps in the horizontal and vertical directions; The final scaling step count is zero when the target scaling step count is zero in both directions. When one direction is zero and the other direction is positive, the target scaling step number in the positive direction is taken as the final scaling step number; When one direction is zero and the other direction is negative, the final scaling step count is zero; When the target scaling steps in both directions are positive, the maximum value between the two is taken as the final scaling step number. When the target scaling steps in both directions are negative, the target scaling step with the smallest absolute value is taken as the final scaling step. When one direction is positive and the other direction is negative, the target scaling step number in the positive direction is taken as the final scaling step number.

7. The adaptive scaling method for graphical views based on discrete stepping as described in claim 5, characterized in that, Calculate the scaling factor based on the final scaling steps in order to create a transformation matrix and apply it to the current view; Specifically, it includes: The scaling factor is calculated by exponentiation of the single-step scaling ratio as the base and the final number of scaling steps as the exponent. Obtain the first transformation matrix of the current view, and obtain the first scaling ratio of the current view from the first transformation matrix; The first scaling factor is multiplied by the scaling factor to obtain a new second scaling factor. The range of the second scaling factor is limited, and a new second transformation matrix is ​​created based on the second scaling factor. The second transformation matrix is ​​then applied to the current view.

8. The adaptive scaling method for graphical views based on discrete stepping as described in any one of claims 1-7, characterized in that, Also includes: Align the center point of the enclosing rectangle with the center point of the effective viewport of the view control to achieve centered display.

9. A discrete-step graph view adaptive scaling system, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-8, specifically including: The bounding rectangle calculation unit is used to traverse all graphic elements in the current view, calculate the independent rectangular boundary of each individual graphic element, and the joint rectangular boundary of all graphic elements, as the content bounding rectangle. Viewport size calculation unit, used to calculate the effective viewport size of view controls; A scaling ratio calculation unit is used to calculate the target scaling ratio of the view in the horizontal and vertical directions based on the effective viewport size and the size of the content-enclosing rectangle. A scaling step calculation unit is used to convert the continuous target scaling ratio into discrete target scaling steps based on logarithmic operations; The final step number determination unit is used to determine the final scaling step number based on the symbol combination of the target scaling step number in the horizontal and vertical directions; The scaling transformation application unit is used to calculate a scaling factor based on the final scaling steps in order to create a transformation matrix and apply it to the current view.

10. An electronic device, characterized in that, The device includes the discrete-stepping-based adaptive scaling system for graphical views as described in claim 9.