A canvas mode switching method, device, equipment and medium
Patent Information
- Application Number
- CN202611053355.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而,现有画布模式切换方式大多依赖简单的按钮点击机制,无法对当前交互上下文进行动态感知与综合判断,在面对复杂节点布局、多层嵌套画布这类场景时,难以准确识别用户真实意图,容易出现模式切换滞后或误触发的问题,从而引发编辑错误或数据丢失,最终导致画布模式切换准确性低下,严重影响整体操作的交互流畅性与用户使用体验
[0009]综上所述,本发明提供了一种画布模式切换方法、装置、设备及介质,通过响应于模式切换触发信号,获取画布的当前操作模式和交互场景状态,对交互场景状态进行多维度校验,得到校验结果,其中,多维度校验包括焦点状态校验、节点操作校验、空间拓扑校验以及交互时序校验,根据校验结果,判断当前操作模式是否满足预设模式切换条件,若当前操作模式满足预设模式切换条件,则将当前操作模式切换至目标操作模式。可见,本申请在执行模式切换前引入了多维度交互场景校验机制,从焦点状态、操作行为、空间布局、时序特征四个层面综合评估当前上下文是否满足切换条件,有效避免了因误触发或上下文不匹配导致的模式切换错误,显著提高了画布模式切换的准确性,增强了整体操作的交互流畅性,优化了用户使用体验。
Smart Images

