Drawing method, system and device for chemical structural formula in multi-dimensional table and storage medium
By setting the chemical structure field type in a multidimensional table and calling the editor's drawing tools, the problems of tables being uneditable and unable to adapt to different sizes are solved, enabling direct drawing and display of chemical structures, which is suitable for recording and managing drug molecule structures and reaction routes.
Patent Information
- Application Number
- CN202511441388.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-10
- Publication Date
- 2026-01-13
AI Technical Summary
In B/S architecture tables, users cannot directly edit chemical structural formulas within the table, and inserted images cannot adapt to cell sizes, resulting in blurry thumbnails or messy layouts, making the display inflexible.
Set the chemical structure field type in the target cell of the multidimensional table, and call the built-in structure editor drawing tool to draw the chemical structure. Then generate a thumbnail according to the cell size, which supports previewing and exporting in multiple formats.
It enables direct drawing and editing of chemical structural formulas in multidimensional tables, with adaptive cell size, neat and flexible display, and supports preview and multi-format export, making it suitable for recording and managing drug molecule structures and reaction routes.
Smart Images

Figure CN121328484A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, system, apparatus, and storage medium for drawing chemical structural formulas in a multidimensional table. Background Technology
[0002] In drug development, researchers need to record molecular structures or reaction routes in tables using a B / S (Browser / Server Architecture) system. The specific process involves users first drawing molecular structures using software like ChemDraw, then saving the drawn structures as images and inserting them into table cells. This method has the following problems: users cannot directly edit the structures within the table, relying on external tools; the inserted images do not adapt to the cell size, resulting in blurry thumbnails or disorganized layout, making the display inflexible. Summary of the Invention
[0003] The purpose of this invention is to provide a method, system, device, and storage medium for drawing chemical structural formulas in a multidimensional table. This method enables the drawing and editing of chemical structural formulas directly within the target cells of the multidimensional table. The chemical structural formulas are automatically scaled according to the size of the target cells and displayed in the cells as thumbnails, resulting in neat layout and flexible display.
[0004] To address the aforementioned technical problems, this invention provides a method for drawing chemical structural formulas in a multidimensional table, comprising:
[0005] Based on the user's field type setting operation, the field type of the target cell in the multidimensional table is set to the pre-registered and configured chemical structure field type;
[0006] When a user is detected to be editing the target cell, the structure editor built into the target cell is invoked to provide a preset chemical structure drawing tool, so that the user can use the chemical structure drawing tool to draw the chemical structure in the canvas provided by the structure editor;
[0007] After detecting that the user has completed drawing the chemical structure formula, the chemical structure formula is stored in the database;
[0008] After detecting that the user has closed the structure editor, a thumbnail corresponding to the chemical structure is generated according to the size of the target cell, and the thumbnail is displayed in the target cell.
[0009] Optionally, after storing the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula, the method further includes:
[0010] When a user is detected performing a preview operation on the target cell, a preview window is invoked, and the chemical structural formula corresponding to the current target cell, read from the database, is loaded into the preview area of the preview window at its original resolution.
[0011] Optionally, after storing the chemical structural formula in the database after detecting that the user has completed drawing the chemical structural formula, the method further includes:
[0012] When a user performs an export operation on the multidimensional table, the chemical structural formulas corresponding to each target cell in the multidimensional table are exported in an editable format from the database, or the chemical structural formulas corresponding to each target cell in the multidimensional table are converted into a general format and then exported. The editable format includes any one or more combinations of SMILES, MOL, SVG and INT formats, and the general format includes PNG or PDF formats.
[0013] Optionally, storing the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula includes:
[0014] The chemical structural formula is stored in the database in a preset storage format, wherein the preset storage format includes SMILES, MOL, SVG and INT.
[0015] Optionally, generating a thumbnail corresponding to the chemical structural formula based on the size of the target cell includes:
[0016] Determine the actual row height and actual column width of the target cell, as well as the actual height and actual width of the chemical structural formula;
[0017] A first scaling factor is determined based on the actual row height of the target cell and the actual height of the chemical structure formula. A second scaling factor is determined based on the actual column width of the target cell and the actual width of the chemical structure formula. The smaller value between the first scaling factor and the second scaling factor is taken as the target scaling factor.
[0018] The chemical structural formula is scaled up to the target scaling ratio to obtain the thumbnail.
[0019] To address the aforementioned technical problems, this invention also provides a system for drawing chemical structural formulas in a multidimensional table, comprising:
[0020] The field setting module is used to set the field type of the target cell in the multidimensional table to the pre-registered and configured chemical structure field type based on the user's field type setting operation.
[0021] The drawing module is used to call the structure editor built into the target cell when it detects that the user has performed an editing operation on the target cell, so that the user can use the chemical structure drawing tool to draw the chemical structure in the canvas provided by the structure editor.
[0022] A storage module is used to store the chemical structure formula to a database after detecting that the user has completed drawing the chemical structure formula;
[0023] The display module is used to generate a thumbnail corresponding to the chemical structure formula based on the size of the target cell after detecting that the user has closed the structure editor, and to display the thumbnail in the target cell.
[0024] Optionally, the system further includes:
[0025] The preview module is used to, after detecting that the user has completed drawing the chemical structure formula and storing the chemical structure formula in the database, call the preview window when the user performs a preview operation on the target cell, and load the chemical structure formula corresponding to the current target cell read from the database into the preview area of the preview window at the original resolution;
[0026] The export module is used to, after detecting that the user has completed drawing the chemical structure and storing the chemical structure in the database, export the chemical structures corresponding to each target cell in the multidimensional table in the database in an editable format when the user performs an export operation on the multidimensional table, or to convert the chemical structures corresponding to each target cell in the database to a general format and then export them. The editable format includes any one or more combinations of SMILES, MOL, SVG and INT formats, and the general format includes PNG or PDF formats.
[0027] Optionally, the display module includes:
[0028] The size determination module is used to determine the actual row height and actual column width of the target cell, as well as the actual height and actual width of the chemical structure, after detecting that the user has closed the structure editor;
[0029] The scaling ratio determination module is used to determine a first scaling ratio based on the actual row height of the target cell and the actual height of the chemical structure, and to determine a second scaling ratio based on the actual column width of the target cell and the actual width of the chemical structure, and to take the smaller value between the first scaling ratio and the second scaling ratio as the target scaling ratio;
[0030] The scaling display module is used to scale the entire chemical structural formula according to a target scaling ratio to obtain the thumbnail, and to display the thumbnail in the target cell.
[0031] To solve the above-mentioned technical problems, the present invention also provides an apparatus for drawing chemical structural formulas in a multidimensional table, comprising:
[0032] Memory, used to store computer programs;
[0033] A processor, used to execute the computer program to implement the steps of the method for drawing chemical structural formulas in any of the above-mentioned multidimensional tables.
[0034] To solve the above-mentioned technical problems, the present invention also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for drawing chemical structural formulas in any of the above-mentioned multidimensional tables.
[0035] The beneficial effects of this invention lie in providing a method, system, apparatus, and storage medium for drawing chemical structural formulas in a multidimensional table. This includes setting the target cell as a chemical structural formula field type, invoking a structural formula editor when the user edits the target cell, allowing the user to directly draw chemical structural formulas in the multidimensional table using the drawing tools provided by the structural formula editor, thus realizing the function of directly drawing and editing chemical structural formulas within the target cell of the multidimensional table; after the user completes the drawing, the chemical structural formula is stored in a database; when the user closes the structural formula editor, the chemical structural formula is automatically scaled according to the size of the target cell, and displayed as a thumbnail in the cell, adapting to cell size, with neat layout and flexible display, suitable for recording and managing data such as drug molecule structures and reaction routes in biomedical laboratories. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the prior art and embodiments 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.
[0037] Figure 1 A flowchart of a method for drawing chemical structural formulas in a multidimensional table provided by the present invention;
[0038] Figure 2 This invention provides a schematic diagram of a chemical structure field type configuration.
[0039] Figure 3This invention provides a schematic diagram for drawing chemical structural formulas using a structural formula editor;
[0040] Figure 4 This invention provides a schematic diagram of a thumbnail display of a chemical structural formula in a multidimensional table.
[0041] Figure 5 A preview diagram of a target cell in a multidimensional table provided by the present invention;
[0042] Figure 6 This is a schematic diagram of the structure of a system for drawing chemical structural formulas in a multidimensional table provided by the present invention;
[0043] Figure 7 This is a schematic diagram of a device for drawing chemical structural formulas in a multidimensional table, as provided by the present invention. Detailed Implementation
[0044] The core of this invention is to provide a method, system, device, and storage medium for drawing chemical structural formulas in a multidimensional table. It can directly draw and edit chemical structural formulas in the target cell of the multidimensional table, and automatically scale the chemical structural formulas according to the size of the target cell to display them in the cell as thumbnails, with neat layout and flexible display.
[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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 embodiments of the present invention, not all embodiments. 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.
[0046] Please refer to Figure 1 , Figure 1 A flowchart of a method for drawing chemical structural formulas in a multidimensional table provided by the present invention, the method comprising:
[0047] S101. Based on the user's field type setting operation, set the field type of the target cell in the multidimensional table to the pre-registered and configured chemical structure field type.
[0048] S102. When the user is detected to be editing the target cell, the structure editor built into the target cell is invoked to provide preset chemical structure drawing tools, so that the user can use the chemical structure drawing tools to draw chemical structures on the canvas provided by the structure editor.
[0049] S103. After detecting that the user has completed the drawing of the chemical structure formula, store the chemical structure formula in the database.
[0050] S104. After detecting that the user has closed the structure editor, generate a thumbnail corresponding to the chemical structure based on the size of the target cell, and display the thumbnail in the target cell.
[0051] This invention pre-adds a chemical structure field type to the multidimensional table and configures the chemical structure field type accordingly, so that cells with the field type set to chemical structure field type allow users to directly draw chemical structures in the cells.
[0052] This invention does not particularly limit the specific implementation of registering and configuring chemical structure field types. For example, the "InDraw" field type can be registered as the aforementioned chemical structure field type in the field registration module, and the "InDraw" field type can be configured accordingly. The configuration includes, but is not limited to: setting the editing permissions for the "InDraw" field type; binding a specific rendering function to the "InDraw" field type, which can be used to draw the chemical structure on the Canvas; binding a double-click event to the "InDraw" field type, where double-clicking a target cell with the field type set to "InDraw" is considered an editing operation on the target cell, and clicking a target cell is considered an attempt to preview the chemical structure within the cell, thus enabling the switching between read-only and edit states of the target cell in the interaction control layer.
[0053] After completing the registration and configuration of the chemical structure field type, users can set the target cell in a multidimensional table as a chemical structure field type according to their needs. Please refer to... Figure 2 , Figure 2 This invention provides a schematic diagram of a chemical structure field type configuration. When a user performs a field type setting operation, a field configuration pop-up window appears. This window provides a drop-down selection box for field types, and a list of field type options, which may include InDraw field types, numeric field types, and other field types. When a user selects the InDraw field type from the drop-down selection box, it is considered that the current cell is set as a chemical structure field type.
[0054] For target cells set as chemical structure field types, when a user's editing operation on the target cell is detected (e.g., listening for click events on the target cell and assuming the user will edit the target cell when double-clicking), the built-in structure editor of the target cell is invoked. This structure editor can be loaded using an iframe, supports importing graphics, and exporting chemical structures from its provided canvas. The structure editor provides preset chemical structure drawing tools, including but not limited to drawing tools for atoms, bonds, and rings, which can be set according to actual needs; this invention does not impose any particular limitations on this. Based on this, users can utilize the drawing tools provided by the structure editor to draw chemical structures on the canvas provided by the structure editor, achieving the goal of directly drawing chemical structures in a multidimensional table without switching software, making the operation convenient.
[0055] As can be seen, whether drawing a new chemical structure for the first time in the target cell or editing an existing chemical structure in the target cell, users can directly draw the chemical structure using the built-in structure editor of the target cell without calling other software, making the operation convenient.
[0056] After detecting that the user has completed drawing the chemical structure (for example, determining that the user has completed drawing the chemical structure when the user closes the structure editor), the current chemical structure on the canvas provided by the structure editor is stored. This storage can be to a specified location in the database for later display and export. The storage format for chemical structures will be introduced later and will not be elaborated here.
[0057] After detecting that the user has closed the structure editor, a thumbnail corresponding to the chemical structure is automatically generated and displayed in the target cell for easy viewing. Furthermore, the thumbnail size is determined based on the target cell size, ensuring the thumbnail adapts to the current target cell size, guaranteeing clear display of the chemical structure and avoiding distortion. The specific implementation method for adapting the thumbnail size to the target cell size will be described in subsequent embodiments and will not be elaborated here.
[0058] Please refer to Figure 3 and Figure 4 , Figure 3 This invention provides a method for drawing schematic diagrams of chemical structures using a structure editor. Figure 4 This is a schematic diagram illustrating a thumbnail representation of a chemical structural formula in a multidimensional table provided by the present invention. For example... Figure 3As shown, when a user performs editing operations on a target cell, the structure editor provides a canvas and drawing tools, allowing the user to draw chemical structural formulas on the canvas. When the user closes the structure editor, the chemical structural formula on the canvas is scaled up to a thumbnail to fit the size of the current target cell, and the aspect ratio of the thumbnail is consistent with the aspect ratio of the original chemical structural formula on the canvas, ensuring clear display of the chemical structural formula and avoiding distortion.
[0059] In summary, this invention provides a method for drawing chemical structures in a multidimensional table. The method includes setting the target cell as a chemical structure field type, invoking the structure editor when the user edits the target cell, allowing the user to directly draw chemical structures in the multidimensional table using the drawing tools provided by the structure editor. This enables the user to directly draw and edit chemical structures within the target cell of the multidimensional table. After the user completes the drawing, the chemical structure is stored in a database. When the user closes the structure editor, the chemical structure is automatically scaled according to the size of the target cell, displaying it as a thumbnail in the cell. This adaptive cell size layout provides neat formatting and flexible display, making it suitable for recording and managing data such as drug molecule structures and reaction routes in biomedical laboratories.
[0060] Based on the above embodiments:
[0061] As an optional embodiment, after storing the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula, the method further includes:
[0062] When a user is detected performing a preview operation on the target cell, the preview window is invoked, and the chemical structural formula corresponding to the current target cell, read from the database, is loaded into the preview area of the preview window at its original resolution.
[0063] The existing technology for inserting chemical structural formulas in the form of images into tables in a B / S architecture has limitations. It cannot quickly preview the details of the chemical structural formula with a single click, and requires manually adjusting the image size or opening an external file.
[0064] To address the aforementioned shortcomings, this embodiment provides a preview function for the chemical structure within the target cell, supporting the preview of the chemical structure in a multidimensional table at its original resolution.
[0065] Specifically, based on event listeners bound to the target cell, the system detects whether the user has performed a preview operation on the target cell. For example, it listens for click events on the target cell and distinguishes between editing and preview operations based on the click event. When a user double-clicks the target cell, it assumes the user will perform an editing operation; when a user clicks the target cell, it assumes the user will perform a preview operation. After determining that the user has performed a preview operation, the system reads the corresponding chemical structure formula from the database, opens the preview window, and loads the chemical structure formula from the database into the preview area of the preview window at its original resolution. The system also allows the user to zoom or rotate the chemical structure formula within the preview window, thus enabling a one-click preview function for quick viewing of structural details.
[0066] Please refer to Figure 5 , Figure 5 This is a preview diagram of a target cell in a multidimensional table provided by the present invention. As can be seen, when a user performs a preview operation on the target cell, a preview window pops up in the multidimensional table, and the chemical structural formula is clearly displayed at the same resolution as the structural formula editor.
[0067] As an optional embodiment, after detecting that the user has completed drawing the chemical structure formula, the chemical structure formula is stored in the database, including:
[0068] Chemical structural formulas are stored in the database in preset storage formats, including SMILES, MOL, SVG, and INT.
[0069] In this embodiment, after the user completes the drawing of the chemical structure (e.g., the user clicks to close the structure editor), the chemical structure can be stored in the database in SMILES, MOL, SVG and INT formats to meet different needs.
[0070] Among them, SMILES (Simplified Molecular Input Line Entry System) is a string-based method for representing chemical structures. It uses ASCII strings to describe molecular structures, such as using "=" to represent double bonds, "#" to represent triple bonds, and brackets to represent ring structures. SMILES' advantages lie in its simplicity, readability, and widespread acceptance, making it suitable for storage and retrieval in chemical databases and online tools. MOL (MDLMolfile) is a 3D structure-based chemical file format that can describe the three-dimensional structure of molecules in detail, including atomic coordinates, bond lengths, bond angles, and other information. The MOL format supports compatibility with various chemical software, such as ChemDraw and GaussView. SVG (Scalable Vector Graphics) is an XML-based 2D graphics format that can store chemical structures in vector form and supports scaling, rotation, and color filling operations. SVG format has certain advantages in web page display and image output, offering strong flexibility and scalability. The core features of INT (International Chemical Identifier) are uniqueness and machine readability. It encodes information such as atomic connections, stereochemical information, isotopic information, and electron charges of a chemical structure into a string, ensuring that a unique identifier is generated regardless of how the structure is drawn. This makes it suitable for storage and retrieval in chemical databases.
[0071] Based on this, when a user performs an export operation on a multidimensional table, the chemical structural formulas corresponding to each target cell in the multidimensional table are exported in an editable format from the database, or the chemical structural formulas corresponding to each target cell in the multidimensional table are converted to a universal format and then exported. The editable format includes any one or more combinations of SMILES, MOL, SVG, and INT formats, while the universal format includes PNG or PDF formats. The choice can be made according to actual needs, and this invention does not impose any particular limitation on it.
[0072] As an optional embodiment, generating a thumbnail corresponding to the chemical structural formula based on the size of the target cell includes:
[0073] Determine the actual row height and column width of the target cell, as well as the actual height and width of the chemical structure; determine the first scaling ratio based on the actual row height of the target cell and the actual height of the chemical structure, and determine the second scaling ratio based on the actual column width of the target cell and the actual width of the chemical structure, and take the smaller value between the first scaling ratio and the second scaling ratio as the target scaling ratio; scale the entire chemical structure according to the target scaling ratio to obtain a thumbnail.
[0074] In this embodiment, in order to ensure the clarity of the chemical structure in the thumbnail and to maintain the display effect without distortion, it is necessary to determine the overall scaling ratio based on the size of the current target cell and the size of the chemical structure in the structure editor, so as to adaptively adjust the size of the thumbnail in the cell according to the size of the cell.
[0075] Specifically, first determine the actual row height and column width of the target cell, as well as the actual height and width of the chemical structure (which can be represented by pixel values). Using the actual row height of the target cell and the actual height of the chemical structure in the structure editor's canvas as a reference, determine the first scaling factor (first scaling factor = actual row height of the target cell / actual height of the chemical structure). Then, using the actual column width of the target cell and the actual width of the chemical structure as a reference, determine the second scaling factor (second scaling factor = actual column width of the target cell / actual width of the chemical structure).
[0076] Based on this, this embodiment uses the smaller of the first scaling ratio and the second scaling ratio as the target scaling ratio to ensure that the structural formula is displayed as large as possible within the cell without overflowing the cell's display area. Simultaneously, the rows and columns of the chemical structural formula are scaled according to the target scaling ratio to maintain the proportional relationship of the chemical structural formula in the thumbnail, avoiding distortion and deformation of the structural formula.
[0077] The following is a partial code demonstration of a method for drawing chemical structural formulas in a multidimensional table provided by this invention.
[0078] 1. Expand the InDraw field type in the field registration module:
[0079] registerFieldType('indraw', {
[0080] render: renderIndrawCell
[0081] editable: true,
[0082] onDoubleClick:handleIndrawEdit}).
[0083] 2. Bind a specific rendering function `renderIndrawCell`, which will draw a structured thumbnail on the Canvas.
[0084] 3. Bind a double-click event to the InDraw field to implement read-only / edit mode switching in the interactive control layer:
[0085] functionhandleIndrawEdit(cell, isReadOnly=false){
[0086] openIndrawEditor(cell.value, newValue=>{
[0087] cell.value = new Value;
[0088] table.repaintCell(cell);
[0089] }, isReadOnly);}.
[0090] 4. Storage structure definition:
[0091] {"type": "indraw",
[0092] "value": {
[0093] "smiles": "CC(=O)OC1=CC=CC=C1C(=O)O",
[0094] "mol": "...molcontent..."
[0095] "int": "...intcontent..."
[0096] "svg": <svg> ...< / svg> "}}.
[0097] The specific process of field rendering is as follows:
[0098] 1. Obtain SVG data by reading SVG from field values.
[0099] 2. Obtain the actual rendered width and row height of the cell:
[0100] const{width,height,x,y}=getCellRenderRect(cell).
[0101] 3. Use Canvg to render SVG:
[0102] import {Canvg}from 'canvg';
[0103] asyncfunctionrenderIndrawCell(ctx, cell){
[0104] const svg = cell.value?.svg;
[0105] if (!svg) return;
[0106] const{width, height, x, y}=getCellRenderRect(cell);
[0107] / / Create a virtual canvas
[0108] constoffscreen=document.createElement('canvas');
[0109] offscreen.width=width;
[0110] offscreen.height=height;
[0111] constvctx=offscreen.getContext('2d');
[0112] / / Render SVG
[0113] constcanvgInstance=awaitCanvg.from(vctx,svg);
[0114] awaitcanvgInstance.render();
[0115] / / Draw onto the main Canvas
[0116] ctx.drawImage(offscreen, x, y, width, height);}.
[0117] The field interaction process is as follows:
[0118] Double-click the target cell to open the structure editor; bind a double-click event to the chemical structure field and listen for the double-click event; pop up a Modal window containing an iframe; load InDraw in the iframe with initialization parameters; pass in SMILES or MOL of the current cell's structure for preloading; callback function: after InDraw is completed and "save" is clicked, call the parent window callback to return the structure data, and the field values are automatically updated.
[0119] functionopenIndrawEditor(data, onSave, readOnly=false){
[0120] constwin=window.open(' / indraw / editor.html', 'InDrawEditor', 'width=800, height=600');
[0121] win.onload=()=>{
[0122] win.postMessage({
[0123] type: 'init'
[0124] data:{
[0125] smiles: data.smiles,
[0126] mol: data.mol
[0127] int: data.int
[0128] },
[0129] readOnly
[0130] },'*');
[0131] };
[0132] window.addEventListener('message', functionhandler(e){
[0133] if (e.data?.type === 'save') {
[0134] onSave(e.data.data); / / Update the cell
[0135] win.close();
[0136] window.removeEventListener('message', handler);
[0137] }})}.
[0138] The process of clicking the thumbnail of the target cell to open a preview is as follows:
[0139] A pop-up preview window displays the structure at full size using raw SVG data. Optional support includes structure rotation, scaling, and zooming (via SVG manipulation or canvas rendering).
[0140] Provide a close button or click on a blank area to close the preview.
[0141] functionpreviewIndrawSVG(svgContent){
[0142] constmodal=document.createElement('div');
[0143] modal.className='preview-modal';
[0144] modal.innerHTML=`
[0145] <divclass="preview-container">
[0146] <divclass="close-btn"onclick="this.parentNode.parentNode.remove()"> ×
[0147] ${svgContent}
[0148] `;
[0149] document.body.appendChild(modal);
[0150] }
[0151] The process of InDraw field type integration is as follows:
[0152] Initialization loading process
[0153] 1. Embed InDraw using iframe
[0154] <iframeid="indraw-frame"src=" / indraw / editor.html"style="width:100%;height:100%">.
[0155] 2. Send initial data to the iframe via postMessage:
[0156] iframe.onload=()=>{
[0157] iframe.contentWindow.postMessage({
[0158] type: 'init'
[0159] data:{
[0160] smiles: '...'
[0161] mol: '...'
[0162] int: '...'
[0163] }
[0164] },'*');
[0165] };
[0166] Get data
[0167] 1. Register a message event listener in the parent window to receive data and update cell values.
[0168] window.addEventListener('message', function(e){
[0169] if (e.data?.type === 'save') {
[0170] const{smiles,mol,int,svg}=e.data.data;
[0171] updateCellData({smiles, mol, int, svg});
[0172] }
[0173] });
[0174] 2. InDraw internally calls postMessage to transmit data to the parent window.
[0175] / / After clicking the save button inside InDraw
[0176] function handleSave(){
[0177] constsmiles = getSmiles();
[0178] constmol = getMol();
[0179] constint=getInternalFormat();
[0180] constsvg = getSVG();
[0181] window.parent.postMessage({
[0182] type: 'save'
[0183] data: {smiles, mol, int, svg}
[0184] },'*');}.
[0185] Please refer to Figure 6 , Figure 6 This is a schematic diagram of a system for drawing chemical structural formulas in a multidimensional table, provided by the present invention. The system includes:
[0186] The field setting module 601 is used to set the field type of the target cell in the multidimensional table to a pre-registered and configured chemical structure field type based on the user's field type setting operation.
[0187] The drawing module 602 is used to call the structure editor built into the target cell when it detects that the user has made an editing operation on the target cell, so that the user can draw the chemical structure in the canvas provided by the structure editor using the chemical structure drawing tool.
[0188] Storage module 603 is used to store the chemical structure formula to the database after detecting that the user has completed the drawing of the chemical structure formula.
[0189] Display module 604 is used to generate a thumbnail corresponding to the chemical structure formula according to the size of the target cell after detecting that the user has closed the structure editor, and then display the thumbnail in the target cell.
[0190] For a detailed description of the system for drawing chemical structural formulas in multidimensional tables provided by this invention, please refer to the embodiments of the method for drawing chemical structural formulas in multidimensional tables described above. This invention will not be elaborated upon here.
[0191] Based on the above embodiments:
[0192] As an optional embodiment, the system further includes:
[0193] The preview module is used to store the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula. When the user performs a preview operation on the target cell, the preview window is called and the chemical structure formula corresponding to the current target cell read from the database is loaded into the preview area of the preview window at the original resolution.
[0194] The export module is used to store the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula. When the user performs an export operation on the multidimensional table, it exports the chemical structure formula corresponding to each target cell in the multidimensional table in the database in an editable format, or converts the chemical structure formula corresponding to each target cell in the database to a general format and then exports it. The editable format includes any one or more combinations of SMILES, MOL, SVG and INT formats, and the general format includes PNG or PDF formats.
[0195] As an optional embodiment, the display module 604 includes:
[0196] The size determination module is used to determine the actual row height and actual column width of the target cell, as well as the actual height and actual width of the chemical structure, after detecting that the user has closed the structure editor;
[0197] The scaling ratio determination module is used to determine a first scaling ratio based on the actual row height of the target cell and the actual height of the chemical structure formula, and to determine a second scaling ratio based on the actual column width of the target cell and the actual width of the chemical structure formula, and to use the smaller value between the first scaling ratio and the second scaling ratio as the target scaling ratio.
[0198] The scaling display module is used to scale the entire chemical structure formula according to the target scaling ratio to obtain a thumbnail, and then display the thumbnail in the target cell.
[0199] Please refer to Figure 7 , Figure 7 This is a schematic diagram of a device for drawing chemical structural formulas in a multidimensional table according to the present invention. The device includes:
[0200] Memory 701 is used to store computer programs;
[0201] Processor 702 is used to implement the steps of the method for drawing chemical structural formulas in any of the above-mentioned multidimensional tables when executing a computer program.
[0202] For a detailed description of the apparatus for drawing chemical structural formulas in multidimensional tables provided by the present invention, please refer to the embodiments of the method of the above-described system for drawing chemical structural formulas in multidimensional tables. The present invention will not be described in detail here.
[0203] To solve the above-mentioned technical problems, the present invention also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for drawing chemical structural formulas in any of the above-mentioned multidimensional tables.
[0204] For a detailed description of the storage medium provided by this invention, please refer to the embodiments of the method for drawing chemical structural formulas in the above-mentioned multidimensional table; this invention will not be elaborated upon here.
[0205] The various embodiments described in this specification are presented in a progressive manner, with each embodiment focusing on its differences from other embodiments. It should also be noted that, in this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, article, or apparatus that includes said element.
[0206] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for drawing chemical structural formulas in a multidimensional table, characterized in that, include: Based on the user's field type setting operation, the field type of the target cell in the multidimensional table is set to the pre-registered and configured chemical structure field type; When a user is detected to be editing the target cell, the structure editor built into the target cell is invoked to provide a preset chemical structure drawing tool, so that the user can use the chemical structure drawing tool to draw the chemical structure in the canvas provided by the structure editor; After detecting that the user has completed drawing the chemical structure formula, the chemical structure formula is stored in the database; After detecting that the user has closed the structure editor, a thumbnail corresponding to the chemical structure is generated according to the size of the target cell, and the thumbnail is displayed in the target cell.
2. The method for drawing chemical structural formulas in a multidimensional table as described in claim 1, characterized in that, After detecting that the user has completed drawing the chemical structure formula and storing the chemical structure formula in the database, the method further includes: When a user is detected performing a preview operation on the target cell, a preview window is invoked, and the chemical structural formula corresponding to the current target cell, read from the database, is loaded into the preview area of the preview window at its original resolution.
3. The method for drawing chemical structural formulas in a multidimensional table as described in claim 1, characterized in that, After detecting that the user has completed drawing the chemical structural formula and storing the chemical structural formula in the database, the method further includes: When a user performs an export operation on the multidimensional table, the chemical structural formulas corresponding to each target cell in the multidimensional table are exported in an editable format from the database, or the chemical structural formulas corresponding to each target cell in the multidimensional table are converted into a general format and then exported. The editable format includes any one or more combinations of SMILES, MOL, SVG and INT formats, and the general format includes PNG or PDF formats.
4. The method for drawing chemical structural formulas in a multidimensional table as described in claim 1, characterized in that, The step of storing the chemical structure formula in the database after detecting that the user has completed drawing the chemical structure formula includes: The chemical structural formula is stored in the database in a preset storage format, wherein the preset storage format includes SMILES, MOL, SVG and INT.
5. The method for drawing chemical structural formulas in a multidimensional table as described in claim 1, characterized in that, Generating a thumbnail of the chemical structural formula based on the size of the target cell includes: Determine the actual row height and actual column width of the target cell, as well as the actual height and actual width of the chemical structural formula; A first scaling factor is determined based on the actual row height of the target cell and the actual height of the chemical structure formula. A second scaling factor is determined based on the actual column width of the target cell and the actual width of the chemical structure formula. The smaller value between the first scaling factor and the second scaling factor is taken as the target scaling factor. The chemical structural formula is scaled up to the target scaling ratio to obtain the thumbnail.
6. A system for drawing chemical structural formulas in a multidimensional table, characterized in that, include: The field setting module is used to set the field type of the target cell in the multidimensional table to the pre-registered and configured chemical structure field type based on the user's field type setting operation. The drawing module is used to call the structure editor built into the target cell when it detects that the user has performed an editing operation on the target cell, so that the user can use the chemical structure drawing tool to draw the chemical structure in the canvas provided by the structure editor. A storage module is used to store the chemical structure formula to a database after detecting that the user has completed drawing the chemical structure formula; The display module is used to generate a thumbnail corresponding to the chemical structure formula based on the size of the target cell after detecting that the user has closed the structure editor, and to display the thumbnail in the target cell.
7. The system for drawing chemical structural formulas in a multidimensional table as described in claim 6, characterized in that, The system also includes: The preview module is used to, after detecting that the user has completed drawing the chemical structure formula and storing the chemical structure formula in the database, call the preview window when the user performs a preview operation on the target cell, and load the chemical structure formula corresponding to the current target cell read from the database into the preview area of the preview window at the original resolution; The export module is used to, after detecting that the user has completed drawing the chemical structure and storing the chemical structure in the database, export the chemical structures corresponding to each target cell in the multidimensional table in the database in an editable format when the user performs an export operation on the multidimensional table, or to convert the chemical structures corresponding to each target cell in the database to a general format and then export them. The editable format includes any one or more combinations of SMILES, MOL, SVG and INT formats, and the general format includes PNG or PDF formats.
8. The system for drawing chemical structural formulas in a multidimensional table as described in claim 6, characterized in that, The display module includes: The size determination module is used to determine the actual row height and actual column width of the target cell, as well as the actual height and actual width of the chemical structure, after detecting that the user has closed the structure editor; The scaling ratio determination module is used to determine a first scaling ratio based on the actual row height of the target cell and the actual height of the chemical structure, and to determine a second scaling ratio based on the actual column width of the target cell and the actual width of the chemical structure, and to take the smaller value between the first scaling ratio and the second scaling ratio as the target scaling ratio; The scaling display module is used to scale the entire chemical structural formula according to a target scaling ratio to obtain the thumbnail, and to display the thumbnail in the target cell.
9. A device for drawing chemical structural formulas in a multidimensional table, characterized in that, include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the method for drawing chemical structural formulas in a multidimensional table as described in any one of claims 1 to 5.
10. A storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the steps of the method for drawing chemical structural formulas in a multidimensional table as described in any one of claims 1 to 5.