Graphical use case generation method and apparatus, vehicle, and storage medium
By listening to mouse events and dynamically filtering node ports in a graphical drawing tool, connection lines are automatically generated, solving the problems of tedious and inaccurate manual connections, improving modeling efficiency and accuracy, supporting dual-mode editing, and achieving a synergy between intuitiveness and flexibility.
Patent Information
- Application Number
- CN202610401452.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-30
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, the connection of nodes in graphical drawing tools relies on manual operation, resulting in low modeling efficiency and poor accuracy. It fails to achieve a combination of intuitiveness and flexibility, leading to limited use case logic expression and maintenance difficulties.
By listening to mouse click events on the canvas, the position coordinates of the source node port are obtained, and candidate node ports are dynamically filtered according to the mouse position during dragging. Euclidean distance judgment and grid area optimization are used to automatically generate connection lines and graphical test cases, and dual-mode editing is supported to improve modeling efficiency and accuracy.
It simplifies the node connection process, improves modeling efficiency and connection accuracy, enables accurate generation and flexible editing of graphical test cases, and reduces the complexity of user operations.
Smart Images

Figure CN122450819A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of node-based graphical programming technology, and in particular to a graphical use case generation method, device, vehicle, and storage medium. Background Technology
[0002] In related technologies, test cases are usually written in tabular format. When using graphical drawing tools to model test cases, the process is cumbersome and inaccurate because the connection of nodes in the drawing tool depends on manual operation, resulting in low modeling efficiency. Summary of the Invention
[0003] This application provides a graphical use case generation method, apparatus, vehicle, and storage medium to solve the problems of cumbersome and inaccurate manual node connection operations in related technologies, resulting in low modeling efficiency.
[0004] The first aspect of this application provides a graphical use case generation method, comprising the following steps: listening to mouse click events on a canvas and obtaining the first position coordinates of a source node port; during the dragging of the source node port, filtering at least one candidate node port from the canvas based on the current position coordinates of the mouse, and determining a target node port from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse; creating a connection line data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, and generating a graphical use case based on the editing result of the target node port and the connection line data structure.
[0005] Optionally, filtering at least one candidate node port from the canvas based on the current mouse position coordinates includes: dividing the canvas into multiple grid regions; determining candidate grid regions from the multiple grid regions based on the current mouse position coordinates; and determining the node ports within the candidate grid regions as candidate node ports.
[0006] Optionally, the target node port is determined from the candidate node ports based on the second position coordinates of the candidate node port and the current position coordinates of the mouse, including: calculating the Euclidean distance between the second position coordinates and the current position coordinates; determining whether the Euclidean distance is less than a preset distance threshold; if the Euclidean distance is less than the distance threshold, the corresponding candidate node port is determined as the target node port.
[0007] Optionally, a target connection data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port, including: generating a first connection line based on the first and third position coordinates; connecting the source node port and the target node port using the first connection line; identifying the mouse release position coordinates when a mouse release event is detected; and modifying the first connection line to a second connection line if the release position coordinates match the third position coordinates, and creating a connection data structure corresponding to the second connection line, wherein the connection data structures of the first and second connection lines are different.
[0008] Optionally, before creating the target connection data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, the method further includes: determining the display area of the target node port based on the third position coordinates; and increasing the current brightness of the display area of the target node port to the target brightness.
[0009] Optionally, before generating a graphical use case based on the editing results of the target node port and the connection line data structure, the process includes: listening for mouse editing events and starting the editing interface of the target node port; responding to the user's selection operation and determining the target editing mode of the target node port in the editing interface; and editing the target node port based on the target editing mode to obtain the editing result of the target node port.
[0010] Optionally, editing the target node port based on the target editing mode includes: if the target editing mode is the first editing mode, generating an intermediate representation data structure based on the user's editing action and the form of the first editing mode, mapping the elements extracted from the intermediate representation data structure to code strings, and setting the code strings to the editor of the second editing mode; if the target editing mode is the second editing mode, generating a code string based on the user's editing action and the editor of the second editing mode, parsing the code string into an abstract syntax tree, and filling the elements extracted from the abstract syntax tree into the form of the first editing mode.
[0011] A second aspect of this application provides a graphical use case generation apparatus, comprising: an acquisition module for listening to mouse click events on a canvas and acquiring the first position coordinates of a source node port; a matching module for filtering at least one candidate node port from the canvas based on the current position coordinates of the mouse during the dragging of the source node port, and determining a target node port from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse; and a generation module for creating a connection line data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, and generating graphical use cases based on the editing result of the target node port and the connection line data structure.
[0012] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the graphical use case generation method as described in the above embodiments.
[0013] A fourth aspect of this application provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed, implement the graphical use case generation method as described in the above embodiments.
[0014] Therefore, this application has at least the following beneficial effects: This application embodiment can listen for mouse click events on the canvas to obtain the first position coordinates of the source node port. During the dragging of the source node port, at least one candidate node port is selected from the canvas based on the current mouse position coordinates. The target node port is determined from the candidate node ports based on the second position coordinates of the candidate node ports and the current mouse position coordinates. A connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port. A graphical use case is generated based on the editing result of the target node port and the connection line data structure. By dynamically filtering and intelligently matching the target node port based on the mouse position during dragging, connection lines and graphical use cases are automatically generated, thus avoiding the need for manual precise alignment of node ports, simplifying the connection process, and improving connection accuracy and modeling efficiency. Therefore, it solves the problems of cumbersome and inaccurate manual node connection operations in related technologies, leading to low modeling efficiency.
[0015] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0016] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart of a graphical use case generation method provided according to an embodiment of this application; Figure 2 This is a schematic diagram of a smart connection according to an embodiment of this application; Figure 3 This is a graphical use case generation system module interaction diagram provided according to an embodiment of this application; Figure 4 This is a flowchart illustrating an intelligent connection method according to an embodiment of this application; Figure 5 This is a graphical generation of use case system architecture diagram provided according to an embodiment of this application; Figure 6 This is a schematic diagram illustrating bidirectional conversion of target editing modes according to an embodiment of this application; Figure 7 This is a schematic diagram of target editing mode conversion according to an embodiment of this application; Figure 8 This is a graphical use case generation flowchart provided according to an embodiment of this application; Figure 9 This is a schematic diagram of the structure of the graphical use case generation device provided in the embodiments of this application; Figure 10 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0017] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0018] In related technologies, test cases are mainly written in tabular format, and then modeled using graphical drawing tools. However, since the node connections rely on manual operation, the process is cumbersome and inaccurate, making it difficult to improve modeling efficiency. At the same time, node logic editing generally uses a single code editor or fixed form, which cannot achieve a combination of intuitiveness and flexibility, resulting in limited expression of test case logic and difficulties in maintenance.
[0019] The following describes a graphical use case generation method, apparatus, vehicle, and storage medium according to embodiments of this application with reference to the accompanying drawings. Addressing the problem mentioned in the background art where manually connecting nodes using drawing tools is cumbersome, inaccurate, and leads to low modeling efficiency, this application provides a graphical use case generation method. In this method, mouse click events on the canvas are monitored to obtain the first position coordinates of a source node port. During the dragging of the source node port, at least one candidate node port is selected from the canvas based on the current mouse position coordinates. A target node port is determined from the candidate node ports based on the second position coordinates of the candidate node ports and the current mouse position coordinates. A connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port. Graphical use cases are generated based on the editing results of the target node port and the connection line data structure. By dynamically filtering and intelligently matching target node ports based on the mouse position during dragging, connection lines and graphical use cases are automatically generated, thereby avoiding the need for manual, precise alignment of node ports, simplifying the connection process, and improving connection accuracy and modeling efficiency. This solves the problems of cumbersome and inaccurate manual node connection operations using drawing tools in related technologies, leading to low modeling efficiency.
[0020] Specifically, Figure 1 This is a flowchart of a graphical use case generation method provided in an embodiment of this application.
[0021] like Figure 1 As shown, the graphical use case generation method includes the following steps: In step S101, the mouse click event on the canvas is listened to, and the first position coordinates of the source node port are obtained.
[0022] Here, the canvas refers to a two-dimensional visual editing area used to carry and display graphic elements such as nodes and connecting lines; the click event refers to the operation signal triggered by the user pressing the left mouse button on the canvas; the source node port refers to the node output or input interface that is clicked and serves as the starting point of the connection; and the first position coordinates refer to the initial position of the source node port in the canvas coordinate system.
[0023] It is understood that by listening to mouse click events and obtaining the first position coordinates of the source node port, the embodiments of this application can accurately identify the starting port and its spatial location of the user's intention to initiate a connection, providing reliable starting point data for subsequent drag-and-drop connections and avoiding connection errors caused by ambiguous port positioning.
[0024] In step S102, during the process of dragging the source node port, at least one candidate node port is selected from the canvas according to the current position coordinates of the mouse, and the target node port is determined from the candidate node ports according to the second position coordinates of the candidate node ports and the current position coordinates of the mouse.
[0025] Among them, the current position coordinates refer to the canvas coordinates that the mouse moves to in real time during the dragging process; the candidate node port refers to the set of node ports that are initially selected from the canvas based on the current mouse position and can be used as the connection endpoint; the second position coordinates refer to the fixed coordinate position of each candidate node port in the canvas; and the target node port refers to the port that is finally determined from the candidate node ports and used to establish a connection with the source node port.
[0026] It is understood that, in the drag-and-drop process, the embodiments of this application dynamically filter candidate node ports based on the current mouse position coordinates, and determine the target node port by combining the second position coordinates of each candidate port with the distance relationship between the current mouse position and the position of each candidate port. This achieves intelligent matching of the connection endpoint, avoids the user from manually aligning precisely, and improves the smoothness and accuracy of the connection operation.
[0027] Specifically, such as Figure 2As shown, when a user drags a node (source node), mouse movement events are continuously monitored. At this time, the system calculates and caches the absolute coordinates of all node ports on the canvas in real time, preparing for collision detection. This application employs an optimized collision detection algorithm based on spatial partitioning. During dragging, the engine does not calculate the distance to all ports, but first performs a coarse detection: quickly determining the canvas area where the current mouse position is located, and only performing precise calculations on node ports within that area and adjacent areas. Then, a fine detection is performed: for the selected candidate ports, the Euclidean distance between them and the mouse position is calculated. Once the Euclidean distance is less than a preset snapping threshold (e.g., 10px), snapping is triggered. After snapping is triggered, the engine immediately draws a pre-connection line from the source node port to the target port (usually represented by a blue dashed line) and highlights the target port, giving the user clear visual confirmation. Finally, when the user releases the mouse, the engine verifies the release position. If it is on a valid port, formal connection line data is created (stored as {id, source, target}), and a smooth Bézier curve is drawn using the graphical interface.
[0028] In some embodiments, filtering at least one candidate node port from the canvas based on the current position coordinates of the mouse includes: dividing the canvas into multiple grid regions; determining candidate grid regions from the multiple grid regions based on the current position coordinates of the mouse; and determining the node ports within the candidate grid regions as candidate node ports.
[0029] Among them, the grid area refers to the multiple rectangular sub-regions into which the canvas is evenly divided, which is used to accelerate spatial query and port filtering.
[0030] It is understood that the embodiments of this application divide the canvas into multiple grid areas and quickly locate candidate grid areas based on the current mouse position coordinates, and only select node ports as candidates within these areas, which significantly reduces the computational overhead of traversing all ports in the map, improves the efficiency of candidate port selection, and provides performance assurance for real-time drag-and-drop connection.
[0031] In some embodiments, determining the target node port from the candidate node ports based on the second position coordinates of the candidate node port and the current position coordinates of the mouse includes: calculating the Euclidean distance between the second position coordinates and the current position coordinates; determining whether the Euclidean distance is less than a preset distance threshold; if the Euclidean distance is less than the distance threshold, then determining the corresponding candidate node port as the target node port.
[0032] Here, Euclidean distance refers to the straight-line distance between the second position coordinates of the candidate node port and the current position coordinates of the mouse; distance threshold refers to the pre-set upper limit value of pixel distance.
[0033] It is understood that, in this embodiment of the application, the Euclidean distance between the second position coordinates of the candidate node port and the current position coordinates of the mouse is calculated, and it is determined whether the distance is less than a preset distance threshold. If the condition is met, the candidate node port is determined as the target node port, thereby automatically selecting the adjacent port during the dragging process, reducing the user's reliance on precise alignment and improving the efficiency of connection operation.
[0034] In step S103, a connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port, and a graphical use case is generated based on the editing results of the target node port and the connection line data structure.
[0035] Among them, the third position coordinates refer to the actual position coordinates of the target node port in the canvas; the connection line data structure refers to the data object used to record the connection relationship between the source node port and the target node port; the editing result refers to the logical or parameter content generated after the user completes the configuration in the editing interface of the target node port; and the graphical test case refers to the visual representation of the test case composed of nodes, connection lines and their editing results.
[0036] It is understood that the embodiments of this application create a connection line data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, and generate graphical use cases in combination with the editing results of the target node port, thereby realizing the integrated modeling of connection relationships and business logic, ensuring that the use case structure is accurate and executable, and avoiding the problem of connection and logic being disconnected.
[0037] Specifically, such as Figure 3 As shown, the user interface layer receives drag and click events through the canvas rendering module and toolbar / property panel, and triggers generation instructions; the business logic layer includes an intelligent connection engine, a dual-mode editor, a test case generation engine, a dual-mode conversion engine, and an intelligent prompt engine, which are responsible for connection establishment, expression editing, test case generation, mode conversion, and intelligent completion, respectively; each engine connects data, expression IR (Intermediate Representation) data, and signal mapping table through the central data bus read and write nodes to achieve data sharing and collaborative processing.
[0038] In some embodiments, creating a target connection data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port includes: generating a first connection line based on the first position coordinates and the third position coordinates; connecting the source node port and the target node port using the first connection line; identifying the mouse release position coordinates when a mouse release event is detected; and modifying the first connection line to a second connection line if the release position coordinates are consistent with the third position coordinates, and creating a connection data structure corresponding to the second connection line, wherein the connection data structures of the first connection line and the second connection line are different.
[0039] The first connection line refers to the connection line temporarily drawn during the dragging process and used to preview the connection path; the release event refers to the operation signal triggered when the user releases the mouse button; the release position coordinates refer to the coordinates of the mouse in the canvas when the mouse release event occurs; the second connection line refers to the formal connection line generated after the valid connection is confirmed, and its data structure is different from that of the first connection line.
[0040] It is understood that the embodiments of this application generate a first connection line for real-time preview during dragging. After listening to the mouse release event, the release position coordinates are compared with the third position coordinates of the target node port. If they match, the first connection line is replaced with a second connection line with a different data structure, thereby distinguishing between the temporary preview and the final valid connection, ensuring the accuracy of the connection line data structure and the reliability of the use case generation.
[0041] In some embodiments, before creating the target connection data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, the method further includes: determining the display area of the target node port based on the third position coordinates; and increasing the current brightness of the display area of the target node port to the target brightness.
[0042] The display area refers to the visible pixel range occupied by the target node port on the canvas; the target brightness refers to the preset display brightness value that is higher than the current brightness.
[0043] It is understood that, before creating the connection data structure, this application embodiment determines the display area of the target node port based on the third position coordinates of the target node port and increases the brightness of the area to the target brightness, so that the user can clearly identify the target port that can be connected during the dragging process, enhance the interactive guidance, and reduce the probability of connection misoperation.
[0044] Specifically, such as Figure 4 As shown, the entire smart connection process, from listening to mouse events to creating the connection data structure, includes: In step 401, the wiring process begins.
[0045] In step 402, the event listening system listens for mousedown events on the canvas.
[0046] In step 403, when the user presses the mouse on the node port, the source node port and port information at this time are recorded.
[0047] In step 404, the coordinate calculation and caching process calculates the absolute coordinates of all node ports on the canvas in real time (considering canvas scaling and scroll offset), and caches the coordinate information in memory, updating it every 100ms (or updating it in real time according to node movement).
[0048] In step 405, the mouse begins to move.
[0049] In step 406, collision detection (coarse detection) divides the canvas into several grid regions (e.g., a 10×10 pixel grid). Based on the current mouse position, the current grid and its eight adjacent grids are quickly determined. Precise distance calculations are performed only on ports within these grids, significantly reducing the computational load.
[0050] In step 407, ports within adjacent grids are filtered.
[0051] In step 408, the distance calculation and snapping judgment calculate the Euclidean distance between the mouse position and each candidate port. If the distance is less than a preset distance threshold (default 10px), snapping is triggered. The system records the information of the nearest target port.
[0052] In step 409, it is determined whether the Euclidean distance is less than a preset distance threshold (default 10px). If it is not less than the preset distance threshold, the process returns to step 405 to move the mouse.
[0053] In step 410, if the Euclidean distance is less than a preset distance threshold, adsorption is triggered, and the system records the information of the nearest target port.
[0054] In step 411, the pre-connection line is drawn during mouse movement. If snapping is triggered, a blue dashed pre-connection line is drawn from the source port to the target port. At the same time, the target port is highlighted (e.g., by changing the border color or zooming in).
[0055] In step 412, release the mouse.
[0056] In step 413, it is determined whether the release position is on a valid port.
[0057] In step 414, if the release location is on a valid port, a formal connection data structure is created and stored in the project data model.
[0058] In step 415, the graphics rendering engine is invoked to draw a smooth Bézier curve connection line.
[0059] In step 416, the connection is now complete.
[0060] In step 417, if the connection is not released effectively, the connection operation is cancelled.
[0061] Understandably, the intelligent connection process effectively reduces the complexity of collision detection, thus ensuring smooth operation in scenarios with a large number of nodes. Furthermore, the pre-connection feedback mechanism provides intuitive operation guidance, effectively reducing user errors.
[0062] In some embodiments, before generating a graphical use case based on the editing result of the target node port and the connection line data structure, the process includes: listening for a mouse editing event and starting the editing interface of the target node port; responding to the user's selection operation and determining the target editing mode of the target node port in the editing interface; and editing the target node port based on the target editing mode to obtain the editing result of the target node port.
[0063] Among them, the edit event refers to the operation signal triggered by the user on the target node port, such as double-clicking the mouse or selecting from the right-click menu; the edit interface refers to the visual window used to configure the logic or parameters of the target node port; the target edit mode refers to the edit method selected by the user in the edit interface; and the edit result refers to the node configuration data generated after editing is completed based on the selected target edit mode.
[0064] It is understood that the embodiments of this application start the editing interface of the target node port by listening to the mouse editing event, respond to the user's selection to determine the target editing mode, and edit based on the mode to obtain the editing result. This allows the user to flexibly choose the editing method according to their own preferences or task requirements, thereby improving the availability and efficiency of node configuration.
[0065] Specifically, such as Figure 5 As shown, the graphical test case expression system consists of three modules: a canvas, a toolbar, and a property bar. The canvas supports both automatic and manual connection methods for building relationships between nodes; the toolbar provides test case generation and canvas export functions, enabling the output and saving of test cases; and the property bar includes simple and advanced editing modes, allowing users to choose different expression configuration methods according to their needs.
[0066] In some embodiments, editing a target node port based on a target editing mode includes: if the target editing mode is a first editing mode, generating an intermediate representation data structure based on the user's editing action and the form of the first editing mode, mapping the elements extracted from the intermediate representation data structure to code strings, and setting the code strings to the editor of a second editing mode; if the target editing mode is a second editing mode, generating a code string based on the user's editing action and the editor of the second editing mode, parsing the code string into an abstract syntax tree, and filling the elements extracted from the abstract syntax tree into the form of the first editing mode.
[0067] The first editing mode refers to a form-based visual editing method where users configure node logic by filling in fields; editing actions refer to the input, selection, or modification operations performed by users in the editing interface; the intermediate representation data structure refers to the internal structured data generated in the first editing mode and used to describe the node logic; the code string refers to an executable code fragment represented in text form; the second editing mode refers to a text-based editing method based on a code editor where users directly write code; and the abstract syntax tree refers to the tree structure generated after parsing the code string, used to represent the code logic.
[0068] It is understood that, in the embodiments of this application, when the target editing mode is the first editing mode, an intermediate representation data structure is generated based on the user's editing actions, and its elements are mapped to code strings and synchronized to the editor in the second editing mode. When the target editing mode is the second editing mode, the code string entered by the user is parsed into an abstract syntax tree, and the extracted elements are filled into the form of the first editing mode, thereby achieving bidirectional synchronization between the two editing modes. This allows users to freely switch between intuitiveness and flexibility, improving editing efficiency and consistency.
[0069] Specifically, such as Figure 6 As shown, the system retrieves expression data in the current mode: First editing mode: retrieves the values of each field in the form and combines them into an IR data structure; Second editing mode: retrieves the complete code string in the code editor. The system automatically prompts the user to switch modes when the user clicks the "Switch Mode" button, or when the system detects that the expression complexity exceeds the capacity of the first editing mode.
[0070] When switching from the first editing mode to the second editing mode, the IR data structure is read, for example: {"variable":"vehicle speed","operator":">","value":"100"}, where ":" is the key-value pair separator, "variable" is the business variable name "vehicle speed", "operator" is the comparison operator ">", and "value" is the threshold "100". The signal mapping table is queried to convert the business name "vehicle speed" to the technical name "ECU1::SpeedSignal", where "::" is the namespace separator, "ECU1" represents the electronic control unit identifier, and "SpeedSignal" represents the vehicle speed signal in that unit. The whole name is the technical name of the signal, used in the advanced mode code, and associated with the business name "vehicle speed" through the signal mapping table. Generate a code string according to a predefined template: ECU1::SpeedSignal>100. Set the code string in the advanced mode editor. When switching from the second editing mode to the first editing mode, use a syntax parser (such as Babel Parser) to parse the code string into an abstract syntax tree. Traverse the abstract syntax tree to extract key elements such as variables, operators, and values. Convert the technical signal name (such as "ECU1::SpeedSignal") into a business name (such as "vehicle speed") through a mapping table. Fill the extracted elements into the corresponding fields of the form in the first editing mode.
[0071] Understandably, after the editing mode conversion is complete, the system verifies the integrity and consistency of the data. If there are syntax errors or missing mappings, clear prompts will be provided on the interface. Using IR as an intermediary bridge, the system ensures that the two expressions are semantically completely equivalent. Furthermore, the system automatically handles the mapping between business names and technical names during the conversion process, eliminating the need for manual processing by the user and significantly improving efficiency.
[0072] Specifically, such as Figure 7 As shown, the user pre-imports a signal mapping table in CSV or Excel format, for example: { "ECU1::SpeedSignal": "Vehicle Speed", "ECU2::BrakeStatus": "Brake Status"}. The system loads this as a hash table in memory, providing a data source for intelligent prompts.
[0073] When the target editing mode is the first editing mode, the system is based on the user's editing actions, namely selecting variables, operators, and input values through a form. Behind this form operation, a structured JSON object (IR) is updated in real time for each change in a form item. For example, after selecting the variable "vehicle speed", the operator ">", and inputting the value "100", an IR is generated. When the target editing mode is the second editing mode, when the user inputs, the editor first retrieves all values from the hash table of the aforementioned signal mapping table based on the current cursor position and pops up a prompt box (e.g., inputting "vehicle" will prompt "vehicle speed"). After the user selects, the corresponding technical signal name is automatically completed (e.g., ECU1::SpeedSignal). After the user inputs code, the engine uses tools such as Babel Parser to parse the code string into an AST (Abstract Syntax Tree). The abstract syntax tree is traversed for syntax validation, and if undefined variables or syntax errors are found, they are immediately marked with a red wavy underline in the editor as an error.
[0074] Furthermore, when switching from the first editing mode to the second editing mode, the IR data generated in the first editing mode is concatenated into the corresponding code string (e.g., ECU1::SpeedSignal>100) using a recursive function. Conversely, when switching from the second editing mode to the first editing mode, the code string in the second editing mode is parsed into an abstract syntax tree (API), which is then mapped back to the intermediate representation data structure (IR structure) that the first editing mode can understand. Finally, the various fields in the form are automatically populated based on the IR data.
[0075] Furthermore, such as Figure 8 As shown, the specific process for generating graphical use cases includes: In step 801, the user first opens the system.
[0076] Specifically, the graphical modeling initialization system loads a predefined library of test nodes, including test steps, assertions, conditional branches, and loop control. It also initializes the canvas, loading user-preserved projects or creating new blank projects.
[0077] In step 802, drag the node to the canvas using the mouse.
[0078] Specifically, the node drag-and-drop layout allows users to drag desired nodes from the toolbar to the canvas area. The system calculates the node positions in real time and automatically aligns them to the grid (optional) to keep the canvas clean.
[0079] In step 803, the system initiates intelligent connection.
[0080] In step 804, it is determined whether the adsorption was successful. If the adsorption was unsuccessful, return to step 802 and continue dragging the node to the canvas. In step 805, if adsorption is successful at this point, a formal connection is established.
[0081] Specifically, in the intelligent connection and relationship establishment process, when the user begins dragging a node, the system activates the intelligent connection engine to calculate the relative position of the node's port to other node ports on the canvas in real time. A spatial partitioning algorithm is used to quickly filter candidate ports, followed by precise distance calculation. When the Euclidean distance is less than a pre-set distance threshold, the pre-connection line is automatically snapped to and displayed. After the user releases the mouse, the system establishes the formal connection relationship and stores it as structured data (source node ID, target node ID, connection type).
[0082] In step 806, double-click the node to edit the expression.
[0083] In step 807, an editing mode is selected. The target editing mode includes a first editing mode and a second editing mode.
[0084] In step 808, if the first editing mode is selected, form-based configuration is performed first.
[0085] In step 809, an intermediate representation data structure is generated.
[0086] In step 810, if the second editing mode is selected, the code editor will be accessed.
[0087] In step 811, the code is parsed into an abstract syntax tree.
[0088] In step 812, the bidirectional conversion engine.
[0089] Specifically, when a user double-clicks a node on the canvas, the system enters the expression editing interface. The system typically defaults to the first editing mode, where users can select variables, operators, and input values via a drop-down menu. Users can switch to the second editing mode (code editor) to directly write expression code. The two modes are synchronized in real-time via a conversion engine: when the form changes in the first editing mode, the code is automatically updated; when the code is modified, the form is automatically parsed and updated.
[0090] In step 813, structured test cases are generated.
[0091] Specifically, after completing the graphical model, the user clicks the "Generate Test Cases" button. The system then iterates through the nodes and connections in the canvas, converting the graphical model into test cases in a specific format (such as JSON, XML, Python scripts, etc.) according to preset template rules. During the conversion process, the system automatically maps business names in the expressions to technical signal names.
[0092] In step 814, export or execute the test cases.
[0093] Specifically, the generated test cases can be exported in various formats (such as Excel, JSON, and Python) or directly pushed to the test execution platform. The system provides a preview function, allowing users to view the generated test case content.
[0094] According to the graphical use case generation method proposed in this application, the mouse click event on the canvas is listened to, and the first position coordinates of the source node port are obtained. During the dragging of the source node port, at least one candidate node port is selected from the canvas based on the current position coordinates of the mouse. The target node port is determined from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse. A connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port. Graphical use cases are generated based on the editing results of the target node port and the connection line data structure. By dynamically filtering and intelligently matching the target node port based on the mouse position during the dragging process, connection lines and graphical use cases are automatically generated, thereby avoiding the manual precise alignment of node ports, simplifying the connection process, and improving connection accuracy and modeling efficiency. This solves the problems of cumbersome and inaccurate manual node connection operations in related technologies, leading to low modeling efficiency.
[0095] Next, the graphical use case generation apparatus proposed according to the embodiments of this application is described with reference to the accompanying drawings.
[0096] Figure 9 This is a block diagram of a graphical use case generation device according to an embodiment of this application.
[0097] like Figure 9 As shown, the graphical use case generation device 10 includes: an acquisition module 100, a matching module 200, and a generation module 300.
[0098] The acquisition module 100 is used to listen for mouse click events on the canvas and acquire the first position coordinates of the source node port; the matching module 200 is used to filter at least one candidate node port from the canvas based on the current position coordinates of the mouse during the dragging of the source node port, and determine the target node port from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse; the generation module 300 is used to create a connection line data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, and generate a graphical use case based on the editing result of the target node port and the connection line data structure.
[0099] In some embodiments, the matching module 200 is configured to: divide the canvas into multiple grid regions; determine candidate grid regions from the multiple grid regions based on the current position coordinates of the mouse; and determine the node ports within the candidate grid regions as candidate node ports.
[0100] In some embodiments, the matching module 200 is used to: calculate the Euclidean distance between the second position coordinates and the current position coordinates; determine whether the Euclidean distance is less than a preset distance threshold; if the Euclidean distance is less than the distance threshold, then determine the corresponding candidate node port as the target node port.
[0101] In some embodiments, the generation module 300 is used to: generate a first connection line based on the first position coordinates and the third position coordinates; connect the source node port and the target node port using the first connection line; if a mouse release event is detected, identify the release position coordinates of the mouse; if the release position coordinates are consistent with the third position coordinates, modify the first connection line to a second connection line, and create a connection line data structure corresponding to the second connection line, wherein the connection line data structures of the first connection line and the second connection line are different.
[0102] In some embodiments, the graphical use case generation apparatus 10 further includes a display module.
[0103] The display module is used to: determine the display area of the target node port based on the third position coordinates; and increase the current brightness of the display area of the target node port to the target brightness.
[0104] In some embodiments, the generation module 300 is configured to: listen for mouse editing events and start the editing interface of the target node port; respond to the user's selection operation and determine the target editing mode of the target node port in the editing interface; and edit the target node port based on the target editing mode to obtain the editing result of the target node port.
[0105] In some embodiments, the generation module 300 is configured to: if the target editing mode is the first editing mode, generate an intermediate representation data structure based on the user's editing actions and the form of the first editing mode, map the elements extracted from the intermediate representation data structure to code strings, and set the code strings to the editor of the second editing mode; if the target editing mode is the second editing mode, generate code strings based on the user's editing actions and the editor of the second editing mode, parse the code strings into an abstract syntax tree, and fill the elements extracted from the abstract syntax tree into the form of the first editing mode.
[0106] It should be noted that the foregoing explanation of the graphical use case generation method embodiment also applies to the graphical use case generation device of this embodiment, and will not be repeated here.
[0107] The graphical use case generation device proposed in this application listens to mouse click events on the canvas and obtains the first position coordinates of the source node port. During the dragging of the source node port, at least one candidate node port is selected from the canvas based on the current mouse position coordinates. The target node port is determined from the candidate node ports based on the second position coordinates of the candidate node ports and the current mouse position coordinates. A connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port. Graphical use cases are generated based on the editing results of the target node port and the connection line data structure. By dynamically filtering and intelligently matching the target node port based on the mouse position during dragging, connection lines and graphical use cases are automatically generated, thus avoiding the need for manual precise alignment of node ports, simplifying the connection process, and improving connection accuracy and modeling efficiency. This solves the problems of cumbersome and inaccurate manual node connection operations in related technologies, leading to low modeling efficiency.
[0108] Figure 10 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 1001, the processor 1002, and the computer program stored on the memory 1001 and capable of running on the processor 1002.
[0109] When the processor 1002 executes the program, it implements the graphical use case generation method provided in the above embodiments.
[0110] Furthermore, electronic devices also include: Communication interface 1003 is used for communication between memory 1001 and processor 1002.
[0111] The memory 1001 is used to store computer programs that can run on the processor 1002.
[0112] The memory 1001 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage.
[0113] If the memory 1001, processor 1002, and communication interface 1003 are implemented independently, then the communication interface 1003, memory 1001, and processor 1002 can be interconnected via a bus to complete communication between them. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0114] Optionally, in a specific implementation, if the memory 1001, processor 1002, and communication interface 1003 are integrated on a single chip, then the memory 1001, processor 1002, and communication interface 1003 can communicate with each other through an internal interface.
[0115] The processor 1002 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of this application.
[0116] This application also provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed, implements the graphical use case generation method as described in the above embodiments.
[0117] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0118] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0119] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0120] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.
[0121] Those skilled in the art will understand that all or part of the steps of the methods implementing the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0122] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A graphical test case generation method, characterized in that, Includes the following steps: Listen for mouse click events on the canvas and obtain the first position coordinates of the source node port; During the process of dragging the source node port, at least one candidate node port is filtered from the canvas according to the current position coordinates of the mouse, and the target node port is determined from the candidate node ports according to the second position coordinates of the candidate node ports and the current position coordinates of the mouse. A connection line data structure is created based on the first position coordinates of the source node port and the third position coordinates of the target node port. A graphical use case is generated based on the editing result of the target node port and the connection line data structure.
2. The graphical use case generation method according to claim 1, characterized in that, The step of filtering at least one candidate node port from the canvas based on the current position coordinates of the mouse includes: The canvas is divided into multiple grid areas; Candidate grid regions are determined from multiple grid regions based on the current position coordinates of the mouse; The node ports within the candidate grid area are determined as the candidate node ports.
3. The graphical use case generation method according to claim 1, characterized in that, The step of determining the target node port from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse includes: Calculate the Euclidean distance between the second position coordinates and the current position coordinates; Determine whether the Euclidean distance is less than a preset distance threshold; If the Euclidean distance is less than the distance threshold, then the corresponding candidate node port is determined as the target node port.
4. The graphical use case generation method according to claim 1, characterized in that, The step of creating the target connection data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port includes: A first connecting line is generated based on the first position coordinates and the third position coordinates; Connect the source node port and the target node port using the first connection line; If the mouse release event is detected, identify the coordinates of the mouse release position; If the release position coordinates are consistent with the third position coordinates, then the first connecting line is modified into the second connecting line, and a connecting line data structure corresponding to the second connecting line is created. The connecting line data structures of the first connecting line and the second connecting line are different.
5. The graphical use case generation method according to claim 1, characterized in that, Before creating the target connection data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, the process also includes: The display area of the target node port is determined based on the third position coordinates; Increase the current brightness of the display area of the target node port to the target brightness.
6. The graphical use case generation method according to claim 1, characterized in that, Before generating a graphical use case based on the editing results of the target node port and the connection line data structure, the process includes: Upon detecting an edit event from the mouse, launch the edit interface of the target node port; In response to the user's selection, the target editing mode of the target node port is determined in the editing interface; The target node port is edited based on the target editing mode to obtain the editing result of the target node port.
7. The graphical use case generation method according to claim 6, characterized in that, The editing of the target node port based on the target editing mode includes: If the target editing mode is the first editing mode, an intermediate representation data structure is generated based on the user's editing action and the form of the first editing mode. The elements extracted from the intermediate representation data structure are mapped to code strings, and the code strings are set to the editor of the second editing mode. If the target editing mode is the second editing mode, the code string is generated based on the user's editing action and the editor of the second editing mode, the code string is parsed into an abstract syntax tree, and the elements extracted from the abstract syntax tree are filled into the form of the first editing mode.
8. A graphical use case generation device, characterized in that, include: The acquisition module is used to listen for mouse click events on the canvas and obtain the first position coordinates of the source node port; The matching module is used to filter at least one candidate node port from the canvas based on the current position coordinates of the mouse during the process of dragging the source node port, and to determine the target node port from the candidate node ports based on the second position coordinates of the candidate node ports and the current position coordinates of the mouse. The generation module is used to create a connection line data structure based on the first position coordinates of the source node port and the third position coordinates of the target node port, and to generate graphical use cases based on the editing results of the target node port and the connection line data structure.
9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the graphical use case generation method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed, they implement the graphical use case generation method according to any one of claims 1-7.