dazscript-framework 0.1.14 → 0.1.16
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/README.md +365 -93
- package/babel.config.js +33 -33
- package/dist/babel/trace-babel-plugin.js +243 -243
- package/dist/babel/trace-log-babel-plugin.js +164 -164
- package/dist/scripts/install-generator.js +185 -185
- package/package.json +72 -70
- package/src/common/dz-dump.ts +120 -120
- package/src/common/log.ts +56 -57
- package/src/common/trace.ts +26 -26
- package/src/core/action-decorator.ts +15 -15
- package/src/core/base-script.ts +30 -30
- package/src/core/custom-action.ts +11 -11
- package/src/core/global.ts +4 -4
- package/src/dialog/basic-dialog.ts +40 -32
- package/src/dialog/builders/button-builder.ts +52 -52
- package/src/dialog/builders/checkbox-builder.ts +29 -29
- package/src/dialog/builders/color-picker-builder.ts +36 -0
- package/src/dialog/builders/combo-box-builder.ts +38 -35
- package/src/dialog/builders/combo-edit-builder.ts +35 -35
- package/src/dialog/builders/dialog-builder.ts +49 -49
- package/src/dialog/builders/groupbox-builder.ts +121 -73
- package/src/dialog/builders/label-builder.ts +33 -29
- package/src/dialog/builders/layout-builder.ts +59 -59
- package/src/dialog/builders/line-edit-builder.ts +124 -119
- package/src/dialog/builders/list-box-builder.ts +103 -0
- package/src/dialog/builders/list-view-builder.ts +396 -328
- package/src/dialog/builders/node-selection-builder.ts +55 -55
- package/src/dialog/builders/path-combo-box-builder.ts +24 -24
- package/src/dialog/builders/popup-menu-builder.ts +46 -46
- package/src/dialog/builders/radio-builder.ts +42 -42
- package/src/dialog/builders/slider-builder.ts +40 -0
- package/src/dialog/builders/splitter-builder.ts +88 -88
- package/src/dialog/builders/tab-builder.ts +120 -106
- package/src/dialog/builders/widget-builder.ts +136 -124
- package/src/dialog/builders/widgets-builder.ts +140 -125
- package/src/dialog/input-dialog.ts +30 -27
- package/src/dialog/input-validator.ts +8 -8
- package/src/dialog/selection-dialog.ts +47 -0
- package/src/dialog/shared.ts +8 -8
- package/src/helpers/action-helper.ts +214 -81
- package/src/helpers/array-helper.ts +170 -145
- package/src/helpers/camera-helper.ts +12 -12
- package/src/helpers/custom-action-helper.ts +176 -176
- package/src/helpers/directory-helper.ts +14 -0
- package/src/helpers/file-helper.ts +90 -90
- package/src/helpers/http-helper.ts +186 -0
- package/src/helpers/input-helper.ts +18 -18
- package/src/helpers/list-view-helper.ts +105 -89
- package/src/helpers/menu-helper.ts +28 -28
- package/src/helpers/message-box-helper.ts +25 -15
- package/src/helpers/node-helper.ts +461 -236
- package/src/helpers/number-helper.ts +10 -10
- package/src/helpers/numeric-property-helper.ts +91 -91
- package/src/helpers/object-helper.ts +2 -2
- package/src/helpers/pane-helper.ts +28 -20
- package/src/helpers/progress-helper.ts +51 -33
- package/src/helpers/property-helper.ts +61 -52
- package/src/helpers/record-helper.ts +16 -16
- package/src/helpers/scene-helper.ts +144 -95
- package/src/helpers/script-helper.ts +15 -15
- package/src/helpers/skeleton-helper.ts +26 -26
- package/src/helpers/splitter-helper.ts +8 -8
- package/src/helpers/string-helper.ts +39 -31
- package/src/helpers/surface-helper.ts +5 -5
- package/src/helpers/undo-helper.ts +8 -7
- package/src/helpers/viewport-helper.ts +21 -8
- package/src/lib/delayed.ts +38 -38
- package/src/lib/dictionary.ts +3 -0
- package/src/lib/frame-keys.ts +67 -67
- package/src/lib/guid.ts +2 -2
- package/src/lib/menu-item.ts +10 -9
- package/src/lib/observable.ts +147 -94
- package/src/lib/set.ts +50 -25
- package/src/lib/settings.ts +112 -104
- package/src/lib/tree-node.ts +149 -145
- package/src/samples/config.ts +2 -2
- package/src/samples/hello-world.dsa.ts +12 -12
- package/src/samples/sample-dialog.dsa.ts +51 -51
- package/src/samples/sample-dialog.ts +48 -48
- package/src/shared/set-keyboard-shortcut.ts +146 -102
- package/tsconfig.json +116 -116
- package/webpack.config.js +70 -70
|
@@ -1,96 +1,145 @@
|
|
|
1
|
-
import { scene } from '@dsf/core/global'
|
|
2
|
-
import { contains, distinct } from './array-helper'
|
|
3
|
-
import { getRoot } from './node-helper'
|
|
4
|
-
import { getParametersPane } from './pane-helper'
|
|
5
|
-
|
|
6
|
-
export const getSelectedOf = <T>(typeName: string): DzNode[] => {
|
|
7
|
-
let nodes = []
|
|
8
|
-
for (let node of scene.getSelectedNodeList()) {
|
|
9
|
-
if (!node.inherits(typeName)) continue
|
|
10
|
-
nodes.push(node)
|
|
11
|
-
}
|
|
12
|
-
return nodes
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const getSelectedNode = (): DzNode | null => {
|
|
16
|
-
if (scene.getNumSelectedNodes() === 0) return null
|
|
17
|
-
return scene.getPrimarySelection()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const getTopParent = (node: DzNode): DzNode => {
|
|
21
|
-
var parent = node.getNodeParent();
|
|
22
|
-
return parent ? getTopParent(parent) : node;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
import { scene } from '@dsf/core/global'
|
|
2
|
+
import { contains, distinct, group } from './array-helper'
|
|
3
|
+
import { getRoot, isFigure } from './node-helper'
|
|
4
|
+
import { getPaneNodeEditor, getParametersPane, getParametersPaneNodeEditor } from './pane-helper'
|
|
5
|
+
|
|
6
|
+
export const getSelectedOf = <T>(typeName: string): DzNode[] => {
|
|
7
|
+
let nodes = []
|
|
8
|
+
for (let node of scene.getSelectedNodeList()) {
|
|
9
|
+
if (!node.inherits(typeName)) continue
|
|
10
|
+
nodes.push(node)
|
|
11
|
+
}
|
|
12
|
+
return nodes
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getSelectedNode = (): DzNode | null => {
|
|
16
|
+
if (scene.getNumSelectedNodes() === 0) return null
|
|
17
|
+
return scene.getPrimarySelection()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getTopParent = (node: DzNode): DzNode => {
|
|
21
|
+
var parent = node.getNodeParent();
|
|
22
|
+
return parent ? getTopParent(parent) : node;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const getParentFigure = (node: DzNode): DzSkeleton | null => {
|
|
26
|
+
if (!node) return null;
|
|
27
|
+
if (isFigure(node)) return node as DzSkeleton;
|
|
28
|
+
return getParentFigure(node.getNodeParent());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getNodes = (): DzNode[] => {
|
|
32
|
+
return scene.getNodeList()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const getRootNodes = (): DzNode[] => {
|
|
36
|
+
return getNodes().map(n => getRoot(n)).filter(n => n !== null)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const getFigures = (): DzSkeleton[] => {
|
|
40
|
+
return distinct(getNodes().map(n => n.getSkeleton?.()), (n => n?.getLabel().valueOf())).filter(n => n !== null)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the selected figure
|
|
45
|
+
* @returns the figure skeleton, or null if there is no current selection or the selected node is not part of a figure
|
|
46
|
+
*/
|
|
47
|
+
export const getSelectedFigure = (): DzSkeleton | null => {
|
|
48
|
+
return getSelectedNode()?.getSkeleton?.()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Given the selected nodes in the scene, return the figures they are part of
|
|
53
|
+
* @returns the selected figures
|
|
54
|
+
*/
|
|
55
|
+
export const getSelectedFigures = (): DzSkeleton[] => {
|
|
56
|
+
let nodes: DzSkeleton[] = []
|
|
57
|
+
for (let node of scene.getSelectedNodeList()) {
|
|
58
|
+
let skeleton = node.getSkeleton?.()
|
|
59
|
+
if (!skeleton || contains(nodes, node)) continue
|
|
60
|
+
nodes.push(skeleton)
|
|
61
|
+
}
|
|
62
|
+
return nodes
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const getSelectedNodes = (): DzNode[] => {
|
|
66
|
+
return scene.getSelectedNodeList()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const getSelectedRoot = (): DzNode => {
|
|
70
|
+
return getRoot(getSelectedNode())
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const getSelectedRoots = (): DzNode[] => {
|
|
74
|
+
return distinct(getSelectedNodes().map(n => getRoot(n)))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const getSelectedProperties = (): DzProperty[] => {
|
|
78
|
+
return getParametersPane()?.getNodeEditor()?.getPropertySelections(true) ?? []
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const getSelectedNumericProperties = (): (DzFloatProperty | DzIntProperty | DzBoolProperty)[] => {
|
|
82
|
+
return getParametersPane()?.getNodeEditor()?.getPropertySelections(true).map(p => p as DzFloatProperty | DzIntProperty | DzBoolProperty) ?? []
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const getSelectedPropertiesOfType = <TProperty extends DzProperty>(type: string): TProperty[] => {
|
|
86
|
+
return getSelectedProperties().filter(p => p.inherits(type)) as TProperty[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const getSelectedPropertiesOfTypes = <TProperty extends DzProperty>(types: string[]): TProperty[] => {
|
|
90
|
+
return getSelectedProperties().filter(p => types.some(type => p.inherits(type))) as TProperty[]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const getSelectedPropertyGroups = (pane?: DzAbstractNodeEditorPane): string[] => {
|
|
94
|
+
var propertyGroups: string[] = [];
|
|
95
|
+
var paneNodeEditor = pane ? getPaneNodeEditor(pane) : getParametersPaneNodeEditor();
|
|
96
|
+
|
|
97
|
+
var selectedProperties = paneNodeEditor?.getPropertySelections(true)
|
|
98
|
+
if (selectedProperties.length == 0)
|
|
99
|
+
selectedProperties = paneNodeEditor?.getPropertySelections(false)
|
|
100
|
+
|
|
101
|
+
if (selectedProperties.length == 0)
|
|
102
|
+
return propertyGroups
|
|
103
|
+
|
|
104
|
+
var pathsGroup = group<DzProperty, string>(selectedProperties, p => p.getPath().valueOf().substr(1) + "/")
|
|
105
|
+
propertyGroups = Object.keys(pathsGroup)
|
|
106
|
+
|
|
107
|
+
return propertyGroups
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const clearSelection = () => {
|
|
111
|
+
for (let node of scene.getSelectedNodeList()) {
|
|
112
|
+
node.select(false)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const currentTime = (): DzTime => {
|
|
117
|
+
return scene.getTime()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @returns the current frame number (0-based)
|
|
122
|
+
*/
|
|
123
|
+
export const getCurrentFrame = (): number => {
|
|
124
|
+
return scene.getTime().valueOf() / scene.getTimeStep().valueOf()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const getEndFrame = (): number => {
|
|
128
|
+
return scene.getAnimRange().end / scene.getTimeStep().valueOf()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use getEndFrame
|
|
133
|
+
* @returns the last frame number (0-based)
|
|
134
|
+
*/
|
|
135
|
+
export const getLastFrame = (): number => {
|
|
136
|
+
return scene.getAnimRange().end / scene.getTimeStep().valueOf()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const timeToFrame = (time: DzTime): number => {
|
|
140
|
+
return time.valueOf() / scene.getTimeStep().valueOf()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const frameToTime = (frame: number): DzTime => {
|
|
144
|
+
return new DzTime(scene.getTimeStep().valueOf() * frame)
|
|
96
145
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export const getScriptPath = (): string => {
|
|
2
|
-
var fileName = getScriptFileName();
|
|
3
|
-
var fileInfo = new DzFileInfo(fileName);
|
|
4
|
-
|
|
5
|
-
let path: string;
|
|
6
|
-
|
|
7
|
-
if (typeof (fileInfo.canonicalPath) == "function") {
|
|
8
|
-
path = fileInfo.canonicalPath();
|
|
9
|
-
} else {
|
|
10
|
-
path = fileInfo.path();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
fileInfo.deleteLater();
|
|
14
|
-
|
|
15
|
-
return path;
|
|
1
|
+
export const getScriptPath = (): string => {
|
|
2
|
+
var fileName = getScriptFileName();
|
|
3
|
+
var fileInfo = new DzFileInfo(fileName);
|
|
4
|
+
|
|
5
|
+
let path: string;
|
|
6
|
+
|
|
7
|
+
if (typeof (fileInfo.canonicalPath) == "function") {
|
|
8
|
+
path = fileInfo.canonicalPath();
|
|
9
|
+
} else {
|
|
10
|
+
path = fileInfo.path();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
fileInfo.deleteLater();
|
|
14
|
+
|
|
15
|
+
return path;
|
|
16
16
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
export const getModifiers = (figure: DzSkeleton): DzModifier[] => {
|
|
3
|
-
let modifiers: DzModifier[] = []
|
|
4
|
-
let obj = figure.getObject()
|
|
5
|
-
|
|
6
|
-
for (let i = 0; i < obj.getNumModifiers(); i++) {
|
|
7
|
-
modifiers.push(obj.getModifier(i))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return modifiers
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const getMirrorNodes = (figure: DzSkeleton, nodes: DzNode[]): DzNode[] => {
|
|
14
|
-
let mirrorNodes: DzNode[] = []
|
|
15
|
-
|
|
16
|
-
nodes.forEach((node) => {
|
|
17
|
-
const name = node.getName().valueOf()
|
|
18
|
-
let prefix = name[0]
|
|
19
|
-
if (prefix !== 'r' && prefix !== 'l') return
|
|
20
|
-
prefix = prefix === 'r' ? 'l' : 'r'
|
|
21
|
-
const mirrorName = `${prefix}${name.substring(1)}`
|
|
22
|
-
const mirrorNode = figure.findNodeChild(mirrorName, true)
|
|
23
|
-
if (mirrorNode) mirrorNodes.push(mirrorNode)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
return mirrorNodes
|
|
1
|
+
|
|
2
|
+
export const getModifiers = (figure: DzSkeleton): DzModifier[] => {
|
|
3
|
+
let modifiers: DzModifier[] = []
|
|
4
|
+
let obj = figure.getObject()
|
|
5
|
+
|
|
6
|
+
for (let i = 0; i < obj.getNumModifiers(); i++) {
|
|
7
|
+
modifiers.push(obj.getModifier(i))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return modifiers
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getMirrorNodes = (figure: DzSkeleton, nodes: DzNode[]): DzNode[] => {
|
|
14
|
+
let mirrorNodes: DzNode[] = []
|
|
15
|
+
|
|
16
|
+
nodes.forEach((node) => {
|
|
17
|
+
const name = node.getName().valueOf()
|
|
18
|
+
let prefix = name[0]
|
|
19
|
+
if (prefix !== 'r' && prefix !== 'l') return
|
|
20
|
+
prefix = prefix === 'r' ? 'l' : 'r'
|
|
21
|
+
const mirrorName = `${prefix}${name.substring(1)}`
|
|
22
|
+
const mirrorNode = figure.findNodeChild(mirrorName, true)
|
|
23
|
+
if (mirrorNode) mirrorNodes.push(mirrorNode)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return mirrorNodes
|
|
27
27
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export const restoreState = (splitter: DzSplitter, state: string) => {
|
|
2
|
-
if (!state) return
|
|
3
|
-
let base64Array = new ByteArray(state)
|
|
4
|
-
splitter.restoreState(base64Array.fromBase64(base64Array))
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const getState = (splitter: DzSplitter): string => {
|
|
8
|
-
return splitter.saveState().toBase64().convertToString()
|
|
1
|
+
export const restoreState = (splitter: DzSplitter, state: string) => {
|
|
2
|
+
if (!state) return
|
|
3
|
+
let base64Array = new ByteArray(state)
|
|
4
|
+
splitter.restoreState(base64Array.fromBase64(base64Array))
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const getState = (splitter: DzSplitter): string => {
|
|
8
|
+
return splitter.saveState().toBase64().convertToString()
|
|
9
9
|
}
|
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
export const isNumeric = (value: string | number): boolean => {
|
|
2
|
-
return ((value != null) &&
|
|
3
|
-
(value !== '') &&
|
|
4
|
-
!isNaN(Number(value.toString())))
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const contains = (source: string, search: string | string[]): boolean => {
|
|
8
|
-
if (Array.isArray(search)) {
|
|
9
|
-
for (const s of search) {
|
|
10
|
-
if (source.indexOf(s) >= 0) return true
|
|
11
|
-
}
|
|
12
|
-
return false
|
|
13
|
-
}
|
|
14
|
-
return source.indexOf(search) >= 0
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const remove = (source: string, search: string): string => {
|
|
18
|
-
return source.replace(search, "")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const trimEnd = (source: string, search: string): string => {
|
|
22
|
-
return source.endsWith(search) ? source.slice(0, -search.length) : source
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const count = (source: string, search: string): number => {
|
|
26
|
-
return source.split(search).length - 1
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const isGUID = (str: string): boolean => {
|
|
30
|
-
const GUIDPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
31
|
-
return GUIDPattern.test(str);
|
|
1
|
+
export const isNumeric = (value: string | number): boolean => {
|
|
2
|
+
return ((value != null) &&
|
|
3
|
+
(value !== '') &&
|
|
4
|
+
!isNaN(Number(value.toString())))
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const contains = (source: string, search: string | string[]): boolean => {
|
|
8
|
+
if (Array.isArray(search)) {
|
|
9
|
+
for (const s of search) {
|
|
10
|
+
if (source.indexOf(s) >= 0) return true
|
|
11
|
+
}
|
|
12
|
+
return false
|
|
13
|
+
}
|
|
14
|
+
return source.indexOf(search) >= 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const remove = (source: string, search: string): string => {
|
|
18
|
+
return source.replace(search, "")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const trimEnd = (source: string, search: string): string => {
|
|
22
|
+
return source.endsWith(search) ? source.slice(0, -search.length) : source
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const count = (source: string, search: string): number => {
|
|
26
|
+
return source.split(search).length - 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const isGUID = (str: string): boolean => {
|
|
30
|
+
const GUIDPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
31
|
+
return GUIDPattern.test(str);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const getFileNameWithoutExtension = (filePath: string | null | undefined): string | null => {
|
|
35
|
+
if (!filePath) return null
|
|
36
|
+
const lastSlash = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'))
|
|
37
|
+
const fileWithExt = filePath.substring(lastSlash + 1)
|
|
38
|
+
const lastDot = fileWithExt.lastIndexOf('.')
|
|
39
|
+
return lastDot > 0 ? fileWithExt.substring(0, lastDot) : fileWithExt
|
|
32
40
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSurfacesPane } from './pane-helper'
|
|
2
|
-
|
|
3
|
-
export const getSelectedSurfacePropertiesOfType = <TProperty extends DzProperty>(className: string): TProperty[] => {
|
|
4
|
-
return getSurfacesPane().getNodeEditor().getPropertySelections(true)
|
|
5
|
-
.filter(p => p.inherits(className)) as TProperty[]
|
|
1
|
+
import { getSurfacesPane } from './pane-helper'
|
|
2
|
+
|
|
3
|
+
export const getSelectedSurfacePropertiesOfType = <TProperty extends DzProperty>(className: string): TProperty[] => {
|
|
4
|
+
return getSurfacesPane().getNodeEditor().getPropertySelections(true)
|
|
5
|
+
.filter(p => p.inherits(className)) as TProperty[]
|
|
6
6
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const acceptUndoFor = (caption: string, callback: () => void) => {
|
|
2
|
-
beginUndo()
|
|
3
|
-
callback?.()
|
|
4
|
-
acceptUndo(caption)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export { acceptUndoFor as acceptUndo }
|
|
1
|
+
const acceptUndoFor = (caption: string, callback: () => void) => {
|
|
2
|
+
beginUndo()
|
|
3
|
+
callback?.()
|
|
4
|
+
acceptUndo(caption)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { acceptUndoFor as acceptUndo }
|
|
8
|
+
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { mainWindow } from '@dsf/core/global'
|
|
2
|
-
|
|
3
|
-
export const selectUniversalRotateTool = (coordinateSpace?: number): DzUniversalRotateTool => {
|
|
4
|
-
const viewportMgr = mainWindow.getViewportMgr()
|
|
5
|
-
const tool = viewportMgr.findTool('DzUniversalRotateTool') as DzUniversalRotateTool
|
|
6
|
-
viewportMgr.setActiveTool(tool)
|
|
7
|
-
if (coordinateSpace) tool.setCoordinateSpace(coordinateSpace)
|
|
8
|
-
return tool
|
|
1
|
+
import { mainWindow } from '@dsf/core/global'
|
|
2
|
+
|
|
3
|
+
export const selectUniversalRotateTool = (coordinateSpace?: number): DzUniversalRotateTool => {
|
|
4
|
+
const viewportMgr = mainWindow.getViewportMgr()
|
|
5
|
+
const tool = viewportMgr.findTool('DzUniversalRotateTool') as DzUniversalRotateTool
|
|
6
|
+
viewportMgr.setActiveTool(tool)
|
|
7
|
+
if (coordinateSpace) tool.setCoordinateSpace(coordinateSpace)
|
|
8
|
+
return tool
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getActiveViewport = (): DzViewport => {
|
|
12
|
+
return mainWindow.getViewportMgr().getActiveViewport()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getAuxViewport = (): DzViewport | null => {
|
|
16
|
+
const viewportMgr = mainWindow.getViewportMgr()
|
|
17
|
+
for (let i = 0; i < viewportMgr.getNumViewports(); i++) {
|
|
18
|
+
const viewport = viewportMgr.getViewport(i)
|
|
19
|
+
if (viewport.name === 'AuxViewportView') return viewport
|
|
20
|
+
}
|
|
21
|
+
return null
|
|
9
22
|
}
|
package/src/lib/delayed.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
export class Delayed {
|
|
2
|
-
private minDelay: number;
|
|
3
|
-
private maxDelay: number;
|
|
4
|
-
private timeout: any;
|
|
5
|
-
private action: () => void;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Perform an action delayed
|
|
9
|
-
* @param action action to delay
|
|
10
|
-
* @param minDelay min delay in milliseconds
|
|
11
|
-
* @param maxDelay max delay in milliseconds
|
|
12
|
-
*/
|
|
13
|
-
constructor(action: () => void, minDelay = 100, maxDelay = 500) {
|
|
14
|
-
this.action = action;
|
|
15
|
-
this.minDelay = minDelay;
|
|
16
|
-
this.maxDelay = maxDelay;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public trigger() {
|
|
20
|
-
if (this.timeout === undefined) {
|
|
21
|
-
this.timeout = new DzTimer();
|
|
22
|
-
this.timeout.timeout.connect(() => {
|
|
23
|
-
this.action();
|
|
24
|
-
this.reset();
|
|
25
|
-
});
|
|
26
|
-
this.timeout.start(this.maxDelay);
|
|
27
|
-
} else {
|
|
28
|
-
this.timeout.stop();
|
|
29
|
-
this.timeout.start(this.minDelay);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private reset() {
|
|
34
|
-
if (this.timeout !== undefined) {
|
|
35
|
-
this.timeout.stop();
|
|
36
|
-
this.timeout = undefined;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
export class Delayed {
|
|
2
|
+
private minDelay: number;
|
|
3
|
+
private maxDelay: number;
|
|
4
|
+
private timeout: any;
|
|
5
|
+
private action: () => void;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Perform an action delayed
|
|
9
|
+
* @param action action to delay
|
|
10
|
+
* @param minDelay min delay in milliseconds
|
|
11
|
+
* @param maxDelay max delay in milliseconds
|
|
12
|
+
*/
|
|
13
|
+
constructor(action: () => void, minDelay = 100, maxDelay = 500) {
|
|
14
|
+
this.action = action;
|
|
15
|
+
this.minDelay = minDelay;
|
|
16
|
+
this.maxDelay = maxDelay;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public trigger() {
|
|
20
|
+
if (this.timeout === undefined) {
|
|
21
|
+
this.timeout = new DzTimer();
|
|
22
|
+
this.timeout.timeout.connect(() => {
|
|
23
|
+
this.action();
|
|
24
|
+
this.reset();
|
|
25
|
+
});
|
|
26
|
+
this.timeout.start(this.maxDelay);
|
|
27
|
+
} else {
|
|
28
|
+
this.timeout.stop();
|
|
29
|
+
this.timeout.start(this.minDelay);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private reset() {
|
|
34
|
+
if (this.timeout !== undefined) {
|
|
35
|
+
this.timeout.stop();
|
|
36
|
+
this.timeout = undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
}
|