Figure CN123011097A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a canvas mode switching method, apparatus, device, and medium. Background Technology
[0002] With the rapid development of visual interaction technology, canvas editors have been widely used in various scenarios such as workflow orchestration, mind mapping, and process modeling. The flexible switching of canvas operation modes directly affects the user's editing efficiency and interactive experience.
[0003] However, most existing canvas mode switching methods rely on simple button click mechanisms, which cannot dynamically perceive and comprehensively judge the current interaction context. When faced with complex node layouts and multi-layered nested canvases, they struggle to accurately identify the user's true intent, easily leading to delayed or accidental mode switching. This can result in editing errors or data loss, ultimately causing low accuracy in canvas mode switching and severely impacting the overall smoothness of the operation and the user experience. Therefore, improving the accuracy of canvas mode switching is a pressing technical problem that needs to be solved. Summary of the Invention
[0004] Therefore, in order to address the above-mentioned technical problems, this invention provides a canvas mode switching method, apparatus, device, and medium that can improve the accuracy of canvas mode switching.
[0005] A first aspect of this application provides a canvas mode switching method, the canvas mode switching method comprising: In response to the mode switching trigger signal, obtain the current operation mode and interaction scene state of the canvas; The interactive scene state is verified in multiple dimensions to obtain the verification results. The multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification, and interaction timing verification. Based on the verification result, determine whether the current operation mode meets the preset mode switching conditions; If the current operating mode meets the preset mode switching conditions, then the current operating mode will be switched to the target operating mode.
[0006] A second aspect of this application provides a canvas mode switching device, the canvas mode switching device comprising: The acquisition module is used to obtain the current operation mode and interaction scene state of the canvas in response to the mode switching trigger signal; The verification module is used to perform multi-dimensional verification on the interactive scene state and obtain the verification result. The multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification, and interaction timing verification. The judgment module is used to determine whether the current operation mode meets the preset mode switching conditions based on the verification result; The switching module is used to switch the current operation mode to the target operation mode if the current operation mode meets the preset mode switching conditions.
[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the canvas mode switching method as described in the first aspect.
[0008] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements the canvas mode switching method as described in the first aspect.
[0009] In summary, this invention provides a canvas mode switching method, apparatus, device, and medium. By responding to a mode switching trigger signal, it acquires the current operation mode and interaction scene state of the canvas, performs multi-dimensional verification of the interaction scene state, and obtains the verification results. These multi-dimensional verifications include focus state verification, node operation verification, spatial topology verification, and interaction timing verification. Based on the verification results, it determines whether the current operation mode meets preset mode switching conditions. If the current operation mode meets the preset mode switching conditions, it switches the current operation mode to the target operation mode. Therefore, this application introduces a multi-dimensional interaction scene verification mechanism before performing mode switching, comprehensively evaluating whether the current context meets the switching conditions from four levels: focus state, operation behavior, spatial layout, and timing characteristics. This effectively avoids mode switching errors caused by accidental triggering or context mismatch, significantly improves the accuracy of canvas mode switching, enhances the overall smoothness of operation, and optimizes the user experience. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart illustrating a canvas mode switching method according to an embodiment of the present invention; Figure 2 This is a schematic diagram of a canvas mode switching device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] It should be understood that, when used in this specification and the appended claims, terms include indicating the presence of the described feature, integral, step, operation, element and / or component, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0014] It should also be understood that the terms used in this specification and the appended claims refer to any combination of one or more of the associated listed items and all possible combinations, and include such combinations.
[0015] As used in this specification and the appended claims, terms if can be interpreted in context as when... or once or in response to determination. Similarly, the phrase if determined or if matched to [described condition or event] can be interpreted in context as once determined or in response to determination or once matched to [described condition or event] or in response to matching to [described condition or event].
[0016] Furthermore, in the description of this invention and the appended claims, the terms first, second, third, etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance.
[0017] References to one or more embodiments described in this specification mean that a particular feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the invention. Therefore, phrases appearing in different parts of this specification as referring to one embodiment, some embodiments, some other embodiments, and others do not necessarily refer to the same embodiment, but rather mean one or more, but not all, embodiments, unless otherwise specifically emphasized. The terms include, comprise, have, and variations thereof mean including but not limited to, unless otherwise specifically emphasized.
[0018] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0019] To illustrate the technical solution of the present invention, specific embodiments are described below.
[0020] See Figure 1 This is a flowchart illustrating a canvas mode switching method according to an embodiment of the present invention, as shown below. Figure 1 As shown, this canvas mode switching method can be implemented through the following steps.
[0021] S101: In response to the mode switching trigger signal, obtain the current operation mode and interaction scene state of the canvas.
[0022] In one implementation, when a user enters the canvas editing page, the canvas is initialized to arrow pointer mode by default. In this mode, the user can perform all editing operations, including clicking, selecting, dragging, connecting, configuring parameters, and editing text, while the mouse pointer retains the default arrow style. When the system detects a mode switching trigger signal, it immediately responds and actively collects the canvas's current operating status information, including the current operation mode and the complete interactive scene state. The mode switching trigger signal can be generated in various ways, such as the user pressing a preset shortcut key combination, clicking the mode switching button in the canvas toolbar, performing a specific gesture, or a trigger event automatically generated by the system according to preset rules. The current operation mode refers to the current interaction mode of the canvas, such as arrow pointer mode, hand panning mode, node connecting mode, box selection mode, zoom mode, etc. Different modes correspond to different mouse interaction behaviors and shortcut key mappings. The interactive scene state is a comprehensive description of the current canvas interaction context, covering real-time parameters from multiple dimensions such as focus state, node operation state, spatial topology layout, and temporal characteristics, reflecting the type of operation the user is currently performing and the characteristics of the canvas environment.
[0023] Specifically, trigger signal acquisition can be achieved through an event listening mechanism. For example, specific key combinations can be detected in keyboard event listeners, or gestures such as multi-clicks and long presses can be recognized in mouse event listeners. Once a trigger signal is captured, the system immediately reads the identifier of the current operation mode from the canvas state manager, and simultaneously collects various parameters of the interaction scenario in batches by calling the state interfaces of each submodule. The entire response process is executed asynchronously and non-blockingly, avoiding interruption of the user's continuous operation due to state acquisition. Through the above steps, a rapid response to mode switching intentions and a complete acquisition of the interaction context are achieved, providing comprehensive and accurate input data for subsequent multi-dimensional verification, ensuring that mode switching decisions are made based on the actual current scenario.
[0024] It should be noted that the specific form and triggering conditions of the mode switching trigger signal can be flexibly configured according to actual business needs, and this application does not impose any restrictions on this.
[0025] S102: Perform multi-dimensional verification on the interactive scene state to obtain the verification result, wherein the multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification, and interaction timing verification.
[0026] In one implementation, after acquiring the interaction scene state, a multi-dimensional comprehensive verification is performed on the interaction scene state to obtain the verification result. This multi-dimensional verification specifically includes four dimensions: focus state verification, node operation verification, spatial topology verification, and interaction timing verification. Focus state verification checks whether the current focus is within the canvas area to avoid accidental mode switching when the canvas does not have focus. Node operation verification determines whether the user is currently performing node-related operations, such as dragging lines, moving nodes, or scaling nodes, preventing interruptions caused by mode switching. Spatial topology verification analyzes spatial characteristics such as the distribution density of nodes and the depth of layer nesting within the current canvas to assess whether mode switching will significantly affect the current view. Interaction timing verification analyzes the frequency and interval of user operations and canvas rendering performance from a time perspective to determine whether the timing of mode switching will cause lag or a decline in user experience. These four dimensions complement each other, forming a comprehensive evaluation of the interaction scene.
[0027] Furthermore, during the verification process, the system executes each verification sequentially according to a preset priority order, outputting the corresponding sub-verification result after each dimension verification is completed. If a dimension verification fails, the system can choose to immediately terminate subsequent verifications and directly determine the overall system as failing, or continue to complete all verifications to collect complete failure reasons for subsequent logging and user prompts, depending on the configuration policy. For scenarios that pass all dimension verifications, the system will synthesize the verification data from each dimension to generate a structured verification result report, including the specific indicator values, judgment conclusions, and comprehensive scores for each dimension. Crucially, the overall verification result is only deemed passed when all four dimensions of verification meet the preset conditions, authorizing subsequent mode switching operations to continue. Through the above steps, a multi-layered, comprehensive scenario verification system is constructed, which can accurately identify interaction contexts unsuitable for mode switching, preventing accidental and inappropriate switching from the source, and significantly improving the accuracy and security of mode switching.
[0028] S103: Based on the verification result, determine whether the current operation mode meets the preset mode switching conditions.
[0029] In one implementation, after obtaining multi-dimensional verification results, the system comprehensively evaluates the current operation mode based on preset mode switching conditions and the verification results to determine whether to allow the mode switching operation. The preset mode switching conditions are a pre-defined set of rules used to determine whether a mode switch can be performed in the current scenario. These conditions include not only the passing requirements of the multi-dimensional verification but can also be set according to actual circumstances; this application does not impose any limitations on this. Historical switching records, mode stability, user preferences, and other factors can also be considered for a comprehensive judgment. If the switching conditions are met, the system authorizes the mode switching operation to continue; otherwise, if the switching conditions are not met, the system will intercept the switching request and may provide the user with corresponding prompts based on the specific verification dimensions that failed, such as "Node dragging operation in progress, mode switching is temporarily unavailable," to help the user understand the reason for the switching failure.
[0030] Specifically, the judgment process can employ a multi-level decision-making logic: First, it checks whether the multi-dimensional verification passes; if it fails, it directly determines that the switching conditions are not met. If the verification passes, it further checks other auxiliary conditions, such as whether the switching frequency of the current mode is too high, and whether there is a mutual exclusion relationship between the target mode and the current mode. Through the above steps, abnormal mode switching caused by misoperation or unsuitable environment can be effectively avoided, thereby further improving the rationality of subsequent canvas mode switching and user experience, and ensuring the stable operation of the system in complex interaction scenarios.
[0031] S104: If the current operation mode meets the preset mode switching conditions, then the current operation mode is switched to the target operation mode.
[0032] In one implementation, if the current operation mode meets the preset mode switching conditions, a mode switching operation is performed, switching the canvas from the current operation mode to the target operation mode. The target operation mode is determined by the target mode corresponding to the trigger signal, such as switching from pointer mode to hand mode, or from selection mode to connection mode. During the switching process, the system will follow the preset switching procedure to sequentially complete operations such as saving the current mode state, unbinding the interactive event listener, loading the new mode configuration, binding the new event listener, and updating the canvas cursor, ensuring that the switching process is complete and orderly, and avoiding state residue or event listener conflicts.
[0033] Furthermore, the canvas view state is preserved during the switching process, including the current zoom level, pan position, and selected node set, allowing users to continue the previous view context after switching modes and not lose their current editing view due to mode change. Simultaneously, a mode change notification event is triggered after the switch, notifying all functional components within the canvas to update their own states synchronously. For example, the corresponding mode button in the toolbar is highlighted, and the operation options for the corresponding mode are switched in the property panel. If the user does not respond to the mode switch trigger signal subsequently, the canvas is restored from the target operation mode to the initial current operation mode, maintaining the current operation mode unchanged. This avoids unnecessary state resets or interface refreshes due to invalid or repeated triggers, thus ensuring the continuity of user operation. Through these steps, accurate canvas mode switching is achieved, ensuring the consistency of the canvas state and the continuity of interaction before and after the switch, effectively improving overall operational efficiency and user experience.
[0034] In summary, this invention provides a canvas mode switching method, apparatus, device, and medium. By responding to a mode switching trigger signal, it acquires the current operation mode and interaction scene state of the canvas, performs multi-dimensional verification of the interaction scene state, and obtains the verification results. These multi-dimensional verifications include focus state verification, node operation verification, spatial topology verification, and interaction timing verification. Based on the verification results, it determines whether the current operation mode meets preset mode switching conditions. If the current operation mode meets the preset mode switching conditions, it switches the current operation mode to the target operation mode. Therefore, this application introduces a multi-dimensional interaction scene verification mechanism before performing mode switching, comprehensively evaluating whether the current context meets the switching conditions from four levels: focus state, operation behavior, spatial layout, and timing characteristics. This effectively avoids mode switching errors caused by accidental triggering or context mismatch, significantly improves the accuracy of canvas mode switching, enhances the overall smoothness of operation, and optimizes the user experience.
[0035] In one embodiment, specifically in step S102, which involves performing multi-dimensional verification on the interaction scenario state to obtain the verification result, the following steps are included: Perform focus state verification on the interactive scene state to obtain a first verification result; Perform node operation verification on the interactive scenario state to obtain a second verification result; A spatial topology verification is performed on the interactive scene state to obtain a third verification result; The interaction sequence of the interaction scenario is verified to obtain a fourth verification result. Determine whether the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions; If the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions, then the verification result is determined to be a successful verification.
[0036] In one implementation, a focus state check is first performed to check if the input focus is located within a text input box or parameter input box, thus obtaining the first check result. If the input focus is not located within a text input box or parameter input box, it indicates that the user may be operating other panels or interface elements. In this case, the triggered mode switching signal is likely to be falsely triggered and should be intercepted. Next, a node operation check is performed to detect if there are any ongoing node operations, such as node dragging, drawing lines, or resizing, thus obtaining the second check result. If the user is in the middle of an operation, switching modes will force the operation to be interrupted, causing the user's operational intent to be lost; therefore, switching should be prohibited in such scenarios. Then, a spatial topology check is performed, calculating spatial feature indicators based on the coordinate distribution of nodes within the current canvas, layer nesting levels, etc., to obtain the third check result, used to assess the complexity of the current canvas layout and determine whether switching modes will cause drastic changes in the view. Finally, an interaction timing check is performed, analyzing the time distribution characteristics of recent operations and rendering performance data to obtain the fourth check result, assessing the system load at the time of switching.
[0037] Furthermore, after obtaining the verification results from the four dimensions, a comprehensive judgment is made, checking whether the first, second, third, and fourth verification results all meet their respective preset verification conditions. Only when all four dimensions pass the verification is the overall verification result considered passed; if any dimension fails, the overall verification result is considered failed. Through the above steps, the verification process becomes clear, controllable, and highly scalable, thereby accurately obtaining verification results and effectively ensuring the accuracy of subsequent mode switching decisions, ensuring that canvas mode switching can proceed smoothly according to the expected behavior and results.
[0038] In one embodiment, the interaction scene state includes a focus state parameter, and the step of performing focus state verification on the interaction scene state to obtain a first verification result includes: Determine whether the focus state parameter is located within a preset target input area, wherein the preset target input area includes a text input area and / or a parameter input area; If the focus state parameter is not located within the preset target input area, then the first verification result is determined to meet the preset verification conditions.
[0039] In one implementation, the interaction scenario state includes a focus state parameter, which describes the specific location of the focus in the current user interface to reflect the user's current operation context, such as a blinking text box, a highlighted button, or an active parameter adjustment control. By determining whether the focus state parameter is located within a preset target input area, which includes a text input area and / or a parameter input area, if the focus state parameter is not within the preset target input area—whether in a specified text input box, text field, or within an input component used for parameter configuration, such as a parameter adjustment slider or numerical input box—then, according to the system's preset logical rules, the evaluation result of the first verification can be definitively determined to meet the preset verification conditions. That is, it verifies whether the current focus is located within a text input box or parameter input box. If the focus is in an input state, the mode switching trigger is disabled, and no mode switching is performed. Through these steps, a crucial basis is provided for subsequent judgment of interaction mode switching, ensuring the accuracy and context adaptability of function switching and avoiding unnecessary mode changes triggered erroneously in non-input scenarios.
[0040] In one embodiment, the interaction scene state includes node operation parameters, that is, performing node operation verification on the interaction scene state to obtain a second verification result includes the following steps: Determine whether the node operation parameters are in a preset node operation state, wherein the preset node operation state includes node connection drag state, node position drag state, or node size scaling state. If the node operation parameters are not in the preset node operation state, then the second verification result is determined to meet the preset verification conditions.
[0041] In one implementation, the interaction scenario state includes node operation parameters, which describe the execution state of the current node-related operations. During node operation verification, the system reads these node operation parameters and determines whether it is in a preset node operation state. The preset node operation states specifically include three typical operations: node connection dragging state, node position dragging state, and node size scaling state. The node connection dragging state indicates that the user is dragging a connection from one node's connection point to another node; the node position dragging state indicates that the user is dragging and moving the position of one or more nodes; and the node size scaling state indicates that the user is dragging the control points on the node's edge to adjust the node's size. In other words, the system verifies whether the user is currently in the process of node connection dragging. If the user is dragging a node connection, the mode switch is disabled to prevent interruption of the connection operation. Alternatively, the system verifies whether the user is currently in the process of node dragging / scaling. If the user is dragging / scaling a node, the mode switch is disabled to prevent interruption of the node operation. If the verification fails, the mode switch is not triggered. If all verifications pass, the mode switch execution process begins.
[0042] If the node operation parameters are in any of the preset node operation states mentioned above, it means that the user is performing a continuous node operation. Switching modes at this time would interrupt the operation flow, so the second verification result determines that the preset verification condition is not met, i.e., switching is not allowed. Conversely, if the node operation parameters are in an idle state, it means that there is no node operation in progress, and the second verification result meets the preset verification condition.
[0043] It should be noted that the preset node operation states in this embodiment list three typical scenarios. In actual applications, more operation types can be expanded according to the canvas function, such as text editing state, port connection state, etc. The specific settings can be made according to the actual situation, and this application does not impose any limitations on this. Through the above steps, it is possible to accurately identify whether the user is in the middle of executing a node operation, effectively avoiding the interruption of continuous operation by mode switching, and ensuring the integrity and smoothness of the user's editing operation.
[0044] In one embodiment, the interactive scene state includes spatial topology parameters, which include layer node coordinates, layer nesting depth, and relative distance between layer nodes. That is, performing spatial topology verification on the interactive scene state to obtain a third verification result includes the following steps: Calculate the node density value within the canvas area based on the coordinates of the layer nodes and the relative distance between the layer nodes; Determine whether the node density value exceeds a preset density threshold and whether the layer nesting depth meets a preset depth threshold; If the node density value does not exceed the preset density threshold and the layer nesting depth meets the preset depth threshold, then the third verification result is determined to meet the preset verification conditions.
[0045] In one implementation, the interactive scene state includes spatial topology parameters, which specifically include layer node coordinates, layer nesting depth, and relative distance between layer nodes. Layer node coordinates are the absolute position information of layer nodes in the canvas coordinate system, used to determine the distribution of each node in the visualization space. Layer nesting depth reflects the hierarchical structure depth of the current node, reflecting its subordinate relationship in the overall layer organization. The relative distance between layer nodes is used to measure the spatial interval between any two adjacent or related nodes, providing basic data support for subsequent density calculation and layout optimization.
[0046] When performing spatial topology verification, the node density value within the currently visible canvas area is first calculated based on the layer node coordinates and relative distances. The node density value reflects the density of node distribution per unit canvas area; higher density indicates more crowded nodes in the current view, and potentially greater visual changes and redrawing overhead when switching between different modes. The calculation can be done by counting the total number of visible nodes within the current viewport and dividing by the actual area of the viewport to obtain the number of nodes per unit area as the density value. Alternatively, a kernel density estimation algorithm based on nearest neighbor distance can be used to more accurately reflect the degree of clustering in local areas.
[0047] Furthermore, after obtaining the node density value, it is compared with a preset density threshold, while simultaneously checking whether the layer nesting depth meets the preset depth threshold. Layer nesting depth refers to the number of nesting levels of the layer or group in which the node in the current canvas resides. A higher depth indicates a more complex canvas structure, and mode switching may involve more levels of state synchronization. Both the preset density threshold and the preset depth threshold are configurable parameters and can be set according to actual conditions; this application does not impose any limitations on them. It should be noted that the spatial topology verification logic in this embodiment is as follows: when the node density value does not exceed the preset density threshold and the layer nesting depth meets the preset depth threshold, it indicates that the current canvas structure is relatively simple, the impact of switching is small, the third verification result meets the preset verification conditions, and switching is allowed. Conversely, it indicates that the current canvas is in a highly complex layout scenario, and mode switching at this time may cause significant view fluctuations or performance fluctuations; therefore, the third verification result is determined to not meet the preset verification conditions, and switching is temporarily suspended. In complex scenarios with high density and deep nesting, in addition to intercepting the switching, the system can also provide degradation processing strategies. For example, it can automatically adjust the view scaling ratio to make the node distribution more sparse before performing the mode switch, thereby reducing the visual impact of the switch. Through the above steps, the suitability of mode switching is evaluated from the perspective of spatial layout, avoiding visual jumps and performance degradation caused by forced switching when the canvas structure is highly complex, and making mode switching more in line with the actual layout characteristics of the current canvas.
[0048] In one embodiment, the interactive scene state includes interactive timing parameters, which include signal trigger frequency, operation time interval, and canvas frame rendering time. That is, performing interactive timing verification on the interactive scene state to obtain the fourth verification result includes the following steps: The user interaction activity level is determined based on the signal triggering frequency and the operation time interval. Determine whether the user interaction activity exceeds a preset activity threshold and whether the canvas frame rendering time is less than a preset latency threshold; If the user interaction activity level does not exceed the preset activity threshold and the canvas frame rendering time is less than the preset latency threshold, then the fourth verification result is determined to meet the preset verification conditions.
[0049] In one implementation, the interaction scene state includes interaction timing parameters, specifically signal trigger frequency, operation time interval, and canvas frame rendering time. Signal trigger frequency is the number of interaction signals triggered by user actions per unit time, used to measure the density of user input. Operation time interval refers to the time span between two adjacent valid interaction behaviors, reflecting the continuity and rhythm of user operations. Canvas frame rendering time represents the processing time required for the system to complete a single frame update, directly affecting the smoothness of the interface response. When performing interaction timing verification, user interaction activity is first calculated based on signal trigger frequency and operation time interval. Signal trigger frequency refers to the number of times a user triggers various interaction events per unit time, and operation time interval refers to the average time interval between two adjacent operations. Both reflect the frequency of the user's current operation from different perspectives. User interaction activity can be obtained through weighted calculation, for example, by giving positive weight to signal trigger frequency and negative weight to operation time interval, resulting in a quantified activity index. A higher value indicates more frequent user operations and a high-intensity editing state.
[0050] Furthermore, after obtaining the user interaction activity level, it is compared with a preset activity threshold, while simultaneously checking whether the canvas frame rendering time is less than a preset latency threshold. Canvas frame rendering time refers to the average time required for the canvas to complete the rendering of one frame, reflecting the current system's rendering load; a longer rendering time indicates greater performance pressure. Both the preset activity threshold and the preset latency threshold are configurable parameters and can be set according to actual conditions; this application does not impose any limitations on them. That is, if the user interaction activity level does not exceed the preset activity threshold and the canvas frame rendering time is less than the preset latency threshold, meaning the user operation is relatively smooth and the system performance is sufficient, the fourth verification result meets the preset verification conditions, allowing mode switching. Conversely, if the user interaction activity level exceeds the preset activity threshold, it indicates that the user is in a state of continuous high-frequency operation; inserting a mode switch at this time is likely to interrupt the operation rhythm, thus failing the verification conditions. Simultaneously, if the canvas frame rendering time is greater than or equal to the preset latency threshold, it indicates that the current rendering pressure is high; switching modes at this time may exacerbate lag, also failing the verification conditions. The rendering time of a canvas frame can be calculated by collecting the start and end timestamps of each frame in real time and calculating the difference between them. Then, a sliding window algorithm is used to smooth the rendering time data of the most recent frames, thereby obtaining a stable average rendering time metric to ensure the real-time performance and stability of the data. Through the above steps, the rationality of the switching timing is judged from both time and performance dimensions. This avoids interrupting the user's operation flow during high-frequency operations and prevents stuttering caused by switching under high rendering pressure, making the timing of mode switching more intelligent and in line with the user's actual operation rhythm and system operating status.
[0051] In one embodiment, specifically step S103, which involves determining whether the current operation mode meets the preset mode switching conditions based on the verification result, includes the following steps: If the verification result is successful, then the historical switching record corresponding to the current operation mode is obtained, wherein the historical switching record includes the mode switching timestamp and the mode switching frequency; Calculate the switching stability index of the current operation mode based on the mode switching timestamp and mode switching frequency; Determine whether the switching stability index is lower than a preset stability threshold; If the switching stability index is lower than the preset stability threshold, then the current operation mode is determined to meet the preset mode switching conditions.
[0052] In one implementation, after the multi-dimensional verification result is passed, the switching conditions are not directly met. Instead, historical switching behavior is introduced for a secondary judgment. First, the historical switching record corresponding to the current operation mode is obtained. This record contains the timestamp of each mode switch and the statistically obtained mode switching frequency, that is, the number of times the user switches out of or into the current mode per unit time. The historical switching record is maintained within a sliding time window, such as the most recent 30 seconds or the most recent 1 minute, retaining only recent switching behavior data to reflect the frequency of switching in the current stage. The switching stability index of the current operation mode is calculated based on the mode switching timestamp and the mode switching frequency. The switching stability index is used to measure the jitter of mode switching. It can be calculated by counting the total number of switching occurrences within the sliding time window and weighting it with the variance of the time interval between adjacent switching. The more frequent the switching and the more irregular the interval, the higher the stability index value, indicating that the mode is more unstable and has a risk of jitter. Conversely, the fewer the switching and the more uniform the interval, the lower the stability index value, indicating that the mode state is more stable. The preset stability threshold is the critical value for determining whether there is switching jitter. It can be set according to the actual situation, and this application does not impose any restrictions on it.
[0053] Furthermore, if the switching stability index is lower than the preset stability threshold, it indicates that the recent mode switching frequency is within a reasonable range and there is no frequent jitter. In this case, the current operation mode is determined to meet the preset mode switching conditions, and the switching is allowed. If the switching stability index is higher than or equal to the preset stability threshold, it indicates that the switching is too frequent in a short period of time, which may be caused by user misoperation or abnormal system triggering. In this case, the switching conditions are determined not to be met, and the switching request is blocked to avoid the mode jumping back and forth between multiple states, which would affect the user experience. By introducing historical switching records and a stability evaluation mechanism, mode jitter is effectively prevented, and the switching decision not only focuses on the current scenario but also takes into account recent switching behavior patterns, further improving the stability of mode switching and the user experience.
[0054] In one embodiment, that is, after step S104, i.e. after switching the current operation mode to the target operation mode, the following steps are included: Obtain the type identifier of the target operation mode; Based on the type identifier and the preset mapping relationship, the target interaction configuration information corresponding to the type identifier is determined, wherein the preset mapping relationship is the mapping relationship between different operation modes and corresponding interaction configuration information; Based on the target interaction configuration information, state remapping and incremental compensation are performed on the interactive objects within the canvas to update the interactive environment of the canvas in the target operation mode.
[0055] In one implementation, after the mode switch is complete, the interactive environment within the canvas also needs to be adapted and updated to ensure that the behavior of various interactive objects in the target mode conforms to expectations. First, the type identifier of the target operation mode is obtained. This identifier is a unique identifier for each operation mode; for example, "pointer" represents pointer mode, "hand" represents grasping mode, and "connect" represents connection mode. Then, based on this type identifier, a preset mapping relationship is queried to find the corresponding target interaction configuration information. The preset mapping relationship is a pre-established lookup table between mode types and interaction configurations. Each mode corresponds to an independent set of interaction configurations, including mouse cursor style, shortcut key mapping table, mouse event response rules, selection highlighting rules, canvas zoom behavior, node interactivity settings, and many other configuration parameters.
[0056] Furthermore, based on the acquired target interaction configuration information, the system performs state remapping and incremental compensation on the interactive objects within the canvas. State remapping refers to remapping and reassigning the various state attributes of the current interactive object according to the target mode configuration. For example, changing the draggable attribute of a node from enabled to disabled, changing the canvas background's translation response from off to on, and changing the cursor style from the default arrow to a grab icon. Incremental compensation corrects potential state deviations that may occur during mode switching. For instance, when switching from zoom mode back to pointer mode, the temporary transformation matrix generated by the zoom operation needs to be normalized to ensure the consistency of the coordinate system; when switching out of connection mode, incomplete temporary connection fragments need to be cleared and the default display state of the node ports needs to be restored to avoid residual intermediate states after mode switching. This state remapping and incremental compensation adopts a differential update strategy, that is, only updating attribute items that are different from the previous mode configuration, avoiding the performance overhead of full redrawing and ensuring a fast and smooth switching process. For a large number of node objects in the canvas, a batch update mechanism can also be used to apply configuration changes all at once, reducing the number of reflows and redraws. Through the above steps, the interactive environment is fully and accurately adapted after mode switching, ensuring that the interactive behavior in each mode meets the user's expectations. At the same time, incremental compensation eliminates state residue and inconsistency issues during the switching process, ensuring the integrity and consistency of mode switching.
[0057] Please see Figure 2 , Figure 2 This is a schematic diagram of the canvas mode switching device provided in an embodiment of the present invention. This canvas mode switching device corresponds one-to-one with the canvas mode switching method in the above embodiments. Please refer to the following for details. Figure 1 as well as Figure 1 The relevant descriptions in the corresponding embodiments are shown below. For ease of explanation, only the parts relevant to this embodiment are shown. See also... Figure 2 The canvas mode switching device 20 includes: an acquisition module 21, a verification module 22, a judgment module 23, and a switching module 24.
[0058] The acquisition module 21 is used to acquire the current operation mode and interaction scene state of the canvas in response to the mode switching trigger signal; The verification module 22 is used to perform multi-dimensional verification on the interactive scene state and obtain the verification result. The multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification and interaction timing verification. The judgment module 23 is used to determine whether the current operation mode meets the preset mode switching conditions based on the verification result; The switching module 24 is used to switch the current operation mode to the target operation mode if the current operation mode meets the preset mode switching conditions.
[0059] Optionally, the verification module 22 described above is specifically used for: Perform focus state verification on the interactive scene state to obtain a first verification result; Perform node operation verification on the interactive scenario state to obtain a second verification result; A spatial topology verification is performed on the interactive scene state to obtain a third verification result; The interaction sequence of the interaction scenario is verified to obtain a fourth verification result. Determine whether the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions; If the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions, then the verification result is determined to be a successful verification.
[0060] Optionally, the verification module 22 described above is also used for: The interactive scenario state includes node operation parameters; Determine whether the node operation parameters are in a preset node operation state, wherein the preset node operation state includes node connection drag state, node position drag state, or node size scaling state. If the node operation parameters are not in the preset node operation state, then the second verification result is determined to meet the preset verification conditions.
[0061] Optionally, the verification module 22 described above is also used for: The interactive scene state includes spatial topology parameters, which include layer node coordinates, layer nesting depth, and relative distance between layer nodes; Calculate the node density value within the canvas area based on the coordinates of the layer nodes and the relative distance between the layer nodes; Determine whether the node density value exceeds a preset density threshold and whether the layer nesting depth meets a preset depth threshold; If the node density value does not exceed the preset density threshold and the layer nesting depth meets the preset depth threshold, then the third verification result is determined to meet the preset verification conditions.
[0062] Optionally, the verification module 22 described above is also used for: The interactive scene state includes interactive timing parameters, which include signal trigger frequency, operation time interval, and canvas frame rendering time. The user interaction activity level is determined based on the signal triggering frequency and the operation time interval. Determine whether the user interaction activity exceeds a preset activity threshold and whether the canvas frame rendering time is less than a preset latency threshold; If the user interaction activity level does not exceed the preset activity threshold and the canvas frame rendering time is less than the preset latency threshold, then the fourth verification result is determined to meet the preset verification conditions.
[0063] Optionally, the aforementioned judgment module 23 is specifically used for: If the verification result is successful, then the historical switching record corresponding to the current operation mode is obtained, wherein the historical switching record includes the mode switching timestamp and the mode switching frequency; Calculate the switching stability index of the current operation mode based on the mode switching timestamp and mode switching frequency; Determine whether the switching stability index is lower than a preset stability threshold; If the switching stability index is lower than the preset stability threshold, then the current operation mode is determined to meet the preset mode switching conditions.
[0064] Optionally, the aforementioned switching module 24 is further configured to: Obtain the type identifier of the target operation mode; Based on the type identifier and the preset mapping relationship, the target interaction configuration information corresponding to the type identifier is determined, wherein the preset mapping relationship is the mapping relationship between different operation modes and corresponding interaction configuration information; Based on the target interaction configuration information, state remapping and incremental compensation are performed on the interactive objects within the canvas to update the interactive environment of the canvas in the target operation mode.
[0065] It should be noted that the information interaction and execution process between the above-mentioned units are based on the same concept as the method embodiments of the present invention. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0066] Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 3 As shown, the computer device of this embodiment includes: at least one processor ( Figure 3 Only one is shown in the diagram), a memory, and a computer program stored in the memory and capable of running on at least one processor, wherein the processor executes the computer program to implement the steps in the above embodiments of the arbitrary canvas mode switching method.
[0067] This computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 3The examples of computer devices are merely examples and do not constitute a limitation on computer devices. Computer devices may include more or fewer components than shown in the illustration, or combinations of certain components, or different components, such as network interfaces, displays, and input systems.
[0068] In one embodiment, a computer-readable storage medium is provided that, when the instructions in the computer-readable storage medium are executed by a processor in a computer device, enables the computer device to perform the steps of any embodiment of the canvas mode switching method disclosed in this invention, which will not be repeated here. The computer-readable storage medium may be non-volatile or volatile.
[0069] The processor referred to can be a CPU, but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0070] Memory includes readable storage media, internal memory, etc., wherein internal memory can be the RAM of a computer device, providing an environment for the operation of the operating system and computer-readable instructions stored in the readable storage media. The readable storage media can be the hard drive of the computer device, or in other embodiments, it can be an external storage device of the computer device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, memory can include both internal storage units and external storage devices of the computer device. Memory is used to store the operating system, cooperative applications, boot loader, data, and other programs, such as program code of computer programs. Memory can also be used to temporarily store data that has been output or will be output.
[0071] Those skilled in the art will understand that implementing all or part of the processes in the methods of the above embodiments can be accomplished by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0072] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this invention. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0073] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A canvas mode switching method, characterized in that, include: In response to the mode switching trigger signal, obtain the current operation mode and interaction scene state of the canvas; The interactive scene state is verified in multiple dimensions to obtain the verification results. The multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification, and interaction timing verification. Based on the verification result, determine whether the current operation mode meets the preset mode switching conditions; If the current operating mode meets the preset mode switching conditions, then the current operating mode will be switched to the target operating mode.
2. The canvas mode switching method as described in claim 1, characterized in that, The multi-dimensional verification of the interaction scenario state to obtain the verification result includes: Perform focus state verification on the interactive scene state to obtain a first verification result; Perform node operation verification on the interactive scenario state to obtain a second verification result; A spatial topology verification is performed on the interactive scene state to obtain a third verification result; The interaction sequence of the interaction scenario is verified to obtain a fourth verification result. Determine whether the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions; If the first verification result, the second verification result, the third verification result, and the fourth verification result all meet the preset verification conditions, then the verification result is determined to be a successful verification.
3. The canvas mode switching method as described in claim 2, characterized in that, The interaction scenario state includes node operation parameters. The step of verifying the node operation of the interaction scenario state to obtain a second verification result includes: Determine whether the node operation parameters are in a preset node operation state, wherein the preset node operation state includes node connection drag state, node position drag state, or node size scaling state. If the node operation parameters are not in the preset node operation state, then the second verification result is determined to meet the preset verification conditions.
4. The canvas mode switching method as described in claim 2, characterized in that, The interactive scene state includes spatial topology parameters, which include layer node coordinates, layer nesting depth, and relative distances between layer nodes. The spatial topology verification of the interactive scene state, to obtain a third verification result, includes: Calculate the node density value within the canvas area based on the coordinates of the layer nodes and the relative distance between the layer nodes; Determine whether the node density value exceeds a preset density threshold and whether the layer nesting depth meets a preset depth threshold; If the node density value does not exceed the preset density threshold and the layer nesting depth meets the preset depth threshold, then the third verification result is determined to meet the preset verification conditions.
5. The canvas mode switching method as described in claim 2, characterized in that, The interactive scene state includes interactive timing parameters, which include signal trigger frequency, operation time interval, and canvas frame rendering time. The interactive scene state is subjected to interactive timing verification to obtain a fourth verification result, including: The user interaction activity level is determined based on the signal triggering frequency and the operation time interval. Determine whether the user interaction activity exceeds a preset activity threshold and whether the canvas frame rendering time is less than a preset latency threshold; If the user interaction activity level does not exceed the preset activity threshold and the rendering time of the drawing canvas frame is less than the preset latency threshold, then the fourth verification result is determined to meet the preset verification conditions.
6. The canvas mode switching method as described in claim 1, characterized in that, The step of determining whether the current operation mode meets the preset mode switching conditions based on the verification result includes: If the verification result is successful, then the historical switching record corresponding to the current operation mode is obtained, wherein the historical switching record includes the mode switching timestamp and the mode switching frequency; Calculate the switching stability index of the current operation mode based on the mode switching timestamp and mode switching frequency; Determine whether the switching stability index is lower than a preset stability threshold; If the switching stability index is lower than the preset stability threshold, then the current operation mode is determined to meet the preset mode switching conditions.
7. The canvas mode switching method as described in claim 1, characterized in that, After switching the current operation mode to the target operation mode, the following steps are included: Obtain the type identifier of the target operation mode; Based on the type identifier and the preset mapping relationship, the target interaction configuration information corresponding to the type identifier is determined, wherein the preset mapping relationship is the mapping relationship between different operation modes and corresponding interaction configuration information; Based on the target interaction configuration information, state remapping and incremental compensation are performed on the interactive objects within the canvas to update the interactive environment of the canvas in the target operation mode.
8. A canvas mode switching device, characterized in that, include: The acquisition module is used to obtain the current operation mode and interaction scene state of the canvas in response to the mode switching trigger signal; The verification module is used to perform multi-dimensional verification on the interactive scene state and obtain the verification result. The multi-dimensional verification includes focus state verification, node operation verification, spatial topology verification, and interaction timing verification. The judgment module is used to determine whether the current operation mode meets the preset mode switching conditions based on the verification result; The switching module is used to switch the current operation mode to the target operation mode if the current operation mode meets the preset mode switching conditions.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the canvas mode switching method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the canvas mode switching method as described in any one of claims 1 to 7.
