@itwin/editor-frontend 3.3.0-dev.49 → 3.3.0-dev.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/EditTool.d.ts.map +1 -1
- package/lib/cjs/EditTool.js +2 -0
- package/lib/cjs/EditTool.js.map +1 -1
- package/lib/cjs/SolidPrimitiveTools.d.ts +100 -0
- package/lib/cjs/SolidPrimitiveTools.d.ts.map +1 -1
- package/lib/cjs/SolidPrimitiveTools.js +504 -13
- package/lib/cjs/SolidPrimitiveTools.js.map +1 -1
- package/lib/esm/EditTool.d.ts.map +1 -1
- package/lib/esm/EditTool.js +3 -1
- package/lib/esm/EditTool.js.map +1 -1
- package/lib/esm/SolidPrimitiveTools.d.ts +100 -0
- package/lib/esm/SolidPrimitiveTools.d.ts.map +1 -1
- package/lib/esm/SolidPrimitiveTools.js +503 -14
- package/lib/esm/SolidPrimitiveTools.js.map +1 -1
- package/lib/public/locales/en/Editor.json +33 -0
- package/package.json +12 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreateConeTool = exports.CreateConePhase = exports.CreateCylinderTool = exports.CreateCylinderPhase = exports.CreateSphereTool = exports.SolidPrimitiveTool = void 0;
|
|
3
|
+
exports.CreateTorusTool = exports.CreateTorusPhase = exports.CreateBoxTool = exports.CreateConeTool = exports.CreateConePhase = exports.CreateCylinderTool = exports.CreateCylinderPhase = exports.CreateSphereTool = exports.SolidPrimitiveTool = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -30,9 +30,10 @@ class SolidPrimitiveTool extends CreateElementTool_1.CreateElementWithDynamicsTo
|
|
|
30
30
|
return EditTool_1.EditTools.callCommand(method, ...args);
|
|
31
31
|
}
|
|
32
32
|
getPlacementProps() {
|
|
33
|
+
var _a;
|
|
33
34
|
if (undefined === this.current)
|
|
34
35
|
return undefined;
|
|
35
|
-
const localToWorld = ("solid" === this.current.geometryCategory ? this.current.getConstructiveFrame() : core_geometry_1.FrameBuilder.createRightHandedFrame(
|
|
36
|
+
const localToWorld = ("solid" === this.current.geometryCategory ? this.current.getConstructiveFrame() : core_geometry_1.FrameBuilder.createRightHandedFrame((_a = this.baseRotation) === null || _a === void 0 ? void 0 : _a.getColumn(2), this.current));
|
|
36
37
|
if (undefined === localToWorld)
|
|
37
38
|
return undefined;
|
|
38
39
|
const origin = localToWorld.getOrigin();
|
|
@@ -115,9 +116,7 @@ class CreateSphereTool extends SolidPrimitiveTool {
|
|
|
115
116
|
this.accepted.push(ev.point.clone());
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
const
|
|
119
|
-
const pt2 = ev.point;
|
|
120
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(pt1, pt2);
|
|
119
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(this.accepted[0], ev.point);
|
|
121
120
|
const radius = (this.useRadius ? this.radius : vector0.magnitude());
|
|
122
121
|
if (!this.useRadius) {
|
|
123
122
|
this.radius = radius;
|
|
@@ -133,7 +132,7 @@ class CreateSphereTool extends SolidPrimitiveTool {
|
|
|
133
132
|
const vector90 = normal.crossProduct(vector0);
|
|
134
133
|
const matrix = core_geometry_1.Matrix3d.createColumns(vector0, vector90, normal);
|
|
135
134
|
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(matrix);
|
|
136
|
-
this.current = core_geometry_1.Sphere.createFromAxesAndScales(
|
|
135
|
+
this.current = core_geometry_1.Sphere.createFromAxesAndScales(this.accepted[0], this.baseRotation, radius, radius, radius, undefined, this.capped);
|
|
137
136
|
if (isDynamics || undefined === this.current)
|
|
138
137
|
return;
|
|
139
138
|
this.accepted.push(ev.point.clone());
|
|
@@ -268,7 +267,7 @@ class CreateCylinderTool extends SolidPrimitiveTool {
|
|
|
268
267
|
if (isDynamics)
|
|
269
268
|
break;
|
|
270
269
|
// Allow creating cylinder by 2 points when orthogonal and radius are locked...
|
|
271
|
-
this.accepted.push(
|
|
270
|
+
this.accepted.push(pt2.clone());
|
|
272
271
|
this.createPhase = (this.orthogonal && this.useRadius ? CreateCylinderPhase.AcceptLength : CreateCylinderPhase.AcceptRadius);
|
|
273
272
|
break;
|
|
274
273
|
}
|
|
@@ -290,7 +289,7 @@ class CreateCylinderTool extends SolidPrimitiveTool {
|
|
|
290
289
|
const arc = core_geometry_1.Arc3d.create(pt1, vector0, vector90);
|
|
291
290
|
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
|
|
292
291
|
this.current = (this.capped ? core_geometry_1.Loop.create(arc) : arc);
|
|
293
|
-
if (isDynamics
|
|
292
|
+
if (isDynamics)
|
|
294
293
|
break;
|
|
295
294
|
this.createPhase = CreateCylinderPhase.AcceptLength;
|
|
296
295
|
break;
|
|
@@ -488,7 +487,7 @@ class CreateConeTool extends SolidPrimitiveTool {
|
|
|
488
487
|
if (isDynamics)
|
|
489
488
|
break;
|
|
490
489
|
// Allow creating cone by 2 points when orthogonal and base/top radii are locked...
|
|
491
|
-
this.accepted.push(
|
|
490
|
+
this.accepted.push(pt2.clone());
|
|
492
491
|
this.createPhase = (this.orthogonal && this.useBaseRadius ? CreateConePhase.AcceptLength : CreateConePhase.AcceptBaseRadius);
|
|
493
492
|
break;
|
|
494
493
|
}
|
|
@@ -510,7 +509,7 @@ class CreateConeTool extends SolidPrimitiveTool {
|
|
|
510
509
|
const arc = core_geometry_1.Arc3d.create(pt1, vector0, vector90);
|
|
511
510
|
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
|
|
512
511
|
this.current = (this.capped ? core_geometry_1.Loop.create(arc) : arc);
|
|
513
|
-
if (isDynamics
|
|
512
|
+
if (isDynamics)
|
|
514
513
|
break;
|
|
515
514
|
this.createPhase = CreateConePhase.AcceptLength;
|
|
516
515
|
break;
|
|
@@ -551,14 +550,14 @@ class CreateConeTool extends SolidPrimitiveTool {
|
|
|
551
550
|
const cone = ("solid" === ((_a = this.current) === null || _a === void 0 ? void 0 : _a.geometryCategory) ? this.current : undefined);
|
|
552
551
|
if (undefined === cone)
|
|
553
552
|
break;
|
|
554
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(cone.getCenterB(),
|
|
553
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(cone.getCenterB(), pt2);
|
|
555
554
|
const radius = (this.useTopRadius ? this.topRadius : vector0.magnitude());
|
|
556
555
|
if (!this.useTopRadius) {
|
|
557
556
|
this.topRadius = radius;
|
|
558
557
|
this.syncToolSettingPropertyValue(this.topRadiusProperty);
|
|
559
558
|
}
|
|
560
559
|
this.current = core_geometry_1.Cone.createBaseAndTarget(cone.getCenterA(), cone.getCenterB(), cone.getVectorX(), cone.getVectorY(), cone.getRadiusA(), radius, this.capped);
|
|
561
|
-
if (isDynamics
|
|
560
|
+
if (isDynamics)
|
|
562
561
|
break;
|
|
563
562
|
this.createPhase = CreateConePhase.AcceptResult;
|
|
564
563
|
break;
|
|
@@ -584,7 +583,7 @@ class CreateConeTool extends SolidPrimitiveTool {
|
|
|
584
583
|
const useBaseRadiusLock = this.useBaseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
585
584
|
toolSettings.push(this.baseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useBaseRadiusLock));
|
|
586
585
|
this.topRadiusProperty.isDisabled = !this.useTopRadius;
|
|
587
|
-
const useTopRadiusLock = this.useTopRadiusProperty.toDialogItem({ rowPriority:
|
|
586
|
+
const useTopRadiusLock = this.useTopRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
|
|
588
587
|
toolSettings.push(this.topRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useTopRadiusLock));
|
|
589
588
|
this.lengthProperty.isDisabled = !this.useLength;
|
|
590
589
|
const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
|
|
@@ -602,4 +601,496 @@ class CreateConeTool extends SolidPrimitiveTool {
|
|
|
602
601
|
exports.CreateConeTool = CreateConeTool;
|
|
603
602
|
CreateConeTool.toolId = "CreateCone";
|
|
604
603
|
CreateConeTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
604
|
+
/** @alpha Creates a bix. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
605
|
+
class CreateBoxTool extends SolidPrimitiveTool {
|
|
606
|
+
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
607
|
+
switch (this.accepted.length) {
|
|
608
|
+
case 0:
|
|
609
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateBox.Prompts.BasePoint");
|
|
610
|
+
break;
|
|
611
|
+
case 1:
|
|
612
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateBox.Prompts.LengthPoint");
|
|
613
|
+
break;
|
|
614
|
+
case 2:
|
|
615
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateBox.Prompts.WidthPoint");
|
|
616
|
+
break;
|
|
617
|
+
default:
|
|
618
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateBox.Prompts.HeightPoint");
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
622
|
+
}
|
|
623
|
+
setupAccuDraw() {
|
|
624
|
+
const nPts = this.accepted.length;
|
|
625
|
+
if (0 === nPts)
|
|
626
|
+
return;
|
|
627
|
+
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
628
|
+
hints.setModeRectangular();
|
|
629
|
+
hints.setOrigin(this.accepted[0]);
|
|
630
|
+
hints.setOriginFixed = true;
|
|
631
|
+
if (undefined !== this.baseRotation) {
|
|
632
|
+
if (2 === nPts) {
|
|
633
|
+
hints.setMatrix(this.baseRotation);
|
|
634
|
+
hints.setLockX = true;
|
|
635
|
+
hints.setLockZ = true;
|
|
636
|
+
}
|
|
637
|
+
else if (3 === nPts) {
|
|
638
|
+
hints.setXAxis2(this.baseRotation.getColumn(2));
|
|
639
|
+
if (this.orthogonal) {
|
|
640
|
+
hints.setLockY = true;
|
|
641
|
+
hints.setLockZ = true;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
hints.sendHints();
|
|
646
|
+
}
|
|
647
|
+
get useLengthProperty() {
|
|
648
|
+
if (!this._useLengthProperty)
|
|
649
|
+
this._useLengthProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useBoxLength"), false);
|
|
650
|
+
return this._useLengthProperty;
|
|
651
|
+
}
|
|
652
|
+
get useLength() { return this.useLengthProperty.value; }
|
|
653
|
+
set useLength(value) { this.useLengthProperty.value = value; }
|
|
654
|
+
get lengthProperty() {
|
|
655
|
+
if (!this._lengthProperty)
|
|
656
|
+
this._lengthProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("boxLength", EditTool_1.EditTools.translate("CreateBox.Label.Length")), 0.1, undefined, !this.useLength);
|
|
657
|
+
return this._lengthProperty;
|
|
658
|
+
}
|
|
659
|
+
get length() { return this.lengthProperty.value; }
|
|
660
|
+
set length(value) { this.lengthProperty.value = value; }
|
|
661
|
+
get useWidthProperty() {
|
|
662
|
+
if (!this._useWidthProperty)
|
|
663
|
+
this._useWidthProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useBoxWidth"), false);
|
|
664
|
+
return this._useWidthProperty;
|
|
665
|
+
}
|
|
666
|
+
get useWidth() { return this.useWidthProperty.value; }
|
|
667
|
+
set useWidth(value) { this.useWidthProperty.value = value; }
|
|
668
|
+
get widthProperty() {
|
|
669
|
+
if (!this._widthProperty)
|
|
670
|
+
this._widthProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("boxWidth", EditTool_1.EditTools.translate("CreateBox.Label.Width")), 0.1, undefined, !this.useWidth);
|
|
671
|
+
return this._widthProperty;
|
|
672
|
+
}
|
|
673
|
+
get width() { return this.widthProperty.value; }
|
|
674
|
+
set width(value) { this.widthProperty.value = value; }
|
|
675
|
+
get useHeightProperty() {
|
|
676
|
+
if (!this._useHeightProperty)
|
|
677
|
+
this._useHeightProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useBoxHeight"), false);
|
|
678
|
+
return this._useHeightProperty;
|
|
679
|
+
}
|
|
680
|
+
get useHeight() { return this.useHeightProperty.value; }
|
|
681
|
+
set useHeight(value) { this.useHeightProperty.value = value; }
|
|
682
|
+
get heightProperty() {
|
|
683
|
+
if (!this._heightProperty)
|
|
684
|
+
this._heightProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("boxHeight", EditTool_1.EditTools.translate("CreateBox.Label.Height")), 0.1, undefined, !this.useHeight);
|
|
685
|
+
return this._heightProperty;
|
|
686
|
+
}
|
|
687
|
+
get height() { return this.heightProperty.value; }
|
|
688
|
+
set height(value) { this.heightProperty.value = value; }
|
|
689
|
+
get cappedProperty() {
|
|
690
|
+
if (!this._cappedProperty)
|
|
691
|
+
this._cappedProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("boxCapped", EditTool_1.EditTools.translate("CreateBox.Label.Capped")), true);
|
|
692
|
+
return this._cappedProperty;
|
|
693
|
+
}
|
|
694
|
+
get capped() { return this.cappedProperty.value; }
|
|
695
|
+
set capped(value) { this.cappedProperty.value = value; }
|
|
696
|
+
get orthogonalProperty() {
|
|
697
|
+
if (!this._orthogonalProperty)
|
|
698
|
+
this._orthogonalProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("boxOrthogonal", EditTool_1.EditTools.translate("CreateBox.Label.Orthogonal")), true);
|
|
699
|
+
return this._orthogonalProperty;
|
|
700
|
+
}
|
|
701
|
+
get orthogonal() { return this.orthogonalProperty.value; }
|
|
702
|
+
set orthogonal(value) { this.orthogonalProperty.value = value; }
|
|
703
|
+
isComplete(_ev) {
|
|
704
|
+
return (4 === this.accepted.length);
|
|
705
|
+
}
|
|
706
|
+
async updateElementData(ev, isDynamics) {
|
|
707
|
+
const vp = this.targetView;
|
|
708
|
+
if (undefined === vp)
|
|
709
|
+
return;
|
|
710
|
+
switch (this.accepted.length) {
|
|
711
|
+
case 0: {
|
|
712
|
+
if (!isDynamics)
|
|
713
|
+
this.accepted.push(ev.point.clone());
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
case 1: {
|
|
717
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(this.accepted[0], ev.point);
|
|
718
|
+
const length = (this.useLength ? this.length : vector0.magnitude());
|
|
719
|
+
if (!this.useLength) {
|
|
720
|
+
this.length = length;
|
|
721
|
+
this.syncToolSettingPropertyValue(this.lengthProperty);
|
|
722
|
+
}
|
|
723
|
+
if (undefined === vector0.scaleToLength(length, vector0)) {
|
|
724
|
+
this.current = undefined;
|
|
725
|
+
this.clearGraphics();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
this.baseRotation = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
|
|
729
|
+
const normal = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
|
|
730
|
+
const vector90 = normal.crossProduct(vector0);
|
|
731
|
+
const matrix = core_geometry_1.Matrix3d.createColumns(vector0, vector90, normal);
|
|
732
|
+
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(matrix);
|
|
733
|
+
this.current = core_geometry_1.LineSegment3d.create(this.accepted[0], this.accepted[0].plus(vector0));
|
|
734
|
+
if (isDynamics)
|
|
735
|
+
return;
|
|
736
|
+
this.accepted.push(ev.point.clone());
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
case 2: {
|
|
740
|
+
const vector90 = core_geometry_1.Vector3d.createStartEnd(this.accepted[0], ev.point);
|
|
741
|
+
const width = (this.useWidth ? this.width : vector90.magnitude());
|
|
742
|
+
if (!this.useWidth) {
|
|
743
|
+
this.width = width;
|
|
744
|
+
this.syncToolSettingPropertyValue(this.widthProperty);
|
|
745
|
+
}
|
|
746
|
+
const vector0 = this.baseRotation ? this.baseRotation.getColumn(0) : core_geometry_1.Vector3d.unitX();
|
|
747
|
+
const normal = vector90.crossProduct(vector0);
|
|
748
|
+
const matrix = core_geometry_1.Matrix3d.createColumns(vector0, vector90, normal);
|
|
749
|
+
if (undefined === vector90.scaleToLength(width, vector90) || undefined === core_geometry_1.Matrix3d.createRigidFromMatrix3d(matrix, undefined, matrix)) {
|
|
750
|
+
this.current = core_geometry_1.LineSegment3d.create(this.accepted[0], this.accepted[0].plusScaled(vector0, this.length));
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
this.baseRotation = matrix; // Update base rotation from cross product...
|
|
754
|
+
const shapePts = [];
|
|
755
|
+
shapePts[0] = this.accepted[0].clone();
|
|
756
|
+
shapePts[1] = shapePts[0].plusScaled(this.baseRotation.getColumn(0), this.length);
|
|
757
|
+
shapePts[2] = shapePts[1].plusScaled(this.baseRotation.getColumn(1), width);
|
|
758
|
+
shapePts[3] = shapePts[0].plusScaled(this.baseRotation.getColumn(1), width);
|
|
759
|
+
shapePts[4] = shapePts[0].clone();
|
|
760
|
+
const base = core_geometry_1.LineString3d.create(shapePts);
|
|
761
|
+
this.current = (this.capped ? core_geometry_1.Loop.create(base) : base);
|
|
762
|
+
if (isDynamics)
|
|
763
|
+
return;
|
|
764
|
+
this.accepted.push(ev.point.clone());
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
default: {
|
|
768
|
+
if (undefined === this.baseRotation)
|
|
769
|
+
return; // Should always have base rotation after width is defined...
|
|
770
|
+
const zAxis = core_geometry_1.Vector3d.createStartEnd(this.accepted[0], ev.point);
|
|
771
|
+
const height = (this.useHeight ? this.height : zAxis.magnitude());
|
|
772
|
+
if (!this.useHeight) {
|
|
773
|
+
this.height = height;
|
|
774
|
+
this.syncToolSettingPropertyValue(this.heightProperty);
|
|
775
|
+
}
|
|
776
|
+
if (undefined === zAxis.scaleToLength(height, zAxis)) {
|
|
777
|
+
const shapePts = [];
|
|
778
|
+
shapePts[0] = this.accepted[0].clone();
|
|
779
|
+
shapePts[1] = shapePts[0].plusScaled(this.baseRotation.getColumn(0), this.length);
|
|
780
|
+
shapePts[2] = shapePts[1].plusScaled(this.baseRotation.getColumn(1), this.width);
|
|
781
|
+
shapePts[3] = shapePts[0].plusScaled(this.baseRotation.getColumn(1), this.width);
|
|
782
|
+
shapePts[4] = shapePts[0].clone();
|
|
783
|
+
const base = core_geometry_1.LineString3d.create(shapePts);
|
|
784
|
+
this.current = (this.capped ? core_geometry_1.Loop.create(base) : base);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
if (this.orthogonal) {
|
|
788
|
+
const normal = this.baseRotation.getColumn(2);
|
|
789
|
+
normal.scaleToLength(normal.dotProduct(zAxis) >= 0.0 ? height : -height, zAxis);
|
|
790
|
+
}
|
|
791
|
+
this.current = core_geometry_1.Box.createDgnBoxWithAxes(this.accepted[0], this.baseRotation, this.accepted[0].plus(zAxis), this.length, this.width, this.length, this.width, this.capped);
|
|
792
|
+
if (isDynamics || undefined === this.current)
|
|
793
|
+
return;
|
|
794
|
+
this.accepted.push(ev.point.clone());
|
|
795
|
+
break;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
getToolSettingPropertyLocked(property) {
|
|
800
|
+
if (property === this.useLengthProperty)
|
|
801
|
+
return this.lengthProperty;
|
|
802
|
+
else if (property === this.useWidthProperty)
|
|
803
|
+
return this.widthProperty;
|
|
804
|
+
else if (property === this.useHeightProperty)
|
|
805
|
+
return this.heightProperty;
|
|
806
|
+
return undefined;
|
|
807
|
+
}
|
|
808
|
+
async applyToolSettingPropertyChange(updatedValue) {
|
|
809
|
+
return this.changeToolSettingPropertyValue(updatedValue);
|
|
810
|
+
}
|
|
811
|
+
supplyToolSettingsProperties() {
|
|
812
|
+
this.initializeToolSettingPropertyValues([this.lengthProperty, this.useLengthProperty, this.widthProperty, this.useWidthProperty, this.heightProperty, this.useHeightProperty, this.orthogonalProperty, this.cappedProperty]);
|
|
813
|
+
const toolSettings = new Array();
|
|
814
|
+
this.lengthProperty.isDisabled = !this.useLength;
|
|
815
|
+
const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
816
|
+
toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useLengthLock));
|
|
817
|
+
this.widthProperty.isDisabled = !this.useWidth;
|
|
818
|
+
const useWidthLock = this.useWidthProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
|
|
819
|
+
toolSettings.push(this.widthProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useWidthLock));
|
|
820
|
+
this.heightProperty.isDisabled = !this.useHeight;
|
|
821
|
+
const useHeightLock = this.useHeightProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
|
|
822
|
+
toolSettings.push(this.heightProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useHeightLock));
|
|
823
|
+
toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
|
|
824
|
+
toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 5, columnIndex: 0 }));
|
|
825
|
+
return toolSettings;
|
|
826
|
+
}
|
|
827
|
+
async onRestartTool() {
|
|
828
|
+
const tool = new CreateBoxTool();
|
|
829
|
+
if (!await tool.run())
|
|
830
|
+
return this.exitTool();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
exports.CreateBoxTool = CreateBoxTool;
|
|
834
|
+
CreateBoxTool.toolId = "CreateBox";
|
|
835
|
+
CreateBoxTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
836
|
+
/** @alpha Values for [[CreateTorusTool.createPhase]. */
|
|
837
|
+
var CreateTorusPhase;
|
|
838
|
+
(function (CreateTorusPhase) {
|
|
839
|
+
/** Current tool phase to define start point */
|
|
840
|
+
CreateTorusPhase[CreateTorusPhase["AcceptStart"] = 0] = "AcceptStart";
|
|
841
|
+
/** Current tool phase to define center point */
|
|
842
|
+
CreateTorusPhase[CreateTorusPhase["AcceptCenter"] = 1] = "AcceptCenter";
|
|
843
|
+
/** Current tool phase to define secondary radius */
|
|
844
|
+
CreateTorusPhase[CreateTorusPhase["AcceptSecondaryRadius"] = 2] = "AcceptSecondaryRadius";
|
|
845
|
+
/** Current tool phase to define sweep angle */
|
|
846
|
+
CreateTorusPhase[CreateTorusPhase["AcceptAngle"] = 3] = "AcceptAngle";
|
|
847
|
+
/** Current tool phase to accept result */
|
|
848
|
+
CreateTorusPhase[CreateTorusPhase["AcceptResult"] = 4] = "AcceptResult";
|
|
849
|
+
})(CreateTorusPhase = exports.CreateTorusPhase || (exports.CreateTorusPhase = {}));
|
|
850
|
+
/** @alpha Creates a torus pipe. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
851
|
+
class CreateTorusTool extends SolidPrimitiveTool {
|
|
852
|
+
constructor() {
|
|
853
|
+
super(...arguments);
|
|
854
|
+
this.createPhase = CreateTorusPhase.AcceptStart;
|
|
855
|
+
}
|
|
856
|
+
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
857
|
+
switch (this.createPhase) {
|
|
858
|
+
case CreateTorusPhase.AcceptStart:
|
|
859
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.StartPoint");
|
|
860
|
+
break;
|
|
861
|
+
case CreateTorusPhase.AcceptCenter:
|
|
862
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.CenterPoint");
|
|
863
|
+
break;
|
|
864
|
+
case CreateTorusPhase.AcceptSecondaryRadius:
|
|
865
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.SecondaryRadiusPoint");
|
|
866
|
+
break;
|
|
867
|
+
default:
|
|
868
|
+
mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.AnglePoint");
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
872
|
+
}
|
|
873
|
+
setupAccuDraw() {
|
|
874
|
+
const nPts = this.accepted.length;
|
|
875
|
+
if (0 === nPts)
|
|
876
|
+
return;
|
|
877
|
+
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
878
|
+
if (CreateTorusPhase.AcceptCenter === this.createPhase) {
|
|
879
|
+
hints.setOrigin(this.accepted[0]);
|
|
880
|
+
}
|
|
881
|
+
else if (CreateTorusPhase.AcceptSecondaryRadius === this.createPhase) {
|
|
882
|
+
hints.setModePolar();
|
|
883
|
+
hints.setOrigin(this.accepted[0]);
|
|
884
|
+
hints.setOriginFixed = true;
|
|
885
|
+
if (undefined !== this.baseRotation)
|
|
886
|
+
hints.setMatrix(core_geometry_1.Matrix3d.createColumns(this.baseRotation.getColumn(0), this.baseRotation.getColumn(2), this.baseRotation.getColumn(1)));
|
|
887
|
+
}
|
|
888
|
+
else if (CreateTorusPhase.AcceptAngle === this.createPhase && 2 === nPts) {
|
|
889
|
+
hints.setModePolar();
|
|
890
|
+
hints.setOrigin(this.accepted[1]);
|
|
891
|
+
hints.setOriginFixed = true;
|
|
892
|
+
if (undefined !== this.baseRotation)
|
|
893
|
+
hints.setMatrix(this.baseRotation);
|
|
894
|
+
}
|
|
895
|
+
hints.sendHints();
|
|
896
|
+
}
|
|
897
|
+
get usePrimaryRadiusProperty() {
|
|
898
|
+
if (!this._usePrimaryRadiusProperty)
|
|
899
|
+
this._usePrimaryRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusPrimaryRadius"), false);
|
|
900
|
+
return this._usePrimaryRadiusProperty;
|
|
901
|
+
}
|
|
902
|
+
get usePrimaryRadius() { return this.usePrimaryRadiusProperty.value; }
|
|
903
|
+
set usePrimaryRadius(value) { this.usePrimaryRadiusProperty.value = value; }
|
|
904
|
+
get primaryRadiusProperty() {
|
|
905
|
+
if (!this._primaryRadiusProperty)
|
|
906
|
+
this._primaryRadiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("torusPrimaryRadius", EditTool_1.EditTools.translate("CreateTorus.Label.PrimaryRadius")), 0.1, undefined, !this.usePrimaryRadius);
|
|
907
|
+
return this._primaryRadiusProperty;
|
|
908
|
+
}
|
|
909
|
+
get primaryRadius() { return this.primaryRadiusProperty.value; }
|
|
910
|
+
set primaryRadius(value) { this.primaryRadiusProperty.value = value; }
|
|
911
|
+
get useSecondaryRadiusProperty() {
|
|
912
|
+
if (!this._useSecondaryRadiusProperty)
|
|
913
|
+
this._useSecondaryRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusSecondaryRadius"), false);
|
|
914
|
+
return this._useSecondaryRadiusProperty;
|
|
915
|
+
}
|
|
916
|
+
get useSecondaryRadius() { return this.useSecondaryRadiusProperty.value; }
|
|
917
|
+
set useSecondaryRadius(value) { this.useSecondaryRadiusProperty.value = value; }
|
|
918
|
+
get secondaryRadiusProperty() {
|
|
919
|
+
if (!this._secondaryRadiusProperty)
|
|
920
|
+
this._secondaryRadiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("torusSecondaryRadius", EditTool_1.EditTools.translate("CreateTorus.Label.SecondaryRadius")), 0.05, undefined, !this.useSecondaryRadius);
|
|
921
|
+
return this._secondaryRadiusProperty;
|
|
922
|
+
}
|
|
923
|
+
get secondaryRadius() { return this.secondaryRadiusProperty.value; }
|
|
924
|
+
set secondaryRadius(value) { this.secondaryRadiusProperty.value = value; }
|
|
925
|
+
get useAngleProperty() {
|
|
926
|
+
if (!this._useAngleProperty)
|
|
927
|
+
this._useAngleProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusAngle"), false);
|
|
928
|
+
return this._useAngleProperty;
|
|
929
|
+
}
|
|
930
|
+
get useAngle() { return this.useAngleProperty.value; }
|
|
931
|
+
set useAngle(value) { this.useAngleProperty.value = value; }
|
|
932
|
+
get angleProperty() {
|
|
933
|
+
if (!this._angleProperty)
|
|
934
|
+
this._angleProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.AngleDescription("torusAngle", EditTool_1.EditTools.translate("CreateTorus.Label.Angle")), Math.PI / 2.0, undefined, !this.useAngle);
|
|
935
|
+
return this._angleProperty;
|
|
936
|
+
}
|
|
937
|
+
get angle() { return this.angleProperty.value; }
|
|
938
|
+
set angle(value) { this.angleProperty.value = value; }
|
|
939
|
+
get cappedProperty() {
|
|
940
|
+
if (!this._cappedProperty)
|
|
941
|
+
this._cappedProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("torusCapped", EditTool_1.EditTools.translate("CreateTorus.Label.Capped")), true);
|
|
942
|
+
return this._cappedProperty;
|
|
943
|
+
}
|
|
944
|
+
get capped() { return this.cappedProperty.value; }
|
|
945
|
+
set capped(value) { this.cappedProperty.value = value; }
|
|
946
|
+
isComplete(_ev) {
|
|
947
|
+
return (CreateTorusPhase.AcceptResult === this.createPhase);
|
|
948
|
+
}
|
|
949
|
+
async updateElementData(ev, isDynamics) {
|
|
950
|
+
const vp = this.targetView;
|
|
951
|
+
if (undefined === vp)
|
|
952
|
+
return;
|
|
953
|
+
switch (this.createPhase) {
|
|
954
|
+
case CreateTorusPhase.AcceptStart: {
|
|
955
|
+
if (isDynamics)
|
|
956
|
+
break;
|
|
957
|
+
this.accepted.push(ev.point.clone());
|
|
958
|
+
this.createPhase = CreateTorusPhase.AcceptCenter;
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
case CreateTorusPhase.AcceptCenter: {
|
|
962
|
+
this.baseRotation = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
|
|
963
|
+
const normal = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
|
|
964
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(ev.point, this.accepted[0]);
|
|
965
|
+
const vector90 = normal.crossProduct(vector0);
|
|
966
|
+
const primaryRadius = (this.usePrimaryRadius ? this.primaryRadius : vector0.magnitude());
|
|
967
|
+
if (!this.usePrimaryRadius) {
|
|
968
|
+
this.primaryRadius = primaryRadius;
|
|
969
|
+
this.syncToolSettingPropertyValue(this.primaryRadiusProperty);
|
|
970
|
+
}
|
|
971
|
+
if (undefined === vector0.scaleToLength(primaryRadius, vector0) || undefined === vector90.scaleToLength(primaryRadius, vector90)) {
|
|
972
|
+
this.current = undefined;
|
|
973
|
+
this.clearGraphics();
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
const center = this.accepted[0].plus(vector0.negate());
|
|
977
|
+
const allowComplete = (this.useSecondaryRadius && this.useAngle && (2 * Math.PI) === this.angle);
|
|
978
|
+
if (allowComplete) {
|
|
979
|
+
vector0.normalizeInPlace();
|
|
980
|
+
vector90.normalizeInPlace();
|
|
981
|
+
this.current = core_geometry_1.TorusPipe.createDgnTorusPipe(center, vector0, vector90, primaryRadius, this.secondaryRadius, core_geometry_1.Angle.createRadians(this.angle), this.capped);
|
|
982
|
+
if (undefined === this.current) {
|
|
983
|
+
this.clearGraphics();
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
if (!isDynamics)
|
|
987
|
+
this.createPhase = CreateTorusPhase.AcceptResult;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
const arc = core_geometry_1.Arc3d.create(center, vector0, vector90);
|
|
991
|
+
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
|
|
992
|
+
this.current = arc;
|
|
993
|
+
if (isDynamics)
|
|
994
|
+
break;
|
|
995
|
+
this.accepted.push(arc.center); // Add center to accepted points for AccuDraw hints...
|
|
996
|
+
this.createPhase = (this.useSecondaryRadius ? CreateTorusPhase.AcceptAngle : CreateTorusPhase.AcceptSecondaryRadius);
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
case CreateTorusPhase.AcceptSecondaryRadius: {
|
|
1000
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(this.accepted[0], ev.point);
|
|
1001
|
+
const secondaryRadius = (this.useSecondaryRadius ? this.secondaryRadius : Math.min(this.primaryRadius, vector0.magnitude()));
|
|
1002
|
+
if (!this.useSecondaryRadius) {
|
|
1003
|
+
this.secondaryRadius = secondaryRadius;
|
|
1004
|
+
this.syncToolSettingPropertyValue(this.secondaryRadiusProperty);
|
|
1005
|
+
}
|
|
1006
|
+
const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : core_geometry_1.Vector3d.unitX();
|
|
1007
|
+
const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : core_geometry_1.Vector3d.unitY();
|
|
1008
|
+
if (undefined === vector0.scaleToLength(secondaryRadius, vector0)) {
|
|
1009
|
+
xAxis.scaleToLength(this.primaryRadius, xAxis);
|
|
1010
|
+
yAxis.scaleToLength(this.primaryRadius, yAxis);
|
|
1011
|
+
this.current = core_geometry_1.Arc3d.create(this.accepted[1], xAxis, yAxis);
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
const sweep = core_geometry_1.Angle.createRadians(this.useAngle ? this.angle : 2 * Math.PI);
|
|
1015
|
+
this.current = core_geometry_1.TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, secondaryRadius, sweep, this.capped);
|
|
1016
|
+
if (undefined === this.current) {
|
|
1017
|
+
this.clearGraphics();
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
if (!isDynamics)
|
|
1021
|
+
this.createPhase = ((this.useAngle && (2 * Math.PI) === this.angle) ? CreateTorusPhase.AcceptResult : CreateTorusPhase.AcceptAngle);
|
|
1022
|
+
break;
|
|
1023
|
+
}
|
|
1024
|
+
case CreateTorusPhase.AcceptAngle: {
|
|
1025
|
+
const vector90 = core_geometry_1.Vector3d.createStartEnd(this.accepted[1], ev.point);
|
|
1026
|
+
const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : core_geometry_1.Vector3d.unitX();
|
|
1027
|
+
const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : core_geometry_1.Vector3d.unitY();
|
|
1028
|
+
const zAxis = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
|
|
1029
|
+
const prevSweep = core_geometry_1.Angle.createRadians(this.angle);
|
|
1030
|
+
const sweep = xAxis.planarAngleTo(vector90, zAxis);
|
|
1031
|
+
if (Math.abs(sweep.radians) < core_geometry_1.Angle.createDegrees(30.0).radians && prevSweep.isFullCircle && ((sweep.radians < 0.0 && prevSweep.radians > 0.0) || (sweep.radians > 0.0 && prevSweep.radians < 0.0)))
|
|
1032
|
+
prevSweep.setRadians(-prevSweep.radians); // Reverse direction...
|
|
1033
|
+
if (sweep.isAlmostZero)
|
|
1034
|
+
sweep.setDegrees(prevSweep.radians < 0.0 ? -360.0 : 360.0); // Create full sweep...
|
|
1035
|
+
if (this.useAngle) {
|
|
1036
|
+
if ((sweep.radians < 0.0 && this.angle > 0.0) || (sweep.radians > 0.0 && this.angle < 0.0))
|
|
1037
|
+
sweep.setRadians(-this.angle);
|
|
1038
|
+
else
|
|
1039
|
+
sweep.setRadians(this.angle);
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
if (sweep.radians < 0.0 && prevSweep.radians > 0.0)
|
|
1043
|
+
sweep.setRadians(core_geometry_1.Angle.pi2Radians + sweep.radians);
|
|
1044
|
+
else if (sweep.radians > 0.0 && prevSweep.radians < 0.0)
|
|
1045
|
+
sweep.setRadians(-(core_geometry_1.Angle.pi2Radians - sweep.radians));
|
|
1046
|
+
this.angle = sweep.radians;
|
|
1047
|
+
this.syncToolSettingPropertyValue(this.angleProperty);
|
|
1048
|
+
}
|
|
1049
|
+
this.current = core_geometry_1.TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, this.secondaryRadius, sweep, this.capped);
|
|
1050
|
+
if (undefined === this.current) {
|
|
1051
|
+
this.clearGraphics();
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
if (!isDynamics)
|
|
1055
|
+
this.createPhase = CreateTorusPhase.AcceptResult;
|
|
1056
|
+
break;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
getToolSettingPropertyLocked(property) {
|
|
1061
|
+
if (property === this.usePrimaryRadiusProperty)
|
|
1062
|
+
return this.primaryRadiusProperty;
|
|
1063
|
+
else if (property === this.useSecondaryRadiusProperty)
|
|
1064
|
+
return this.secondaryRadiusProperty;
|
|
1065
|
+
else if (property === this.useAngleProperty)
|
|
1066
|
+
return this.angleProperty;
|
|
1067
|
+
return undefined;
|
|
1068
|
+
}
|
|
1069
|
+
async applyToolSettingPropertyChange(updatedValue) {
|
|
1070
|
+
return this.changeToolSettingPropertyValue(updatedValue);
|
|
1071
|
+
}
|
|
1072
|
+
supplyToolSettingsProperties() {
|
|
1073
|
+
this.initializeToolSettingPropertyValues([this.primaryRadiusProperty, this.usePrimaryRadiusProperty, this.secondaryRadiusProperty, this.useSecondaryRadiusProperty, this.angleProperty, this.useAngleProperty, this.cappedProperty]);
|
|
1074
|
+
const toolSettings = new Array();
|
|
1075
|
+
this.primaryRadiusProperty.isDisabled = !this.usePrimaryRadius;
|
|
1076
|
+
const usePrimaryRadiusLock = this.usePrimaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
1077
|
+
toolSettings.push(this.primaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, usePrimaryRadiusLock));
|
|
1078
|
+
this.secondaryRadiusProperty.isDisabled = !this.useSecondaryRadius;
|
|
1079
|
+
const useSecondaryRadiusLock = this.useSecondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
|
|
1080
|
+
toolSettings.push(this.secondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useSecondaryRadiusLock));
|
|
1081
|
+
this.angleProperty.isDisabled = !this.useAngle;
|
|
1082
|
+
const useAngleLock = this.useAngleProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
|
|
1083
|
+
toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useAngleLock));
|
|
1084
|
+
toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
|
|
1085
|
+
return toolSettings;
|
|
1086
|
+
}
|
|
1087
|
+
async onRestartTool() {
|
|
1088
|
+
const tool = new CreateTorusTool();
|
|
1089
|
+
if (!await tool.run())
|
|
1090
|
+
return this.exitTool();
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
exports.CreateTorusTool = CreateTorusTool;
|
|
1094
|
+
CreateTorusTool.toolId = "CreateTorus";
|
|
1095
|
+
CreateTorusTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
605
1096
|
//# sourceMappingURL=SolidPrimitiveTools.js.map
|