@inweb/viewer-visualize 25.7.2 → 25.7.4

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.
Files changed (54) hide show
  1. package/dist/viewer-visualize.js +7358 -7450
  2. package/dist/viewer-visualize.js.map +1 -1
  3. package/dist/viewer-visualize.min.js +1 -1
  4. package/dist/viewer-visualize.module.js +3755 -3755
  5. package/dist/viewer-visualize.module.js.map +1 -1
  6. package/lib/Viewer/Markup/MarkupFactory.d.ts +1 -1
  7. package/lib/Viewer/Markup/{Impl/Visualize → Visualize}/VisualizeMarkup.d.ts +1 -3
  8. package/lib/Viewer/Viewer.d.ts +1 -2
  9. package/lib/index.d.ts +1 -11
  10. package/package.json +5 -12
  11. package/src/Viewer/Markup/MarkupFactory.ts +2 -3
  12. package/src/Viewer/Markup/{Impl/Visualize → Visualize}/VisualizeMarkup.ts +4 -6
  13. package/src/Viewer/Viewer.ts +1 -2
  14. package/src/index.ts +1 -11
  15. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +0 -52
  16. package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +0 -50
  17. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +0 -15
  18. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +0 -50
  19. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +0 -50
  20. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +0 -43
  21. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +0 -47
  22. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +0 -50
  23. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +0 -40
  24. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +0 -46
  25. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaCloud.d.ts +0 -35
  26. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +0 -40
  27. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +0 -36
  28. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +0 -35
  29. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +0 -38
  30. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +0 -37
  31. package/lib/Viewer/Markup/IMarkup.d.ts +0 -130
  32. package/lib/Viewer/Markup/IWorldTransform.d.ts +0 -39
  33. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +0 -82
  34. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +0 -38
  35. package/src/Viewer/Markup/Api/IMarkupArrow.ts +0 -69
  36. package/src/Viewer/Markup/Api/IMarkupCloud.ts +0 -78
  37. package/src/Viewer/Markup/Api/IMarkupColorable.ts +0 -39
  38. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +0 -78
  39. package/src/Viewer/Markup/Api/IMarkupImage.ts +0 -78
  40. package/src/Viewer/Markup/Api/IMarkupLine.ts +0 -70
  41. package/src/Viewer/Markup/Api/IMarkupObject.ts +0 -78
  42. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +0 -78
  43. package/src/Viewer/Markup/Api/IMarkupText.ts +0 -66
  44. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +0 -147
  45. package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +0 -213
  46. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +0 -150
  47. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +0 -149
  48. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +0 -136
  49. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +0 -149
  50. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +0 -141
  51. package/src/Viewer/Markup/IMarkup.ts +0 -173
  52. package/src/Viewer/Markup/IWorldTransform.ts +0 -46
  53. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +0 -1264
  54. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +0 -82
