@ccpc/platform 0.1.10 → 0.1.12
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/index.js +36 -32
- package/package.json +5 -5
- package/types/app/app.d.ts +1 -0
- package/types/app/app.d.ts.map +1 -1
- package/types/cmd/cmd_action_controller.d.ts.map +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DefaultController as V, CCanvas as b } from "@ccpc/canvas";
|
|
2
2
|
import { ClassManager as O, DebugUtil as E, TmpElementPainter as M, GPoint2d as R, GCurve2d as S, GPolycurve as B, GPolygon as F, GText2d as K, ElementId as X, GNODE_TYPE as D, GRep as U } from "@ccpc/core";
|
|
3
|
-
import { Ln2 as
|
|
3
|
+
import { Ln2 as m, Vec2 as P, CONST as w, alg as j, Arc2 as z, Plane as W, Vec3 as q } from "@ccpc/math";
|
|
4
4
|
import { SnapSetting as y, EN_SNAP_TYPE as a, EN_SNAP_HELP_OBJ as v, SnapEngine as Y, SnapCandidates as J, PtSnap as x, SnapContext as $ } from "@ccpc/snap";
|
|
5
5
|
class k {
|
|
6
6
|
constructor() {
|
|
@@ -78,13 +78,13 @@ class N extends V {
|
|
|
78
78
|
* 获取画布
|
|
79
79
|
*/
|
|
80
80
|
getCanvas() {
|
|
81
|
-
return
|
|
81
|
+
return d.getCanvas();
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* 获取文档
|
|
85
85
|
*/
|
|
86
86
|
getDoc() {
|
|
87
|
-
return
|
|
87
|
+
return d.doc;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* 执行动作
|
|
@@ -161,6 +161,7 @@ class N extends V {
|
|
|
161
161
|
* 清除所有绘制的临时元素
|
|
162
162
|
*/
|
|
163
163
|
clearTmp() {
|
|
164
|
+
d.highLight.clear();
|
|
164
165
|
for (const e of this._tmpElementPainters)
|
|
165
166
|
e && e.clearTmp();
|
|
166
167
|
}
|
|
@@ -174,7 +175,7 @@ class N extends V {
|
|
|
174
175
|
* 结束cmd
|
|
175
176
|
*/
|
|
176
177
|
_resolve(e) {
|
|
177
|
-
this._status.finish
|
|
178
|
+
this.clearTmp(), !this._status.finish && (this._status.finish = !0, this._status.resolve(e), this.onDestroy());
|
|
178
179
|
}
|
|
179
180
|
onKeyDown(e) {
|
|
180
181
|
return e.domEvent.key === "Escape" ? (this.cancel(), !0) : !1;
|
|
@@ -209,17 +210,17 @@ class T {
|
|
|
209
210
|
class Z extends N {
|
|
210
211
|
onMouseMove(e) {
|
|
211
212
|
const t = T.pickGNode(this.getCanvas(), e.pos);
|
|
212
|
-
return t ? (
|
|
213
|
+
return t ? (d.highLight.reset([t]), this._updateView(), !1) : (d.highLight.clear(), this._updateView(), !1);
|
|
213
214
|
}
|
|
214
215
|
onClick(e) {
|
|
215
216
|
const t = T.pickGNode(this.getCanvas(), e.pos);
|
|
216
|
-
return
|
|
217
|
+
return d.highLight.clear(), !t && !e.fnKey.ctrlKey ? (d.selection.clear(), this._updateView(), !1) : (t && (e.fnKey.ctrlKey ? d.selection.add([t]) : d.selection.reset([t]), this._updateView()), !1);
|
|
217
218
|
}
|
|
218
219
|
onRButtonDown(e) {
|
|
219
|
-
return
|
|
220
|
+
return d.highLight.clear(), d.selection.clear(), this._updateView(), !1;
|
|
220
221
|
}
|
|
221
222
|
onKeyDown(e) {
|
|
222
|
-
return e.domEvent.key !== "Escape" ? !1 : (
|
|
223
|
+
return e.domEvent.key !== "Escape" ? !1 : (d.highLight.clear(), d.selection.clear(), this._updateView(), !0);
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
class A {
|
|
@@ -379,6 +380,9 @@ class G {
|
|
|
379
380
|
constructor() {
|
|
380
381
|
this._cmdMgr = Q, this.selection = f.instance(), this.highLight = u.instance();
|
|
381
382
|
}
|
|
383
|
+
get cmdMgr() {
|
|
384
|
+
return this._cmdMgr;
|
|
385
|
+
}
|
|
382
386
|
static instance() {
|
|
383
387
|
return this._instance || (this._instance = new G()), this._instance;
|
|
384
388
|
}
|
|
@@ -405,7 +409,7 @@ class G {
|
|
|
405
409
|
return this._curCanvas = s, this._curDoc && this._curCanvas.resetModelView(this._curDoc.modelView), this._curCanvas.startListening(), s;
|
|
406
410
|
}
|
|
407
411
|
}
|
|
408
|
-
const
|
|
412
|
+
const d = G.instance();
|
|
409
413
|
var C = /* @__PURE__ */ ((n) => (n[n.OK = 0] = "OK", n[n.CANCEL = 1] = "CANCEL", n))(C || {});
|
|
410
414
|
class L {
|
|
411
415
|
constructor(e, t) {
|
|
@@ -511,16 +515,16 @@ class h {
|
|
|
511
515
|
return t;
|
|
512
516
|
}
|
|
513
517
|
}
|
|
514
|
-
var
|
|
518
|
+
var p = /* @__PURE__ */ ((n) => (n[n.POINT_ON_FACE = 1842204] = "POINT_ON_FACE", n[n.END_POINT = 4063173] = "END_POINT", n[n.POINT_ON_CURVE = 1842204] = "POINT_ON_CURVE", n[n.MIDDLE_POINT = 4063173] = "MIDDLE_POINT", n[n.PARALLEL_TO_AXIS = 4063173] = "PARALLEL_TO_AXIS", n[n.INTERSECT_POINT = 4063173] = "INTERSECT_POINT", n[n.VERTICAL_PARALLEL = 4063173] = "VERTICAL_PARALLEL", n))(p || {});
|
|
515
519
|
const H = 200;
|
|
516
520
|
function se(n, e) {
|
|
517
521
|
if (!y.instance().canSnapHelperObject || !n?.pickedGNodes?.length)
|
|
518
522
|
return;
|
|
519
523
|
const t = (/* @__PURE__ */ new Date()).getTime();
|
|
520
524
|
if (n && (n.snapType === a.MiddlePoint || n.snapType === a.EndPoint) && t - e > H && n.pickedPlane) {
|
|
521
|
-
const s = n.pickedPlane.getUVAt(n.point), i = new
|
|
525
|
+
const s = n.pickedPlane.getUVAt(n.point), i = new m(s, P.X(), [-w.MODEL_MAX_LENGTH, w.MODEL_MAX_LENGTH]);
|
|
522
526
|
i.userData = { snapType: a.ReferCurve, lastPickedPt: s.clone() };
|
|
523
|
-
const r = new
|
|
527
|
+
const r = new m(s, P.Y(), [-w.MODEL_MAX_LENGTH, w.MODEL_MAX_LENGTH]);
|
|
524
528
|
r.userData = { snapType: a.ReferCurve, lastPickedPt: s.clone() }, h.instance().addSnapHelperCurves(_.BRIEF, [i, r]);
|
|
525
529
|
}
|
|
526
530
|
}
|
|
@@ -532,18 +536,18 @@ function ne(n, e, t) {
|
|
|
532
536
|
return;
|
|
533
537
|
const i = n.pickedGNodes[0];
|
|
534
538
|
let r;
|
|
535
|
-
if (i.getType() === D.GCurve2d && i.geo instanceof
|
|
539
|
+
if (i.getType() === D.GCurve2d && i.geo instanceof m)
|
|
536
540
|
r = i.geo;
|
|
537
541
|
else if (i.getType() === D.GPolycurve) {
|
|
538
542
|
const g = i.geo.getAllCurves();
|
|
539
|
-
g.length === 1 && g[0] instanceof
|
|
543
|
+
g.length === 1 && g[0] instanceof m && (r = g[0]);
|
|
540
544
|
}
|
|
541
545
|
if (!r)
|
|
542
546
|
return;
|
|
543
547
|
const c = r.getDirection().clone();
|
|
544
548
|
if (c.userData = { refCurve: r }, h.instance().addSnapHelperDirs(_.BRIEF, c), !t)
|
|
545
549
|
return;
|
|
546
|
-
const l = new
|
|
550
|
+
const l = new P();
|
|
547
551
|
if (j.D.ptToCurve2d(t, r, l), l.equals(t))
|
|
548
552
|
return;
|
|
549
553
|
const o = l.subtracted(t).normalize();
|
|
@@ -583,11 +587,11 @@ function I(n, e) {
|
|
|
583
587
|
return;
|
|
584
588
|
const t = W.XOY();
|
|
585
589
|
for (const s of n.getSnappedObjects())
|
|
586
|
-
if (s instanceof
|
|
587
|
-
const i = s.userData.lastPickedPt, r = new
|
|
588
|
-
let c =
|
|
590
|
+
if (s instanceof m && s.userData?.snapType === a.ReferCurve && s.userData?.lastPickedPt) {
|
|
591
|
+
const i = s.userData.lastPickedPt, r = new m(i, n.snappedPt);
|
|
592
|
+
let c = p.PARALLEL_TO_AXIS;
|
|
589
593
|
const l = r.getDirection();
|
|
590
|
-
l.isParallel(
|
|
594
|
+
l.isParallel(P.X()) ? c = 16711680 : l.isParallel(P.Y()) && (c = 65280);
|
|
591
595
|
const o = new S(t, r);
|
|
592
596
|
o.setStyle({
|
|
593
597
|
line: {
|
|
@@ -598,7 +602,7 @@ function I(n, e) {
|
|
|
598
602
|
const g = new R(t, i.clone());
|
|
599
603
|
g.setStyle({
|
|
600
604
|
point: {
|
|
601
|
-
color:
|
|
605
|
+
color: p.PARALLEL_TO_AXIS,
|
|
602
606
|
size: 6
|
|
603
607
|
}
|
|
604
608
|
}), e.addNode(g);
|
|
@@ -606,7 +610,7 @@ function I(n, e) {
|
|
|
606
610
|
const i = s.userData.refCurve, r = new S(t, i);
|
|
607
611
|
r.setStyle({
|
|
608
612
|
line: {
|
|
609
|
-
color:
|
|
613
|
+
color: p.VERTICAL_PARALLEL
|
|
610
614
|
}
|
|
611
615
|
}), e.addNode(r);
|
|
612
616
|
}
|
|
@@ -639,38 +643,38 @@ class ce {
|
|
|
639
643
|
if (!(t instanceof x))
|
|
640
644
|
return;
|
|
641
645
|
const s = new U();
|
|
642
|
-
let i =
|
|
646
|
+
let i = p.POINT_ON_FACE;
|
|
643
647
|
switch (t.getSnapType()) {
|
|
644
648
|
case a.Pole:
|
|
645
649
|
case a.EndPoint:
|
|
646
|
-
i =
|
|
650
|
+
i = p.END_POINT;
|
|
647
651
|
break;
|
|
648
652
|
case a.MiddlePoint:
|
|
649
653
|
case a.Center:
|
|
650
|
-
i =
|
|
654
|
+
i = p.MIDDLE_POINT;
|
|
651
655
|
break;
|
|
652
656
|
case a.ExtensionPoint:
|
|
653
657
|
case a.ParallelToX:
|
|
654
658
|
case a.ParallelToY:
|
|
655
|
-
i =
|
|
659
|
+
i = p.PARALLEL_TO_AXIS;
|
|
656
660
|
break;
|
|
657
661
|
case a.PointOnCurve:
|
|
658
|
-
i =
|
|
662
|
+
i = p.POINT_ON_CURVE;
|
|
659
663
|
break;
|
|
660
664
|
case a.ClosedLineParallelToX:
|
|
661
665
|
case a.ClosedLineParallelToY:
|
|
662
|
-
i =
|
|
666
|
+
i = p.PARALLEL_TO_AXIS;
|
|
663
667
|
break;
|
|
664
668
|
case a.XPt:
|
|
665
|
-
i =
|
|
669
|
+
i = p.INTERSECT_POINT;
|
|
666
670
|
break;
|
|
667
671
|
case a.ReferCurve:
|
|
668
|
-
I(t, s), i =
|
|
672
|
+
I(t, s), i = p.POINT_ON_CURVE;
|
|
669
673
|
break;
|
|
670
674
|
case a.PerpendicularPoint:
|
|
671
675
|
case a.ParallelToCurve:
|
|
672
676
|
case a.VerticalToCurve:
|
|
673
|
-
I(t, s), i =
|
|
677
|
+
I(t, s), i = p.VERTICAL_PARALLEL;
|
|
674
678
|
break;
|
|
675
679
|
}
|
|
676
680
|
if (t.anotherSnapType)
|
|
@@ -688,7 +692,7 @@ class ce {
|
|
|
688
692
|
}
|
|
689
693
|
class ue extends te {
|
|
690
694
|
constructor(e = new ae()) {
|
|
691
|
-
super(), this._currentMousePos =
|
|
695
|
+
super(), this._currentMousePos = P.O(), this._hoverSnappedPtTime = Date.now(), this._hoverPickedGNodeTime = Date.now(), this._context = e, e.snapContext && e.snapContext.addSnapHelpers(
|
|
692
696
|
v.POINT,
|
|
693
697
|
h.instance().getAllSnapHelperPoints()
|
|
694
698
|
);
|
|
@@ -784,7 +788,7 @@ export {
|
|
|
784
788
|
ce as RunSnapUtil,
|
|
785
789
|
f as Selection,
|
|
786
790
|
h as SnapHelpMgr,
|
|
787
|
-
|
|
791
|
+
d as app,
|
|
788
792
|
Q as cmdMgr,
|
|
789
793
|
se as createReferenceCurves,
|
|
790
794
|
ne as createReferenceDirs,
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccpc/platform",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Platform command interaction layer for editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@ccpc/canvas": "^0.1.
|
|
11
|
-
"@ccpc/core": "^0.1.
|
|
12
|
-
"@ccpc/math": "^0.1.
|
|
13
|
-
"@ccpc/snap": "^0.1.
|
|
10
|
+
"@ccpc/canvas": "^0.1.12",
|
|
11
|
+
"@ccpc/core": "^0.1.15",
|
|
12
|
+
"@ccpc/math": "^0.1.18",
|
|
13
|
+
"@ccpc/snap": "^0.1.12"
|
|
14
14
|
}
|
|
15
15
|
}
|
package/types/app/app.d.ts
CHANGED
package/types/app/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAa,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,qBAAa,GAAG;IACZ,OAAO,CAAC,MAAM,CAAC,SAAS,CAAK;IAE7B,OAAO,CAAC,OAAO,CAAC,CAAW;IAE3B,OAAO,CAAC,UAAU,CAAC,CAAS;IAE5B,OAAO,CAAC,OAAO,CAAS;IAEjB,SAAS,EAAE,SAAS,CAAA;IAEpB,SAAS,EAAE,SAAS,CAAA;;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAa,SAAS,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,qBAAa,GAAG;IACZ,OAAO,CAA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