OMCompiler/Compiler/Util/OMGraphics.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of OpenModelica. | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), | ||
| 5 | * c/o Linköpings universitet, Department of Computer and Information Science, | ||
| 6 | * SE-58183 Linköping, Sweden. | ||
| 7 | * | ||
| 8 | * All rights reserved. | ||
| 9 | * | ||
| 10 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR | ||
| 11 | * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. | ||
| 12 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
| 13 | * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL | ||
| 14 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 15 | * | ||
| 16 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) | ||
| 17 | * Public License (OSMC-PL) are obtained from OSMC, either from the above | ||
| 18 | * address, from the URLs: | ||
| 19 | * http://www.openmodelica.org or | ||
| 20 | * https://github.com/OpenModelica/ or | ||
| 21 | * http://www.ida.liu.se/projects/OpenModelica, | ||
| 22 | * and in the OpenModelica distribution. | ||
| 23 | * | ||
| 24 | * GNU AGPL version 3 is obtained from: | ||
| 25 | * https://www.gnu.org/licenses/licenses.html#GPL | ||
| 26 | * | ||
| 27 | * This program is distributed WITHOUT ANY WARRANTY; without | ||
| 28 | * even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 29 | * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
| 30 | * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
| 31 | * | ||
| 32 | * See the full OSMC Public License conditions for more details. | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | encapsulated package OMGraphics | ||
| 37 | " file: OMGraphics.mo | ||
| 38 | package: OMGraphics | ||
| 39 | description: Qt-free rendering of Modelica graphical (Icon) annotations. | ||
| 40 | |||
| 41 | Renders the Icon of an in-memory model instance (issue #15219; the handle | ||
| 42 | comes from NFApi.getModelInstanceReference) to SVG, to a PNG raster, or to | ||
| 43 | the FMI 3.0 <GraphicalRepresentation> element. First user: FMI 3.0 export." | ||
| 44 | |||
| 45 | 15 | public function iconSVGFromHandle | |
| 46 | "`modelName` is substituted for the %name placeholder of Text shapes. | ||
| 47 | Empty if there is no icon." | ||
| 48 | input Integer handle; | ||
| 49 | input String modelName; | ||
| 50 | output String svg; | ||
| 51 | external "C" svg = OMGraphics_iconSVGFromHandle(handle, modelName) annotation(Library = "omcruntime"); | ||
| 52 | end iconSVGFromHandle; | ||
| 53 | |||
| 54 | 15 | public function graphicalRepresentationXMLFromHandle | |
| 55 | "Empty if there is no icon." | ||
| 56 | input Integer handle; | ||
| 57 | input Real scaleToMm; | ||
| 58 | output String xml; | ||
| 59 | external "C" xml = OMGraphics_graphicalRepresentationXMLFromHandle(handle, scaleToMm) annotation(Library = "omcruntime"); | ||
| 60 | end graphicalRepresentationXMLFromHandle; | ||
| 61 | |||
| 62 | 15 | public function writeIconPNGFromHandle | |
| 63 | "FMI 3.0 requires a PNG icon file. PNG bytes are binary, so the file is | ||
| 64 | written here rather than returned as a String." | ||
| 65 | input Integer handle; | ||
| 66 | input String modelName; | ||
| 67 | input String path; | ||
| 68 | output Boolean ok; | ||
| 69 | external "C" ok = OMGraphics_writeIconPNGFromHandle(handle, modelName, path) annotation(Library = "omcruntime"); | ||
| 70 | end writeIconPNGFromHandle; | ||
| 71 | |||
| 72 | 4 | public function placedConnectorCount | |
| 73 | "Top-level connector components with a graphical placement." | ||
| 74 | input Integer handle; | ||
| 75 | output Integer n; | ||
| 76 | external "C" n = OMGraphics_placedConnectorCount(handle) annotation(Library = "omcruntime"); | ||
| 77 | end placedConnectorCount; | ||
| 78 | |||
| 79 | 15 | public function placedConnectorInfo | |
| 80 | "Tab-separated graphical info for placed connector `index`: | ||
| 81 | name, iconBaseName, x1, y1, x2, y2 (placement bounding box in icon coordinates)." | ||
| 82 | input Integer handle; | ||
| 83 | input Integer index; | ||
| 84 | output String info; | ||
| 85 | external "C" info = OMGraphics_placedConnectorInfo(handle, index) annotation(Library = "omcruntime"); | ||
| 86 | end placedConnectorInfo; | ||
| 87 | |||
| 88 | 19 | public function placedConnectorIconSVG | |
| 89 | "The port symbol, i.e. the icon of the connector's type. Empty if it has none." | ||
| 90 | input Integer handle; | ||
| 91 | input Integer index; | ||
| 92 | output String svg; | ||
| 93 | external "C" svg = OMGraphics_placedConnectorIconSVG(handle, index) annotation(Library = "omcruntime"); | ||
| 94 | end placedConnectorIconSVG; | ||
| 95 | |||
| 96 | ✗ | public function writePlacedConnectorIconPNG | |
| 97 | "The port symbol of placed connector `index`, rasterised to `path`." | ||
| 98 | input Integer handle; | ||
| 99 | input Integer index; | ||
| 100 | input String path; | ||
| 101 | output Boolean ok; | ||
| 102 | external "C" ok = OMGraphics_writePlacedConnectorIconPNG(handle, index, path) annotation(Library = "omcruntime"); | ||
| 103 | end writePlacedConnectorIconPNG; | ||
| 104 | |||
| 105 | annotation(__OpenModelica_Interface="omgraphics"); | ||
| 106 | end OMGraphics; | ||
| 107 |