Graph generation method, device and equipment supporting interaction, and storage medium
By adding pointers to the internal data structure of the graphical visualization tool within the QT framework, parsing the layout script, and replacing primitives, the problems of low efficiency and insufficient flexibility in drawing structured graphics in existing technologies are solved, enabling automated generation and interactive adjustment of structured graphics.
Patent Information
- Application Number
- CN202511508185.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-22
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-10-22
AI Technical Summary
Existing technologies for drawing structured graphics suffer from low efficiency, complex modifications, and unstable graphic quality when manually adjusting them, while automatically generated graphics lack flexibility and cannot achieve effective interactive adjustments.
Using QT framework primitives as the base class, pointers to internal data structures of graphical visualization tools are added to parse layout scripts to generate scene graph objects, and elements in the base layout graph are replaced by extended primitives to achieve automated generation and interactive adjustment.
It achieves automated generation of structured graphics while supporting interactive adjustment of nodes and connections, improving the efficiency and quality of graphics generation and enhancing the flexibility and modifiability of graphics.
Smart Images

Figure CN120976372B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to interactive graphics generation methods, apparatus, devices, and storage media. Background Technology
[0002] In daily work, it is often necessary to draw various structured diagrams, such as flowcharts, state transition diagrams, system architecture diagrams, sequence diagrams, and class diagrams in software development; network topology diagrams and system architecture diagrams in system and network architecture; and relationship diagrams in data visualization and analysis. The common method is to manually and interactively draw using drawing tools such as Visio, dragging and dropping nodes and lines, and then setting the attributes of nodes and edges to change the appearance of the diagram, such as setting colors, font styles, and line thickness. When modifying complex diagrams, each element must be manually adjusted, while considering aesthetic issues such as hierarchy, layout direction, and line intersections. This is inefficient when modifications and iterations are needed. Summary of the Invention
[0003] In view of this, this application provides a method, apparatus, device, and storage medium for generating interactive graphics to achieve automated generation of structural diagrams that support interactive adjustments.
[0004] The first aspect of this application provides a method for generating interactive graphics, the method comprising:
[0005] Extended primitives are created by adding pointers to the internal data structures of graphical visualization tools based on the primitives of the QT framework;
[0006] The layout script of the target structure diagram generated by the graphical visualization tool is analyzed, and the structural data of the target structure diagram is extracted; the structural data includes edge information, graph element information, node attributes, and subgraph information;
[0007] Call the scene graph object generated by the QT framework based on the structure data;
[0008] Run the layout engine of the graphical visualization tool in the scene graph object to generate a basic layout graph;
[0009] The position to be replaced in the basic layout diagram is located using the pointer of the internal data structure, and the position to be replaced is updated with the extended primitive to obtain a structured graphic.
[0010] In one possible implementation of the first aspect, pointers to the internal data structures of the graphical visualization tool are added to the primitives of the QT framework as the base class to create extended primitives, including:
[0011] Extended primitives are created by adding pointers to the internal data structures of graphical visualization tools and adding operation interfaces for modifying primitive states, using the primitives of the QT framework as the base class;
[0012] The method further includes:
[0013] The structured graphics are displayed on a display device, and the user's first trigger information for the display device is collected.
[0014] If the first triggering information corresponds to modifying the structured graph, determine the target extended primitive and generate an operation instruction for the target extended primitive;
[0015] The operation command is sent to the target extended graphic element through the operation interface, and the target extended graphic element is controlled to change according to the user's trigger information.
[0016] In one possible implementation of the first aspect, pointers to the internal data structures of the graphical visualization tool are added to the primitives of the QT framework as the base class to create extended primitives, including:
[0017] Add pointers to the internal data structure of the graphics visualization tool based on the primitives of the QT framework, as well as add rendering interfaces and hierarchical query interfaces;
[0018] The method further includes:
[0019] The structured graphics are displayed on a display device, and second trigger information from the user on the display device is collected.
[0020] The hierarchical query interface is used to locate and determine the portion of the graphic to be exported selected by the user in the structured graphic; the portion of the graphic to be exported consists of multiple extended graphic elements corresponding to the second trigger information.
[0021] The portion of the graphic to be exported is rendered using the rendering interface to obtain the saved graphic;
[0022] Export the saved image.
[0023] In one possible implementation of the first aspect, the position to be replaced includes the position of the node and the position of the edge. The position to be replaced in the basic layout graph is located using the internal data structure pointer, and the position to be replaced is updated with the extended primitive to obtain a structured graph, including:
[0024] Based on the structural data of the target structure diagram, determine the specific extended elements required for the target structure diagram, and the display position of the specific extended elements in the target structure diagram;
[0025] Traverse the nodes and edges in the basic layout graph. For each visited node or edge, delete the node or edge and add it as the corresponding extended primitive through the pointer of the internal data structure, so as to update the position to be replaced with the extended primitive and obtain the structured graph.
[0026] In one possible implementation of the first aspect, the position to be replaced in the basic layout diagram is located using the internal data structure pointer, and the position to be replaced is updated with the extended primitive to obtain a structured graph, including:
[0027] For each edge or each node, the position information of the internal data structure is transformed into the coordinates of the QT framework to obtain the reference position of the node or edge;
[0028] Find the target display location that matches the reference location;
[0029] The specific extended primitive corresponding to the target display position is used as the target specific extended primitive, and the specific extended primitive corresponding to the target display position is used to replace the edge or node of the current operation.
[0030] In one possible implementation of the first aspect, the location information of the internal data structure is transformed to the coordinates of the QT framework through the following relationship:
[0031] qt_x = (gv_x - llx) scale + offset_x (1);
[0032] qt_y = (ury - gv_y) scale + offset_y (2);
[0033] `qt_x` represents the X-axis coordinate of the transformed QT frame, and `qt_y` represents the Y-axis coordinate of the transformed QT frame; `gv_x` represents the X-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool, and `gv_y` represents the Y-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool; `llx` represents the X-axis coordinate of the lower left corner of the graph boundary in the graphics visualization tool, and `ury` represents the Y-axis coordinate of the upper right corner of the graph boundary in the graphics visualization tool; `offset_x` represents the X-axis coordinate of the upper left corner of the graph below the QT frame, and `offset_y` represents the Y-axis coordinate of the upper left corner of the graph below the QT frame; `scale` is the minimum value between the aspect ratio of the graphic rectangular region and the aspect ratio of the visible rectangular region. The graphic rectangular region is the rectangular region formed by the minimum horizontal and vertical coordinates, the maximum horizontal and vertical coordinates, and the maximum vertical coordinates of all graphic coordinates in the graphics visualization tool. The visible rectangular region is the rectangular region drawn by the graphics visualization tool.
[0034] In one possible implementation of the first aspect, pointers to the internal data structures of the graphical visualization tool are added to the primitives of the QT framework as the base class to create extended primitives, including:
[0035] Add pointers to the internal data structure of the graphical visualization tool based on the primitives of the QT framework, and add a hierarchical query interface;
[0036] Traverse the nodes and edges in the basic layout graph, including:
[0037] The nodes and edges of each layer of the basic layout diagram are accessed sequentially through the hierarchical query interface.
[0038] A second aspect of this application provides an interactive graphics generation apparatus, the apparatus comprising:
[0039] Create a module to add pointers to the internal data structures of graphical visualization tools based on the primitives of the QT framework, and create extended primitives;
[0040] The parsing module is used to parse the layout script of the target structure diagram generated by the graphics visualization tool and extract the structural data of the target structure diagram; the structural data includes edge information, graph feature information, node attributes, and subgraph information;
[0041] The scene generation module is used to call the scene graph object generated by the QT framework based on the structure data;
[0042] The layout engine module is a layout engine used to run graphical visualization tools in the scene graph object and generate a basic layout graph.
[0043] The update module is used to locate the position to be replaced in the basic layout diagram using the pointer of the internal data structure, update the position to be replaced to the extended primitive, and obtain a structured graphic.
[0044] A third aspect of this application provides an electronic device, comprising: a processor and a memory, the processor and the memory being connected via a communication bus; wherein the processor is configured to call and execute a program stored in the memory; and the memory is configured to store the program, the program being configured to implement the interactive graphics generation method provided in the first aspect of this application.
[0045] A fourth aspect of this application provides a computer-readable storage medium storing computer-executable instructions for performing an interactive graphics generation method as provided in the first aspect of this application.
[0046] Compared to existing technologies, this application provides a method, apparatus, device, and storage medium for generating interactive graphics. Its advantages lie in: using primitives inherited from the QT framework as a base class, adding pointers to internal data structures for maintaining Graphviz graphics elements, and creating extended primitives that support modification and maintain Graphviz graphics information. The layout script (Dot language file) is parsed to obtain key information needed to generate the target structure graph. Based on this key information, a scene graph object under the QT framework is generated. The Graphviz layout engine is called to generate a basic layout graph on the scene graph object. Then, pre-created extended primitives are used to replace elements in the basic layout graph, such as nodes or edges, to obtain an adjustable structured graph. The scene graph object, nodes, and edges are all adjustable, thus achieving automated generation of structure graphs that support interactive adjustment. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0048] Figure 1 This is a flowchart of the interactive graphics generation method proposed in the embodiments of this application;
[0049] Figure 2 This is an information flow diagram in the process of obtaining structured graphics from scene graph objects in the embodiments of this application;
[0050] Figure 3 This is a schematic diagram of a graphic rectangular region and a visible rectangular region in one example of this application;
[0051] Figure 4 This is a flowchart illustrating an example of an interactive graphics generation method according to this application;
[0052] Figure 5 This is a functional block diagram of an interactive graphics generation device proposed in an embodiment of this application. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0054] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0055] To better understand this application, the technical names involved in this application are explained below:
[0056] Graph Visualization Software (Graphviz) is an open-source toolset used to automate the creation of structured graphs such as relationship diagrams, network diagrams, and tree diagrams. It automatically generates visualizations by parsing the DOT text-based graphical description language.
[0057] The Qt framework is a cross-platform C++ application development framework, a 2D graphics rendering framework for handling large numbers of interactive graphical objects. It is primarily implemented through a scene graph, including: the primitive container class (QGraphicsScene), the base primitive class (QGraphicsItem), and the view window (QGraphicsView). QGraphicsScene is a container for managing all primitive collections. QGraphicsItem refers to a primitive, which is an object encapsulating graphical attributes and interactive logic. For example, nodes, lines, rectangles, circles, edges, and combinations of basic shapes can all be primitives. QGraphicsView refers to the editing window, an interactive canvas control based on a viewport, displaying a 2D graphical scene in Qt and providing a way to collect interactive information within the 2D graphical scene.
[0058] Example 1
[0059] As described in the background, manually drawing a structure diagram involves dragging nodes, drawing or dragging lines, setting attributes such as node and edge color, thickness, size, transparency, fill method, and hierarchy. Modifications also require manual adjustment of elements within the structure diagram, making the process complex, inefficient, and the quality of the graph unstable due to manual operation. Some programs, such as the graph visualization tool Graphviz, can automatically generate structure diagrams, but these diagrams cannot be modified, lacking flexibility. If adjustments are needed, the Dot text often needs to be modified and the generation process rerun, resulting in redundancy and wasted computational resources.
[0060] Therefore, this application provides an interactive graphic generation method that can automatically generate a layout relationship diagram based on the structural information of the target structure diagram. After the automatic layout is completed, the layout of objects such as nodes and connections on the graphic can be manually dragged and adjusted, realizing interactive adjustment of interactive objects after automatic layout and further improving the graphic quality.
[0061] Interactive graphics generation methods are applied to applications installed on terminal devices, such as computers, mobile phones, and tablets; for example... Figure 1 As shown, Figure 1 This is a flowchart of the interactive graphics generation method proposed in this application embodiment, the method including:
[0062] S11: Using the primitives of the QT framework as the base class, add pointers to the internal data structure of the graphical visualization tool to create extended primitives.
[0063] Executing S11 calls the QT framework, inheriting primitives from the QT framework template library. Multiple primitives in the template library can be inherited sequentially and extended, or they can be inherited in batches and then extended one primitive at a time. Extending a single primitive can be done by: adding pointers to the internal data structures of graphical visualization tools, adding operation interfaces for modifying primitive states, adding rendering interfaces, and adding hierarchical query interfaces.
[0064] The internal data structure pointers refer to the pointers to Anode, Aedge, and Agraph in Graphviz.
[0065] This class encapsulates the attributes and operations of ANode(Agnode_t).
[0066] The implementation process of adding pointers to the internal data structure of the graphical visualization tool based on the primitives of the QT framework can be as follows: In a custom QGraphicsItem subclass, directly hold the pointer of the ANode and encapsulate the property synchronization logic.
[0067] ANode is part of Graphviz's internal data structure, used to represent node objects in a graph, such as a flowchart that records the specific execution flow; Aedge is part of Graphviz's internal data structure, usually representing edge objects in a graph.
[0068] Extended primitives include node primitives and edge primitives. Node primitives are created based on the Qt framework's node base classes (such as rectangles, ellipses, circles, etc.), while edge primitives are created based on the Qt framework's edge base classes (such as lines, polylines, orthogonal lines, etc.). In one example, node primitives encapsulate Anode pointers, and edge primitives encapsulate Aedge pointers.
[0069] The steps described above for creating extended primitives in S11 can be explained as follows: Create a custom GraphicsNodeItem class, or a subclass of GraphicsNodeItem, such as QgraphicsEllipseItem, and encapsulate the properties and operations of Anode and Aedge, as well as other operation interfaces in the created class.
[0070] Other operation interfaces include: operation interfaces for modifying the status of graphic elements, adding rendering interfaces, querying by layer interfaces, interfaces for controlling the display status of graphic elements, interfaces for controlling the hiding status of graphic elements, and interfaces for setting the style of graphic elements.
[0071] While executing step S11, step S10 can also be executed: inherit QgraphicsScene from the QT framework, maintain the graph object AGraph of Graphviz and manage each graph primitive through QgraphicsScene, and provide functions for adding, deleting, modifying and querying nodes, edges and subgraphs.
[0072] Agraph is also part of the internal data structure, typically representing the global properties of all elements (nodes, edges) in the entire graph or subgraph, as well as being used to represent layout and rendering.
[0073] The above-mentioned primitives inheriting from the QT framework are further encapsulated with pointers to Graphviz's internal data structures, binding primitives under the QT framework and nodes in Graphviz. This provides the following foundation for the operability of primitives under the QT framework: operations on Graphviz nodes can be implemented through primitives under the QT framework.
[0074] In summary, step S11 can be achieved by executing the following sub-steps:
[0075] S111: Using the primitives of the QT framework as the base class, add pointers to the internal data structures of the graphical visualization tools, and add operation interfaces for modifying the primitive state to create extended primitives.
[0076] S112: Add pointers to the internal data structures of the graphics visualization tool based on the primitives of the QT framework, as well as add rendering interfaces and hierarchical query interfaces.
[0077] S113: Add pointers to the internal data structure of the graphical visualization tool based on the primitives of the QT framework, and add a hierarchical query interface.
[0078] S111, S112, and S113 are in a parallel relationship.
[0079] S12: Analyze the layout script of the target structure diagram generated by the graphical visualization tool, and extract the structural data of the target structure diagram; the structural data includes edge information, graph element information, node attributes, and subgraph information.
[0080] The target structure diagram is the final presentation of the structure diagram corresponding to the user's intent.
[0081] The graph visualization tool Graphviz parses the DOT text-based graphical description language and automatically generates visual graphics. Therefore, the layout script refers to the defined Dot language file, or the memory structure data in Dot form converted according to the business data format, such as database tables, JSON API data, and structures in the code converted into the resulting Dot language file.
[0082] Terminal devices can parse the Dot language files used by Graphviz to generate visualizations and obtain key information about the target graph structure, such as the order of nodes, node connection methods, edge types, node styles, edge styles, number of nodes, and node types.
[0083] The process of generating the layout script for the target structure diagram using a graphical visualization tool is as follows:
[0084] (1) Obtain graph feature information, including whether the graph type is a directed or undirected graph, set, graph type and attributes, etc.;
[0085] (2) Obtain node attributes, including text label name, color, style, shape, etc.;
[0086] (3) Obtain edge information, including starting node, ending node, and node attributes (such as label name, style, color, etc.).
[0087] (4) Obtain subgraph information, including node set, edge set, etc.
[0088] The information obtained by executing S12 includes information used to construct the structure diagram scenario.
[0089] S13: Call the scene graph object generated by the QT framework based on the structure data.
[0090] Scene graph objects can now be generated using QgraphicsScene, which inherits from the Qt framework. A scene graph object includes the scene, primitives, and view content. A scene graph object can be understood as a canvas before a concrete structural diagram has been generated.
[0091] Agraph is also part of the internal data structure, typically representing the global properties of all elements (nodes, edges) in the entire graph or subgraph, as well as being used to represent layout and rendering.
[0092] The specific process of executing the scene graph object generated by S13 is as follows:
[0093] (1) Set scene style.
[0094] (2) Traverse the parsed structural data, select the matching node primitives in the structural data, set the corresponding attributes, select the matching edge primitives in the structural data, and set the corresponding attributes.
[0095] (3) Extract subgraph information from structural data, create node primitives and edge primitives corresponding to the combined subgraph based on the subgraph information, and obtain subgraph objects, node and edge primitive objects in the set; subgraph refers to a set of primitives with logical grouping relationship.
[0096] S14: Run the layout engine of the graphics visualization tool in the scene graph object to generate a basic layout graph.
[0097] The system utilizes Graphviz's layered layout engine, force-directed layout engine, radial layout engine, and circular layout engine to generate a graph within the Graphviz framework on the canvas generated in S13, thus obtaining the basic layout graph.
[0098] Specifically, based on the characteristics of the structural data, a target layout engine that matches the structural data can be selected to generate a basic layout diagram. For example, if the target structural diagram contains multiple layers, and each layer has graphics or edges, a layered layout engine is called; if the target structural diagram is a friend relationship diagram or a community detection diagram, a force-directed layout engine is called to automatically calculate the node positions by simulating physical forces, so that closely connected nodes are clustered together and irrelevant nodes are moved away.
[0099] S15: Locate the position to be replaced in the basic layout diagram using the pointer of the internal data structure, update the position to be replaced with the extended primitive, and obtain a structured graphic.
[0100] The extended primitive created in step S11 contains pointers to Graphviz's Anode, Aedge, and Agraph. Therefore, the ANode information of Graphviz node objects can be maintained through the node primitive, and the AEDge information of Graphviz edge objects can be maintained through the edge primitive.
[0101] By replacing the nodes in the basic layout diagram generated by S14 with primitives in S15, the unmodifiable graph under the Graphviz framework is transformed into a modifiable graph, that is, a structure graph that supports interactive adjustment.
[0102] The above-described method in this application uses primitives inherited from the QT framework as the base class, adds pointers to internal data structures for maintaining Graphviz graphical elements, and creates extended primitives that support modification and maintain Graphviz graphical information. The layout script Dot language file is parsed to obtain key information needed to generate the target structure graph. Based on this key information, a scene graph object under the QT framework is generated. The Graphviz layout engine is called to generate a basic layout graph on the scene graph object. Then, pre-created extended primitives are used to replace elements in the basic layout graph, such as nodes or edges, to obtain an adjustable structured graph. The scene graph object, nodes, and edges are all adjustable, thereby achieving automated generation of structure graphs that support interactive adjustment.
[0103] Figure 2 This is an information flow diagram in the process of obtaining structured graphics from scene graph objects in this embodiment of the application, referencing... Figure 2 This describes the specific process of creating extended primitives, calling the QT framework to generate a scene graph object, then calling the graph visualization tool Graphviz to generate a basic layout graph from the scene graph object, and finally replacing the elements in the basic layout graph with extended primitives to obtain a structured graph:
[0104] K11: The application calls the scene graph object generated by the QT framework based on the structure data.
[0105] In one example, the application processes multiple graphs consecutively. After generating and adjusting the i-th structured graph, K11 is executed to generate a scene graph object to update the display layout of the display device.
[0106] K12: Calls Graphviz's layout engine to generate a base layout graph. In one example, the application processes multiple graphs consecutively. After generating and adjusting the structured graph for the i-th time, K11 is executed for the (i+1)-th time. The generated scene graph object is used to generate a graph based on the scene graph object, and the base layout graph displayed on the device is updated.
[0107] K13: Locate the position to be replaced in the basic layout diagram using the pointer of the internal data structure, and update the position to be replaced with the extended primitive.
[0108] Step K13 includes the following process:
[0109] K131: Based on the structural data of the target structure diagram, determine the specific extended elements required by the target structure diagram, and the display position of the specific extended elements in the target structure diagram.
[0110] For example, when searching structural data, it can be determined that the specific extended primitives needed to generate the target structural diagram include rectangular primitives, circular primitives, and straight lines; the display position of the specific extended primitive in the target structural diagram refers to the position of the specific extended primitive within the QT framework.
[0111] Since Graphviz node object ANode information and Graphviz edge object AEdge information can be maintained by extending primitives, the position of a specific extended primitive can be determined and placed at the position of its corresponding node or edge, thereby replacing the nodes and edges in the basic layout graph, that is, updating all nodes or edges in Graphviz to extended primitives.
[0112] K132: Traverse the nodes and edges in the basic layout graph. For each visited node or edge, delete the node or edge and add it as the corresponding extended primitive through the pointer of the internal data structure, so as to update the position to be replaced with the extended primitive and obtain the structured graph.
[0113] This application also provides an example of an implementation method for traversing nodes and edges in a basic layout graph: by using the hierarchical query interface, the nodes and edges of each layer of the basic layout graph are accessed sequentially.
[0114] Since it iterates through the nodes and edges in Graphviz, for the currently visited and processed node, the following process can be performed before executing K132 to determine the specific extended primitive corresponding to the currently processed edge or node in Graphviz, and replace the node or edge with the specific extended primitive.
[0115] M110: For each edge or each node, that is, during the traversal of nodes and edges, for the currently visited node or edge, the position information of the internal data structure is converted to the coordinates of the QT framework to obtain the reference position of the node or edge.
[0116] The location information of the internal data structure is transformed to the coordinates of the QT framework using the following relationship:
[0117] qt_x = (gv_x - llx) scale + offset_x (1);
[0118] qt_y = (ury - gv_y) scale + offset_y (2);
[0119] `qt_x` represents the X-axis coordinate of the transformed QT frame, and `qt_y` represents the Y-axis coordinate of the transformed QT frame; `gv_x` represents the X-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool, and `gv_y` represents the Y-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool; `llx` represents the X-axis coordinate of the lower left corner of the graph boundary in the graphics visualization tool, and `ury` represents the Y-axis coordinate of the upper right corner of the graph boundary in the graphics visualization tool; `offset_x` represents the X-axis coordinate of the upper left corner of the graph below the QT frame, and `offset_y` represents the Y-axis coordinate of the upper left corner of the graph below the QT frame; `scale` is the minimum value between the aspect ratio of the graphic rectangular region and the aspect ratio of the visible rectangular region. The graphic rectangular region is the rectangular region formed by the minimum horizontal and vertical coordinates, the maximum horizontal and vertical coordinates, and the maximum vertical coordinates of all graphic coordinates in the graphics visualization tool. The visible rectangular region is the rectangular region drawn by the graphics visualization tool.
[0120] Assume the length of the rectangular region of the graphic is AB, the width of the rectangular region of the graphic is BC, the ratio of AB to BC is AB / BC, the length of the visible rectangular region is ab, the length of the visible rectangular region is bc, the ratio of ab to bc is ab / bc, ab / bc > AB / BC, and scale = AB / BC.
[0121] Figure 3 This is a schematic diagram of a graphic rectangular region and a visible rectangular region in one example of this application, such as... Figure 3 Given the positional relationship between the rectangular region of the graphic and the visible rectangular region, the smallest horizontal axis coordinate of all graphic coordinates in the graphic visualization tool is Xp, that is, the smallest x-axis coordinate of all graphic coordinates is Xp; the smallest vertical axis coordinate of all graphic coordinates in the graphic visualization tool is Yp, that is, the smallest y-axis coordinate of all graphic coordinates is Yp; the largest horizontal axis coordinate of all graphic coordinates in the graphic visualization tool is Xq, that is, the largest x-axis coordinate of all graphic coordinates is Xq; the largest vertical axis coordinate of all graphic coordinates in the graphic visualization tool is Yq, that is, the largest y-axis coordinate of all graphic coordinates is Yq.
[0122] M120: Find the target display location that is the same as the reference location.
[0123] M130: The specific extended primitive corresponding to the target display position is used as the target specific extended primitive, and the specific extended primitive corresponding to the target display position is used to replace the edge or node of the current operation.
[0124] For the determination of specific extended primitives, please refer to other embodiments of this application.
[0125] Using the above method, embodiments of this application generate structured graphics that support interactive adjustment. That is, the edges or nodes in the structured graphics generated in embodiments of this application can be adjusted by manipulating extended primitives. Therefore, one embodiment of this application provides specific implementation steps for adjusting structured graphics.
[0126] S16: Display the structured graphic through the display device and collect the user's first trigger information for the display device.
[0127] The display device can be the display screen of a terminal device, or a third display device. The third display device is used by the application to transmit structured graphics to other display devices based on a communication protocol.
[0128] S17: If the first triggering information corresponds to modifying the structured graph, determine the target extended primitive and generate an operation instruction for the target extended primitive.
[0129] Users select an extended primitive of a structured graph through operations such as clicking, double-clicking, long-pressing, dragging, and moving. The extended primitive corresponding to the operation position is the target extended primitive. If the user intends to modify the target extended primitive, an instruction to modify the target extended primitive is generated.
[0130] If the first trigger message corresponds to the confirmation of the structured graph, it is determined that the structured graph will not be modified. For example, the operation of confirming the structured graph can be done by clicking the confirmation button link.
[0131] S18: Send the operation command to the target extended graphic element through the operation interface, and control the target extended graphic element to change according to the user's trigger information.
[0132] For example, the target extended graphic element can be controlled through the interfaces for controlling the display state of graphic elements, the interfaces for controlling the hidden state of graphic elements, and the interfaces for setting the style of graphic elements as described in other embodiments of this application. The target extended graphic element can be controlled to change according to the user's trigger information, and the target extended graphic element can be dragged, moved, rotated, scaled, deleted, renamed, and styled.
[0133] One embodiment of this application provides an implementation method for exporting structured graphics. Since the extended primitives are all equipped with an add rendering interface and a query interface by hierarchy, the graphic part to be exported can be determined by querying by hierarchy, and only the selected part of the graphic is rendered, thereby realizing the partial export of structured graphics.
[0134] S19: Display the structured graphics through a display device and collect the second trigger information from the user on the display device.
[0135] The second triggering information may be information corresponding to the operation of selecting a portion of the extended primitives in the structured graphic.
[0136] S20: Using the hierarchical query interface, locate and determine the portion of the graphic to be exported selected by the user in the structured graphic; the portion of the graphic to be exported is a plurality of extended graphic elements corresponding to the second trigger information.
[0137] S21: Render the portion of the graphic to be exported through the rendering interface to obtain the saved graphic; export the saved graphic.
[0138] In one example of this application, after generating the structured graph, before executing S16, user operation information can be collected to determine whether the structured graph meets the user's needs. If it meets the needs, the structured graph is directly exported; if it does not meet the needs, the structured graph is adjusted and then the adjusted structured graph is exported. Figure 4 This is a flowchart illustrating an example of an interactive graphics generation method described in this application. (See reference...) Figure 4 The flow of an example of executing an interactive graphics generation method according to this application is as follows:
[0139] M11: Edit and parse the structure data: Create extended primitives by inheriting from the QT framework. Parse the layout script of the target structure diagram generated by the graphical visualization tool and extract the structure data of the target structure diagram. Call the scene graph object generated by the QT framework based on the structure data.
[0140] M13: Select layout engine type: Select the layout engine that matches the structure data.
[0141] M14: Automatically generates interactive graphics, i.e., structured graphics that support interactive adjustments: Run the selected layout engine in the scene graph object to generate a basic layout graph. Locate the position to be replaced in the basic layout graph using the internal data structure pointer, update the position to be replaced with the extended primitive, and obtain the structured graphics.
[0142] M15: Determine if the automatic layout meets the requirements: Check if the internal data structure required by the automatic layout is complete, that is, check if the structured graphic generated by the automatic layout in M14 is complete. If the structured graphic is complete, the requirements are met. If the requirements are not met, repeat M11-M14. If the requirements are met, execute M16.
[0143] M16: Local Graphic Object Interactive Adjustment: Display the structured graphic through a display device, collect the user's first trigger information on the display device; if the first trigger information corresponds to modifying the structured graphic, determine the target extended graphic element and generate an operation instruction for the target extended graphic element; send the operation instruction to the target extended graphic element through the operation interface, and control the target extended graphic element to change according to the user's trigger information.
[0144] M17: Determine if the local adjustment meets the requirements: The user sends an operation command to the target extended graphic element. If the target extended graphic element changes according to the user's trigger information after receiving the command, then the local adjustment is determined to meet the requirements.
[0145] M18: Export image.
[0146] Example 2
[0147] Based on the interactive graphics generation method provided in Embodiment 1 of this application, Embodiment 2 of this application also provides an interactive graphics generation apparatus. Figure 5 This is a functional block diagram of an interactive graphics generation device proposed in an embodiment of this application, such as... Figure 5 As shown, the device includes:
[0148] Create module 41, which is used to add pointers to the internal data structures of the graphical visualization tools based on the primitives of the QT framework, and create extended primitives;
[0149] The parsing module 42 is used to parse the layout script of the target structure diagram generated by the graphics visualization tool and extract the structural data of the target structure diagram; the structural data includes edge information, graph element information, node attributes, and subgraph information;
[0150] Scene generation module 43 is used to call the scene graph object generated by the QT framework based on the structure data;
[0151] Layout engine module 44 is a layout engine used to run graphical visualization tools in the scene graph object to generate a basic layout graph.
[0152] The update module 45 is used to locate the position to be replaced in the basic layout diagram using the internal data structure pointer, update the position to be replaced to the extended primitive, and obtain a structured graphic.
[0153] Optionally, the creation module is specifically used to add pointers to the internal data structures of the graphical visualization tool based on the primitives of the QT framework, and to add operation interfaces for modifying the primitive state, thereby creating extended primitives;
[0154] The device further includes:
[0155] The display module is used to display the structured graphics through a display device and to collect the user's first trigger information on the display device;
[0156] The judgment module is used to determine the target extended graphic element and generate an operation instruction for the target extended graphic element if the structured graphic is modified in accordance with the first trigger information.
[0157] The adjustment module is used to send the operation command to the target extended graphic element through the operation interface, and control the target extended graphic element to change according to the user's trigger information.
[0158] Optionally, the creation module is specifically used to add pointers to the internal data structures of the graphics visualization tool based on the primitives of the QT framework, as well as to add rendering interfaces and hierarchical query interfaces.
[0159] The device further includes:
[0160] The display module is used to display the structured graphics through a display device and to collect second trigger information from the user on the display device;
[0161] The image search module is used to search for and determine the portion of the image to be exported selected by the user in the structured image through a hierarchical query interface; the portion of the image to be exported is a plurality of extended primitives corresponding to the second trigger information.
[0162] The export module is used to render the part of the graphic to be exported through the rendering interface to obtain the saved graphic; and to export the saved graphic.
[0163] Optionally, the update module is specifically used for:
[0164] Based on the structural data of the target structure graph, determine the specific extended primitives required for the target structure graph, and the display positions of the specific extended primitives in the target structure graph; traverse the nodes and edges in the basic layout graph, and for each visited node or edge, delete the node or edge and add it as the corresponding extended primitive through the internal data structure pointer, so as to update the position to be replaced with the extended primitive and obtain the structured graph.
[0165] Optionally, the update module includes:
[0166] The coordinate transformation submodule is used to transform the position information of the internal data structure to the coordinates of the QT framework for each edge or each node, so as to obtain the reference position of the node or edge.
[0167] The location lookup submodule is used to find the target display location that is the same as the reference location;
[0168] The specific extended primitive corresponding to the target display position is used as the target specific extended primitive, and the specific extended primitive corresponding to the target display position is used to replace the edge or node of the current operation.
[0169] The update submodule is used to replace the edge or node of the current operation with the specific extended primitive corresponding to the target display position as the target specific extended primitive.
[0170] The coordinate transformation submodule is specifically used to transform the position information of the internal data structure to the coordinates of the QT framework through the following relationship:
[0171] qt_x = (gv_x - llx) scale + offset_x (1);
[0172] qt_y = (ury - gv_y) scale + offset_y (2);
[0173] `qt_x` represents the X-axis coordinate of the transformed QT frame, and `qt_y` represents the Y-axis coordinate of the transformed QT frame; `gv_x` represents the X-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool, and `gv_y` represents the Y-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool; `llx` represents the X-axis coordinate of the lower left corner of the graph boundary in the graphics visualization tool, and `ury` represents the Y-axis coordinate of the upper right corner of the graph boundary in the graphics visualization tool; `offset_x` represents the X-axis coordinate of the upper left corner of the graph below the QT frame, and `offset_y` represents the Y-axis coordinate of the upper left corner of the graph below the QT frame; `scale` is the minimum value between the aspect ratio of the graphic rectangular region and the aspect ratio of the visible rectangular region. The graphic rectangular region is the rectangular region formed by the minimum x and minimum y coordinates and the maximum x and maximum y coordinates of all graphic coordinates in the graphics visualization tool, and the visible rectangular region is the rectangular region drawn by the graphics visualization tool.
[0174] Optionally, the creation module is specifically used to add pointers to the internal data structures of the graphical visualization tool based on the primitives of the QT framework, and to add a hierarchical query interface;
[0175] The update module is specifically used to access the nodes and edges of each layer of the basic layout diagram sequentially through the hierarchical query interface.
[0176] The specific principles and execution processes of each module / unit in the interactive graphics generation device disclosed in Embodiment 2 of this application are the same as those of the interactive graphics generation method disclosed in Embodiment 1 of this application. Please refer to the corresponding parts of the interactive graphics generation method disclosed in Embodiment 1 of this application, and they will not be repeated here.
[0177] Example 3
[0178] This application provides an electronic device in embodiment three, including: a processor and a memory, the processor and the memory being connected via a communication bus; wherein, the processor is used to call and execute a program stored in the memory; the memory is used to store the program, the program being used to implement the interactive graphics generation method provided in embodiment one of this application.
[0179] Example 4
[0180] Embodiment 4 of this application provides a computer-readable storage medium storing computer-executable instructions for executing an interactive graphics generation method as provided in Embodiment 1 of this application.
[0181] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computing software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0182] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0183] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for generating interactive graphics, characterized in that, The method includes: Extended primitives are created by adding pointers to the internal data structures of graphical visualization tools based on the primitives of the QT framework; The layout script of the target structure diagram generated by the graphical visualization tool is analyzed, and the structural data of the target structure diagram is extracted; the structural data includes edge information, graph element information, node attributes, and subgraph information; Call the scene graph object generated by the QT framework based on the structure data; Run the layout engine of the graphical visualization tool in the scene graph object to generate a basic layout graph; The position to be replaced in the basic layout diagram is located using the pointer of the internal data structure, and the position to be replaced is updated with the extended primitive to obtain a structured graphic. Run the layout engine of the graphics visualization tool within the scene graph object to generate a basic layout graph, including: The application calls the scene graph object generated by the QT framework based on the structured data; Call Graphviz's layout engine to generate a basic layout diagram; The internal data structure pointer is used to locate the position to be replaced in the basic layout diagram, and the position to be replaced is updated with the extended primitive to obtain a structured graph, including: K131: Based on the structural data of the target structure diagram, determine the specific extended elements required by the target structure diagram, and the display position of the specific extended elements in the target structure diagram; K132: Traverse the nodes and edges in the basic layout graph. For each visited node or edge, delete the node or edge using the internal data structure pointer and add it as the corresponding extended primitive to update the position to be replaced with the extended primitive, thus obtaining a structured graph. The specific process of step K132 includes: For each edge or each node, the position information of the internal data structure is transformed into the coordinates of the QT framework to obtain the reference position of the node or edge; The location information of the internal data structure is transformed to the coordinates of the QT framework using the following relationship: qt_x = (gv_x - llx) scale + offset_x(1); qt_y = (ury - gv_y) scale + offset_y(2); `qt_x` represents the X-axis coordinate of the transformed QT frame, and `qt_y` represents the Y-axis coordinate of the transformed QT frame; `gv_x` represents the X-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool, and `gv_y` represents the Y-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool; `llx` represents the X-axis coordinate of the lower left corner of the graph boundary in the graphics visualization tool, and `ury` represents the Y-axis coordinate of the upper right corner of the graph boundary in the graphics visualization tool; `offset_x` represents the X-axis coordinate of the upper left corner of the graph below the QT frame, and `offset_y` represents the Y-axis coordinate of the upper left corner of the graph below the QT frame; `scale` is the minimum value between the aspect ratio of the graphic rectangular region and the aspect ratio of the visible rectangular region. The graphic rectangular region is the rectangular region formed by the minimum horizontal and vertical coordinates, the maximum horizontal and vertical coordinates, and the maximum vertical coordinates of all graphic coordinates in the graphics visualization tool. The visible rectangular region is the rectangular region drawn by the graphics visualization tool.
2. The method according to claim 1, characterized in that, By adding pointers to the internal data structures of graphical visualization tools to the primitives of the QT framework as the base class, extended primitives are created, including: Extended primitives are created by adding pointers to the internal data structures of graphical visualization tools and operation interfaces for modifying primitive states, using the primitives of the QT framework as the base class. The method further includes: The structured graphics are displayed on a display device, and the user's first trigger information for the display device is collected. If the first triggering information corresponds to modifying the structured graph, determine the target extended primitive and generate operation instructions for the target extended primitive; The operation command is sent to the target extended graphic element through the operation interface, and the target extended graphic element is controlled to change according to the user's trigger information.
3. The method according to claim 1, characterized in that, By adding pointers to the internal data structures of graphical visualization tools to the primitives of the QT framework as the base class, extended primitives are created, including: Add pointers to the internal data structure of the graphics visualization tool based on the primitives of the QT framework, as well as add rendering interfaces and hierarchical query interfaces; The method further includes: The structured graphics are displayed on a display device, and second trigger information from the user on the display device is collected. The hierarchical query interface is used to locate and determine the portion of the graphic to be exported selected by the user in the structured graphic; the portion of the graphic to be exported consists of multiple extended graphic elements corresponding to the second trigger information. The portion of the graphic to be exported is rendered using the rendering interface to obtain the saved graphic; Export the saved image.
4. The method according to claim 1, characterized in that, The positions to be replaced include the positions of nodes and edges. The internal data structure pointer is used to locate the positions to be replaced in the basic layout graph. These positions are then updated with the extended primitives to obtain a structured graph, including: Based on the structural data of the target structure diagram, determine the specific extended elements required for the target structure diagram, and the display position of the specific extended elements in the target structure diagram; Traverse the nodes and edges in the basic layout graph. For each visited node or edge, delete the node or edge and add it as the corresponding extended primitive through the pointer of the internal data structure, so as to update the position to be replaced with the extended primitive and obtain the structured graph.
5. The method according to claim 1, characterized in that, The internal data structure pointer is used to locate the position to be replaced in the basic layout diagram, and the position to be replaced is updated with the extended primitive to obtain a structured graph, including: Find the target display location that matches the reference location; The specific extended primitive corresponding to the target display position is used as the target specific extended primitive, and the specific extended primitive corresponding to the target display position is used to replace the edge or node of the current operation.
6. The method according to claim 4, characterized in that, By adding pointers to the internal data structures of graphical visualization tools to the primitives of the QT framework as the base class, extended primitives are created, including: Add pointers to the internal data structure of the graphical visualization tool based on the primitives of the QT framework, and add a hierarchical query interface; Traverse the nodes and edges in the basic layout graph, including: The nodes and edges of each layer of the basic layout diagram are accessed sequentially through the hierarchical query interface.
7. A graphics generation device supporting interaction, characterized in that, The device includes: Create a module to add pointers to the internal data structures of graphical visualization tools based on the primitives of the QT framework, and create extended primitives; The parsing module is used to parse the layout script of the target structure diagram generated by the graphics visualization tool and extract the structural data of the target structure diagram; the structural data includes edge information, graph feature information, node attributes, and subgraph information; The scene generation module is used to call the scene graph object generated by the QT framework based on the structure data; The layout engine module is used to run the layout engine of the graphical visualization tool in the scene graph object and generate the basic layout graph; specifically, it is used by the application to call the scene graph object generated by the QT framework based on the structure data; and to call the layout engine of Graphviz to generate the basic layout graph. The update module is used to locate the position to be replaced in the basic layout diagram using the pointer of the internal data structure, update the position to be replaced to the extended primitive, and obtain a structured graphic. The update module is specifically used for: Based on the structural data of the target structure graph, determine the specific extended primitives required by the target structure graph, and the display positions of the specific extended primitives in the target structure graph; traverse the nodes and edges in the basic layout graph, and for each visited node or edge, delete the node or edge and add it as the corresponding extended primitive through the internal data structure pointer, so as to update the position to be replaced with the extended primitive and obtain the structured graph. The update module includes an update submodule, which is used to replace the edge or node of the current operation with the specific extended primitive corresponding to the target display position as the target specific extended primitive. The coordinate transformation submodule is specifically used to transform the position information of the internal data structure to the coordinates of the QT framework through the following relationship: qt_x = (gv_x - llx) scale + offset_x(1); qt_y = (ury - gv_y) scale + offset_y(2); `qt_x` represents the X-axis coordinate of the transformed QT frame, and `qt_y` represents the Y-axis coordinate of the transformed QT frame; `gv_x` represents the X-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool, and `gv_y` represents the Y-axis coordinate of the node or edge position information in the coordinate system of the graphics visualization tool; `llx` represents the X-axis coordinate of the lower left corner of the graph boundary in the graphics visualization tool, and `ury` represents the Y-axis coordinate of the upper right corner of the graph boundary in the graphics visualization tool; `offset_x` represents the X-axis coordinate of the upper left corner of the graph below the QT frame, and `offset_y` represents the Y-axis coordinate of the upper left corner of the graph below the QT frame; `scale` is the minimum value between the aspect ratio of the graphic rectangular region and the aspect ratio of the visible rectangular region. The graphic rectangular region is the rectangular region formed by the minimum x and minimum y coordinates and the maximum x and maximum y coordinates of all graphic coordinates in the graphics visualization tool, and the visible rectangular region is the rectangular region drawn by the graphics visualization tool.
8. An electronic device, characterized in that, include: A processor and a memory are connected via a communication bus; wherein the processor is used to call and execute a program stored in the memory; The memory is used to store a program for implementing the interactive graphics generation method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for performing the interactive graphics generation method as described in any one of claims 1-6.
Citation Information
Patent Citations
Vector map display method and system under VxWorks system
CN120670074A
System and framework for multi-dimensionally visualizing and interacting with large data sets
US20150026606A1