Vector diagram primitive interaction control method and device, equipment and storage medium

By parsing, converting formats, and handling mouse events for vector graphics files, the problems of low display efficiency and insufficient interactive accuracy of vector graphics on the Qt platform are solved, enabling adaptive display and real-time remote control, thus improving the efficiency and accuracy of graphics processing.

CN121807209APending Publication Date: 2026-04-07CRSC RESEARCH & DESIGN INSTITUTE GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-04
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies for vector graphics processing on the Qt platform suffer from poor display quality and efficiency, low interactive accuracy, and poor coupling of remote control, making it particularly difficult to achieve adaptive display and real-time synchronous control in complex scenarios.

Method used

By parsing vector graphics files, converting and assigning primitive formats and identifiers, adapting and scaling containers, and associating mouse events with primitive identifiers, efficient parsing and precise interactive control of primitives are achieved. This includes loading vector graphics files, parsing primitive types, converting to specified formats, assigning primitive identifiers, calculating scaling ratios, listening to mouse events, and obtaining pixel coordinates to determine primitive identifiers for interactive control.

Benefits of technology

It improves the display efficiency and interactive accuracy of vector graphics, ensures that graphic elements are not distorted in display containers of different sizes, realizes real-time synchronous remote control, and enhances response speed and operational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807209A_ABST
    Figure CN121807209A_ABST
Patent Text Reader

Abstract

The invention discloses a vector diagram primitive interaction control method and device, equipment and a storage medium. Comprising the following steps: loading a target vector diagram file, analyzing the target vector diagram file, performing specified format conversion on an analyzed primitive, and assigning a primitive identifier; obtaining a target container and calculating a scaling ratio, and displaying the target vector diagram file in the center of the target container based on the scaling ratio; and monitoring a mouse event, obtaining a selected pixel point coordinate, determining a target primitive identifier corresponding to the pixel point coordinate, and performing interaction control based on the target primitive identifier. A unified data basis is provided by analyzing and converting the primitives; and the accuracy of subsequent positioning is ensured by assigning the pixel identifier. By calculating the scaling, the vector diagram adapts to the size of the container, and distortion or display range exceeding is avoided. By monitoring the mouse event, the operation intention of the user is quickly captured, and the target primitive is directly associated through the identifier, so that the interaction speed is increased, and the operation accuracy is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of graphics processing, and more particularly to a method, apparatus, device, and storage medium for interactive control of vector graphics primitives. Background Technology

[0002] In fields such as industrial monitoring and equipment management, vector graphics are frequently used to represent equipment layout and status due to their high editability and lossless scaling. Users need to interact with these elements to control the corresponding devices. Although the Qt framework provides basic graphics components, it lacks integrated support for efficient parsing, precise interaction, and adaptive display of vector graphics elements, making this need increasingly prominent.

[0003] Currently, most vector graphics processing solutions on the Qt platform use a simple parsing method to load files and render them using basic drawing tools. During interaction, they rely on pixel traversal or region-based rough matching of graphic elements. Some solutions require combining external databases to associate graphic element information in order to achieve basic display and operation.

[0004] However, existing technologies have several shortcomings: First, the display effect and efficiency are poor. When rendering complex scenes using bitmaps or simple drawing tools, scaling and rotation can easily lead to image distortion, and there is a lack of dynamic adjustment capabilities for adaptive windows, making it unable to adapt to display containers of different sizes. Second, the interaction accuracy and efficiency are low. The mapping logic between pixel coordinates and primitives is crude, making it difficult to quickly locate device information by clicking on primitives, requiring reliance on external database queries, resulting in high response latency. Third, the coupling of remote control is poor. The graphical interface and device status data are separated, making real-time synchronization impossible. Command issuance requires additional manual operation, which is not only cumbersome but also prone to errors, making it difficult to adapt to the visualization monitoring and remote control needs of complex 2D scenes. Summary of the Invention

[0005] This invention provides a vector graphic element interactive control method, apparatus, device, and storage medium. By parsing vector graphic files, converting graphic element formats and assigning identifiers, adapting and scaling containers, and associating mouse events with graphic element identifiers, it solves the problems of low display efficiency, weak interactive capabilities, and poor remote control coupling in existing technologies.

[0006] According to one aspect of the present invention, a vector graphics primitive interaction control method is provided, the method comprising:

[0007] Load the target vector graphic file, parse the target vector graphic file, convert the parsed graphic elements to a specified format, and assign graphic element identifiers;

