A Modular Sub-label Construction and Drawing Method Based on Script Dynamic Scheduling
By combining scripting languages and host programs in a graphical plotting system, the independent definition and dynamic scheduling of sub-labels are realized, solving the problem of fixed sub-label logic in existing technologies, improving the system's flexibility and scalability, and supporting real-time updates and complex interactions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE 28TH RES INST OF CHINA ELECTRONICS TECH GROUP CORP
- Filing Date
- 2025-12-16
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, graphic plotting methods suffer from tight coupling between sub-labels and main labels, resulting in rigid logic, poor scalability, difficulty in meeting real-time and adaptability requirements, and a lack of flexible integration of scripting languages with graphic plotting.
By combining scripting languages and host programs, the drawing logic and state of sub-labels are encapsulated, enabling independent definition, flexible registration, and unified management of sub-labels. The main label dynamically calls the sub-labels through a standard interface, avoiding the compilation process and achieving dynamic scheduling and combination.
It improves the flexibility, scalability, and maintainability of graphical plotting, supports real-time updates and complex interactive operations, and enhances development efficiency and system responsiveness.
Smart Images

Figure CN122086389A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of graphic plotting technology, specifically to a method for constructing and drawing modular sub-labels based on dynamic script scheduling. Background Technology
[0002] This section provides only background information relevant to this disclosure and is not necessarily prior art.
[0003] In the field of graphic plotting, some complex labels are often composed of multiple sub-labels. These sub-labels are used to represent different information such as equipment type, current status, and direction of movement. Traditional graphic plotting methods often use hard-coded implementations in compiled languages (such as C++), resulting in tight coupling between sub-labels and main labels. This leads to problems such as rigid plotting logic and poor scalability. Therefore, any minor adjustment to the label logic requires modifying the source code and recompiling and re-deploying the entire system, resulting in long update cycles, slow response times, and difficulty in meeting the stringent real-time and adaptability requirements of field environments for graphic plotting.
[0004] Scripting languages typically feature lightweight design, high efficiency, flexibility, and ease of embedding (e.g., interaction with C++ programs), giving them unique advantages in the field of graphic illustration. They can capture and retain the environment state at the time of creation, allowing functions to carry their context information and maintain behavioral consistency across different call points. This provides the possibility for dynamically and flexibly defining and managing sublabel drawing units with independent states and behaviors. However, existing technologies lack an architecture that can combine the flexibility of scripting with the complexity and systemic nature of graphic illustration, particularly in achieving independent management, dynamic scheduling, and compile-free updates of sublabels, where significant technical shortcomings exist. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a modular sub-label construction and drawing method based on script dynamic scheduling. This method encapsulates the drawing logic and state of sub-labels by combining a scripting language and a host program (such as C++), enabling independent definition, flexible registration, and unified management of sub-labels. The main label dynamically calls the sub-label scripts through a set of standard interfaces, switching and combining sub-labels in real time at runtime, thus eliminating the compilation process. This greatly improves the flexibility, scalability, and maintainability of composite label drawing and lays the foundation for further intelligent layout and interactive operations.
[0006] A modular sub-label construction and drawing method based on script dynamic scheduling, which defines the graphics drawing logic through a scripting language, and the main label calls and draws the sub-label units in real time, includes the following steps:
[0007] Step 1: Set up the host program and script environment of the plotting system. The host program implements the drawing and interactive operation of basic graphic elements, including but not limited to points, lines and surfaces. The script environment is responsible for the definition and management of plotting symbols, including main labels and sub-labels.
[0008] Step 2: Write the main label and sub-label scripts. The main label script includes metadata, core drawing logic, and sub-label call interface. Each script defines a main label. The sub-label script defines a type of sub-label, including metadata, identifier ID, sub-label drawing logic, and callback interface. Each sub-label is uniquely identified by the identifier ID.
[0009] Step 3: Establish a sub-label registry to manage the sub-labels defined in Step 2. The registry is a global singleton object. The management services include sub-label registration, querying, and hot reloading. The registry supports accurate acquisition of sub-label objects by identifier ID, and also supports retrieval of sub-label sets that meet the conditions by sub-label name, type, etc.
[0010] Step 4: Perception and Scheduling. The main label queries and calls the target sub-label through the sub-label interface in Step 2, relying on the sub-label registry in Step 3. The sub-label is accurately drawn according to the parameters, including but not limited to the identifier ID, anchor point position, azimuth angle and size ratio. The main label dynamically switches the called sub-label through the host program's state perception.
[0011] Step 5: For the sub-labels called by the main label in Step 4, when a main label calls two or more sub-labels at the same time, the position and size of each sub-label are adjusted by configuring space occupancy information and intelligent layout algorithm to avoid visual overlap and overlay.
[0012] Step 6: Implement the picking and judgment logic for the sub-labels that have been laid out in Step 5, establish the position index of the sub-labels, quickly complete the picking result filtering in the interaction event, and determine whether the picking point is located on the sub-label graphic by detection, thereby optimizing the human-computer interaction event of the labeling system. The detection method includes, but is not limited to, collision detection and primitive color detection.
[0013] In some embodiments, the plotting system consists of a host program and a script environment. The host program is responsible for efficient plotting and display, while the script environment is responsible for writing and managing the label plotting logic, thus balancing the system's plotting performance and label production efficiency.
[0014] In some embodiments, the main label script includes:
[0015] Metadata describes the identity and basic attributes of the main label for system management, retrieval, and display; the core drawing logic defines the main outline of the label, which includes basic drawing instructions and anchor points as references for the placement of sub-labels; the sub-label calling interface has a standardized calling method, which can pass data to the sub-labels and receive returned drawing information.
[0016] The sub-label script includes:
[0017] Metadata includes a unique identifier, name, and description, used for system management, retrieval, and display; the sub-label drawing logic determines the sub-label's position, scale, rotation, color, and line type; the callback interface returns the sub-label's intrinsic geometric information, including the bounding box and its own anchor point, providing a basis for subsequent layout.
[0018] In some embodiments, the sub-label registry in step 3 is implemented as a globally accessible table structure using a scripting language. When the sub-label script is loaded, it automatically executes the registration logic, associates its unique identifier with the corresponding drawing function, and stores it in the registry.
[0019] In some embodiments, the process of dynamically scheduling sub-labels in step 4 specifically includes:
[0020] Step 4-1: The host program obtains status information such as label type, sub-label type, and drawing position through user drawing operations, and transmits it to the script environment in real time as parameters;
[0021] Step 4-2: The main label completes its own drawing according to the parameters, and queries the sub-label registry by sub-label name or identifier ID to select sub-labels that meet the drawing conditions;
[0022] Step 4-3: The sub-label calculates the geometry based on the anchor point, direction, size, and drawing logic, and returns its own state to the main label;
[0023] Among them, the perception and scheduling logic and data structures involved in steps 4-1 to 4-3 are all defined by scripting language and can be recognized and run by the host program without compilation.
[0024] In some embodiments, adjusting the sub-label layout in step 5 specifically includes:
[0025] Step 5-1: Calculate the space occupancy information for the sub-label, including the bounding box of the sub-label and its own anchor point. By comparing spatial relationships, check for overlapping and occupancy issues between the main label, sub-labels, and anchor points.
[0026] Step 5-2: Apply an intelligent layout algorithm to calculate the positional relationship between the sub-labels and the main label based on the space occupancy information. If there is overlap, the algorithm will automatically select a layout algorithm to readjust the position and size of the sub-labels. Layout algorithms include, but are not limited to, layered layout and nine-grid layout algorithms.
[0027] In some embodiments, step 4 includes setting the judgment logic for picking events in the sub-label script, thereby optimizing the human-computer interaction efficiency of the mapping system.
[0028] In some embodiments, the host program interacts with the script environment through an embedded script engine, which is one of a Lua virtual machine, a JavaScript engine, or a Python interpreter.
[0029] In some embodiments, in step 4, the main identifier dynamically selects the sub-identifier ID to be called based on the received real-time status information and through condition judgment logic; the status information includes, but is not limited to, equipment type, unit status, direction of action, or affiliation.
[0030] The beneficial effects of this invention are as follows:
[0031] No compilation required: Sublabels are defined in the form of scripts. After modification, they can be recognized and called by the system without recompiling the main program, which greatly improves development efficiency and deployment flexibility.
[0032] Easy to maintain: The logic of each sub-label is encapsulated in an independent file, which is highly decoupled from the main label and other sub-labels. The code structure is clear, easy to maintain and test independently.
[0033] Dynamic replacement: The main label can be dynamically switched and combined with different sub-labels according to the on-site situation (such as unit status and equipment type) during runtime, which greatly enriches the display effect of the label and the efficiency of information transmission.
[0034] Flexible expansion: Through a unified registration and management mechanism, adding new sub-labels only requires writing a script and registering according to the specifications, without modifying the existing system framework code, resulting in extremely low system expansion costs;
[0035] Interactive: By adding geometric information and a hit detection interface to the sub-labels, technical support is provided for realizing complex graphic plotting interactive operations (such as viewing attributes and editing status). Attached Figure Description
[0036] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and the advantages of the present invention in the above and / or other aspects will become clearer.
[0037] Figure 1 This is a flowchart illustrating the method of the present invention.
[0038] Figure 2 This is a sequence diagram of the main label real-time scheduling sub-labels of the present invention.
[0039] Figure 3 This is a schematic diagram illustrating the effect of a composite label with sub-labels in one embodiment. Detailed Implementation
[0040] like Figure 1-3 As shown, this embodiment is a non-limiting example using the Lua language to illustrate the specific implementation process of the present invention, but it should not be considered as limiting the only implementation of the present invention. The example uses a C++ host program to provide the graphics rendering and runtime environment, and embeds a Lua virtual machine to execute script logic.
[0041] Step 1: Set up the host program and script environment of the plotting system. The host program implements the drawing and interactive operation of basic graphic elements, including but not limited to points, lines and surfaces. The script environment is responsible for the definition and management of plotting symbols, including main labels and sub-labels.
[0042] Step 2: Write the main label and sub-label scripts. The main label script includes metadata, core drawing logic, and sub-label call interface. Each script defines a main label. The sub-label script defines a type of sub-label, including metadata, identifier ID, sub-label drawing logic, and callback interface. Each sub-label is uniquely identified by the identifier ID.
[0043] Step 3: Establish a sub-label registry to manage the sub-labels defined in Step 2. The registry is a global singleton object. The management services include sub-label registration, querying, and hot reloading. The registry supports accurate acquisition of sub-label objects by identifier ID, and also supports retrieval of sub-label sets that meet the conditions by sub-label name, type, etc.
[0044] Step 4: Perception and Scheduling. The main label queries and calls the target sub-label through the sub-label interface in Step 2, relying on the sub-label registry in Step 3. The sub-label is accurately drawn according to the parameters, including but not limited to the identifier ID, anchor point position, azimuth angle and size ratio. The main label dynamically switches the called sub-label through the host program's state perception.
[0045] Step 5: For the sub-labels called by the main label in Step 4, when a main label calls two or more sub-labels at the same time, the position and size of each sub-label are adjusted by configuring space occupancy information and intelligent layout algorithm to avoid visual overlap and overlay.
[0046] Step 6: Implement the picking and judgment logic for the sub-labels that have been laid out in Step 5, establish the position index of the sub-labels, quickly complete the picking result filtering in the interaction event, and determine whether the picking point is located on the sub-label graphic by detection, thereby optimizing the human-computer interaction event of the labeling system. The detection method includes, but is not limited to, collision detection and primitive color detection.
[0047] 1. Set up the host program and script environment for the plotting system, and initialize the system:
[0048] This step is led by the C++ host program, which establishes and initializes the script execution environment, and builds the system framework of the host program, main label object, sublabel registry, sublabel object, and graphical rendering interface.
[0049] (1) Initialize the script runtime environment
[0050] During the startup phase of the C++ host program, a Lua virtual machine instance is created and initialized, establishing an information interaction mode between the host program and the script environment. At the same time, the Lua virtual machine schedules and manages the Lua scripts, loading the necessary primary labels, registry entries, sub-labels, and other objects.
[0051] (2) Load the registry definition script
[0052] The virtual machine actively loads a script file named sub_symbol_registry.lua, and creates a singleton object named SubSymbolRegistry in the global scope. Internally, it maintains a mapping table _registry to store the association between sub-label identifiers ID and corresponding drawing logic.
[0053] Define three core methods in the registry object:
[0054] (i) register(sub_symbol_id, sub_symbol): Receives a unique string identifier ID and a drawing logic closure. It checks whether the ID already exists. If there is no conflict, it stores the ID in the mapping table and outputs a registration success log. If there is a conflict, it throws an error.
[0055] (ii) get(symbol_id): Query and return the corresponding drawing closure based on the identifier ID;
[0056] (iii) getAllIDs(): Iterates through the mapping table and returns a list of IDs of all registered sub-labels for debugging or interface display.
[0057] (3) Batch loading of sub-label scripts
[0058] The script environment scans all Lua files in the directory to which the sublabel belongs (such as / symbols / sub / ), reads and instantiates the sublabel object, and actively calls SubSymbolRegistry.register() to complete the registration, thereby realizing the automatic construction of the sublabel resource pool.
[0059] 2. Write the scripts for main labels and sub-labels, and define and implement sub-labels:
[0060] Sub-labels are defined through independent script files, and their implementation process includes the following four standardized steps. Commonly used sub-labels include vehicles, aircraft, and ships. Here, we take the "vehicle" sub-label as an example:
[0061] (1) Define the metadata structure
[0062] Create a local table object (SubSymbol_Vehicle) in the script and write the semantic information of the sub-label into its metadata field, including: id: a unique string identifier, "ss_vehicle"; name: a readable name, "vehicle"; tags: an array of category tags, {"Equipment", "Armor"}, for subsequent retrieval by category.
[0063] (2) Encapsulate the drawing logic
[0064] Define a function named createDrawClosure, which:
[0065] Capture local variables (such as the default line width defaultStrokeWidth=2) as a closure environment inside;
[0066] Returns an anonymous function that accepts two arguments: ctx (drawing context object) and params (runtime parameter list), and is able to draw a triangle shape;
[0067] Inside this anonymous function, the following steps are executed in sequence: obtain the context state → apply affine transformations of translation, rotation, and scaling → set the color and line width → call drawing commands to draw the triangle.
[0068] (3) Provide a geometry information callback interface
[0069] Define a function named getBoundingBox in the script, which returns a table containing width and height fields, with the values being the original pixel dimensions of the sub-label (width=30, height=36), for use by the subsequent layout and picking modules.
[0070] (4) Perform automatic registration
[0071] At the end of the script, createDrawClosure() is called to generate a drawing closure instance, and then SubSymbolRegistry.register() is called to bind metadata.id to the closure and store it in the global registry.
[0072] 3. Main label drawing and real-time scheduling
[0073] The main label script is responsible for combining multiple sub-labels. Taking a simplified "direction of travel" main label as an example, its implementation is divided into the following three stages:
[0074] (1) Define the main label core drawing logic and slot configuration
[0075] Define a drawing function (AdvanceDirection.draw) in the script, which accepts three parameters: drawing context ctx, unit state parameter table params, and suboverrides explicit sublabel override instruction table subOverrides.
[0076] The function first parses the key fields in params, including position, membership, and health value; then it defines the base graphic of the main label, which is a curve with an arrow, and reserves an anchor point position and a sub-label drawing area; next, it declares a "logical slot" with the following configurations: default sub-label ID ("ss_vehicle"); anchor point offset (coordinate offset relative to the center of the main label, {0, -35}); and default scaling ratio (0.7).
[0077] For cases with two or more sub-labels, a corresponding number of anchor point positions and "logic slots" need to be reserved.
[0078] (2) Execute dynamic scheduling decisions
[0079] Traverse all slots and determine the final sub-label to be used based on explicit priority rules:
[0080] If a corresponding slot name is explicitly specified in subOverrides, it will be used first.
[0081] Otherwise, conditional judgment is made based on the real-time status in params (e.g., when params.health < 0.3 and the current status slot is "ss_damaged").
[0082] If there is no overlay or state trigger, the default configuration will be used.
[0083] (3) Call the sub-label to complete the cascading drawing.
[0084] For each slot configuration after a decision: call SubSymbolRegistry.get() to query the drawing closure of the corresponding sublabel; calculate the world coordinates of the sublabel geometry based on the anchor point position, offset, and scaling ratio; and execute the drawing command.
[0085] 4. The execution logic of the host program
[0086] The host program, acting as the execution driver layer, demonstrates system-level coordination in its call flow, with the following specific steps:
[0087] (1) Prepare the drawing context and unit data
[0088] In each frame rendering loop, the host program creates a drawing context object that encapsulates the underlying graphics API; at the same time, it obtains current entity data from the simulation or combat system, including: two-dimensional position, membership, health value, etc.
[0089] (2) Organize Lua call parameters
[0090] The Lua virtual machine push operations for the drawing context object, unit parameter table, and sublabel overwrite instruction table (optional) are executed sequentially to ensure that the parameter order is consistent with the function signature of the main label script.
[0091] (3) Trigger the execution of the main label script
[0092] The main label's draw method (AdvanceDirection.draw) is called through the Lua interface, passing in the aforementioned three parameters, and executing the following steps in sequence: drawing the main label's base → scheduling decision → querying the registry → calling the sub-label closure → completing the sub-label drawing.
[0093] (4) Support for layout and interaction expansion
[0094] During the drawing process, the sub-label synchronously returns its bounding box and anchor point information to the host program, which is then used by the intelligent layout module in step 5 for overlay detection and position rearrangement.
[0095] The sub-label also provides a pick detection function pointer or geometric description, which is called by the host in mouse or touch events to achieve a fast hit determination in step 6.
[0096] This invention provides a method and approach for constructing and drawing sub-labels in a graphic plotting system. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment of the invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A modular sub-label construction and drawing method based on script dynamic scheduling, wherein the graphics drawing logic is defined through a scripting language, and the main label calls and draws the sub-label units in real time, characterized in that, Includes the following steps: Step 1: Set up the host program and script environment of the plotting system. The host program implements the drawing and interactive operation of basic graphic elements, while the script environment is responsible for the definition and management of plotting symbols, including main labels and sub-labels. Step 2: Write the main label and sub-label scripts. The main label script includes metadata, core drawing logic, and sub-label call interface. Each script defines a main label. The sub-label script defines a type of sub-label, including metadata, identifier ID, sub-label drawing logic, and callback interface. Each sub-label is uniquely identified by the identifier ID. Step 3: Establish a sub-label registry to manage the sub-labels defined in Step 2. The registry is a global singleton object, and the management services include sub-label registration, querying, and hot reloading. Step 4: Perception and Scheduling. The main label queries and calls the target sub-label through the sub-label interface in Step 2, relying on the sub-label registry in Step 3, and draws the sub-label according to the parameters. The main label dynamically switches the called sub-label through the host program's state perception. Step 5: For the sub-labels called by the main label in Step 4, when a main label calls two or more sub-labels at the same time, the position and size of each sub-label are adjusted by configuring space occupancy information and intelligent layout algorithm to avoid visual overlap and overlay. Step 6: Implement the picking and judgment logic for the sub-labels that have been laid out in Step 5, establish the position index of the sub-labels, quickly complete the picking result filtering in the interaction event, and optimize the human-computer interaction event of the labeling system by detecting whether the picking point is located on the sub-label graphic.
2. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, In step 2, the main label script includes: Metadata describes the identity and basic attributes of the main label for system management, retrieval, and display; the core drawing logic defines the main outline of the label, which includes basic drawing instructions and anchor points as references for the placement of sub-labels; the sub-label calling interface has a standardized calling method, which can pass data to the sub-labels and receive returned drawing information. The sub-label script includes: Metadata includes a unique identifier, name, and description, used for system management, retrieval, and display; the sub-label drawing logic determines the sub-label's position, scale, rotation, color, and line type; the callback interface returns the sub-label's intrinsic geometric information, including the bounding box and its own anchor point, providing a basis for subsequent layout.
3. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, The sub-label registry in step 3 is implemented as a globally accessible table structure using a scripting language. When the sub-label script is loaded, it automatically executes the registration logic, associating its unique identifier with the corresponding drawing function and storing it in the registry.
4. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, The process of dynamically scheduling sub-labels in step 4 specifically includes: Step 4-1: The host program obtains status information such as label type, sub-label type, and drawing position through user drawing operations, and transmits it to the script environment in real time as parameters; Step 4-2: The main label completes its own drawing according to the parameters, and queries the sub-label registry by sub-label name or identifier ID to select sub-labels that meet the drawing conditions; Step 4-3: The sub-label calculates the geometry based on the anchor point, direction, size, and drawing logic, and returns its own state to the main label; Among them, the perception and scheduling logic and data structures involved in steps 4-1 to 4-3 are all defined by scripting language and can be recognized and run by the host program without compilation.
5. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, The adjustment of the sub-label layout in step 5 specifically includes: Step 5-1: Calculate the space occupancy information for the sub-label, including the bounding box of the sub-label and its own anchor point. By comparing spatial relationships, check for overlapping and occupancy issues between the main label, sub-labels, and anchor points. Step 5-2: Apply the intelligent layout algorithm to calculate the positional relationship between the sub-label and the main label based on the space occupancy information. If there is overlap, the layout algorithm will be automatically selected to readjust the position and size of the sub-label.
6. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, The layout algorithms in step 5-2 include, but are not limited to, layered layout and nine-grid layout algorithms.
7. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, In step 6, the judgment logic for picking events is set in the sub-label script, thereby optimizing the human-computer interaction efficiency of the labeling system.
8. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, The host program and the script environment interact through an embedded script engine, which is one of the following: a Lua virtual machine, a JavaScript engine, or a Python interpreter.
9. The modular sub-label construction and drawing method based on script dynamic scheduling according to claim 1, characterized in that, In step 4, the main identifier dynamically selects the sub-identifier ID to be called based on the received status information and condition judgment logic; the status information includes, but is not limited to, equipment type, unit status, direction of action, or affiliation.