@itwin/core-markup 5.0.0-dev.8 → 5.0.0-dev.83

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/esm/Markup.js CHANGED
@@ -22,6 +22,117 @@ import { UndoManager } from "./Undo";
22
22
  * @public
23
23
  */
24
24
  export class MarkupApp {
25
+ /** the current Markup being created */
26
+ static markup;
27
+ /** The namespace for the Markup tools */
28
+ static namespace;
29
+ /** By setting members of this object, applications can control the appearance and behavior of various parts of MarkupApp. */
30
+ static props = {
31
+ /** the UI controls displayed on Elements by the Select Tool to allow users to modify them. */
32
+ handles: {
33
+ /** The diameter of the circles for the handles. */
34
+ size: 10,
35
+ /** The attributes of the stretch handles */
36
+ stretch: { "fill-opacity": .85, "stroke": "black", "fill": "white" },
37
+ /** The attributes of the line that connects the top-center stretch handle to the rotate handle. */
38
+ rotateLine: { "stroke": "grey", "fill-opacity": .85 },
39
+ /** The attributes of the rotate handle. */
40
+ rotate: { "cursor": `url(${IModelApp.publicPath}Markup/rotate.png) 12 12, auto`, "fill-opacity": .85, "stroke": "black", "fill": "lightBlue" },
41
+ /** The attributes of box around the element. */
42
+ moveOutline: { "cursor": "move", "stroke-dasharray": "6,6", "fill": "none", "stroke-opacity": .85, "stroke": "white" },
43
+ /** The attributes of box that provides the move cursor. */
44
+ move: { "cursor": "move", "opacity": 0, "stroke-width": 10, "stroke": "white" },
45
+ /** The attributes of handles on the vertices of lines. */
46
+ vertex: { "cursor": `url(${IModelApp.publicPath}cursors/crosshair.cur), crosshair`, "fill-opacity": .85, "stroke": "black", "fill": "white" },
47
+ },
48
+ /** properties for providing feedback about selected elements. */
49
+ hilite: {
50
+ /** the color of selected elements */
51
+ color: "magenta",
52
+ /** the color of an element as the cursor passes over it */
53
+ flash: "cyan",
54
+ },
55
+ /** optionally, show a drop-shadow behind all markup elements. */
56
+ dropShadow: {
57
+ /** if false, no drop shadow */
58
+ enable: true,
59
+ /** the attributes of the drop shadow. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow */
60
+ attr: {
61
+ "stdDeviation": 2,
62
+ "dx": 1.2,
63
+ "dy": 1.4,
64
+ "flood-color": "#1B3838",
65
+ },
66
+ },
67
+ /** The "active placement" parameters. New elements are created with these parameters, so UI controls should set them. */
68
+ active: {
69
+ /** the CSS style properties of new text elements. */
70
+ text: {
71
+ "font-family": "sans-serif",
72
+ "font-size": "30px",
73
+ "stroke": "none",
74
+ "fill": "red",
75
+ },
76
+ /** the CSS style properties of new elements. */
77
+ element: {
78
+ "stroke": "red",
79
+ "stroke-opacity": 0.8,
80
+ "stroke-width": 3,
81
+ "stroke-dasharray": 0,
82
+ "stroke-linecap": "round",
83
+ "stroke-linejoin": "round",
84
+ "fill": "blue",
85
+ "fill-opacity": 0.2,
86
+ },
87
+ arrow: {
88
+ length: 7,
89
+ width: 6,
90
+ },
91
+ cloud: {
92
+ 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",
93
+ },
94
+ },
95
+ /** Values for placing and editing Text. */
96
+ text: {
97
+ /** A default string for the Markup.Text.Place command. Applications can turn this off, or supply the user's initials, for example. */
98
+ startValue: "Note: ",
99
+ /** Parameters for the size and appearance of the text editor */
100
+ edit: {
101
+ background: "blanchedalmond",
102
+ /** Starting size, will be updated if user stretches the box */
103
+ size: { width: "25%", height: "4em" },
104
+ /** font size of the text editor */
105
+ fontSize: "14pt",
106
+ /** A background box drawn around text so user can tell what's being selected */
107
+ textBox: { "fill": "lightGrey", "fill-opacity": .1, "stroke-opacity": .85, "stroke": "lightBlue" },
108
+ },
109
+ },
110
+ /** Used to draw the border outline around the view while it is being marked up so the user can tell Markup is active */
111
+ borderOutline: {
112
+ "stroke": "gold",
113
+ "stroke-width": 6,
114
+ "stroke-opacity": 0.4,
115
+ "fill": "none",
116
+ },
117
+ /** Used to draw the border corner symbols for the view while it is being marked up so the user can tell Markup is active */
118
+ borderCorners: {
119
+ "stroke": "black",
120
+ "stroke-width": 2,
121
+ "stroke-opacity": 0.2,
122
+ "fill": "gold",
123
+ "fill-opacity": 0.2,
124
+ },
125
+ /** Determines what is returned by MarkupApp.stop */
126
+ result: {
127
+ /** The format for the image data. */
128
+ imageFormat: "image/png",
129
+ /** If true, the markup graphics will be imprinted in the returned image. */
130
+ imprintSvgOnImage: true,
131
+ /** the maximum width for the returned image. If the source view width is larger than this, it will be scaled down to this size. */
132
+ maxWidth: 2048,
133
+ },
134
+ };
135
+ static _saveDefaultToolId = "";
25
136
  /** @internal */
26
137
  static screenToVbMtx() {
27
138
  const matrix = this.markup?.svgMarkup?.screenCTM().inverse();
@@ -42,6 +153,7 @@ export class MarkupApp {
42
153
  }
43
154
  /** determine whether there's a markup session currently active */
44
155
  static get isActive() { return undefined !== this.markup; }
156
+ static markupSelectToolId = "Markup.Select";
45
157
  static createMarkup(view, markupData) { return new Markup(view, markupData); }
46
158
  static lockViewportSize(view, markupData) {
47
159
  const parentDiv = view.vpDiv;
@@ -149,7 +261,7 @@ export class MarkupApp {
149
261
  /** @internal */
150
262
  static async readMarkup() {
151
263
  const result = this.props.result;
152
- let canvas = this.markup.vp.readImageToCanvas();
264
+ let canvas = this.markup.vp.readImageToCanvas({ omitCanvasDecorations: false });
153
265
  let svg, image;
154
266
  try {
155
267
  svg = this.readMarkupSvg(); // read the current svg data for the markup
@@ -176,6 +288,8 @@ export class MarkupApp {
176
288
  return { rect: { width: canvas.width, height: canvas.height }, svg, image };
177
289
  }
178
290
  /** @internal */
291
+ static markupPrefix = "markup-";
292
+ /** @internal */
179
293
  static get dropShadowId() { return `${this.markupPrefix}dropShadow`; } // this is referenced in the markup Svg to apply the drop-shadow filter to all markup elements.
180
294
  /** @internal */
181
295
  static get cornerId() { return `${this.markupPrefix}photoCorner`; }
@@ -206,116 +320,6 @@ export class MarkupApp {
206
320
  /** @internal */
207
321
  static get textEditorClass() { return `${this.markupPrefix}textEditor`; }
208
322
  }
209
- /** By setting members of this object, applications can control the appearance and behavior of various parts of MarkupApp. */
210
- MarkupApp.props = {
211
- /** the UI controls displayed on Elements by the Select Tool to allow users to modify them. */
212
- handles: {
213
- /** The diameter of the circles for the handles. */
214
- size: 10,
215
- /** The attributes of the stretch handles */
216
- stretch: { "fill-opacity": .85, "stroke": "black", "fill": "white" },
217
- /** The attributes of the line that connects the top-center stretch handle to the rotate handle. */
218
- rotateLine: { "stroke": "grey", "fill-opacity": .85 },
219
- /** The attributes of the rotate handle. */
220
- rotate: { "cursor": `url(${IModelApp.publicPath}Markup/rotate.png) 12 12, auto`, "fill-opacity": .85, "stroke": "black", "fill": "lightBlue" },
221
- /** The attributes of box around the element. */
222
- moveOutline: { "cursor": "move", "stroke-dasharray": "6,6", "fill": "none", "stroke-opacity": .85, "stroke": "white" },
223
- /** The attributes of box that provides the move cursor. */
224
- move: { "cursor": "move", "opacity": 0, "stroke-width": 10, "stroke": "white" },
225
- /** The attributes of handles on the vertices of lines. */
226
- vertex: { "cursor": `url(${IModelApp.publicPath}cursors/crosshair.cur), crosshair`, "fill-opacity": .85, "stroke": "black", "fill": "white" },
227
- },
228
- /** properties for providing feedback about selected elements. */
229
- hilite: {
230
- /** the color of selected elements */
231
- color: "magenta",
232
- /** the color of an element as the cursor passes over it */
233
- flash: "cyan",
234
- },
235
- /** optionally, show a drop-shadow behind all markup elements. */
236
- dropShadow: {
237
- /** if false, no drop shadow */
238
- enable: true,
239
- /** the attributes of the drop shadow. See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow */
240
- attr: {
241
- "stdDeviation": 2,
242
- "dx": 1.2,
243
- "dy": 1.4,
244
- "flood-color": "#1B3838",
245
- },
246
- },
247
- /** The "active placement" parameters. New elements are created with these parameters, so UI controls should set them. */
248
- active: {
249
- /** the CSS style properties of new text elements. */
250
- text: {
251
- "font-family": "sans-serif",
252
- "font-size": "30px",
253
- "stroke": "none",
254
- "fill": "red",
255
- },
256
- /** the CSS style properties of new elements. */
257
- element: {
258
- "stroke": "red",
259
- "stroke-opacity": 0.8,
260
- "stroke-width": 3,
261
- "stroke-dasharray": 0,
262
- "stroke-linecap": "round",
263
- "stroke-linejoin": "round",
264
- "fill": "blue",
265
- "fill-opacity": 0.2,
266
- },
267
- arrow: {
268
- length: 7,
269
- width: 6,
270
- },
271
- cloud: {
272
- 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",
273
- },
274
- },
275
- /** Values for placing and editing Text. */
276
- text: {
277
- /** A default string for the Markup.Text.Place command. Applications can turn this off, or supply the user's initials, for example. */
278
- startValue: "Note: ",
279
- /** Parameters for the size and appearance of the text editor */
280
- edit: {
281
- background: "blanchedalmond",
282
- /** Starting size, will be updated if user stretches the box */
283
- size: { width: "25%", height: "4em" },
284
- /** font size of the text editor */
285
- fontSize: "14pt",
286
- /** A background box drawn around text so user can tell what's being selected */
287
- textBox: { "fill": "lightGrey", "fill-opacity": .1, "stroke-opacity": .85, "stroke": "lightBlue" },
288
- },
289
- },
290
- /** Used to draw the border outline around the view while it is being marked up so the user can tell Markup is active */
291
- borderOutline: {
292
- "stroke": "gold",
293
- "stroke-width": 6,
294
- "stroke-opacity": 0.4,
295
- "fill": "none",
296
- },
297
- /** Used to draw the border corner symbols for the view while it is being marked up so the user can tell Markup is active */
298
- borderCorners: {
299
- "stroke": "black",
300
- "stroke-width": 2,
301
- "stroke-opacity": 0.2,
302
- "fill": "gold",
303
- "fill-opacity": 0.2,
304
- },
305
- /** Determines what is returned by MarkupApp.stop */
306
- result: {
307
- /** The format for the image data. */
308
- imageFormat: "image/png",
309
- /** If true, the markup graphics will be imprinted in the returned image. */
310
- imprintSvgOnImage: true,
311
- /** the maximum width for the returned image. If the source view width is larger than this, it will be scaled down to this size. */
312
- maxWidth: 2048,
313
- },
314
- };
315
- MarkupApp._saveDefaultToolId = "";
316
- MarkupApp.markupSelectToolId = "Markup.Select";
317
- /** @internal */
318
- MarkupApp.markupPrefix = "markup-";
319
323
  const removeSvgNamespace = (svg) => {
320
324
  svg.node.removeAttribute("xmlns:svgjs");
321
325
  return svg;
@@ -327,6 +331,21 @@ const newSvgElement = (name) => adopt(create(name));
327
331
  * @public
328
332
  */
329
333
  export class Markup {
334
+ vp;
335
+ /** @internal */
336
+ markupDiv;
337
+ /** Support undo/redo of markup operations */
338
+ undo = new UndoManager();
339
+ /** The set of currently selected markup elements */
340
+ selected;
341
+ /** @internal */
342
+ svgContainer;
343
+ /** @internal */
344
+ svgMarkup;
345
+ /** @internal */
346
+ svgDynamics;
347
+ /** @internal */
348
+ svgDecorations;
330
349
  /** create the drop-shadow filter in the Defs section of the supplied svg element */
331
350
  createDropShadow(svg) {
332
351
  const filter = SVG(`#${MarkupApp.dropShadowId}`); // see if we already have one?
@@ -358,8 +377,6 @@ export class Markup {
358
377
  */
359
378
  constructor(vp, markupData) {
360
379
  this.vp = vp;
361
- /** Support undo/redo of markup operations */
362
- this.undo = new UndoManager();
363
380
  this.markupDiv = vp.addNewDiv("overlay-markup", true, 20); // this div goes on top of the canvas, but behind UI layers
364
381
  const rect = this.markupDiv.getBoundingClientRect();
365
382
  // 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,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3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Q,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","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,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAS,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAuC,MAAM,EAAE,KAAK,EAAO,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AA6BrC;;;;;;GAMG;AACH,MAAM,OAAO,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,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE;YACrD,2CAA2C;YAC3C,MAAM,EA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AMG;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,GAAG,CAAC,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","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({omitCanvasDecorations: false});\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"]}
@@ -11,6 +11,8 @@ import { MarkupApp } from "./Markup";
11
11
  * @public
12
12
  */
13
13
  export class MarkupTool extends PrimitiveTool {
14
+ markup;
15
+ static toolKey = "MarkupTools:tools.Markup.";
14
16
  requireWriteableTarget() { return false; }
15
17
  isCompatibleViewport(vp, isSelectedViewChange) { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && vp === IModelApp.toolAdmin.markupView); }
16
18
  async onInstall() {
@@ -81,5 +83,4 @@ export class MarkupTool extends PrimitiveTool {
81
83
  return boxedText;
82
84
  }
83
85
  }
84
- MarkupTool.toolKey = "MarkupTools:tools.Markup.";
85
86
  //# sourceMappingURL=MarkupTool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkupTool.js","sourceRoot":"","sources":["../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C;IACnB,CAAC;;AA/Ea,kBAAO,GAAG,2BAA2B,CAAC","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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AS,CAAC,CAAC,CAAC,+BAA+B;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC","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"]}