[0008] Obtain the target container and calculate the scaling ratio, then center the target vector file within the target container based on the scaling ratio.

[0009] The mouse event is listened to, the selected pixel point coordinates are acquired, the target graphic element identifier corresponding to the pixel point coordinates is determined, and interactive control is performed based on the target graphic element identifier.

[0010] Optionally, the target vector graph file is parsed, including: determining a graphic element type included in the target vector graph file, wherein the graphic element type includes a line segment, text, a rectangle, a path and a custom; and parsing the target vector graph file according to the graphic element type, to generate parsed graphic elements, and storing the parsed graphic elements in the form of an object linked list array.

[0011] Optionally, the parsed graphic elements are converted into a specified format and assigned a graphic element identifier, including: sequentially filling the parsed graphic elements into a specified format of a QGraphicsLineItem object through loop iteration, and sequentially assigning a graphic element identifier to each QGraphicsLineItem object, wherein the QGraphicsLineItem object is a subclass object of a QGraphicsItem base class.

[0012] Optionally, the target container is acquired and a scaling ratio is calculated, including: acquiring a QGraphicsScene as the target container; determining a parent window size of the target container, calculating a display area when the target vector graph file is displayed in the center based on the parent window size; determining an actual size of the target vector graph file, and calculating a scaling ratio according to a ratio of the actual size to the display area.

[0013] Optionally, the mouse event is listened to, and the selected pixel point coordinates are acquired, including: listening to an interactive action of the mouse, and acquiring pixel point coordinates corresponding to a selected graphic element in a screen when the mouse event is triggered.

[0014] Optionally, the target graphic element identifier corresponding to the pixel point coordinates is determined, including: calling a preset method under a QGraphicsView base class, returning a selected graphic element object corresponding to the pixel point coordinates according to the input pixel point coordinates; and parsing the selected graphic element object, and extracting a target graphic element identifier assigned to the selected graphic element object.

[0015] Optionally, the interactive control is performed based on the target graphic element identifier, including: acquiring a graphic item operation interface, generating an interactive instruction corresponding to the target graphic element identifier based on the graphic item operation interface; and delivering the interactive instruction to the selected graphic element object, to realize the interactive control.

[0016] According to another aspect of the present application, a vector graph graphic element interactive control device is provided, and the device includes:

[0017] A vector graph file parsing module is configured to load a target vector graph file, parse the target vector graph file, convert parsed graphic elements into a specified format, and assign a graphic element identifier to the parsed graphic elements.

[0018] The vector graph file display module is configured to acquire a target container and calculate a scaling ratio, and display a target vector graph file in the target container based on the scaling ratio.

[0019] The primitive interaction control module is configured to listen to a mouse event, acquire a selected pixel point coordinate, determine a target primitive identifier corresponding to the pixel point coordinate, and perform interaction control based on the target primitive identifier.

[0020] According to another aspect of the present application, an electronic device is provided, which comprises:

[0021] at least one processor;

[0022] and a memory connected in communication with the at least one processor;

[0023] wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the vector graph primitive interaction control method according to any one of the embodiments of the present application.

[0024] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to perform the vector graph primitive interaction control method according to any one of the embodiments of the present application when executed by the processor.

[0025] The technical solution of the embodiments of the present application provides a unified data basis for subsequent interaction through the standardized processing of the primitives, and guarantees the accuracy of subsequent positioning and operation through the accurate differentiation of the primitives by the primitive identifier. The vector graph is adapted to the size of the target container by calculating the scaling ratio, so that distortion or exceeding the display range is avoided. The user operation intention is quickly captured by listening to the mouse event, so that the accurate mapping of the pixel coordinate and the primitive is realized. The target primitive is directly associated by the identifier, so that the response speed of the interaction is improved, and the accuracy and efficiency of the operation are guaranteed.

[0026] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0028] Figure 1 is a flow chart of a vector graph figure element interaction control method according to an embodiment of the present application;

[0029] Figure 2 is a flow chart of another vector graph figure element interaction control method according to another embodiment of the present application;

[0030] Figure 3 is a structural schematic diagram of a vector graph figure element interaction control device according to an embodiment of the present application;

[0031] Figure 4 is a structural schematic diagram of an electronic device implementing a vector graph figure element interaction control method according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.

[0033] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0034] Embodiment one