@@ -1,149 +0,0 @@
1
- import Konva from "konva";
2
- import { IMarkupRectangle } from "../../IMarkupRectangle";
3
- import { IMarkupColorable } from "../../IMarkupColorable";
4
-
5
- export class KonvaRectangle implements IMarkupRectangle, IMarkupColorable {
6
- private _ref: Konva.Rect;
7
-
8
- constructor(
9
- params: {
10
- position: { x: number; y: number };
11
- width?: number;
12
- height?: number;
13
- lineWidth?: number;
14
- color?: string;
15
- id?: string;
16
- },
17
- ref = null
18
- ) {
19
- if (ref) {
20
- this._ref = ref;
21
- return;
22
- }
23
-
24
- if (!params.position) return;
25
-
26
- this._ref = new Konva.Rect({
27
- stroke: params.color ?? "#ff0000",
28
- strokeWidth: params.lineWidth ?? 4,
29
- globalCompositeOperation: "source-over",
30
- lineCap: "round",
31
- lineJoin: "round",
32
- x: params.position.x,
33
- y: params.position.y,
34
- width: params.width ?? 200,
35
- height: params.height ?? 200,
36
- draggable: true,
37
- strokeScaleEnabled: false,
38
- });
39
-
40
- this._ref.on("transform", (e) => {
41
- const attrs = e.target.attrs;
42
-
43
- if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
44
-
45
- const scaleByX = Math.abs(attrs.scaleX - 1) > 10e-6;
46
- const scaleByY = Math.abs(attrs.scaleY - 1) > 10e-6;
47
-
48
- let newWidth = this._ref.width();
49
- if (scaleByX) newWidth *= attrs.scaleX;
50
- let newHeight = this._ref.height();
51
- if (scaleByY) newHeight *= attrs.scaleY;
52
-
53
- const minWidth = 50;
54
- const minHeight = 50;
55
-
56
- if (newWidth < minWidth) newWidth = minWidth;
57
- if (newHeight < minHeight) newHeight = minHeight;
58
-
59
- if (scaleByX) {
60
- this._ref.width(newWidth);
61
- }
62
-
63
- if (scaleByY) {
64
- this._ref.height(newHeight);
65
- }
66
-
67
- this._ref.scale({ x: 1, y: 1 });
68
- });
69
-
70
- this._ref.id(this._ref._id.toString());
71
- }
72
-
73
- getPosition(): { x: number; y: number } {
74
- return this._ref.position();
75
- }
76
-
77
- getWidth(): number {
78
- return this._ref.width();
79
- }
80
-
81
- getHeigth(): number {
82
- return this._ref.height();
83
- }
84
-
85
- setWidth(w: number) {
86
- this._ref.width(w);
87
- }
88
-
89
- setHeight(h: number) {
90
- this._ref.height(h);
91
- }
92
-
93
- setPosition(x: number, y: number) {
94
- this._ref.setPosition({ x, y });
95
- }
96
-
97
- ref() {
98
- return this._ref;
99
- }
100
-
101
- id(): string {
102
- return this._ref.id();
103
- }
104
-
105
- enableMouseEditing(value: boolean): void {
106
- this._ref.draggable(value);
107
- }
108
-
109
- type(): string {
110
- return "rectangle";
111
- }
112
-
113
- getColor(): string {
114
- return this._ref.stroke() as string;
115
- }
116
-
117
- setColor(hex: string): void {
118
- this._ref.stroke(hex);
119
- }
120
-
121
- getRotation(): number {
122
- return this._ref.rotation();
123
- }
124
-
125
- setRotation(degrees: number): void {
126
- this._ref.rotation(degrees);
127
- }
128
-
129
- getZIndex(): number {
130
- return this._ref.zIndex();
131
- }
132
-
133
- setZIndex(zIndex: number): void {
134
- this._ref.zIndex(zIndex);
135
- }
136
-
137
- delete(): void {
138
- this._ref.destroy();
139
- this._ref = null;
140
- }
141
-
142
- setLineWidth(size: number): void {
143
- this._ref.strokeWidth(size);
144
- }
145
-
146
- getLineWidth(): number {
147
- return this._ref.strokeWidth();
148
- }
149
- }
@@ -1,141 +0,0 @@
1
- import Konva from "konva";
2
- import { IMarkupText } from "../../IMarkupText";
3
- import { IMarkupColorable } from "../../IMarkupColorable";
4
-
5
- export class KonvaText implements IMarkupText, IMarkupColorable {
6
- private _ref: Konva.Text;
7
- private readonly TEXT_FONT_FAMILY = "Calibri";
8
-
9
- constructor(
10
- params: {
11
- position: { x: number; y: number };
12
- text: string;
13
- rotation?: number;
14
- fontSize?: number;
15
- color?: string;
16
- id?: string;
17
- },
18
- ref = null
19
- ) {
20
- if (ref) {
21
- this._ref = ref;
22
- return;
23
- }
24
-
25
- if (!params || !params.text) return;
26
-
27
- this._ref = new Konva.Text({
28
- x: params.position.x,
29
- y: params.position.y,
30
- text: params.text,
31
- fontSize: params.fontSize ?? 34,
32
- fontFamily: this.TEXT_FONT_FAMILY,
33
- fill: params.color ?? "#ff0000",
34
- align: "left",
35
- draggable: true,
36
- rotation: params.rotation ?? 0,
37
- });
38
-
39
- this._ref.width(this._ref.getTextWidth());
40
-
41
- this._ref.on("transform", (e) => {
42
- const attrs = e.target.attrs;
43
-
44
- if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
45
-
46
- const scaleByX = Math.abs(attrs.scaleX - 1) > 10e-6;
47
- const scaleByY = Math.abs(attrs.scaleY - 1) > 10e-6;
48
-
49
- let newWidth = this._ref.width();
50
- if (scaleByX) newWidth *= attrs.scaleX;
51
- let newHeight = this._ref.height();
52
- if (scaleByY) newHeight *= attrs.scaleY;
53
-
54
- const minWidth = 50;
55
-
56
- if (newWidth < minWidth) newWidth = minWidth;
57
- if (newHeight < Math.round(this.getFontSize())) newHeight = Math.round(this.getFontSize());
58
-
59
- if (scaleByX) {
60
- this._ref.width(newWidth);
61
- }
62
-
63
- if (scaleByY) {
64
- this._ref.height(newHeight);
65
- }
66
-
67
- this._ref.scale({ x: 1, y: 1 });
68
- });
69
-
70
- this._ref.id(this._ref._id.toString());
71
- }
72
-
73
- ref() {
74
- return this._ref;
75
- }
76
-
77
- id(): string {
78
- return this._ref.id();
79
- }
80
-
81
- enableMouseEditing(value: boolean) {
82
- this._ref.draggable(value);
83
- }
84
-
85
- type(): string {
86
- return "text";
87
- }
88
-
89
- getColor(): string {
90
- return this._ref.fill() as string;
91
- }
92
-
93
- setColor(hex: string) {
94
- this._ref.fill(hex);
95
- }
96
-
97
- getRotation(): number {
98
- return this._ref.rotation();
99
- }
100
-
101
- setRotation(degrees: number): void {
102
- this._ref.rotation(degrees);
103
- }
104
-
105
- getZIndex(): number {
106
- return this._ref.zIndex();
107
- }
108
-
109
- setZIndex(zIndex: number): void {
110
- this._ref.zIndex(zIndex);
111
- }
112
-
113
- delete() {
114
- this._ref.destroy();
115
- this._ref = null;
116
- }
117
-
118
- getText(): string {
119
- return this._ref.text();
120
- }
121
-
122
- setText(text: string): void {
123
- this._ref.text(text);
124
- }
125
-
126
- getPosition(): { x: number; y: number } {
127
- return this._ref.getPosition();
128
- }
129
-
130
- setPosition(x: number, y: number) {
131
- this._ref.setPosition({ x, y });
132
- }
133
-
134
- getFontSize() {
135
- return this._ref.fontSize();
136
- }
137
-
138
- setFontSize(size: number) {
139
- this._ref.fontSize(size);
140
- }
141
- }
@@ -1,173 +0,0 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3
- // All rights reserved.
4
- //
5
- // This software and its documentation and related materials are owned by
6
- // the Alliance. The software may only be incorporated into application
7
- // programs owned by members of the Alliance, subject to a signed
8
- // Membership Agreement and Supplemental Software License Agreement with the
9
- // Alliance. The structure and organization of this software are the valuable
10
- // trade secrets of the Alliance and its suppliers. The software is also
11
- // protected by copyright law and international treaty provisions. Application
12
- // programs incorporating this software must include the following statement
13
- // with their copyright notices:
14
- //
15
- // This application incorporates Open Design Alliance software pursuant to a
16
- // license agreement with Open Design Alliance.
17
- // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18
- // All rights reserved.
19
- //
20
- // By use of this software, its documentation or related materials, you
21
- // acknowledge and accept the above terms.
22
- ///////////////////////////////////////////////////////////////////////////////
23
-
24
- import { IEventEmitter } from "@inweb/eventemitter2";
25
- import { IViewpoint } from "@inweb/viewer-core";
26
- import { IWorldTransform } from "./IWorldTransform";
27
- import { IMarkupObject } from "./Api/IMarkupObject";
28
-
29
- /**
30
- * Defines type of markup object. For `VisualizeJS` markup only the `Line` and `Text` markup
31
- * objects are supported.
32
- */
33
- export enum MarkupMode {
34
- SelectMarkup = "SelectMarkup",
35
- Line = "Line",
36
- Text = "Text",
37
- Rectangle = "Rectangle",
38
- Ellipse = "Ellipse",
39
- Arrow = "Arrow",
40
- Image = "Image",
41
- Cloud = "Cloud",
42
- }
43
-
44
- /**
45
- * 2D markup core interface.
46
- */
47
- export interface IMarkup {
48
- /**
49
- * Line width of the markup objects. Default is 4.
50
- */
51
- lineWidth: number;
52
-
53
- /**
54
- * Type of the markup line. Available types: `solid`, `dot`, `dash`. Default is `solid`.
55
- */
56
- lineType: string;
57
-
58
- /**
59
- * Font size of the markup text. Default is 34 px.
60
- */
61
- fontSize: number;
62
-
63
- /**
64
- * Start method to init Markup support for the Viewer instance.
65
- *
66
- * @param canvas -
67
- * {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement}
68
- * used to operate on.
69
- * @param canvasEvents - List of `canvas` events that the markup should redirect to the `viewer`.
70
- * @param viewer - `Viewer` instance viewer that receives `canvas` events.
71
- * @param worldTransformer - Transformer of screen space into world space and vice versa. If
72
- * a transformer is defined, viewpoint objects will be stored in world coordinates,
73
- * otherwise in screen coordinates.
74
- */
75
- initialize(
76
- canvas: HTMLCanvasElement,
77
- canvasEvents: string[],
78
- viewer?: IEventEmitter,
79
- worldTransformer?: IWorldTransform
80
- ): void;
81
-
82
- /**
83
- * Releases all resources allocated by this `Markup` instance. Call this method before
84
- * release the `Markup` instance.
85
- */
86
- dispose(): void;
87
-
88
- /**
89
- * Create markup overlay.
90
- */
91
- syncOverlay(): void;
92
-
93
- /**
94
- * Clear markup overlay.
95
- */
96
- clearOverlay(): void;
97
-
98
- /**
99
- * Set markup color.
100
- *
101
- * @param r - `Red` part of color.
102
- * @param g - `Green` part of color.
103
- * @param b - `Blue` part of color.
104
- */
105
- setMarkupColor(r: number, g: number, b: number): void;
106
-
107
- /**
108
- * Get markup color.
109
- *
110
- * @returns Color with `RGB` values.
111
- */
112
- getMarkupColor(): { r: number; g: number; b: number };
113
-
114
- /**
115
- * Colorize all markup entities with the specified color.
116
- *
117
- * @param r - `Red` part of color.
118
- * @param g - `Green` part of color.
119
- * @param b - `Blue` part of color.
120
- */
121
- colorizeAllMarkup(r: number, g: number, b: number): void;
122
-
123
- /**
124
- * Colorize all selected markup entities with the specified color.
125
- *
126
- * @param r - `Red` part of color.
127
- * @param g - `Green` part of color.
128
- * @param b - `Blue` part of color.
129
- */
130
- colorizeSelectedMarkups(r: number, g: number, b: number): void;
131
-
132
- /**
133
- * Draw a viewpoint. To get a list of available model viewpoints, use the
134
- *
135
- * @param viewpoint - Viewpoint data.
136
- */
137
- setViewpoint(viewpoint: IViewpoint): void;
138
-
139
- /**
140
- * Create a viewpoint.
141
- */
142
- getViewpoint(): IViewpoint;
143
-
144
- /**
145
- * Create a Markup object.
146
- *
147
- * @param type - string identificator of Markup object type.
148
- * @param params - Markup object parameters.
149
- */
150
- createObject(type: string, params: any): IMarkupObject;
151
-
152
- /**
153
- * Get Markup objects.
154
- */
155
- getObjects(): IMarkupObject[];
156
-
157
- /**
158
- * Get selected Markup objects.
159
- */
160
- getSelectedObjects(): IMarkupObject[];
161
-
162
- /**
163
- * Select Markup objects.
164
- *
165
- * @param objects
166
- */
167
- selectObjects(objects: IMarkupObject[]): void;
168
-
169
- /**
170
- * Clear Markup objects selection.
171
- */
172
- clearSelected(): void;
173
- }
@@ -1,46 +0,0 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3
- // All rights reserved.
4
- //
5
- // This software and its documentation and related materials are owned by
6
- // the Alliance. The software may only be incorporated into application
7
- // programs owned by members of the Alliance, subject to a signed
8
- // Membership Agreement and Supplemental Software License Agreement with the
9
- // Alliance. The structure and organization of this software are the valuable
10
- // trade secrets of the Alliance and its suppliers. The software is also
11
- // protected by copyright law and international treaty provisions. Application
12
- // programs incorporating this software must include the following statement
13
- // with their copyright notices:
14
- //
15
- // This application incorporates Open Design Alliance software pursuant to a
16
- // license agreement with Open Design Alliance.
17
- // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18
- // All rights reserved.
19
- //
20
- // By use of this software, its documentation or related materials, you
21
- // acknowledge and accept the above terms.
22
- ///////////////////////////////////////////////////////////////////////////////
23
-
24
- /**
25
- * Viewer coordiate system transformer.
26
- */
27
- export interface IWorldTransform {
28
- /**
29
- * Transforms `position` from screen space into world space.
30
- *
31
- * @param position - screen position in pixels.
32
- */
33
- screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number };
34
-
35
- /**
36
- * Transforms `position` from world space into screen space.
37
- *
38
- * @param position - position in world space coordinates.
39
- */
40
- worldToScreen(position: { x: number; y: number; z: number }): { x: number; y: number };
41
-
42
- /**
43
- * Returns the scaling factors for each axis in world space.
44
- */
45
- getScale(): { x: number; y: number; z: number };
46
- }