Element abstraction and positioning method and system in visual programming
By introducing vertical and horizontal scroll bars and projected highlight blocks in visual programming, the problem of difficult to reflect element differences and incomplete element display after scaling is solved, achieving a more intuitive representation of element positions and improving the development experience.
Patent Information
- Application Number
- CN202310226332.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-09
- Publication Date
- 2024-09-10
AI Technical Summary
In existing visual programming, it is difficult to reflect the differences between elements. Key elements outside the canvas cannot be fully displayed after scaling. Thumbnails and scroll bar highlighting schemes are not displayed uniformly when the canvas range is not determined, and are not suitable for visual programming.
Expand the scroll bar container in the vertical and horizontal directions on the right and bottom of the canvas, control the scrolling of the canvas through the slider, and generate a projected highlight block in the scroll bar to reflect the position of the element. Combine the mouse click and drag events to adjust the visible area and customize the height. Highlight attributes to distinguish element types.
It avoids the problem of inconsistent display of thumbnails under an uncertain canvas range, and more intuitively represents the position of elements by projecting highlight blocks, improving the visual development experience.
Smart Images

Figure CN118626068A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer visual programming, and in particular to a method and system for element abstraction and positioning in visual programming. Background Art
[0002] Visual programming is a programming method that uses a combination of graphic elements to represent program logic. Compared with conventional text programming, it is simpler and more intuitive. It can assist conventional programming tasks to a certain extent, and even replace specific languages, such as ladder diagrams in industrial PLCs, scratch in children's programming enlightenment, and LABVIEW for automated research verification and production testing.
[0003] However, the current optimization of development experience in visual programming is not as good as that of conventional text programming. For example, the flat layout cannot well reflect the differences between elements; element markings (labels, searches, and modification records) are limited to the current visible area, and key elements outside the visible area cannot be displayed after zooming; the solutions to the above problems in conventional text programming are thumbnails and scroll bar highlights; the thumbnail solution is not completely suitable for situations where the canvas size is uncertain. For example, when the canvas range is too large, scaling it according to width priority will lose vertical element information, and taking both length and width into consideration will lead to uncertain actual scaling ratios, loss of details, and inconsistent display; scroll bar highlights only need to consider vertical information in text, which is not completely suitable for visual programming.
[0004] Patent document CN115543290A (application number: CN202211250470.4) discloses a visual programming method and system, which includes the steps of: mapping multiple preset programming capability elements into graphic element nodes respectively; displaying the graphic element nodes on an editing page; based on a received drag operation trigger signal, connecting the graphic element nodes in the editing page to form a target configuration page; and executing the target configuration page to generate a corresponding target display page.
[0005] The thumbnail form in current graphics and the mini map method in text programming both use zooming to achieve an overview of the overall content and highlight key elements to emphasize elements; while the present invention uses projection to reflect the position of elements in the canvas and emphasizes the element content through projection highlighting. Summary of the invention
[0006] In view of the defects in the prior art, the object of the present invention is to provide a method and system for element abstraction and positioning in visual programming.
[0007] The element abstraction and positioning method in visual programming provided by the present invention includes:
[0008] Step 1: Expand an area of preset width and height on the right and bottom of the canvas, with the width and height in the vertical and horizontal directions flush with the canvas, to serve as containers for the vertical and horizontal scroll bars;
[0009] Step 2: Generate a slider based on the visible range of the current canvas to control the scrolling of the canvas up, down, left, and right;
[0010] Step 3: Set the corresponding click event of the container to adjust the offset distance of the visible area according to the relative distance between the mouse and the top and left side of the container; set the corresponding drag event of the slider to control the vertical and horizontal scrolling of the canvas;
[0011] Step 4: For the graphic elements in the canvas, projections are generated in the vertical and horizontal scroll bars respectively, which are displayed as highlight blocks of specific shapes and colors. The position of the elements in the actual canvas is reflected by the position of the projection in the scroll bar.
[0012] Preferably, let the current actual canvas width w a , high h a , the width of the visible area is w v , high h v , vertical offset x, horizontal offset y, vertical and horizontal scroll bar container width and height are t, then: vertical slider height is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively.
[0013] Preferably, assuming that the element has a height h and a width w, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, the center point of the highlight block is at a distance of The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is
[0014] Preferably, when the canvas loses focus, the slider is faded; when the actual size of the canvas is less than or equal to the visible size, the slider is hidden.
[0015] Preferably, in the scroll bar, the height or width and the vertical and horizontal offset distances of the highlight block are customized to distinguish the highlight blocks of different types of elements; an attribute domain is set for each visual element, including type, label and name, and corresponding highlight block related configuration is added for each attribute type or specific value; the corresponding highlight block is generated according to the preset configuration when the canvas and scroll bar are rendered, or the highlight block changes with the system status; for search needs, the corresponding highlight block is generated according to the search content matching element; for statistical needs, the highlight block opacity is set to change with the number of identical elements.
[0016] The element abstraction and positioning system in visual programming provided by the present invention includes:
[0017] Module M1: Expand an area of preset width and height on the right and bottom of the canvas, and the width and height in the vertical and horizontal directions are flush with the canvas, respectively, serving as a container for the vertical and horizontal scroll bars;
[0018] Module M2: Generate a slider according to the visible range of the current canvas to control the scrolling of the canvas up, down, left, and right;
[0019] Module M3: Set the corresponding click event of the container to adjust the offset distance of the visible area according to the relative distance between the mouse and the top and left side of the container; at the same time, set the corresponding drag event of the slider to control the vertical and horizontal scrolling of the canvas;
[0020] Module M4: For graphic elements in the canvas, projections are generated in the vertical and horizontal scroll bars respectively, which are displayed as highlight blocks of specific shapes and colors. The position of the elements in the actual canvas is reflected by the position of the projections in the scroll bars.
[0021] Preferably, let the current actual canvas width w a , high h a , the width of the visible area is w v , high h v , vertical offset x, horizontal offset y, vertical and horizontal scroll bar container width and height are t, then: vertical slider height is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively.
[0022] Preferably, assuming that the element has a height h and a width w, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, the center point of the highlight block is at a distance of The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is
[0023] Preferably, when the canvas loses focus, the slider is faded; when the actual size of the canvas is less than or equal to the visible size, the slider is hidden.
[0024] Preferably, in the scroll bar, the height or width and the vertical and horizontal offset distances of the highlight block are customized to distinguish the highlight blocks of different types of elements; an attribute domain is set for each visual element, including type, label and name, and corresponding highlight block related configuration is added for each attribute type or specific value; the corresponding highlight block is generated according to the preset configuration when the canvas and scroll bar are rendered, or the highlight block changes with the system status; for search needs, the corresponding highlight block is generated according to the search content matching element; for statistical needs, the highlight block opacity is set to change with the number of identical elements.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] Compared with the thumbnail format, the present invention avoids the problem of inconsistent display in the case of an uncertain canvas range; through the abstract target element position information, combined with the defined projection configuration, the key focus elements can be grasped more intuitively and comprehensively, thereby improving the visual development experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0028] Figure 1 Schematic diagram of element projection in the canvas. DETAILED DESCRIPTION
[0029] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0030] Embodiment 1:
[0031] The present invention provides an element abstraction and positioning method in visual programming, which is used to optimize the development experience and program reading experience, and specifically includes the following contents:
[0032] Expand an area of appropriate width on the right side of the canvas and expand an area of appropriate height below the canvas. The height and width in the vertical and horizontal directions are flush with the canvas respectively, which serve as containers for the vertical and horizontal scroll bars. At the same time, generate a slider according to the visible range of the current canvas to control the scrolling of the canvas up, down, left, and right.
[0033] Set the current actual canvas width w a , high h a , the width of the visible area is w v , high h v , vertical offset x, horizontal offset y, vertical (horizontal) scroll bar container width (height) t, such as Figure 1 :
[0034] The outer dotted area is the actual size of the canvas, the large rectangle in the middle is the visible area, and elements outside the visible area are hidden; the vertical slider is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively, similar to the scroll bar of the text field.
[0035] The container responds to click events and adjusts the offset distance of the visible area according to the relative distance between the mouse and the top (left) of the container. At the same time, the slider responds to drag events to control the vertical or horizontal scrolling of the canvas. When the canvas loses focus, the slider fades. When the actual size of the canvas is less than or equal to the visible size, the slider hides.
[0036] For graphic elements in the canvas, projections are generated in the vertical and horizontal scroll bars according to the configuration. The actual form is a highlight block with a specific shape and color. The position of the projection in the scroll bar reflects the position of the element in the actual canvas. The calculation method is similar to that of the slider. Assuming that the element is h high, w wide, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, the center point of the highlight block is at a distance of The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is In special forms, the height (width) can be fixed to a specific value.
[0037] The remaining properties include shape, width (height), offset distance, color, etc., which can be dynamically controlled by custom configuration; for example, the shape can be rectangular, 30 degree rounded, red, and 50% opacity; in the vertical scroll bar, the highlight block width and horizontal offset distance are customized to distinguish the highlight blocks of different types of elements. Figure 1 , the rectangular element is mapped to a highlight block with a width of 33%, an offset of 0%, black color, and an opacity of 10%;
[0038] For each visualization element, there are attribute fields: type, label, name, etc. For each attribute type or specific value, you can add corresponding highlight block related configuration; Figure 1Different highlight blocks are configured based on element type. Parallelogram elements are mapped to highlight blocks with a width of 33%, an offset of 0%, black, and an opacity of 20%. Elliptical elements are mapped to highlight blocks with a width of 33%, an offset of 0%, black, and an opacity of 30%. A highlight block is configured based on the tag. Elements with tags containing tag1 are mapped to highlight blocks with a width of 33%, an offset of 33%, black, and an opacity of 30%.
[0039] Related configurations can be hard-coded or dynamically generated. Hard coding means that the highlight blocks with given conditions are pre-configured, and the corresponding highlight blocks are directly generated according to the configuration when the canvas and scroll bar are rendered; dynamic generation means that the highlight block generation strategy will change with the system status; for search needs, the corresponding highlight blocks can be generated according to the search content matching elements; for statistical needs, the opacity of the highlight blocks changes with the number of identical elements. Figure 1 In the figure, the current search content is D, and the ellipse element named D is matched, and a highlight block with a width of 33%, an offset of 66%, a radius of 10, black, and an opacity of 30% is mapped in the scroll bar; for the element F with an error, a highlight block with a width of 100%, a height of 1px, black, and an opacity of 30% is mapped in the scroll bar.
[0040] Embodiment 2:
[0041] The present invention also provides an element abstraction and positioning system in visual programming, which can be implemented by executing the process steps of the element abstraction and positioning method in visual programming, that is, those skilled in the art can understand the element abstraction and positioning method in visual programming as a preferred implementation of the element abstraction and positioning system in visual programming.
[0042] The element abstraction and positioning system in visual programming provided by the present invention includes: module M1: extending an area of preset width and height on the right and bottom of the canvas respectively, with the width and height in the vertical and horizontal directions being flush with the canvas respectively, serving as a container for scroll bars in the vertical and horizontal directions; module M2: generating a slider according to the visible range of the current canvas to control the scrolling of the canvas up, down, left and right; module M3: setting a corresponding click event for the container, adjusting the offset distance of the visible area according to the relative distance between the mouse and the top and left side of the container; and setting a corresponding drag event for the slider at the same time to control the vertical and horizontal scrolling of the canvas; module M4: for the graphic elements in the canvas, generating projections in the vertical and horizontal scroll bars respectively, which are expressed as highlight blocks of specific shapes and colors, and the position of the element in the actual canvas is reflected by the position of the projection in the scroll bar.
[0043] Set the current actual canvas width w a , high h a , the width of the visible area is w v , high hv , vertical offset x, horizontal offset y, vertical and horizontal scroll bar container width and height are t, then: vertical slider height is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively.
[0044] Assume that the element is h high and w wide, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, then the distance between the center point of the highlighted block and the top of the vertical scroll bar is The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is
[0045] When the canvas loses focus, the slider is faded; when the actual size of the canvas is less than or equal to the visible size, the slider is hidden.
[0046] In the scroll bar, the height or width and the vertical and horizontal offset distances of the highlight block can be customized to distinguish the highlight blocks of different types of elements; an attribute domain is set for each visual element, including type, label and name, and corresponding highlight block related configuration is added for each attribute type or specific value; when the canvas and scroll bar are rendered, the corresponding highlight block is generated according to the preset configuration, or the highlight block changes with the system status; for search needs, the corresponding highlight block is generated according to the search content matching element; for statistical needs, the opacity of the highlight block is set to change with the number of identical elements.
[0047] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0048] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A method for element abstraction and positioning in visual programming, characterized in that: include: Step 1: Expand an area of preset width and height on the right and bottom of the canvas, with the width and height in the vertical and horizontal directions flush with the canvas, to serve as containers for the vertical and horizontal scroll bars; Step 2: Generate a slider based on the visible range of the current canvas to control the scrolling of the canvas up, down, left, and right; Step 3: Set the corresponding click event of the container to adjust the offset distance of the visible area according to the relative distance between the mouse and the top and left side of the container; set the corresponding drag event of the slider to control the vertical and horizontal scrolling of the canvas; Step 4: For the graphic elements in the canvas, projections are generated in the vertical and horizontal scroll bars respectively, which are displayed as highlight blocks of specific shapes and colors. The position of the elements in the actual canvas is reflected by the position of the projection in the scroll bar.
2. The element abstraction and positioning method in visual programming according to claim 1, characterized in that Current actual canvas width w a , high h a , the width of the visible area is w v , high h v , vertical offset x, horizontal offset y, vertical and horizontal scroll bar container width and height are t, then: vertical slider height is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively.
3. The element abstraction and positioning method in visual programming according to claim 2, characterized in that: Assume that the element is h high and w wide, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, then the distance between the center point of the highlighted block and the top of the vertical scroll bar is The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is 4. The element abstraction and positioning method in visual programming according to claim 1, characterized in that: When the canvas loses focus, the slider is faded; when the actual size of the canvas is less than or equal to the visible size, the slider is hidden.
5. The element abstraction and positioning method in visual programming according to claim 1, characterized in that: In the scroll bar, the height or width and the vertical and horizontal offset distances of the highlight block can be customized to distinguish the highlight blocks of different types of elements; an attribute domain is set for each visual element, including type, label and name, and corresponding highlight block related configuration is added for each attribute type or specific value; when the canvas and scroll bar are rendered, the corresponding highlight block is generated according to the preset configuration, or the highlight block changes with the system status; for search needs, the corresponding highlight block is generated according to the search content matching element; for statistical needs, the opacity of the highlight block is set to change with the number of identical elements.
6. A visual programming element abstraction and positioning system, characterized in that: include: Module M1: Expand an area of preset width and height on the right and bottom of the canvas, and the width and height in the vertical and horizontal directions are flush with the canvas, respectively, serving as a container for the vertical and horizontal scroll bars; Module M2: Generate a slider according to the visible range of the current canvas to control the scrolling of the canvas up, down, left, and right; Module M3: Set the corresponding click event of the container to adjust the offset distance of the visible area according to the relative distance between the mouse and the top and left side of the container; at the same time, set the corresponding drag event of the slider to control the vertical and horizontal scrolling of the canvas; Module M4: For graphic elements in the canvas, projections are generated in the vertical and horizontal scroll bars respectively, which are displayed as highlight blocks of specific shapes and colors. The position of the elements in the actual canvas is reflected by the position of the projections in the scroll bars.
7. The element abstraction and positioning system in visual programming according to claim 6, characterized in that Current actual canvas width w a , high h a , the width of the visible area is w v , high h v , vertical offset x, horizontal offset y, vertical and horizontal scroll bar container width and height are t, then: vertical slider height is Offset downward from the top of the container The length of the horizontal slider is Offset to the right from the left side of the container Map the visible range in the vertical and horizontal directions respectively.
8. The element abstraction and positioning system in visual programming according to claim 7, characterized in that: Assume that the element is h high and w wide, and the horizontal distance a and vertical distance b of the center point relative to the upper left corner of the canvas, then the distance between the center point of the highlighted block and the top of the vertical scroll bar is The relative left distance in the horizontal scroll bar is The height of the highlight block in the vertical scroll bar is In a horizontal scroll bar, the width is 9. The element abstraction and positioning system in visual programming according to claim 6, characterized in that: When the canvas loses focus, the slider is faded; when the actual size of the canvas is less than or equal to the visible size, the slider is hidden.
10. The element abstraction and positioning system in visual programming according to claim 6, characterized in that: In the scroll bar, the height or width and the vertical and horizontal offset distances of the highlight block can be customized to distinguish the highlight blocks of different types of elements; an attribute domain is set for each visual element, including type, label and name, and corresponding highlight block related configuration is added for each attribute type or specific value; when the canvas and scroll bar are rendered, the corresponding highlight block is generated according to the preset configuration, or the highlight block changes with the system status; for search needs, the corresponding highlight block is generated according to the search content matching element; for statistical needs, the opacity of the highlight block is set to change with the number of identical elements.