[0035] Figure 1 A flow chart of a vector graph figure element interaction control method is provided for the first embodiment of the present application. The present embodiment can be applicable to Qt application programs. The method can be performed by a vector graph figure element interaction control device, which can be realized in the form of hardware and / or software, and can be configured in a computer controller. As shown in the figure, the method comprises: Figure 1

[0036] ​S110, load a target vector graph file, parse the target vector graph file, convert the parsed graph elements into a specified format, and assign a graph element identifier.

[0037] The vector graph is a scalable vector graphics (SVG), which refers to a graph defined by mathematical formulas, and the graph element is a basic independent element constituting the vector graph, such as a rectangle, a line segment, a circle, and a text. Each graph element has independent attributes and can be individually selected and operated. The target vector graph file refers to a vector graph file that needs to be interactively controlled, which is in the SVG format and includes all graph elements constituting the vector graph and their attribute information. The specified format conversion refers to converting the parsed graph element data into a specific internal processing format, so as to subsequently uniformly manage, calculate, and interactively control the graph elements. The graph element identifier refers to a unique identifier, such as an ID or a number, assigned to each graph element, which is used to accurately distinguish different graph elements in the system. Through the graph element identifier, a specific graph element can be quickly located and interactively operated.

[0038] Optionally, the target vector graph file is parsed, including: determining the graph element types included in the target vector graph file, wherein the graph element types include line segments, texts, rectangles, paths, and customizations; parsing the target vector graph file according to the graph element types to generate parsed graph elements, and storing the parsed graph elements in the form of an object linked list array.

[0039] Specifically, when the target vector graph file is parsed, the types of graph elements included in the file need to be determined, including line segments, texts, rectangles, paths, and customizations. The line segment refers to a straight line element defined by two end points, the text refers to a text element including character content, font, size, and other attributes, the rectangle refers to a rectangular element with fixed width, height, and corner attributes, the path refers to a complex contour element composed of multiple anchor points and curve segments, and the customization refers to a non-standard basic graph element defined according to specific requirements.

[0040] Further, after determining the graph element types, the system will parse the vector graph file according to different types. For example, when parsing a line segment, the coordinates of its two end points, line color, thickness, and other attributes are extracted; when parsing a text, the text content, starting coordinates, font style, color, and other information are obtained; when parsing a rectangle, the top-left corner coordinate, width, height, fill color, and border attributes are extracted; when parsing a path, the anchor point coordinates, curve control parameters, and path closure state of the path are parsed; and when parsing a customization, the corresponding attribute parameters are extracted according to the predefined definition rules.

[0041] Specifically, after parsing by type, a parsed primitive containing respective attribute information is generated. The parsed primitives are stored in the form of an object linked list array, that is, each primitive is an object containing its type identifier and all attribute data, and multiple primitive objects form a linked list in sequence, and primitive linked lists of different types are combined into an array structure. The storage mode of the object linked list array facilitates quick searching of primitives by type and efficient traversal of all primitives in sequence through the linked list.

[0042] Optionally, the parsed primitives are converted into a specified format and assigned primitive identifiers, including: filling and converting each parsed primitive into a QGraphicLineItem object of a specified format in sequence through loop iteration, and assigning primitive identifiers to each QGraphicLineItem object in sequence, wherein the QGraphicLineItem object is a subclass object of the QGraphicItem base class.

[0043] Specifically, the system processes all primitives obtained after parsing one by one through loop iteration. The specified format conversion refers to filling and converting each parsed primitive into a QGraphicLineItem object. QGraphicLineItem is a subclass of the QGraphicItem base class in the Qt framework and is specially used to represent and process straight line primitives, which contains attributes such as the start point, end point, line style, color, etc. of a straight line and can adapt to the display and interaction requirements in the graphics view framework. During the conversion process, the primitive attributes obtained through parsing are mapped to the attributes of the QGraphicLineItem object to ensure that the converted object retains the key information of the original primitive.

[0044] Further, after the conversion of each primitive into a QGraphicLineItem object is completed, a unique primitive identifier is assigned to each QGraphicLineItem object in sequence. The primitive identifier can be a string of numbers, characters or special codes, which is used to uniquely distinguish different primitive objects in subsequent operations. Through conversion and assignment, the parsed primitive data is converted into an object form suitable for processing and interaction in the Qt graphics view framework, and a unique correspondence between the object and the original primitive is established through the primitive identifier.

