@itwin/core-markup 5.0.0-dev.56 → 5.0.0-dev.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/Markup.js CHANGED
@@ -25,8 +25,12 @@ const Undo_1 = require("./Undo");
25
25
  * @public
26
26
  */
27
27
  class MarkupApp {
28
+ /** the current Markup being created */
29
+ static markup;
30
+ /** The namespace for the Markup tools */
31
+ static namespace;
28
32
  /** By setting members of this object, applications can control the appearance and behavior of various parts of MarkupApp. */
29
- static { this.props = {
33
+ static props = {
30
34
  /** the UI controls displayed on Elements by the Select Tool to allow users to modify them. */
31
35
  handles: {
32
36
  /** The diameter of the circles for the handles. */
@@ -130,8 +134,8 @@ class MarkupApp {
130
134
  /** the maximum width for the returned image. If the source view width is larger than this, it will be scaled down to this size. */
131
135
  maxWidth: 2048,
132
136
  },
133
- }; }
134
- static { this._saveDefaultToolId = ""; }
137
+ };
138
+ static _saveDefaultToolId = "";
135
139
  /** @internal */
136
140
  static screenToVbMtx() {
137
141
  const matrix = this.markup?.svgMarkup?.screenCTM().inverse();
@@ -152,7 +156,7 @@ class MarkupApp {
152
156
  }
153
157
  /** determine whether there's a markup session currently active */
154
158
  static get isActive() { return undefined !== this.markup; }
155
- static { this.markupSelectToolId = "Markup.Select"; }
159
+ static markupSelectToolId = "Markup.Select";
156
160
  static createMarkup(view, markupData) { return new Markup(view, markupData); }
157
161
  static lockViewportSize(view, markupData) {
158
162
  const parentDiv = view.vpDiv;
@@ -287,7 +291,7 @@ class MarkupApp {
287
291
  return { rect: { width: canvas.width, height: canvas.height }, svg, image };
288
292
  }
289
293
  /** @internal */
290
- static { this.markupPrefix = "markup-"; }
294
+ static markupPrefix = "markup-";
291
295
  /** @internal */
292
296
  static get dropShadowId() { return `${this.markupPrefix}dropShadow`; } // this is referenced in the markup Svg to apply the drop-shadow filter to all markup elements.
293
297
  /** @internal */
@@ -331,6 +335,21 @@ const newSvgElement = (name) => (0, svg_js_1.adopt)((0, svg_js_1.create)(name));
331
335
  * @public
332
336
  */
333
337
  class Markup {
338
+ vp;
339
+ /** @internal */
340
+ markupDiv;
341
+ /** Support undo/redo of markup operations */
342
+ undo = new Undo_1.UndoManager();
343
+ /** The set of currently selected markup elements */
344
+ selected;
345
+ /** @internal */
346
+ svgContainer;
347
+ /** @internal */
348
+ svgMarkup;
349
+ /** @internal */
350
+ svgDynamics;
351
+ /** @internal */
352
+ svgDecorations;
334
353
  /** create the drop-shadow filter in the Defs section of the supplied svg element */
335
354
  createDropShadow(svg) {
336
355
  const filter = (0, svg_js_1.SVG)(`#${MarkupApp.dropShadowId}`); // see if we already have one?
@@ -362,8 +381,6 @@ class Markup {
362
381
  */
363
382
  constructor(vp, markupData) {
364
383
  this.vp = vp;
365
- /** Support undo/redo of markup operations */
366
- this.undo = new Undo_1.UndoManager();
367
384
  this.markupDiv = vp.addNewDiv("overlay-markup", true, 20); // this div goes on top of the canvas, but behind UI layers
368
385
  const rect = this.markupDiv.getBoundingClientRect();
369
386
  // First, see if there is a markup passed in as an argument
@@ -1 +1 @@
1
- {"version":3,"file":"Markup.js","sourceRoot":"","sources":["../../src/Markup.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,wDAAsD;AACtD,oDAAoE;AACpE,wDAAsH;AACtH,6CAA+G;AAC/G,6CAA6C;AAC7C,6CAA0D;AAC1D,uCAAuC;AACvC,iCAAqC;AA6BrC;;;;;;GAMG;AACH,MAAa,SAAS;IAKpB,6HAA6H;aAC/G,UAAK,GAAG;QACpB,8FAA8F;QAC9F,OAAO,EAAE;YACP,mDAAmD;YACnD,IAAI,EAAE,EAAE;YACR,4CAA4C;YAC5C,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;YACpE,mGAAmG;YACnG,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,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GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,aAAa,GAAG,cAAc,MAAM,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QAC/D,IAAI,MAAM,GAAG,IAAA,YAAG,EAAC,IAAI,aAAa,EAAE,CAAW,CAAC;QAChD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,MAAM,GAAG,IAAI,CAAC,SAAU,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;YACjE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC5C,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,6JAA6J;YACjM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA1ID,wBA0IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MarkupApp\n */\n\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\nimport { Point3d, XAndY } from \"@itwin/core-geometry\";\nimport { ImageSource, ImageSourceFormat } from \"@itwin/core-common\";\nimport { FrontendLoggerCategory, imageElementFromImageSource, IModelApp, ScreenViewport } from \"@itwin/core-frontend\";\nimport { adopt, create, G, Marker, Element as MarkupElement, Matrix, Point, Svg, SVG } from \"@svgdotjs/svg.js\";\nimport * as redlineTool from \"./RedlineTool\";\nimport { MarkupSelected, SelectTool } from \"./SelectTool\";\nimport * as textTool from \"./TextEdit\";\nimport { UndoManager } from \"./Undo\";\n\n// cspell:ignore blanchedalmond, lmultiply, svgs\n\n/** The width and height of a Markup image, in pixels.\n * @public */\nexport interface WidthAndHeight {\n width: number;\n height: number;\n}\n\n/** The size and SVG string for a Markup\n * @public\n */\nexport interface MarkupSvgData {\n /** The size of the image, in pixels. This also indicates the aspect ratio of the SVG data. */\n rect: WidthAndHeight;\n /** a string holding the svg data for the markup. Will be undefined if [[MarkupApp.stop]] is called without an active Markup */\n svg?: string;\n}\n\n/** Markup data returned by [[MarkupApp.stop]]\n * @public\n */\nexport interface MarkupData extends MarkupSvgData {\n /** a base64 encoded string with the image of the view that was marked up. See [[MarkupApp.props.result]] for options. */\n image?: string;\n}\n\n/**\n * The main object for the Markup package. It is a singleton that stores the state of the Markup application.\n * It has only static members and methods. Applications may customize and control the behavior of the Markup by\n * setting members of [[MarkupApp.props]]. When [[MarkupApp.start]] is first called, it registers a set of \"Markup.xxx\"\n * tools that may be invoked from UI controls.\n * @public\n */\nexport class MarkupApp {\n /** the current Markup being created */\n public static markup?: Markup;\n /** The namespace for the Markup tools */\n public static namespace?: string;\n /** By setting members of this object, applications can control the appearance and behavior of various parts of MarkupApp. */\n public static props = {\n /** the UI controls displayed on Elements by the Select Tool to allow users to modify them. */\n handles: {\n /** The diameter of the circles for the handles. */\n size: 10,\n /** The attributes of the stretch handles */\n stretch: { \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"white\" },\n /** The attributes of the line that connects the top-center stretch handle to the rotate handle. */\n rotateLine: { \"stroke\": \"grey\", \"fill-opacity\": .85 },\n /** The attributes of the rotate handle. */\n rotate: { \"cursor\": `url(${IModelApp.publicPath}Markup/rotate.png) 12 12, auto`, \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"lightBlue\" },\n /** The attributes of box around the element. */\n moveOutline: { \"cursor\": \"move\", \"stroke-dasharray\": \"6,6\", \"fill\": \"none\", \"stroke-opacity\": .85, \"stroke\": \"white\" },\n /** The attributes of box that provides the move cursor. */\n move: { \"cursor\": \"move\", \"opacity\": 0, \"stroke-width\": 10, \"stroke\": \"white\" },\n /** The attributes of handles on the vertices of lines. */\n vertex: { \"cursor\": `url(${IModelApp.publicPath}cursors/crosshair.cur), crosshair`, \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"white\" },\n },\n /** properties for providing feedback about selected elements. */\n hilite: {\n /** the color of selected elements */\n color: \"magenta\",\n /** the color of an element as the cursor passes over it */\n flash: \"cyan\",\n },\n /** optionally, show a drop-shadow behind all markup elements. */\n dropShadow: {\n /** if false, no drop shadow */\n enable: true,\n /** the attributes of the drop shadow. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow */\n attr: {\n \"stdDeviation\": 2,\n \"dx\": 1.2,\n \"dy\": 1.4,\n \"flood-color\": \"#1B3838\",\n },\n },\n /** The \"active placement\" parameters. New elements are created with these parameters, so UI controls should set them. */\n active: {\n /** the CSS style properties of new text elements. */\n text: {\n \"font-family\": \"sans-serif\",\n \"font-size\": \"30px\",\n \"stroke\": \"none\",\n \"fill\": \"red\",\n },\n /** the CSS style properties of new elements. */\n element: {\n \"stroke\": \"red\",\n \"stroke-opacity\": 0.8,\n \"stroke-width\": 3,\n \"stroke-dasharray\": 0,\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n \"fill\": \"blue\",\n \"fill-opacity\": 0.2,\n },\n arrow: {\n length: 7,\n width: 6,\n },\n cloud: {\n path: \"M3.0,2.5 C3.9,.78 5.6,-.4 8.1,1.0 C9.1,0 11.3,-.2 12.5,.5 C14.2,-.5 17,.16 17.9,2.5 C21,3 20.2,7.3 17.6,7.5 C16.5,9.2 14.4,9.8 12.7,8.9 C11.6,10 9.5,10.3 8.1,9.4 C5.7,10.8 3.3,9.4 2.6,7.5 C-.9,7.7 .6,1.7 3.0,2.5z\",\n },\n },\n /** Values for placing and editing Text. */\n text: {\n /** A default string for the Markup.Text.Place command. Applications can turn this off, or supply the user's initials, for example. */\n startValue: \"Note: \",\n /** Parameters for the size and appearance of the text editor */\n edit: {\n background: \"blanchedalmond\",\n /** Starting size, will be updated if user stretches the box */\n size: { width: \"25%\", height: \"4em\" },\n /** font size of the text editor */\n fontSize: \"14pt\",\n /** A background box drawn around text so user can tell what's being selected */\n textBox: { \"fill\": \"lightGrey\", \"fill-opacity\": .1, \"stroke-opacity\": .85, \"stroke\": \"lightBlue\" },\n },\n },\n /** Used to draw the border outline around the view while it is being marked up so the user can tell Markup is active */\n borderOutline: {\n \"stroke\": \"gold\",\n \"stroke-width\": 6,\n \"stroke-opacity\": 0.4,\n \"fill\": \"none\",\n },\n /** Used to draw the border corner symbols for the view while it is being marked up so the user can tell Markup is active */\n borderCorners: {\n \"stroke\": \"black\",\n \"stroke-width\": 2,\n \"stroke-opacity\": 0.2,\n \"fill\": \"gold\",\n \"fill-opacity\": 0.2,\n },\n /** Determines what is returned by MarkupApp.stop */\n result: {\n /** The format for the image data. */\n imageFormat: \"image/png\",\n /** If true, the markup graphics will be imprinted in the returned image. */\n imprintSvgOnImage: true,\n /** the maximum width for the returned image. If the source view width is larger than this, it will be scaled down to this size. */\n maxWidth: 2048,\n },\n };\n\n private static _saveDefaultToolId = \"\";\n /** @internal */\n public static screenToVbMtx(): Matrix {\n const matrix = this.markup?.svgMarkup?.screenCTM().inverse();\n return (undefined !== matrix ? matrix : new Matrix());\n }\n /** @internal */\n public static getVpToScreenMtx(): Matrix {\n const rect = this.markup!.markupDiv.getBoundingClientRect();\n return (new Matrix()).translateO(rect.left, rect.top);\n }\n\n /** @internal */\n public static getVpToVbMtx(): Matrix { return this.getVpToScreenMtx().lmultiplyO(this.screenToVbMtx()); }\n /** @internal */\n public static convertVpToVb(pt: XAndY): Point3d {\n const pt0 = new Point(pt.x, pt.y);\n pt0.transformO(this.getVpToVbMtx());\n return new Point3d(pt0.x, pt0.y, 0);\n }\n\n /** determine whether there's a markup session currently active */\n public static get isActive() { return undefined !== this.markup; }\n public static markupSelectToolId = \"Markup.Select\";\n\n protected static createMarkup(view: ScreenViewport, markupData?: MarkupSvgData) { return new Markup(view, markupData); }\n\n protected static lockViewportSize(view: ScreenViewport, markupData?: MarkupSvgData) {\n const parentDiv = view.vpDiv;\n const rect = parentDiv.getBoundingClientRect();\n let width = rect.width;\n let height = rect.height;\n if (markupData) {\n const aspect = markupData.rect.height / markupData.rect.width;\n if ((width * aspect) > height)\n width = Math.floor(height / aspect);\n else\n height = Math.floor(width * aspect);\n }\n const style = parentDiv.style;\n style.width = `${width}px`;\n style.height = `${height}px`;\n }\n\n /** @internal */\n public static getActionName(action: string) { return IModelApp.localization.getLocalizedString(`${this.namespace}:actions.${action}`); }\n\n /** Start a markup session */\n public static async start(view: ScreenViewport, markupData?: MarkupSvgData): Promise<void> {\n if (this.markup)\n return; // a markup session is already active.\n\n await this.initialize();\n\n // first, lock the viewport to its current size while the markup session is running\n this.lockViewportSize(view, markupData);\n\n this.markup = this.createMarkup(view, markupData); // start a markup against the provided view.\n if (!this.markup.svgMarkup) {\n ScreenViewport.setToParentSize(this.markup.vp.vpDiv);\n this.markup.markupDiv.remove();\n return;\n }\n\n IModelApp.toolAdmin.markupView = view; // so viewing tools won't operate on the view.\n\n // set the markup Select tool as the default tool and start it, saving current default tool\n this._saveDefaultToolId = IModelApp.toolAdmin.defaultToolId;\n IModelApp.toolAdmin.defaultToolId = this.markupSelectToolId;\n return IModelApp.toolAdmin.startDefaultTool();\n }\n\n /** Read the result of a Markup session, then stop the session.\n * @note see [MarkupApp.props.result] for options.\n */\n public static async stop(): Promise<MarkupData> {\n await IModelApp.toolAdmin.startDefaultTool(); // Make sure current markup tool exits first...\n const data = await this.readMarkup();\n if (!this.markup)\n return data;\n\n // restore original size for vp.\n ScreenViewport.setToParentSize(this.markup.vp.vpDiv);\n\n IModelApp.toolAdmin.markupView = undefined; // re-enable viewing tools for the view being marked-up\n this.markup.destroy();\n this.markup = undefined;\n // now restore the default tool and start it\n IModelApp.toolAdmin.defaultToolId = this._saveDefaultToolId;\n this._saveDefaultToolId = \"\";\n await IModelApp.toolAdmin.startDefaultTool();\n return data;\n }\n\n /** Call this method to initialize the Markup system.\n * It asynchronously loads the MarkupTools namespace for the prompts and tool names for the Markup system, and\n * also registers all of the Markup tools.\n * @return a Promise that may be awaited to ensure that the MarkupTools namespace had been loaded.\n * @note This method is automatically called every time you call [[start]]. Since the Markup tools cannot\n * start unless there is a Markup active, there's really no need to call this method directly.\n * The only virtue in doing so is to pre-load the Markup namespace if you have an opportunity to do so earlier in your\n * startup code.\n * @note This method may be called multiple times, but only the first time initiates the loading/registering. Subsequent\n * calls return the same Promise.\n */\n public static async initialize(): Promise<void> {\n if (undefined === this.namespace) { // only need to do this once\n this.namespace = \"MarkupTools\";\n const namespacePromise = IModelApp.localization.registerNamespace(this.namespace);\n IModelApp.tools.register(SelectTool, this.namespace);\n IModelApp.tools.registerModule(redlineTool, this.namespace);\n IModelApp.tools.registerModule(textTool, this.namespace);\n return namespacePromise;\n }\n return IModelApp.localization.getNamespacePromise(this.namespace)!; // so caller can make sure localized messages are ready.\n }\n\n /** convert the current markup SVG into a string, but don't include decorations or dynamics\n * @internal\n */\n protected static readMarkupSvg() {\n const markup = this.markup;\n if (!markup || !markup.svgContainer)\n return undefined;\n markup.svgDecorations!.remove(); // we don't want the decorations or dynamics to be included\n markup.svgDynamics!.remove();\n void IModelApp.toolAdmin.startDefaultTool();\n return markup.svgContainer.svg(); // string-ize the SVG data\n }\n\n /** convert the current markup SVG into a string (after calling readMarkupSvg) making sure width and height are specified.\n * @internal\n */\n protected static readMarkupSvgForDrawImage() {\n const markup = this.markup;\n if (!markup || !markup.svgContainer)\n return undefined;\n // Firefox requires width and height on top-level svg or drawImage does nothing, passing width/height to drawImage doesn't work.\n const rect = markup.markupDiv.getBoundingClientRect();\n markup.svgContainer.width(rect.width);\n markup.svgContainer.height(rect.height);\n return markup.svgContainer.svg(); // string-ize the SVG data\n }\n\n /** @internal */\n protected static async readMarkup(): Promise<MarkupData> {\n const result = this.props.result;\n let canvas = this.markup!.vp.readImageToCanvas();\n let svg, image;\n try {\n svg = this.readMarkupSvg(); // read the current svg data for the markup\n const svgForImage = (svg && result.imprintSvgOnImage ? this.readMarkupSvgForDrawImage() : undefined);\n if (svgForImage) {\n const svgImage = await imageElementFromImageSource(new ImageSource(svgForImage, ImageSourceFormat.Svg));\n canvas.getContext(\"2d\")!.drawImage(svgImage, 0, 0); // draw markup svg onto view's canvas2d\n }\n\n // is the source view too wide? If so, we need to scale the image down.\n if (canvas.width > result.maxWidth) {\n // yes, we have to scale it down, create a new canvas and set the new canvas' size\n const newCanvas = document.createElement(\"canvas\");\n newCanvas.width = result.maxWidth;\n newCanvas.height = canvas.height * (result.maxWidth / canvas.width);\n newCanvas.getContext(\"2d\")!.drawImage(canvas, 0, 0, canvas.width, canvas.height, 0, 0, newCanvas.width, newCanvas.height);\n canvas = newCanvas; // return the image from adjusted canvas, not view canvas.\n }\n\n // return the markup data to be saved by the application.\n image = (!result.imageFormat ? undefined : canvas.toDataURL(result.imageFormat));\n } catch (e) {\n Logger.logError(`${FrontendLoggerCategory.Package}.markup`, \"Error creating image from svg\", BentleyError.getErrorProps(e));\n }\n return { rect: { width: canvas.width, height: canvas.height }, svg, image };\n }\n\n /** @internal */\n public static markupPrefix = \"markup-\";\n /** @internal */\n public static get dropShadowId() { return `${this.markupPrefix}dropShadow`; } // this is referenced in the markup Svg to apply the drop-shadow filter to all markup elements.\n /** @internal */\n public static get cornerId() { return `${this.markupPrefix}photoCorner`; }\n /** @internal */\n public static get containerClass() { return `${this.markupPrefix}container`; }\n /** @internal */\n public static get dynamicsClass() { return `${this.markupPrefix}dynamics`; }\n /** @internal */\n public static get decorationsClass() { return `${this.markupPrefix}decorations`; }\n /** @internal */\n public static get markupSvgClass() { return `${this.markupPrefix}svg`; }\n /** @internal */\n public static get boxedTextClass() { return `${this.markupPrefix}boxedText`; }\n /** @internal */\n public static get textClass() { return `${this.markupPrefix}text`; }\n /** @internal */\n public static get stretchHandleClass() { return `${this.markupPrefix}stretchHandle`; }\n /** @internal */\n public static get rotateLineClass() { return `${this.markupPrefix}rotateLine`; }\n /** @internal */\n public static get rotateHandleClass() { return `${this.markupPrefix}rotateHandle`; }\n /** @internal */\n public static get vertexHandleClass() { return `${this.markupPrefix}vertexHandle`; }\n /** @internal */\n public static get moveHandleClass() { return `${this.markupPrefix}moveHandle`; }\n /** @internal */\n public static get textOutlineClass() { return `${this.markupPrefix}textOutline`; }\n /** @internal */\n public static get textEditorClass() { return `${this.markupPrefix}textEditor`; }\n}\n\nconst removeSvgNamespace = (svg: Svg) => {\n svg.node.removeAttribute(\"xmlns:svgjs\");\n return svg;\n};\n\nconst newSvgElement = (name: string) => adopt(create(name));\n\n/**\n * The current markup being created/edited. Holds the SVG elements, plus the active [[MarkupTool]].\n * When starting a Markup, a new Div is added as a child of the ScreenViewport's vpDiv.\n * @public\n */\nexport class Markup {\n /** @internal */\n public readonly markupDiv: HTMLDivElement;\n /** Support undo/redo of markup operations */\n public readonly undo = new UndoManager();\n /** The set of currently selected markup elements */\n public readonly selected!: MarkupSelected;\n /** @internal */\n public readonly svgContainer?: Svg;\n /** @internal */\n public readonly svgMarkup?: G;\n /** @internal */\n public readonly svgDynamics?: G;\n /** @internal */\n public readonly svgDecorations?: G;\n\n /** create the drop-shadow filter in the Defs section of the supplied svg element */\n private createDropShadow(svg: Svg) {\n const filter = SVG(`#${MarkupApp.dropShadowId}`); // see if we already have one?\n if (filter)\n filter.remove(); // yes, remove it. This must be someone modifying the drop shadow properties\n\n // create a new filter, and add it to the Defs of the supplied svg\n svg.defs()\n .add(newSvgElement(\"filter\").id(MarkupApp.dropShadowId)\n .add(newSvgElement(\"feDropShadow\").attr(MarkupApp.props.dropShadow.attr)));\n }\n private addNested(className: string): G { return this.svgContainer!.group().addClass(className); }\n private addBorder() {\n const rect = this.svgContainer!.viewbox();\n const inset = MarkupApp.props.borderOutline[\"stroke-width\"];\n const cornerSize = inset * 6;\n const cornerPts = [0, 0, cornerSize, 0, cornerSize * .7, cornerSize * .3, cornerSize * .3, cornerSize * .3, cornerSize * .3, cornerSize * .7, 0, cornerSize];\n const decorations = this.svgDecorations!;\n const photoCorner = decorations.symbol().polygon(cornerPts).attr(MarkupApp.props.borderCorners).id(MarkupApp.cornerId);\n const cornerGroup = decorations.group();\n cornerGroup.rect(rect.width - inset, rect.height - inset).move(inset / 2, inset / 2).attr(MarkupApp.props.borderOutline);\n cornerGroup.use(photoCorner);\n cornerGroup.use(photoCorner).rotate(90).translate(rect.width - cornerSize, 0);\n cornerGroup.use(photoCorner).rotate(180).translate(rect.width - cornerSize, rect.height - cornerSize);\n cornerGroup.use(photoCorner).rotate(270).translate(0, rect.height - cornerSize);\n }\n\n /** Create a new Markup for the supplied ScreenViewport. Adds a new \"overlay-markup\" div into the \"vpDiv\"\n * of the viewport.\n * @note you must call destroy on this object at end of markup to remove the markup div.\n */\n public constructor(public vp: ScreenViewport, markupData?: MarkupSvgData) {\n this.markupDiv = vp.addNewDiv(\"overlay-markup\", true, 20); // this div goes on top of the canvas, but behind UI layers\n const rect = this.markupDiv.getBoundingClientRect();\n\n // First, see if there is a markup passed in as an argument\n if (markupData && markupData.svg) {\n this.markupDiv.innerHTML = markupData.svg; // make it a child of the markupDiv\n this.svgContainer = SVG(`.${MarkupApp.containerClass}`) as Svg | undefined; // get it in svg.js format\n this.svgMarkup = SVG(`.${MarkupApp.markupSvgClass}`) as G | undefined;\n if (!this.svgContainer || !this.svgMarkup) // if either isn't present, its not a valid markup\n return;\n removeSvgNamespace(this.svgContainer); // the SVG call above adds this - remove it\n this.svgMarkup.each(() => { }, true); // create an SVG.Element for each entry in the supplied markup.\n } else {\n // create the container that will be returned as the \"svg\" data for this markup\n this.svgContainer = SVG().addTo(this.markupDiv).addClass(MarkupApp.containerClass).viewbox(0, 0, rect.width, rect.height);\n removeSvgNamespace(this.svgContainer);\n this.svgMarkup = this.addNested(MarkupApp.markupSvgClass);\n }\n\n if (MarkupApp.props.dropShadow.enable) {\n this.createDropShadow(this.svgContainer);\n this.svgContainer.attr(\"filter\", `url(#${MarkupApp.dropShadowId})`);\n }\n\n /** add two nested groups for providing feedback during the markup session. These Svgs are removed before the data is returned. */\n this.svgDynamics = this.addNested(MarkupApp.dynamicsClass); // only for tool dynamics of SVG graphics.\n this.svgDecorations = this.addNested(MarkupApp.decorationsClass); // only for temporary decorations of SVG graphics.\n this.addBorder();\n this.selected = new MarkupSelected(this.svgDecorations);\n }\n\n /** Called when the Markup is destroyed */\n public destroy() { this.markupDiv.remove(); }\n /** Turn on picking the markup elements in the markup view */\n public enablePick() { this.markupDiv.style.pointerEvents = \"auto\"; }\n /** Turn off picking the markup elements in the markup view */\n public disablePick() { this.markupDiv.style.pointerEvents = \"none\"; }\n /** Change the default cursor for the markup view */\n public setCursor(cursor: string) { this.markupDiv.style.cursor = cursor; }\n /** Delete all the entries in the selection set, then empty it. */\n public deleteSelected() { this.selected.deleteAll(this.undo); }\n /** Bring all the entries in the selection set to the front. */\n public bringToFront() { this.selected.reposition(MarkupApp.getActionName(\"toFront\"), this.undo, (el) => el.front()); }\n /** Send all the entries in the selection set to the back. */\n public sendToBack() { this.selected.reposition(MarkupApp.getActionName(\"toBack\"), this.undo, (el) => el.back()); }\n /** Group all the entries in the selection set, then select the group. */\n public groupSelected() {\n if (undefined !== this.svgMarkup)\n this.selected.groupAll(this.undo);\n }\n\n /** Ungroup all the group entries in the selection set. */\n public ungroupSelected() {\n if (undefined !== this.svgMarkup)\n this.selected.ungroupAll(this.undo);\n }\n\n /** Check if the supplied MarkupElement is a group of MarkupText and the MarkupText's outline Rect.\n * @param el the markup element to check\n * @returns true if boxed text\n */\n public isBoxedText(el: MarkupElement): boolean {\n return el.type === \"g\" &&\n el.node.classList.length > 0 &&\n el.node.classList[0] === MarkupApp.boxedTextClass &&\n el.children().length === 2;\n }\n\n /** Get an existing or create a new reusable symbol representing an arrow head.\n * If a Marker for the supplied color and size already exists it is returned, otherwise a new Marker is created.\n * @param color the arrow head color\n * @param length the arrow head length\n * @param width the arrow head width\n * @note Flashing doesn't currently affect markers, need support for \"context-stroke\" and \"context-fill\". For now encode color in name...\n */\n public createArrowMarker(color: string, length: number, width: number): Marker {\n length = Math.ceil(length); // Don't allow \".\" in selector string...\n width = Math.ceil(width);\n const arrowMarkerId = `ArrowMarker${length}x${width}-${color}`;\n let marker = SVG(`#${arrowMarkerId}`) as Marker;\n if (null === marker) {\n marker = this.svgMarkup!.marker(length, width).id(arrowMarkerId);\n marker.polygon([0, 0, length, width * 0.5, 0, width]);\n marker.attr(\"orient\", \"auto-start-reverse\");\n marker.attr(\"overflow\", \"visible\"); // Don't clip the stroke that is being applied to allow the specified start/end to be used directly while hiding the arrow tail fully under the arrow head...\n marker.attr(\"refX\", length);\n marker.css({ stroke: color, fill: color });\n }\n return marker;\n }\n}\n"]}
1
+ {"version":3,"file":"Markup.js","sourceRoot":"","sources":["../../src/Markup.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,wDAAsD;AACtD,oDAAoE;AACpE,wDAAsH;AACtH,6CAA+G;AAC/G,6CAA6C;AAC7C,6CAA0D;AAC1D,uCAAuC;AACvC,iCAAqC;AA6BrC;;;;;;GAMG;AACH,MAAa,SAAS;IACpB,uCAAuC;IAChC,MAAM,CAAC,MAAM,CAAU;IAC9B,yCAAyC;IAClC,MAAM,CAAC,SAAS,CAAU;IACjC,6HAA6H;IACtH,MAAM,CAAC,KAAK,GAAG;QACpB,8FAA8F;QAC9F,OAAO,EAAE;YACP,mDAAmD;YACnD,IAAI,EAAE,EAAE;YACR,4CAA4C;YAC5C,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;YACpE,mGAAmG;YACnG,UAA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,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,cAAc;YACjD,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACI,iBAAiB,CAAC,KAAa,EAAE,MAAc,EAAE,KAAa;QACnE,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,wCAAwC;QACpE,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,aAAa,GAAG,cAAc,MAAM,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QAC/D,IAAI,MAAM,GAAG,IAAA,YAAG,EAAC,IAAI,aAAa,EAAE,CAAW,CAAC;QAChD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,MAAM,GAAG,IAAI,CAAC,SAAU,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;YACjE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC5C,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,6JAA6J;YACjM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA1ID,wBA0IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MarkupApp\n */\n\nimport { BentleyError, Logger } from \"@itwin/core-bentley\";\nimport { Point3d, XAndY } from \"@itwin/core-geometry\";\nimport { ImageSource, ImageSourceFormat } from \"@itwin/core-common\";\nimport { FrontendLoggerCategory, imageElementFromImageSource, IModelApp, ScreenViewport } from \"@itwin/core-frontend\";\nimport { adopt, create, G, Marker, Element as MarkupElement, Matrix, Point, Svg, SVG } from \"@svgdotjs/svg.js\";\nimport * as redlineTool from \"./RedlineTool\";\nimport { MarkupSelected, SelectTool } from \"./SelectTool\";\nimport * as textTool from \"./TextEdit\";\nimport { UndoManager } from \"./Undo\";\n\n// cspell:ignore blanchedalmond, lmultiply, svgs\n\n/** The width and height of a Markup image, in pixels.\n * @public */\nexport interface WidthAndHeight {\n width: number;\n height: number;\n}\n\n/** The size and SVG string for a Markup\n * @public\n */\nexport interface MarkupSvgData {\n /** The size of the image, in pixels. This also indicates the aspect ratio of the SVG data. */\n rect: WidthAndHeight;\n /** a string holding the svg data for the markup. Will be undefined if [[MarkupApp.stop]] is called without an active Markup */\n svg?: string;\n}\n\n/** Markup data returned by [[MarkupApp.stop]]\n * @public\n */\nexport interface MarkupData extends MarkupSvgData {\n /** a base64 encoded string with the image of the view that was marked up. See [[MarkupApp.props.result]] for options. */\n image?: string;\n}\n\n/**\n * The main object for the Markup package. It is a singleton that stores the state of the Markup application.\n * It has only static members and methods. Applications may customize and control the behavior of the Markup by\n * setting members of [[MarkupApp.props]]. When [[MarkupApp.start]] is first called, it registers a set of \"Markup.xxx\"\n * tools that may be invoked from UI controls.\n * @public\n */\nexport class MarkupApp {\n /** the current Markup being created */\n public static markup?: Markup;\n /** The namespace for the Markup tools */\n public static namespace?: string;\n /** By setting members of this object, applications can control the appearance and behavior of various parts of MarkupApp. */\n public static props = {\n /** the UI controls displayed on Elements by the Select Tool to allow users to modify them. */\n handles: {\n /** The diameter of the circles for the handles. */\n size: 10,\n /** The attributes of the stretch handles */\n stretch: { \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"white\" },\n /** The attributes of the line that connects the top-center stretch handle to the rotate handle. */\n rotateLine: { \"stroke\": \"grey\", \"fill-opacity\": .85 },\n /** The attributes of the rotate handle. */\n rotate: { \"cursor\": `url(${IModelApp.publicPath}Markup/rotate.png) 12 12, auto`, \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"lightBlue\" },\n /** The attributes of box around the element. */\n moveOutline: { \"cursor\": \"move\", \"stroke-dasharray\": \"6,6\", \"fill\": \"none\", \"stroke-opacity\": .85, \"stroke\": \"white\" },\n /** The attributes of box that provides the move cursor. */\n move: { \"cursor\": \"move\", \"opacity\": 0, \"stroke-width\": 10, \"stroke\": \"white\" },\n /** The attributes of handles on the vertices of lines. */\n vertex: { \"cursor\": `url(${IModelApp.publicPath}cursors/crosshair.cur), crosshair`, \"fill-opacity\": .85, \"stroke\": \"black\", \"fill\": \"white\" },\n },\n /** properties for providing feedback about selected elements. */\n hilite: {\n /** the color of selected elements */\n color: \"magenta\",\n /** the color of an element as the cursor passes over it */\n flash: \"cyan\",\n },\n /** optionally, show a drop-shadow behind all markup elements. */\n dropShadow: {\n /** if false, no drop shadow */\n enable: true,\n /** the attributes of the drop shadow. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow */\n attr: {\n \"stdDeviation\": 2,\n \"dx\": 1.2,\n \"dy\": 1.4,\n \"flood-color\": \"#1B3838\",\n },\n },\n /** The \"active placement\" parameters. New elements are created with these parameters, so UI controls should set them. */\n active: {\n /** the CSS style properties of new text elements. */\n text: {\n \"font-family\": \"sans-serif\",\n \"font-size\": \"30px\",\n \"stroke\": \"none\",\n \"fill\": \"red\",\n },\n /** the CSS style properties of new elements. */\n element: {\n \"stroke\": \"red\",\n \"stroke-opacity\": 0.8,\n \"stroke-width\": 3,\n \"stroke-dasharray\": 0,\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n \"fill\": \"blue\",\n \"fill-opacity\": 0.2,\n },\n arrow: {\n length: 7,\n width: 6,\n },\n cloud: {\n path: \"M3.0,2.5 C3.9,.78 5.6,-.4 8.1,1.0 C9.1,0 11.3,-.2 12.5,.5 C14.2,-.5 17,.16 17.9,2.5 C21,3 20.2,7.3 17.6,7.5 C16.5,9.2 14.4,9.8 12.7,8.9 C11.6,10 9.5,10.3 8.1,9.4 C5.7,10.8 3.3,9.4 2.6,7.5 C-.9,7.7 .6,1.7 3.0,2.5z\",\n },\n },\n /** Values for placing and editing Text. */\n text: {\n /** A default string for the Markup.Text.Place command. Applications can turn this off, or supply the user's initials, for example. */\n startValue: \"Note: \",\n /** Parameters for the size and appearance of the text editor */\n edit: {\n background: \"blanchedalmond\",\n /** Starting size, will be updated if user stretches the box */\n size: { width: \"25%\", height: \"4em\" },\n /** font size of the text editor */\n fontSize: \"14pt\",\n /** A background box drawn around text so user can tell what's being selected */\n textBox: { \"fill\": \"lightGrey\", \"fill-opacity\": .1, \"stroke-opacity\": .85, \"stroke\": \"lightBlue\" },\n },\n },\n /** Used to draw the border outline around the view while it is being marked up so the user can tell Markup is active */\n borderOutline: {\n \"stroke\": \"gold\",\n \"stroke-width\": 6,\n \"stroke-opacity\": 0.4,\n \"fill\": \"none\",\n },\n /** Used to draw the border corner symbols for the view while it is being marked up so the user can tell Markup is active */\n borderCorners: {\n \"stroke\": \"black\",\n \"stroke-width\": 2,\n \"stroke-opacity\": 0.2,\n \"fill\": \"gold\",\n \"fill-opacity\": 0.2,\n },\n /** Determines what is returned by MarkupApp.stop */\n result: {\n /** The format for the image data. */\n imageFormat: \"image/png\",\n /** If true, the markup graphics will be imprinted in the returned image. */\n imprintSvgOnImage: true,\n /** the maximum width for the returned image. If the source view width is larger than this, it will be scaled down to this size. */\n maxWidth: 2048,\n },\n };\n\n private static _saveDefaultToolId = \"\";\n /** @internal */\n public static screenToVbMtx(): Matrix {\n const matrix = this.markup?.svgMarkup?.screenCTM().inverse();\n return (undefined !== matrix ? matrix : new Matrix());\n }\n /** @internal */\n public static getVpToScreenMtx(): Matrix {\n const rect = this.markup!.markupDiv.getBoundingClientRect();\n return (new Matrix()).translateO(rect.left, rect.top);\n }\n\n /** @internal */\n public static getVpToVbMtx(): Matrix { return this.getVpToScreenMtx().lmultiplyO(this.screenToVbMtx()); }\n /** @internal */\n public static convertVpToVb(pt: XAndY): Point3d {\n const pt0 = new Point(pt.x, pt.y);\n pt0.transformO(this.getVpToVbMtx());\n return new Point3d(pt0.x, pt0.y, 0);\n }\n\n /** determine whether there's a markup session currently active */\n public static get isActive() { return undefined !== this.markup; }\n public static markupSelectToolId = \"Markup.Select\";\n\n protected static createMarkup(view: ScreenViewport, markupData?: MarkupSvgData) { return new Markup(view, markupData); }\n\n protected static lockViewportSize(view: ScreenViewport, markupData?: MarkupSvgData) {\n const parentDiv = view.vpDiv;\n const rect = parentDiv.getBoundingClientRect();\n let width = rect.width;\n let height = rect.height;\n if (markupData) {\n const aspect = markupData.rect.height / markupData.rect.width;\n if ((width * aspect) > height)\n width = Math.floor(height / aspect);\n else\n height = Math.floor(width * aspect);\n }\n const style = parentDiv.style;\n style.width = `${width}px`;\n style.height = `${height}px`;\n }\n\n /** @internal */\n public static getActionName(action: string) { return IModelApp.localization.getLocalizedString(`${this.namespace}:actions.${action}`); }\n\n /** Start a markup session */\n public static async start(view: ScreenViewport, markupData?: MarkupSvgData): Promise<void> {\n if (this.markup)\n return; // a markup session is already active.\n\n await this.initialize();\n\n // first, lock the viewport to its current size while the markup session is running\n this.lockViewportSize(view, markupData);\n\n this.markup = this.createMarkup(view, markupData); // start a markup against the provided view.\n if (!this.markup.svgMarkup) {\n ScreenViewport.setToParentSize(this.markup.vp.vpDiv);\n this.markup.markupDiv.remove();\n return;\n }\n\n IModelApp.toolAdmin.markupView = view; // so viewing tools won't operate on the view.\n\n // set the markup Select tool as the default tool and start it, saving current default tool\n this._saveDefaultToolId = IModelApp.toolAdmin.defaultToolId;\n IModelApp.toolAdmin.defaultToolId = this.markupSelectToolId;\n return IModelApp.toolAdmin.startDefaultTool();\n }\n\n /** Read the result of a Markup session, then stop the session.\n * @note see [MarkupApp.props.result] for options.\n */\n public static async stop(): Promise<MarkupData> {\n await IModelApp.toolAdmin.startDefaultTool(); // Make sure current markup tool exits first...\n const data = await this.readMarkup();\n if (!this.markup)\n return data;\n\n // restore original size for vp.\n ScreenViewport.setToParentSize(this.markup.vp.vpDiv);\n\n IModelApp.toolAdmin.markupView = undefined; // re-enable viewing tools for the view being marked-up\n this.markup.destroy();\n this.markup = undefined;\n // now restore the default tool and start it\n IModelApp.toolAdmin.defaultToolId = this._saveDefaultToolId;\n this._saveDefaultToolId = \"\";\n await IModelApp.toolAdmin.startDefaultTool();\n return data;\n }\n\n /** Call this method to initialize the Markup system.\n * It asynchronously loads the MarkupTools namespace for the prompts and tool names for the Markup system, and\n * also registers all of the Markup tools.\n * @return a Promise that may be awaited to ensure that the MarkupTools namespace had been loaded.\n * @note This method is automatically called every time you call [[start]]. Since the Markup tools cannot\n * start unless there is a Markup active, there's really no need to call this method directly.\n * The only virtue in doing so is to pre-load the Markup namespace if you have an opportunity to do so earlier in your\n * startup code.\n * @note This method may be called multiple times, but only the first time initiates the loading/registering. Subsequent\n * calls return the same Promise.\n */\n public static async initialize(): Promise<void> {\n if (undefined === this.namespace) { // only need to do this once\n this.namespace = \"MarkupTools\";\n const namespacePromise = IModelApp.localization.registerNamespace(this.namespace);\n IModelApp.tools.register(SelectTool, this.namespace);\n IModelApp.tools.registerModule(redlineTool, this.namespace);\n IModelApp.tools.registerModule(textTool, this.namespace);\n return namespacePromise;\n }\n return IModelApp.localization.getNamespacePromise(this.namespace)!; // so caller can make sure localized messages are ready.\n }\n\n /** convert the current markup SVG into a string, but don't include decorations or dynamics\n * @internal\n */\n protected static readMarkupSvg() {\n const markup = this.markup;\n if (!markup || !markup.svgContainer)\n return undefined;\n markup.svgDecorations!.remove(); // we don't want the decorations or dynamics to be included\n markup.svgDynamics!.remove();\n void IModelApp.toolAdmin.startDefaultTool();\n return markup.svgContainer.svg(); // string-ize the SVG data\n }\n\n /** convert the current markup SVG into a string (after calling readMarkupSvg) making sure width and height are specified.\n * @internal\n */\n protected static readMarkupSvgForDrawImage() {\n const markup = this.markup;\n if (!markup || !markup.svgContainer)\n return undefined;\n // Firefox requires width and height on top-level svg or drawImage does nothing, passing width/height to drawImage doesn't work.\n const rect = markup.markupDiv.getBoundingClientRect();\n markup.svgContainer.width(rect.width);\n markup.svgContainer.height(rect.height);\n return markup.svgContainer.svg(); // string-ize the SVG data\n }\n\n /** @internal */\n protected static async readMarkup(): Promise<MarkupData> {\n const result = this.props.result;\n let canvas = this.markup!.vp.readImageToCanvas();\n let svg, image;\n try {\n svg = this.readMarkupSvg(); // read the current svg data for the markup\n const svgForImage = (svg && result.imprintSvgOnImage ? this.readMarkupSvgForDrawImage() : undefined);\n if (svgForImage) {\n const svgImage = await imageElementFromImageSource(new ImageSource(svgForImage, ImageSourceFormat.Svg));\n canvas.getContext(\"2d\")!.drawImage(svgImage, 0, 0); // draw markup svg onto view's canvas2d\n }\n\n // is the source view too wide? If so, we need to scale the image down.\n if (canvas.width > result.maxWidth) {\n // yes, we have to scale it down, create a new canvas and set the new canvas' size\n const newCanvas = document.createElement(\"canvas\");\n newCanvas.width = result.maxWidth;\n newCanvas.height = canvas.height * (result.maxWidth / canvas.width);\n newCanvas.getContext(\"2d\")!.drawImage(canvas, 0, 0, canvas.width, canvas.height, 0, 0, newCanvas.width, newCanvas.height);\n canvas = newCanvas; // return the image from adjusted canvas, not view canvas.\n }\n\n // return the markup data to be saved by the application.\n image = (!result.imageFormat ? undefined : canvas.toDataURL(result.imageFormat));\n } catch (e) {\n Logger.logError(`${FrontendLoggerCategory.Package}.markup`, \"Error creating image from svg\", BentleyError.getErrorProps(e));\n }\n return { rect: { width: canvas.width, height: canvas.height }, svg, image };\n }\n\n /** @internal */\n public static markupPrefix = \"markup-\";\n /** @internal */\n public static get dropShadowId() { return `${this.markupPrefix}dropShadow`; } // this is referenced in the markup Svg to apply the drop-shadow filter to all markup elements.\n /** @internal */\n public static get cornerId() { return `${this.markupPrefix}photoCorner`; }\n /** @internal */\n public static get containerClass() { return `${this.markupPrefix}container`; }\n /** @internal */\n public static get dynamicsClass() { return `${this.markupPrefix}dynamics`; }\n /** @internal */\n public static get decorationsClass() { return `${this.markupPrefix}decorations`; }\n /** @internal */\n public static get markupSvgClass() { return `${this.markupPrefix}svg`; }\n /** @internal */\n public static get boxedTextClass() { return `${this.markupPrefix}boxedText`; }\n /** @internal */\n public static get textClass() { return `${this.markupPrefix}text`; }\n /** @internal */\n public static get stretchHandleClass() { return `${this.markupPrefix}stretchHandle`; }\n /** @internal */\n public static get rotateLineClass() { return `${this.markupPrefix}rotateLine`; }\n /** @internal */\n public static get rotateHandleClass() { return `${this.markupPrefix}rotateHandle`; }\n /** @internal */\n public static get vertexHandleClass() { return `${this.markupPrefix}vertexHandle`; }\n /** @internal */\n public static get moveHandleClass() { return `${this.markupPrefix}moveHandle`; }\n /** @internal */\n public static get textOutlineClass() { return `${this.markupPrefix}textOutline`; }\n /** @internal */\n public static get textEditorClass() { return `${this.markupPrefix}textEditor`; }\n}\n\nconst removeSvgNamespace = (svg: Svg) => {\n svg.node.removeAttribute(\"xmlns:svgjs\");\n return svg;\n};\n\nconst newSvgElement = (name: string) => adopt(create(name));\n\n/**\n * The current markup being created/edited. Holds the SVG elements, plus the active [[MarkupTool]].\n * When starting a Markup, a new Div is added as a child of the ScreenViewport's vpDiv.\n * @public\n */\nexport class Markup {\n /** @internal */\n public readonly markupDiv: HTMLDivElement;\n /** Support undo/redo of markup operations */\n public readonly undo = new UndoManager();\n /** The set of currently selected markup elements */\n public readonly selected!: MarkupSelected;\n /** @internal */\n public readonly svgContainer?: Svg;\n /** @internal */\n public readonly svgMarkup?: G;\n /** @internal */\n public readonly svgDynamics?: G;\n /** @internal */\n public readonly svgDecorations?: G;\n\n /** create the drop-shadow filter in the Defs section of the supplied svg element */\n private createDropShadow(svg: Svg) {\n const filter = SVG(`#${MarkupApp.dropShadowId}`); // see if we already have one?\n if (filter)\n filter.remove(); // yes, remove it. This must be someone modifying the drop shadow properties\n\n // create a new filter, and add it to the Defs of the supplied svg\n svg.defs()\n .add(newSvgElement(\"filter\").id(MarkupApp.dropShadowId)\n .add(newSvgElement(\"feDropShadow\").attr(MarkupApp.props.dropShadow.attr)));\n }\n private addNested(className: string): G { return this.svgContainer!.group().addClass(className); }\n private addBorder() {\n const rect = this.svgContainer!.viewbox();\n const inset = MarkupApp.props.borderOutline[\"stroke-width\"];\n const cornerSize = inset * 6;\n const cornerPts = [0, 0, cornerSize, 0, cornerSize * .7, cornerSize * .3, cornerSize * .3, cornerSize * .3, cornerSize * .3, cornerSize * .7, 0, cornerSize];\n const decorations = this.svgDecorations!;\n const photoCorner = decorations.symbol().polygon(cornerPts).attr(MarkupApp.props.borderCorners).id(MarkupApp.cornerId);\n const cornerGroup = decorations.group();\n cornerGroup.rect(rect.width - inset, rect.height - inset).move(inset / 2, inset / 2).attr(MarkupApp.props.borderOutline);\n cornerGroup.use(photoCorner);\n cornerGroup.use(photoCorner).rotate(90).translate(rect.width - cornerSize, 0);\n cornerGroup.use(photoCorner).rotate(180).translate(rect.width - cornerSize, rect.height - cornerSize);\n cornerGroup.use(photoCorner).rotate(270).translate(0, rect.height - cornerSize);\n }\n\n /** Create a new Markup for the supplied ScreenViewport. Adds a new \"overlay-markup\" div into the \"vpDiv\"\n * of the viewport.\n * @note you must call destroy on this object at end of markup to remove the markup div.\n */\n public constructor(public vp: ScreenViewport, markupData?: MarkupSvgData) {\n this.markupDiv = vp.addNewDiv(\"overlay-markup\", true, 20); // this div goes on top of the canvas, but behind UI layers\n const rect = this.markupDiv.getBoundingClientRect();\n\n // First, see if there is a markup passed in as an argument\n if (markupData && markupData.svg) {\n this.markupDiv.innerHTML = markupData.svg; // make it a child of the markupDiv\n this.svgContainer = SVG(`.${MarkupApp.containerClass}`) as Svg | undefined; // get it in svg.js format\n this.svgMarkup = SVG(`.${MarkupApp.markupSvgClass}`) as G | undefined;\n if (!this.svgContainer || !this.svgMarkup) // if either isn't present, its not a valid markup\n return;\n removeSvgNamespace(this.svgContainer); // the SVG call above adds this - remove it\n this.svgMarkup.each(() => { }, true); // create an SVG.Element for each entry in the supplied markup.\n } else {\n // create the container that will be returned as the \"svg\" data for this markup\n this.svgContainer = SVG().addTo(this.markupDiv).addClass(MarkupApp.containerClass).viewbox(0, 0, rect.width, rect.height);\n removeSvgNamespace(this.svgContainer);\n this.svgMarkup = this.addNested(MarkupApp.markupSvgClass);\n }\n\n if (MarkupApp.props.dropShadow.enable) {\n this.createDropShadow(this.svgContainer);\n this.svgContainer.attr(\"filter\", `url(#${MarkupApp.dropShadowId})`);\n }\n\n /** add two nested groups for providing feedback during the markup session. These Svgs are removed before the data is returned. */\n this.svgDynamics = this.addNested(MarkupApp.dynamicsClass); // only for tool dynamics of SVG graphics.\n this.svgDecorations = this.addNested(MarkupApp.decorationsClass); // only for temporary decorations of SVG graphics.\n this.addBorder();\n this.selected = new MarkupSelected(this.svgDecorations);\n }\n\n /** Called when the Markup is destroyed */\n public destroy() { this.markupDiv.remove(); }\n /** Turn on picking the markup elements in the markup view */\n public enablePick() { this.markupDiv.style.pointerEvents = \"auto\"; }\n /** Turn off picking the markup elements in the markup view */\n public disablePick() { this.markupDiv.style.pointerEvents = \"none\"; }\n /** Change the default cursor for the markup view */\n public setCursor(cursor: string) { this.markupDiv.style.cursor = cursor; }\n /** Delete all the entries in the selection set, then empty it. */\n public deleteSelected() { this.selected.deleteAll(this.undo); }\n /** Bring all the entries in the selection set to the front. */\n public bringToFront() { this.selected.reposition(MarkupApp.getActionName(\"toFront\"), this.undo, (el) => el.front()); }\n /** Send all the entries in the selection set to the back. */\n public sendToBack() { this.selected.reposition(MarkupApp.getActionName(\"toBack\"), this.undo, (el) => el.back()); }\n /** Group all the entries in the selection set, then select the group. */\n public groupSelected() {\n if (undefined !== this.svgMarkup)\n this.selected.groupAll(this.undo);\n }\n\n /** Ungroup all the group entries in the selection set. */\n public ungroupSelected() {\n if (undefined !== this.svgMarkup)\n this.selected.ungroupAll(this.undo);\n }\n\n /** Check if the supplied MarkupElement is a group of MarkupText and the MarkupText's outline Rect.\n * @param el the markup element to check\n * @returns true if boxed text\n */\n public isBoxedText(el: MarkupElement): boolean {\n return el.type === \"g\" &&\n el.node.classList.length > 0 &&\n el.node.classList[0] === MarkupApp.boxedTextClass &&\n el.children().length === 2;\n }\n\n /** Get an existing or create a new reusable symbol representing an arrow head.\n * If a Marker for the supplied color and size already exists it is returned, otherwise a new Marker is created.\n * @param color the arrow head color\n * @param length the arrow head length\n * @param width the arrow head width\n * @note Flashing doesn't currently affect markers, need support for \"context-stroke\" and \"context-fill\". For now encode color in name...\n */\n public createArrowMarker(color: string, length: number, width: number): Marker {\n length = Math.ceil(length); // Don't allow \".\" in selector string...\n width = Math.ceil(width);\n const arrowMarkerId = `ArrowMarker${length}x${width}-${color}`;\n let marker = SVG(`#${arrowMarkerId}`) as Marker;\n if (null === marker) {\n marker = this.svgMarkup!.marker(length, width).id(arrowMarkerId);\n marker.polygon([0, 0, length, width * 0.5, 0, width]);\n marker.attr(\"orient\", \"auto-start-reverse\");\n marker.attr(\"overflow\", \"visible\"); // Don't clip the stroke that is being applied to allow the specified start/end to be used directly while hiding the arrow tail fully under the arrow head...\n marker.attr(\"refX\", length);\n marker.css({ stroke: color, fill: color });\n }\n return marker;\n }\n}\n"]}
@@ -14,7 +14,8 @@ const Markup_1 = require("./Markup");
14
14
  * @public
15
15
  */
16
16
  class MarkupTool extends core_frontend_1.PrimitiveTool {
17
- static { this.toolKey = "MarkupTools:tools.Markup."; }
17
+ markup;
18
+ static toolKey = "MarkupTools:tools.Markup.";
18
19
  requireWriteableTarget() { return false; }
19
20
  isCompatibleViewport(vp, isSelectedViewChange) { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && vp === core_frontend_1.IModelApp.toolAdmin.markupView); }
20
21
  async onInstall() {
@@ -1 +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mFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MarkupTools\n */\n\nimport { XAndY } from \"@itwin/core-geometry\";\nimport { BeButton, BeTouchEvent, CoordinateLockOverrides, EventHandled, IModelApp, PrimitiveTool, Viewport } from \"@itwin/core-frontend\";\nimport { G, LinkedHTMLElement, Element as MarkupElement, Text as MarkupText } from \"@svgdotjs/svg.js\";\nimport { Markup, MarkupApp } from \"./Markup\";\n\n/** Base class for all tools that operate on Markup elements.\n * @public\n */\nexport abstract class MarkupTool extends PrimitiveTool {\n public markup!: Markup;\n public static toolKey = \"MarkupTools:tools.Markup.\";\n public override requireWriteableTarget(): boolean { return false; }\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && vp === IModelApp.toolAdmin.markupView); }\n public override async onInstall(): Promise<boolean> {\n if (undefined === MarkupApp.markup)\n return false;\n\n this.markup = MarkupApp.markup;\n return super.onInstall();\n }\n\n public override async onPostInstall() {\n await super.onPostInstall();\n this.setupAndPromptForNextAction();\n }\n public override async onUnsuspend() { this.showPrompt(); }\n public async onRestartTool() { return this.exitTool(); }\n\n protected showPrompt(): void { }\n protected setupAndPromptForNextAction(): void {\n IModelApp.toolAdmin.toolState.coordLockOvr = CoordinateLockOverrides.All; // Don't adjust point to ACS or grid...\n this.showPrompt();\n }\n protected outputMarkupPrompt(msg: string) { IModelApp.notifications.outputPromptByKey(MarkupTool.toolKey + msg); }\n\n public override async onTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): Promise<EventHandled> {\n if (startEv.isSingleTouch)\n await IModelApp.toolAdmin.convertTouchMoveStartToButtonDownAndMotion(startEv, ev);\n return EventHandled.Yes; // View tools are not allowed during redlining; use touch events to create markup and don't pass event to IdleTool...\n }\n\n public override async onTouchMove(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchMoveToMotion(ev); }\n public override async onTouchComplete(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchEndToButtonUp(ev); }\n public override async onTouchCancel(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchEndToButtonUp(ev, BeButton.Reset); }\n\n public override async undoPreviousStep(): Promise<boolean> {\n if (await this.onUndoPreviousStep()) // first see if this tool has an \"oops\" operation.\n return true; // yes, we're done\n this.markup.undo.doUndo(); // otherwise undo the last change by previous tools\n return true;\n }\n\n public override async redoPreviousStep(): Promise<boolean> {\n if (await this.onRedoPreviousStep())\n return true;\n this.markup.undo.doRedo();\n return true;\n }\n\n /** Find the topmost MarkupElement at the specified point in the markup view.\n * @param pt the point in view coordinates\n * @returns The topmost element, or undefined if no elements under pt.\n */\n public pickElement(pt: XAndY): MarkupElement | undefined {\n const markup = this.markup;\n const rect = markup.markupDiv.getBoundingClientRect();\n const node = document.elementFromPoint(pt.x + rect.left, pt.y + rect.top) as LinkedHTMLElement | null;\n if (!node || !node.instance)\n return undefined;\n const el = node.instance;\n return el.getChildOrGroupOf(markup.svgMarkup!);\n }\n protected setCurrentStyle(element: MarkupElement, canBeFilled: boolean): void {\n element.css(MarkupApp.props.active.element);\n if (!canBeFilled)\n element.css({ fill: \"none\" });\n }\n\n protected setCurrentTextStyle(element: MarkupElement): void { element.css(MarkupApp.props.active.text); }\n\n /** @internal */\n public createBoxedText(g: G, text: MarkupText) {\n const boxedText = g.group().addClass(MarkupApp.boxedTextClass);\n const outline = text.getOutline(3);\n this.setCurrentStyle(outline, true);\n outline.css({ \"stroke-width\": 1 });\n outline.addTo(boxedText);\n text.addTo(boxedText); // make sure the text is on top\n return boxedText;\n }\n\n}\n"]}
1
+ {"version":3,"file":"MarkupTool.js","sourceRoot":"","sources":["../../src/MarkupTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GA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,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAA6B,CAAC;QACtG,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzB,OAAO,SAAS,CAAC;QACnB,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzB,OAAO,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAU,CAAC,CAAC;IACjD,CAAC;IACS,eAAe,CAAC,OAAsB,EAAE,WAAoB;QACpE,OAAO,CAAC,GAAG,CAAC,kBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW;YACd,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,CAAC;IAES,mBAAmB,CAAC,OAAsB,IAAU,OAAO,CAAC,GAAG,CAAC,kBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEzG,gBAAgB;IACT,eAAe,CAAC,CAAI,EAAE,IAAgB;QAC3C,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,kBAAS,CAAC,cAAc,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,+BAA+B;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC;;AAjFH,gCAmFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MarkupTools\n */\n\nimport { XAndY } from \"@itwin/core-geometry\";\nimport { BeButton, BeTouchEvent, CoordinateLockOverrides, EventHandled, IModelApp, PrimitiveTool, Viewport } from \"@itwin/core-frontend\";\nimport { G, LinkedHTMLElement, Element as MarkupElement, Text as MarkupText } from \"@svgdotjs/svg.js\";\nimport { Markup, MarkupApp } from \"./Markup\";\n\n/** Base class for all tools that operate on Markup elements.\n * @public\n */\nexport abstract class MarkupTool extends PrimitiveTool {\n public markup!: Markup;\n public static toolKey = \"MarkupTools:tools.Markup.\";\n public override requireWriteableTarget(): boolean { return false; }\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && vp === IModelApp.toolAdmin.markupView); }\n public override async onInstall(): Promise<boolean> {\n if (undefined === MarkupApp.markup)\n return false;\n\n this.markup = MarkupApp.markup;\n return super.onInstall();\n }\n\n public override async onPostInstall() {\n await super.onPostInstall();\n this.setupAndPromptForNextAction();\n }\n public override async onUnsuspend() { this.showPrompt(); }\n public async onRestartTool() { return this.exitTool(); }\n\n protected showPrompt(): void { }\n protected setupAndPromptForNextAction(): void {\n IModelApp.toolAdmin.toolState.coordLockOvr = CoordinateLockOverrides.All; // Don't adjust point to ACS or grid...\n this.showPrompt();\n }\n protected outputMarkupPrompt(msg: string) { IModelApp.notifications.outputPromptByKey(MarkupTool.toolKey + msg); }\n\n public override async onTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): Promise<EventHandled> {\n if (startEv.isSingleTouch)\n await IModelApp.toolAdmin.convertTouchMoveStartToButtonDownAndMotion(startEv, ev);\n return EventHandled.Yes; // View tools are not allowed during redlining; use touch events to create markup and don't pass event to IdleTool...\n }\n\n public override async onTouchMove(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchMoveToMotion(ev); }\n public override async onTouchComplete(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchEndToButtonUp(ev); }\n public override async onTouchCancel(ev: BeTouchEvent): Promise<void> { return IModelApp.toolAdmin.convertTouchEndToButtonUp(ev, BeButton.Reset); }\n\n public override async undoPreviousStep(): Promise<boolean> {\n if (await this.onUndoPreviousStep()) // first see if this tool has an \"oops\" operation.\n return true; // yes, we're done\n this.markup.undo.doUndo(); // otherwise undo the last change by previous tools\n return true;\n }\n\n public override async redoPreviousStep(): Promise<boolean> {\n if (await this.onRedoPreviousStep())\n return true;\n this.markup.undo.doRedo();\n return true;\n }\n\n /** Find the topmost MarkupElement at the specified point in the markup view.\n * @param pt the point in view coordinates\n * @returns The topmost element, or undefined if no elements under pt.\n */\n public pickElement(pt: XAndY): MarkupElement | undefined {\n const markup = this.markup;\n const rect = markup.markupDiv.getBoundingClientRect();\n const node = document.elementFromPoint(pt.x + rect.left, pt.y + rect.top) as LinkedHTMLElement | null;\n if (!node || !node.instance)\n return undefined;\n const el = node.instance;\n return el.getChildOrGroupOf(markup.svgMarkup!);\n }\n protected setCurrentStyle(element: MarkupElement, canBeFilled: boolean): void {\n element.css(MarkupApp.props.active.element);\n if (!canBeFilled)\n element.css({ fill: \"none\" });\n }\n\n protected setCurrentTextStyle(element: MarkupElement): void { element.css(MarkupApp.props.active.text); }\n\n /** @internal */\n public createBoxedText(g: G, text: MarkupText) {\n const boxedText = g.group().addClass(MarkupApp.boxedTextClass);\n const outline = text.getOutline(3);\n this.setCurrentStyle(outline, true);\n outline.css({ \"stroke-width\": 1 });\n outline.addTo(boxedText);\n text.addTo(boxedText); // make sure the text is on top\n return boxedText;\n }\n\n}\n"]}
@@ -17,12 +17,9 @@ const MarkupTool_1 = require("./MarkupTool");
17
17
  * @public
18
18
  */
19
19
  class RedlineTool extends MarkupTool_1.MarkupTool {
20
- constructor() {
21
- super(...arguments);
22
- this._minPoints = 1;
23
- this._nRequiredPoints = 2;
24
- this._points = [];
25
- }
20
+ _minPoints = 1;
21
+ _nRequiredPoints = 2;
22
+ _points = [];
26
23
  onAdded(el) {
27
24
  const markup = this.markup;
28
25
  const undo = markup.undo;
@@ -91,8 +88,8 @@ exports.RedlineTool = RedlineTool;
91
88
  * @public
92
89
  */
93
90
  class LineTool extends RedlineTool {
94
- static { this.toolId = "Markup.Line"; }
95
- static { this.iconSpec = "icon-line"; }
91
+ static toolId = "Markup.Line";
92
+ static iconSpec = "icon-line";
96
93
  showPrompt() { this.provideToolAssistance(core_frontend_1.CoreTools.tools + (0 === this._points.length ? "ElementSet.Prompts.StartPoint" : "ElementSet.Prompts.EndPoint")); }
97
94
  createMarkup(svgMarkup, ev, isDynamics) {
98
95
  if (this._points.length < (isDynamics ? this._nRequiredPoints - 1 : this._nRequiredPoints))
@@ -110,8 +107,9 @@ exports.LineTool = LineTool;
110
107
  * @public
111
108
  */
112
109
  class RectangleTool extends RedlineTool {
113
- static { this.toolId = "Markup.Rectangle"; }
114
- static { this.iconSpec = "icon-rectangle"; }
110
+ _cornerRadius;
111
+ static toolId = "Markup.Rectangle";
112
+ static iconSpec = "icon-rectangle";
115
113
  constructor(_cornerRadius) {
116
114
  super();
117
115
  this._cornerRadius = _cornerRadius;
@@ -141,8 +139,9 @@ exports.RectangleTool = RectangleTool;
141
139
  * @public
142
140
  */
143
141
  class PolygonTool extends RedlineTool {
144
- static { this.toolId = "Markup.Polygon"; }
145
- static { this.iconSpec = "icon-polygon"; }
142
+ _numSides;
143
+ static toolId = "Markup.Polygon";
144
+ static iconSpec = "icon-polygon";
146
145
  constructor(_numSides) {
147
146
  super();
148
147
  this._numSides = _numSides;
@@ -193,8 +192,9 @@ exports.PolygonTool = PolygonTool;
193
192
  * @public
194
193
  */
195
194
  class CloudTool extends RedlineTool {
196
- static { this.toolId = "Markup.Cloud"; }
197
- static { this.iconSpec = "icon-cloud"; }
195
+ static toolId = "Markup.Cloud";
196
+ static iconSpec = "icon-cloud";
197
+ _cloud;
198
198
  showPrompt() { this.provideToolAssistance(core_frontend_1.CoreTools.tools + (0 === this._points.length ? "ElementSet.Prompts.StartCorner" : "ElementSet.Prompts.OppositeCorner")); }
199
199
  createMarkup(svgMarkup, ev, isDynamics) {
200
200
  if (this._points.length < (isDynamics ? this._nRequiredPoints - 1 : this._nRequiredPoints))
@@ -230,8 +230,8 @@ exports.CloudTool = CloudTool;
230
230
  * @public
231
231
  */
232
232
  class CircleTool extends RedlineTool {
233
- static { this.toolId = "Markup.Circle"; }
234
- static { this.iconSpec = "icon-circle"; }
233
+ static toolId = "Markup.Circle";
234
+ static iconSpec = "icon-circle";
235
235
  showPrompt() { this.provideToolAssistance(MarkupTool_1.MarkupTool.toolKey + (0 === this._points.length ? "Circle.Prompts.FirstPoint" : "Circle.Prompts.NextPoint")); }
236
236
  createMarkup(svgMarkup, ev, isDynamics) {
237
237
  if (this._points.length < (isDynamics ? this._nRequiredPoints - 1 : this._nRequiredPoints))
@@ -252,8 +252,8 @@ exports.CircleTool = CircleTool;
252
252
  * @public
253
253
  */
254
254
  class EllipseTool extends RedlineTool {
255
- static { this.toolId = "Markup.Ellipse"; }
256
- static { this.iconSpec = "icon-ellipse"; }
255
+ static toolId = "Markup.Ellipse";
256
+ static iconSpec = "icon-ellipse";
257
257
  showPrompt() { this.provideToolAssistance(core_frontend_1.CoreTools.tools + (0 === this._points.length ? "ElementSet.Prompts.StartCorner" : "ElementSet.Prompts.OppositeCorner")); }
258
258
  createMarkup(svgMarkup, ev, isDynamics) {
259
259
  if (this._points.length < (isDynamics ? this._nRequiredPoints - 1 : this._nRequiredPoints))
@@ -277,8 +277,9 @@ exports.EllipseTool = EllipseTool;
277
277
  * @public
278
278
  */
279
279
  class ArrowTool extends RedlineTool {
280
- static { this.toolId = "Markup.Arrow"; }
281
- static { this.iconSpec = "icon-callout"; }
280
+ _arrowPos;
281
+ static toolId = "Markup.Arrow";
282
+ static iconSpec = "icon-callout";
282
283
  /** ctor for ArrowTool
283
284
  * @param _arrowPos "start", "end", or "both". If undefined = "end".
284
285
  */
@@ -317,12 +318,9 @@ exports.ArrowTool = ArrowTool;
317
318
  * @public
318
319
  */
319
320
  class DistanceTool extends ArrowTool {
320
- constructor() {
321
- super(...arguments);
322
- this._startPointWorld = new core_geometry_1.Point3d();
323
- }
324
- static { this.toolId = "Markup.Distance"; }
325
- static { this.iconSpec = "icon-distance"; }
321
+ static toolId = "Markup.Distance";
322
+ static iconSpec = "icon-distance";
323
+ _startPointWorld = new core_geometry_1.Point3d();
326
324
  showPrompt() { this.provideToolAssistance(core_frontend_1.CoreTools.tools + (0 === this._points.length ? "ElementSet.Prompts.StartPoint" : "ElementSet.Prompts.EndPoint")); }
327
325
  setupAndPromptForNextAction() {
328
326
  core_frontend_1.IModelApp.accuSnap.enableSnap(true);
@@ -381,12 +379,9 @@ exports.DistanceTool = DistanceTool;
381
379
  * @public
382
380
  */
383
381
  class SketchTool extends RedlineTool {
384
- constructor() {
385
- super(...arguments);
386
- this._minDistSquared = 100;
387
- }
388
- static { this.toolId = "Markup.Sketch"; }
389
- static { this.iconSpec = "icon-draw"; }
382
+ static toolId = "Markup.Sketch";
383
+ static iconSpec = "icon-draw";
384
+ _minDistSquared = 100;
390
385
  showPrompt() { this.provideToolAssistance(core_frontend_1.CoreTools.tools + (0 === this._points.length ? "ElementSet.Prompts.StartPoint" : "ElementSet.Prompts.EndPoint")); }
391
386
  createMarkup(svgMarkup, ev, isDynamics) {
392
387
  if (this._points.length < (isDynamics ? this._nRequiredPoints - 1 : this._nRequiredPoints))
@@ -419,8 +414,11 @@ exports.SketchTool = SketchTool;
419
414
  * @public
420
415
  */
421
416
  class SymbolTool extends RedlineTool {
422
- static { this.toolId = "Markup.Symbol"; }
423
- static { this.iconSpec = "icon-symbol"; }
417
+ _symbolData;
418
+ _applyCurrentStyle;
419
+ static toolId = "Markup.Symbol";
420
+ static iconSpec = "icon-symbol";
421
+ _symbol;
424
422
  constructor(_symbolData, _applyCurrentStyle) {
425
423
  super();
426
424
  this._symbolData = _symbolData;