Graphic editing canceling and redoing method and system
By using the undo stack and the redo stack to manage the primary key ID in the GIS system, the problem of inefficient undo and redo operations in the existing technology is solved, and the rapid recovery and consistency of data is achieved, and the operation efficiency of the GIS system is improved.
Patent Information
- Application Number
- CN202510388534.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-03-31
AI Technical Summary
When existing GIS systems frequently perform geometric editing across layers, it is difficult to effectively manage the consistency and correctness of primary key IDs, resulting in inefficient undo and redo operations.
The data structure of the undo stack and the redo stack are adopted. By increasing the ID as the primary key ID, the user operations are recorded and the reverse operation statement is generated to ensure the consistency and correctness of the primary key ID when undoing or redoing.
It realizes efficient undo and redo operations in GIS systems, improves the flexibility and efficiency of data editing, and ensures data consistency and integrity.
Smart Images

Figure CN120523818A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a graphic editing undo and redo method and system. Background Art
[0002] A Geographic Information System (GIS) is a collection of tools for collecting, storing, querying, transforming, and displaying spatial data. The core function of GIS is to process geographic spatial data, which usually involves operations on different types of geometric features. Common geometric operations include drawing, moving, copying, and deleting. It also supports post-calculation operations on features, such as breaking, extending, zooming in, and zooming out. These operations involve not only the geometric data itself, but also the storage and updating of data. In order to efficiently store and process this data, many GIS systems use relational database systems to store spatial data, and use auto-incrementing primary key IDs to ensure the uniqueness of entities and the consistency of data. In this way, GIS systems can efficiently query and operate on large amounts of spatial data.
[0003] In existing GIS systems, when geometric editing is frequently performed across layers, each layer needs to start and end the editing mode. This process is often cumbersome and inefficient, significantly reducing production efficiency. In order to improve the convenience of operation, many GIS tools have implemented the function of opening an editing mode without opening it. In this mode, geometric data operations are updated to the database in real time after completion, including the execution of add, delete, and modify statements. However, when performing undo and redo operations, since relational databases usually use auto-increment primary key IDs as primary keys to ensure the integrity of entities and the logical consistency of relationships, how to correctly manage primary key IDs and ensure their consistency and correctness when undoing or redoing operations becomes a difficult problem. Existing technologies cannot effectively solve this problem, so a new data record model is needed that can efficiently support the reverse execution of add, delete, and modify operations to ensure that the stored data can be quickly restored to the correct state when undoing or redoing. Summary of the Invention
[0004] In order to overcome the defect of the prior art described above that inconsistency of primary key IDs in a database occurs when editing a graphic, the present invention provides a method and system for undoing and redoing graphic editing.
[0005] In order to achieve the above technical effects, the technical solutions of the present invention are as follows:
[0006] The present invention provides a graphic editing undo and redo method, comprising the following steps:
[0007] Creating an undo stack and a redo stack based on the layer object; storing the layer object in a relational database, and using an auto-incrementing ID as a primary key ID corresponding to the layer object when the layer object is stored in the relational database;
[0008] When it is detected that the user operates the layer, the operation record is saved into the undo stack;
[0009] When a user's undo instruction is detected, the operation record is extracted from the undo stack, the operation record is transferred to the redo stack, and a reverse operation statement is generated according to the operation record and then executed;
[0010] When a redo instruction of the user is detected, the operation record is extracted from the redo stack and executed;
[0011] When the undo instruction or redo instruction is completed, the new primary key ID of the current operation record in the relational database is recorded, the undo stack and redo stack are traversed, and the operation record identical to the current operation record is found, and its primary key ID is changed to the new primary key ID.
[0012] As a preferred solution, the operation record includes operation records of one or more entities in a layer, and multiple entities in the same operation record have the same feature identifier and are saved in an undo stack or a redo stack in sequence.
[0013] As a preferred solution, when executing the undo instruction or redo instruction, when popping the stack, entities whose characteristic identifiers are consistent with the characteristic identifier of the entity at the end of the stack are popped one by one until the end of the stack has entities with different characteristic identifiers.
[0014] As a preferred solution, the operation record includes the entity's feature identifier, geometric information, attribute information, operation type and primary key ID.
[0015] As a preferred solution, the step of saving the operation record into the undo stack includes:
[0016] When the operation record type is new, the database generates the primary key ID before entering the undo stack;
[0017] When the type of the operation record is modification, a deep copy is made to the modified entity and then stored in the undo stack;
[0018] When the type of the operation record is deletion, the primary key ID of the operation record is cleared and then stored in the undo stack.
[0019] As a preferred solution, when an operation record is saved in the undo stack, the redo stack is cleared.
[0020] As a preferred solution, the step of generating and executing a reverse operation statement according to the operation record includes: generating a corresponding reverse SQL operation statement at the database layer based on the operation record.
[0021] The present invention also provides a graphics editing undo and redo system, comprising:
[0022] Operation record saving module: used for detecting the user's operation on the layer and saving the operation record into the undo stack;
[0023] Undo module: It is equipped with an undo stack. When a user's undo instruction is detected, it extracts the operation record from the undo stack, transfers the operation record to the redo stack, and generates and executes the reverse operation statement based on the operation record;
[0024] Redo module: It is equipped with a redo stack and is used to extract and execute operation records from the redo stack when a redo instruction from a user is detected;
[0025] Primary key ID synchronization module: used to record the new primary key ID of the current operation record in the relational database when completing the undo or redo instruction, traverse the undo stack and redo stack, and change the primary key ID of the operation record that is the same as the current operation record to the new primary key ID.
[0026] The present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the graphic editing undo and redo method according to the present invention is implemented.
[0027] The present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for undoing and redoing graphic editing as described in the present invention is implemented.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] This invention effectively reverses add, delete, and modify operations, ensuring that geometric features or attribute data stored in the database can be quickly restored to their correct state when an undo or redo operation is performed. This technology significantly improves the flexibility and efficiency of data editing in GIS systems, particularly in scenarios involving large amounts of data and complex operations. It effectively reduces the tediousness of manual operations and ensures data consistency and integrity. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a flowchart of a graphic editing undo and redo method according to Example 1.
[0031] Figure 2This is an architectural diagram of a graphics editing undo and redo system according to Example 2. DETAILED DESCRIPTION
[0032] The accompanying drawings are for illustrative purposes only and are not to be construed as limiting the present invention;
[0033] It is understandable to those skilled in the art that some well-known descriptions may be omitted in the drawings.
[0034] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.
[0035] Example 1
[0036] This embodiment proposes a method for undoing and redoing graphic editing. Figure 1 FIG. 1 is a flowchart of a method for undoing and redoing graphic editing according to an embodiment of the present invention.
[0037] This embodiment provides a method for undoing and redoing graphics editing, including the following steps:
[0038] Creating an undo stack and a redo stack based on the layer object; storing the layer object in a relational database, and using an auto-incrementing ID as a primary key ID corresponding to the layer object when the layer object is stored in the relational database;
[0039] When it is detected that the user operates the layer, the operation record is saved into the undo stack;
[0040] When a user's undo instruction is detected, the operation record is extracted from the undo stack, the operation record is transferred to the redo stack, and a reverse operation statement is generated according to the operation record and then executed;
[0041] When a redo instruction of the user is detected, the operation record is extracted from the redo stack and executed;
[0042] When the undo instruction or redo instruction is completed, the new primary key ID of the current operation record in the relational database is recorded, the undo stack and redo stack are traversed, and the operation record identical to the current operation record is found, and its primary key ID is changed to the new primary key ID.
[0043] In this embodiment, when a layer object changes, the system saves the operation record sequentially to the undo stack. When the user issues an undo or redo command, the stack data structure is used to reverse or repeat the operation. Secondly, by recording the new primary key ID of the current operation record, the undo and redo stacks are traversed, and the primary key ID of the same operation record is changed to the new primary key ID. This ensures data consistency and accuracy when undoing or redoing.
[0044] In an optional embodiment, the operation record includes an operation record of operating one or more entities in a layer, and multiple entities in the same operation record have the same feature identifier and are saved in an undo stack or a redo stack in sequence.
[0045] In this embodiment, batch operation management is achieved through feature identification. When a user performs continuous operations on multiple entities with the same feature, the system automatically identifies the feature identification and stores them in an associated manner, thereby improving the processing efficiency of batch operations.
[0046] Further optionally, when executing the undo instruction or redo instruction, when popping the stack, entities whose characteristic identifiers are consistent with the characteristic identifier of the entity at the end of the stack are popped one by one until the end of the stack has entities with different characteristic identifiers.
[0047] In this embodiment, the pop-up recovery of batch operations is achieved through a feature identifier matching mechanism, ensuring that entities with the same feature identifier maintain operational consistency during undo / redo, thereby avoiding the problem of inconsistent states of some entities.
[0048] In an optional embodiment, the operation record includes a feature identifier, geometric information, attribute information, operation type, and primary key ID of the entity.
[0049] In this embodiment, by constructing a multi-dimensional operation record data structure, the reverse operation can accurately restore the entity state, ensuring data recovery accuracy.
[0050] In an optional embodiment, saving the operation record into the undo stack includes:
[0051] When the operation record type is new, the database generates the primary key ID before entering the undo stack;
[0052] When the type of the operation record is modification, a deep copy is made to the modified entity and then stored in the undo stack;
[0053] When the type of the operation record is deletion, the primary key ID of the operation record is cleared and then stored in the undo stack.
[0054] In this embodiment, differentiated storage strategies are used to effectively distinguish data storage methods for different operation types. A new primary key pre-generation mechanism for new operations enables reverse operations to accurately locate database entities, and deep copy technology ensures the reversibility of modification operations.
[0055] In an optional embodiment, when an operation record is saved into the undo stack, the redo stack is cleared.
[0056] In this embodiment, when a new operation record is saved and entered into the undo stack, the system will automatically clear the redo stack to prevent the redo operation from conflicting with the new operation. This can ensure that the operation record in the redo stack is always the latest after each undo, avoiding data redundancy and error generation.
[0057] In an optional embodiment, the step of generating and executing a reverse operation statement according to the operation record includes: generating a corresponding reverse SQL operation statement at the database layer based on the operation record.
[0058] In this embodiment, by directly generating reverse SQL at the database level, undo / redo operations can be directly applied to the database storage layer, which can improve data processing efficiency compared to traditional application layer processing methods.
[0059] Example 2
[0060] This embodiment proposes a graphics editing undo and redo system, and applies a graphics editing undo and redo method proposed in Example 1. Figure 2 , which is an architecture diagram of a graphics editing undo and redo system according to this embodiment.
[0061] This embodiment provides a graphics editing undo and redo system including:
[0062] Operation record saving module: used for detecting the user's operation on the layer and saving the operation record into the undo stack;
[0063] Undo module: It is equipped with an undo stack. When a user's undo instruction is detected, it extracts the operation record from the undo stack, transfers the operation record to the redo stack, and generates and executes the reverse operation statement based on the operation record;
[0064] Redo module: It is equipped with a redo stack and is used to extract and execute operation records from the redo stack when a redo instruction from a user is detected;
[0065] Primary key ID synchronization module: used to record the new primary key ID of the current operation record in the relational database when completing the undo or redo instruction, traverse the undo stack and redo stack, and change the primary key ID of the operation record that is the same as the current operation record to the new primary key ID.
[0066] It can be understood that the system of this embodiment corresponds to the method of the above-mentioned embodiment 1, and the options in the above-mentioned embodiment 1 are also applicable to this embodiment, so they will not be described again here.
[0067] Example 3
[0068] This embodiment proposes a computer device including a memory and a processor, wherein the memory stores computer-readable instructions, wherein when the computer-readable instructions are executed by the processor, the processor executes the steps of a graphic editing undo and redo method proposed in Example 1.
[0069] Example 4
[0070] This embodiment provides a storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by a processor, implement the steps of a graphic editing undo and redo method provided in Embodiment 1.
Claims
1. A graphic editing undo and redo method, characterized in that: The following steps are involved: Creating an undo stack and a redo stack based on the layer object; storing the layer object in a relational database, and using an auto-incrementing ID as a primary key ID corresponding to the layer object when the layer object is stored in the relational database; When it is detected that the user operates the layer, the operation record is saved into the undo stack; When a user's undo instruction is detected, the operation record is extracted from the undo stack, the operation record is transferred to the redo stack, and a reverse operation statement is generated according to the operation record and then executed; When a redo instruction of the user is detected, the operation record is extracted from the redo stack and executed; When the undo instruction or redo instruction is completed, the new primary key ID of the current operation record in the relational database is recorded, the undo stack and redo stack are traversed, and the operation record identical to the current operation record is found, and its primary key ID is changed to the new primary key ID.
2. A graphic editing undo and redo method according to claim 1, characterized in that: The operation record includes an operation record of operating one or more entities in a layer. Multiple entities in the same operation record have the same feature identifier and are saved in an undo stack or a redo stack in sequence.
3. A graphic editing undo and redo method according to claim 2, characterized in that: When executing the undo instruction or redo instruction, when popping the stack, entities with characteristic identifiers consistent with the characteristic identifier of the entity at the end of the stack are popped out one by one until the end of the stack is an entity with a different characteristic identifier.
4. A graphic editing undo and redo method according to claim 2, characterized in that: The operation record includes the entity's feature identifier, geometric information, attribute information, operation type, and primary key ID.
5. A graphic editing undo and redo method according to claim 2, characterized in that: Saving the operation record into the undo stack includes: When the operation record type is new, the database generates the primary key ID before entering the undo stack; When the type of the operation record is modification, a deep copy is made to the modified entity and then stored in the undo stack; When the type of the operation record is deletion, the primary key ID of the operation record is cleared and then stored in the undo stack.
6. A graphic editing undo and redo method according to any one of claims 1 to 5, characterized in that: When an operation record is saved in the undo stack, the redo stack is cleared.
7. A graphic editing undo and redo method according to any one of claims 1 to 5, characterized in that: The step of generating and executing a reverse operation statement according to the operation record includes: generating a corresponding reverse SQL operation statement at the database layer based on the operation record.
8. A graphics editing undo and redo system, applied to a graphics editing undo and redo method according to any one of claims 1 to 7, characterized in that: The system comprises: Operation record saving module: used for detecting the user's operation on the layer and saving the operation record into the undo stack; Undo module: It is equipped with an undo stack. When a user's undo instruction is detected, it extracts the operation record from the undo stack, transfers the operation record to the redo stack, and generates and executes the reverse operation statement based on the operation record; Redo module: It is equipped with a redo stack and is used to extract and execute operation records from the redo stack when a redo instruction from a user is detected; Primary key ID synchronization module: used to record the new primary key ID of the current operation record in the relational database when completing the undo or redo instruction, traverse the undo stack and redo stack, and change the primary key ID of the operation record that is the same as the current operation record to the new primary key ID.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for undoing and redoing graphics editing as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a graphic editing undo and redo method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Restoration of UI state in transactional systems
CN107924411A
Operation control method and device and storage medium
CN118819502A
Medical image management system, method, equipment and medium
CN119446439A
Already executed operation canceller
JP1993324556A
Efficient support of consistent cyclic search with read-copy-update
US20050198030A1
Cited By
Geometric topology updating method and device and storage medium
CN120951410A