[0045] S120, obtaining a target container and calculating a scaling ratio, and displaying the target vector graphics file in the target container in a centered manner based on the scaling ratio.

[0046] The target container refers to an interface area or component for displaying and carrying the vector diagram, and its size and attributes affect the display range and scaling ratio of the vector diagram. The scaling ratio target container size is in a proportional relationship with the original size of the vector diagram. By calculating the scaling ratio, the vector diagram can be adapted to the target container to avoid the graphic elements exceeding the display range. After scaling the vector diagram based on the calculated scaling ratio, the center display adjusts the position of the vector diagram in the target container, so that the geometric center of the vector diagram is aligned with the center of the target container, ensuring an aesthetic display effect and balanced distribution of graphic elements.

[0047] Optionally, the target container is obtained and the scaling ratio is calculated, including: obtaining a QGraphicsScene as the target container; determining the size of the parent window of the target container, calculating the display area of the target vector diagram file when displayed in the center based on the size of the parent window; determining the actual size of the target vector diagram file, and calculating the scaling ratio according to the ratio of the actual size to the display area.

[0048] The target container refers to a QGraphicsScene, which is a scene container in the Qt framework for managing graphic items, and all graphic objects are added to this scene container for unified management and display.

[0049] It should be noted that the parent window generally refers to a window component carrying the QGraphicsScene, and by obtaining the width and height of the parent window, the actual interface space size available for vector diagram display can be obtained. Then based on the size of the parent window, the display area of the target vector diagram file when displayed in the center can be calculated. The display area refers to the effective area inside the parent window suitable for placing the vector diagram, which is generally slightly smaller than the size of the parent window, so that the vector diagram can be displayed in the center of the parent window without exceeding the boundary.

[0050] Specifically, the system determines the actual size of the target vector diagram file, which can be obtained from the parsed graphic data, for example, by traversing the coordinate ranges of all graphic elements to calculate the minimum bounding rectangle of the entire vector diagram. The width and height of the minimum bounding rectangle are the actual width and actual height of the vector diagram. Finally, the scaling ratio is calculated, that is, the width of the display area is divided by the actual width of the vector diagram to obtain the ratio in the width direction, and the height of the display area is divided by the actual height of the vector diagram to obtain the ratio in the height direction. In order to ensure that the vector diagram can be displayed completely in the display area without distortion, the smaller value of the two ratios is usually selected as the final scaling ratio, so that the vector diagram can be adapted to the display area in both width and height directions, and a suitable scaling basis is provided for subsequent center display.

[0051] S130, listen to the mouse event, obtain the selected pixel point coordinates, determine the target graphic element identifier corresponding to the pixel point coordinates, and perform interactive control based on the target graphic element identifier.

[0052] The mouse event refers to an action triggered when a user interacts with the vector diagram in the target container through a mouse, such as mouse clicking, moving, dragging, etc., and is an input mode for obtaining the user interaction intention. The selected pixel point coordinate refers to a click position coordinate obtained in the pixel coordinate system of the target container when the user triggers the mouse event, and the coordinate corresponds to a certain pixel point of the vector diagram displayed in the container. The target graph element identifier refers to the graph element identifier of the graph element corresponding to the selected pixel point coordinate matched in reverse. For example, if the click position falls within the display range of a certain rectangular graph element, the graph element identifier of the rectangle is the target graph element identifier. The interaction control refers to an operation performed on the corresponding graph element based on the target graph element identifier, such as selection highlighting, moving position, modifying color, adjusting size, deleting, etc., and is a specific function implementation of user interaction with the vector diagram graph element.

[0053] The technical scheme of the embodiment of the application provides a unified data basis for subsequent interaction through the standardized processing of the graph element; the accuracy of subsequent positioning and operation is guaranteed by accurately distinguishing each graph element through the graph element identifier. By calculating the scaling ratio, the vector diagram is adapted to the size of the target container to avoid distortion or exceeding the display range. By listening to the mouse event, the user operation intention is quickly captured to realize accurate mapping of the pixel coordinate and the graph element; the interaction response speed is improved by directly associating the target graph element through the identifier, and the accuracy and efficiency of the operation are guaranteed.

[0054] Embodiment two

[0055] Figure 2 A flowchart of a vector diagram graph element interaction control method provided by the second embodiment of the application, the embodiment adds the specific process of listening to the mouse event, obtaining the selected pixel point coordinate, determining the target graph element identifier corresponding to the pixel point coordinate, and performing interaction control based on the target graph element identifier on the basis of the above-mentioned embodiment one. The specific content of steps S250-S260 is substantially the same as that of steps S120-S130 in embodiment one, so the embodiment will not be described again. As shown in the figure, the method comprises the following steps. Figure 2

[0056] S210, load the target vector diagram file, analyze the target vector diagram file, convert the analyzed graph element into a specified format and assign a graph element identifier.

[0057] Optionally, the target vector diagram file is analyzed, including: determining the graph element types included in the target vector diagram file, wherein the graph element types include line segments, text, rectangles, paths and custom; the target vector diagram file is analyzed according to the graph element types, the analyzed graph elements are stored in the form of an object linked list array.

[0058] ​Optionally, the parsed graphics primitives are converted into a specified format and assigned a graphics primitive identifier, including: sequentially filling each parsed graphics primitive into a QGraphicLineItem object of the specified format through a loop, and sequentially assigning a graphics primitive identifier to each QGraphicLineItem object, wherein the QGraphicLineItem object is a subclass object of the QGraphicItem base class.

[0059] S220, obtaining a target container and calculating a scaling ratio, and displaying the target vector graphics file in the target container based on the scaling ratio.

[0060] Optionally, the target container is obtained and the scaling ratio is calculated, including: obtaining a QGraphicScene as the target container; determining the size of a parent window of the target container, calculating a display area of the target vector graphics file when displayed in the center based on the size of the parent window; determining the actual size of the target vector graphics file, and calculating the scaling ratio according to the ratio of the actual size to the display area.

[0061] S230, listening to the interactive actions of the mouse, and obtaining the pixel point coordinates corresponding to the selected graphics primitive in the screen when a mouse event is triggered.

[0062] Specifically, the system continuously monitors various interactive actions of the mouse, such as left-click, right-click, double-click, or mouse movement, etc. When the user interacts with the vector graphics primitives in the target container through the mouse and triggers a specific mouse event, the system will immediately capture it. At this time, the system will extract the pixel point coordinates corresponding to the selected position on the screen from the mouse event. The pixel point coordinates are in units of screen pixels, corresponding to the specific position of the mouse click on the display device. For example, in a computer screen, the upper left corner is usually taken as the origin, the horizontal direction is taken as the X-axis, and the vertical direction is taken as the Y-axis, and the coordinate value is accurate to a single pixel. The coordinates directly reflect the physical position of the user's operation, which will be mapped to the coordinate system of the vector graphics through coordinate conversion in the future, so as to determine the specific graphics primitive corresponding to the position.

[0063] S240, calling a preset method under the QGraphicView base class, and returning the selected graphics primitive object corresponding to the input pixel point coordinates.

[0064] Specifically, the system will help the preset method provided by the QGraphicsView base class in the Qt framework to achieve. QGraphicsView is a view component that displays graphics items in QGraphicsScene, which contains functions that convert screen pixel coordinates to scene coordinates and find corresponding primitives, such as the itemAt(event->pos()) method. When the selected pixel coordinates are obtained, the preset method is called, which automatically handles coordinate conversion, i.e. converts screen pixel coordinates to scene coordinates in QGraphicsScene, and finds the primitive object at that coordinate position in the scene, and finally returns the selected primitive object corresponding to the pixel coordinates.

[0065] S250, analyze the selected primitive object and extract the target primitive identifier assigned to the selected primitive object.

[0066] Specifically, the system will analyze the returned selected primitive object. Since in the previous step, each primitive object is assigned a unique primitive identifier, and the primitive identifier usually exists as an attribute of the primitive object, the analysis process is to read the preset attribute value from the selected primitive object, thereby extracting the target primitive identifier corresponding to the primitive object.

[0067] S260, get the graphics item operation interface, and generate an interactive instruction corresponding to the target primitive identifier based on the graphics item operation interface.

[0068] Specifically, the system will obtain the graphics item operation interface, which is a set of functions predefined for performing various operations on primitive objects, such as moving, rotating, scaling, modifying color, deleting, etc. The implementation methods of these operations are encapsulated in the graphics item operation interface. Then according to the target primitive identifier, the corresponding interactive instruction is generated through the graphics item operation interface. For example, if the user's interactive intention is to move the selected primitive, the interface will determine the specific primitive to be operated according to the target primitive identifier, and then generate a moving instruction containing the moving direction, distance, etc. If it is to modify the color, a color modification instruction containing the new color value is generated. The interactive instruction will explicitly specify the object of the operation and the specific content of the operation.

[0069] S270, issue the interactive instruction to the selected primitive object to achieve interactive control.

[0070] It can be known that since each graphic object has a unique target graphic identification, the instruction is accurately matched to the selected graphic, and after the selected graphic object receives the instruction, it performs the corresponding operation according to the requirement in the instruction, such as adjusting the coordinate position of itself according to the moving instruction, updating the fill color or border color of itself according to the color modification instruction, and the like, so as to realize the interactive control of the selected graphic. The whole process ensures the accuracy of the operation through the target graphic identification, and unifies the interactive logic through the graphic item operation interface, so that different types of graphics can respond to the interactive instruction in a unified manner.

[0071] The technical scheme of the embodiment of the application realizes accurate capture of the screen pixel point coordinates corresponding to the selected position when triggering the related event by real-time monitoring of the mouse interaction action, provides accurate position basis for subsequent graphic positioning. The corresponding selected graphic object is quickly matched and returned according to the pixel point coordinates by calling the preset method of the QGraphicsView base class, and the unique identification on the graphic is efficiently parsed and extracted, so as to realize accurate association of the coordinates and the graphic identification. The interactive instruction corresponding to the target graphic identification is generated by means of the graphic item operation interface, the instruction is accurately issued to the corresponding graphic object, and accurate and efficient response of the interactive control of the target graphic is ensured.

[0072] Embodiment three

[0073] Figure 3 A structural schematic diagram of a vector graphic graphic interactive control device provided by the third embodiment of the application is shown in FIG. 3. Figure 3 As shown in the figure, the device includes: a vector graphic file analysis module 310, configured to load a target vector graphic file, analyze the target vector graphic file, convert the analyzed graphics into a specified format and assign a graphic identification to the graphics;

[0074] A vector graphic file display module 320, configured to obtain a target container and calculate a scaling ratio, and display the target vector graphic file in the target container based on the scaling ratio;

[0075] A graphic interactive control module 330, configured to listen to a mouse event, obtain a selected pixel point coordinate, determine a target graphic identification corresponding to the pixel point coordinate, and perform interactive control based on the target graphic identification.

[0076] Optionally, the vector graphic file analysis module 310 specifically includes: a graphic analysis unit, configured to: determine a graphic type included in the target vector graphic file, wherein the graphic type includes a line segment, a text, a rectangle, a path and a custom; analyze the target vector graphic file according to the graphic type, generate an analyzed graphic, and store the analyzed graphic in the form of an object linked list array.

[0077] Optionally, the vector graph file parsing module 310 specifically comprises: a primitive conversion unit, configured to sequentially fill and convert each parsed primitive into a specified format of a QGraphicsLineItem object through loop traversal, and sequentially assign a primitive identifier to each QGraphicsLineItem object, wherein the QGraphicsLineItem object is a subclass object of a QGraphicsItem base class.

[0078] Optionally, the vector graph file display module 320 is specifically configured to: acquire a QGraphicsScene as a target container; determine a parent window size of the target container, calculate a display area when the target vector graph file is displayed in the center based on the parent window size; determine an actual size of the target vector graph file, and calculate a scaling ratio according to a ratio of the actual size to the display area.

[0079] Optionally, the primitive interaction control module 330 specifically comprises: a pixel point coordinate acquisition unit, configured to: listen to an interactive action of a mouse, and acquire a pixel point coordinate corresponding to a selected primitive in a screen when a mouse event is triggered.

[0080] Optionally, the primitive interaction control module 330 specifically comprises: a target primitive identifier determination unit, configured to: call a preset method under a QGraphicsView base class, return a selected primitive object corresponding to the pixel point coordinate according to the input pixel point coordinate, and parse the selected primitive object to extract a target primitive identifier assigned to the selected primitive object.

[0081] Optionally, the primitive interaction control module 330 specifically comprises: a primitive interaction control unit, configured to: acquire a graphics item operation interface, generate an interaction instruction corresponding to the target primitive identifier based on the graphics item operation interface, and send the interaction instruction to the selected primitive object to implement interaction control.

[0082] The technical scheme of the embodiment of the application provides a unified data basis for subsequent interaction through standardized processing of primitives; the accuracy of subsequent positioning and operation is guaranteed through accurate differentiation of each primitive by the primitive identifier. The vector graph is adapted to the size of the target container by calculating the scaling ratio, so that distortion or exceeding the display range is avoided. The user operation intention is quickly captured by listening to the mouse event, so that accurate mapping of the pixel coordinates and the primitives is implemented; the interaction response speed is improved by directly associating the target primitive by the identifier, so that the accuracy and efficiency of the operation are guaranteed.

[0083] The vector graph primitive interaction control device provided in the embodiment of the application can execute the vector graph primitive interaction control method provided in any embodiment of the application, and has the corresponding function modules and beneficial effects of the execution method.

[0084] Embodiment four

[0085] Figure 4 A structural diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices such as personal digital assistants, cellular telephones, smartphones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.

[0086] As shown in Figure 4 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected in communication with the at least one processor 11, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0087] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0088] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as a vector graphics figure element interaction control method.

[0089] In some embodiments, a vector graphics figure element interaction control method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of a vector graphics figure element interaction control method as described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform a vector graphics figure element interaction control method by other means, e.g., via firmware.

[0090] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, specially designed application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0091] Computer programs used to implement the methods of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor of the machine, implements the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0092] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0093] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0094] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0095] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0096] It should be understood that the various forms of flow shown above can be used to reorder, add or delete steps. For example, each step described in the present application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein.

[0097] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A vector graphics primitive interaction control method, characterized in that, include: Load the target vector graphic file, parse the target vector graphic file, convert the parsed graphic elements to a specified format, and assign graphic element identifiers; Obtain the target container and calculate the scaling ratio, then center the target vector image file within the target container based on the scaling ratio; Listen for mouse events, obtain the coordinates of the selected pixel, determine the target primitive identifier corresponding to the pixel coordinates, and perform interactive control based on the target primitive identifier.

2. The method according to claim 1, characterized in that, The parsing of the target vector file includes: Determine the types of graphic elements included in the target vector file, wherein the graphic element types include line segments, text, rectangles, paths, and custom elements; The target vector file is parsed according to the primitive type to generate parsed primitives, and the parsed primitives are stored in the form of an object linked list array.

3. The method according to claim 2, characterized in that, The step of converting the parsed primitives to a specified format and assigning primitive identifiers includes: By iterating through the loop, each parsed primitive is filled and converted into a QGraphicsLineItem object of a specified format, and a primitive identifier is assigned to each QGraphicsLineItem object in turn. The QGraphicsLineItem object is a subclass object of the QGraphicsItem base class.

4. The method according to claim 1, characterized in that, The step of obtaining the target container and calculating the scaling ratio includes: Get QGraphicsScene as the target container; Determine the size of the parent window of the target container, and calculate the display area of ​​the target vector file when it is centered based on the size of the parent window; Determine the actual size of the target vector graphic file and calculate the scaling ratio based on the ratio of the actual size to the display area.

5. The method according to claim 1, characterized in that, The process of listening to mouse events and obtaining the coordinates of the selected pixel includes: Listen for mouse interactions and, when a mouse event is triggered, obtain the pixel coordinates of the selected graphic element on the screen.

6. The method according to claim 1, characterized in that, The determination of the target primitive identifier corresponding to the pixel coordinates includes: Call the preset method under the QGraphicsView base class to return the selected primitive object corresponding to the input pixel coordinates; The selected graphic object is parsed to extract the target graphic element identifier assigned to the selected graphic element object.

7. The method according to claim 6, characterized in that, The interactive control based on the target primitive identifier includes: Obtain the graphical item operation interface, and generate an interactive instruction corresponding to the target graphic element identifier based on the graphical item operation interface; The interactive command is sent to the selected graphic element object to achieve interactive control.

8. A vector graphic element interactive control device, characterized in that, include: The vector graphic file parsing module is used to load the target vector graphic file, parse the target vector graphic file, convert the parsed graphic elements to a specified format, and assign graphic element identifiers. The vector graphic file display module is used to acquire the target container and calculate the scaling ratio, and display the target vector graphic file in the target container in a centered manner based on the scaling ratio; The primitive interaction control module is used to listen for mouse events, obtain the coordinates of the selected pixel, determine the target primitive identifier corresponding to the pixel coordinates, and perform interactive control based on the target primitive identifier.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.

10. A computer storage medium, characterized in that, The computer storage medium stores computer instructions that are used to cause a processor to execute the method of any one of claims 1-7.