@itwin/editor-frontend 3.3.0-dev.48 → 3.3.0-dev.50

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.
@@ -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(undefined, this.current));
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 pt1 = this.accepted[0];
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(pt1, this.baseRotation, radius, radius, radius, undefined, this.capped);
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(ev.point.clone());
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 || undefined === this.current)
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(ev.point.clone());
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 || undefined === this.current)
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(), ev.point);
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 || undefined === this.current)
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: 1, columnIndex: 0 });
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,464 @@ 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 sweep angle and secondary radius */
844
+ CreateTorusPhase[CreateTorusPhase["AcceptAngle"] = 2] = "AcceptAngle";
845
+ /** Current tool phase to accept result */
846
+ CreateTorusPhase[CreateTorusPhase["AcceptResult"] = 3] = "AcceptResult";
847
+ })(CreateTorusPhase = exports.CreateTorusPhase || (exports.CreateTorusPhase = {}));
848
+ /** @alpha Creates a torus pipe. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
849
+ class CreateTorusTool extends SolidPrimitiveTool {
850
+ constructor() {
851
+ super(...arguments);
852
+ this.createPhase = CreateTorusPhase.AcceptStart;
853
+ }
854
+ provideToolAssistance(mainInstrText, additionalInstr) {
855
+ switch (this.createPhase) {
856
+ case CreateTorusPhase.AcceptStart:
857
+ mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.StartPoint");
858
+ break;
859
+ case CreateTorusPhase.AcceptCenter:
860
+ mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.CenterPoint");
861
+ break;
862
+ default:
863
+ mainInstrText = EditTool_1.EditTools.translate("CreateTorus.Prompts.AnglePoint");
864
+ break;
865
+ }
866
+ super.provideToolAssistance(mainInstrText, additionalInstr);
867
+ }
868
+ setupAccuDraw() {
869
+ const nPts = this.accepted.length;
870
+ if (0 === nPts)
871
+ return;
872
+ const hints = new core_frontend_1.AccuDrawHintBuilder();
873
+ if (CreateTorusPhase.AcceptCenter === this.createPhase) {
874
+ hints.setOrigin(this.accepted[0]);
875
+ }
876
+ else if (CreateTorusPhase.AcceptAngle === this.createPhase && 2 === nPts) {
877
+ hints.setModePolar();
878
+ hints.setOrigin(this.accepted[1]);
879
+ hints.setOriginFixed = true;
880
+ if (undefined !== this.baseRotation)
881
+ hints.setMatrix(this.baseRotation);
882
+ }
883
+ hints.sendHints();
884
+ }
885
+ get usePrimaryRadiusProperty() {
886
+ if (!this._usePrimaryRadiusProperty)
887
+ this._usePrimaryRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusPrimaryRadius"), false);
888
+ return this._usePrimaryRadiusProperty;
889
+ }
890
+ get usePrimaryRadius() { return this.usePrimaryRadiusProperty.value; }
891
+ set usePrimaryRadius(value) { this.usePrimaryRadiusProperty.value = value; }
892
+ get primaryRadiusProperty() {
893
+ if (!this._primaryRadiusProperty)
894
+ 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);
895
+ return this._primaryRadiusProperty;
896
+ }
897
+ get primaryRadius() { return this.primaryRadiusProperty.value; }
898
+ set primaryRadius(value) { this.primaryRadiusProperty.value = value; }
899
+ get useSecondaryRadiusProperty() {
900
+ if (!this._useSecondaryRadiusProperty)
901
+ this._useSecondaryRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusSecondaryRadius"), false);
902
+ return this._useSecondaryRadiusProperty;
903
+ }
904
+ get useSecondaryRadius() { return this.useSecondaryRadiusProperty.value; }
905
+ set useSecondaryRadius(value) { this.useSecondaryRadiusProperty.value = value; }
906
+ get secondaryRadiusProperty() {
907
+ if (!this._secondaryRadiusProperty)
908
+ 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);
909
+ return this._secondaryRadiusProperty;
910
+ }
911
+ get secondaryRadius() { return this.secondaryRadiusProperty.value; }
912
+ set secondaryRadius(value) { this.secondaryRadiusProperty.value = value; }
913
+ get useAngleProperty() {
914
+ if (!this._useAngleProperty)
915
+ this._useAngleProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useTorusAngle"), false);
916
+ return this._useAngleProperty;
917
+ }
918
+ get useAngle() { return this.useAngleProperty.value; }
919
+ set useAngle(value) { this.useAngleProperty.value = value; }
920
+ get angleProperty() {
921
+ if (!this._angleProperty)
922
+ 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);
923
+ return this._angleProperty;
924
+ }
925
+ get angle() { return this.angleProperty.value; }
926
+ set angle(value) { this.angleProperty.value = value; }
927
+ get cappedProperty() {
928
+ if (!this._cappedProperty)
929
+ this._cappedProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("torusCapped", EditTool_1.EditTools.translate("CreateTorus.Label.Capped")), true);
930
+ return this._cappedProperty;
931
+ }
932
+ get capped() { return this.cappedProperty.value; }
933
+ set capped(value) { this.cappedProperty.value = value; }
934
+ isComplete(_ev) {
935
+ return (CreateTorusPhase.AcceptResult === this.createPhase);
936
+ }
937
+ async updateElementData(ev, isDynamics) {
938
+ const vp = this.targetView;
939
+ if (undefined === vp)
940
+ return;
941
+ switch (this.createPhase) {
942
+ case CreateTorusPhase.AcceptStart: {
943
+ if (isDynamics)
944
+ break;
945
+ this.accepted.push(ev.point.clone());
946
+ this.createPhase = CreateTorusPhase.AcceptCenter;
947
+ break;
948
+ }
949
+ case CreateTorusPhase.AcceptCenter: {
950
+ this.baseRotation = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
951
+ const normal = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
952
+ const vector0 = core_geometry_1.Vector3d.createStartEnd(ev.point, this.accepted[0]);
953
+ const vector90 = normal.crossProduct(vector0);
954
+ const primaryRadius = (this.usePrimaryRadius ? this.primaryRadius : vector0.magnitude());
955
+ if (!this.usePrimaryRadius) {
956
+ this.primaryRadius = primaryRadius;
957
+ this.syncToolSettingPropertyValue(this.primaryRadiusProperty);
958
+ }
959
+ if (undefined === vector0.scaleToLength(primaryRadius, vector0) || undefined === vector90.scaleToLength(primaryRadius, vector90)) {
960
+ this.current = undefined;
961
+ this.clearGraphics();
962
+ return;
963
+ }
964
+ const center = this.accepted[0].plus(vector0.negate());
965
+ const allowComplete = (this.useSecondaryRadius && this.useAngle && (2 * Math.PI) === this.angle);
966
+ if (allowComplete) {
967
+ vector0.normalizeInPlace();
968
+ vector90.normalizeInPlace();
969
+ this.current = core_geometry_1.TorusPipe.createDgnTorusPipe(center, vector0, vector90, primaryRadius, this.secondaryRadius, core_geometry_1.Angle.createRadians(this.angle), this.capped);
970
+ if (undefined === this.current) {
971
+ this.clearGraphics();
972
+ break;
973
+ }
974
+ if (!isDynamics)
975
+ this.createPhase = CreateTorusPhase.AcceptResult;
976
+ break;
977
+ }
978
+ const arc = core_geometry_1.Arc3d.create(center, vector0, vector90);
979
+ this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
980
+ this.current = arc;
981
+ if (isDynamics)
982
+ break;
983
+ this.accepted.push(arc.center); // Add center to accepted points for AccuDraw hints...
984
+ this.createPhase = CreateTorusPhase.AcceptAngle;
985
+ break;
986
+ }
987
+ case CreateTorusPhase.AcceptAngle: {
988
+ const vector90 = core_geometry_1.Vector3d.createStartEnd(this.accepted[1], ev.point);
989
+ const secondaryRadius = (this.useSecondaryRadius ? this.secondaryRadius : Math.min(this.primaryRadius, Math.abs(this.primaryRadius - vector90.magnitude())));
990
+ if (!this.useSecondaryRadius) {
991
+ this.secondaryRadius = secondaryRadius;
992
+ this.syncToolSettingPropertyValue(this.secondaryRadiusProperty);
993
+ }
994
+ const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : core_geometry_1.Vector3d.unitX();
995
+ const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : core_geometry_1.Vector3d.unitY();
996
+ const zAxis = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
997
+ const prevSweep = core_geometry_1.Angle.createRadians(this.angle);
998
+ const sweep = xAxis.planarAngleTo(vector90, zAxis);
999
+ 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)))
1000
+ prevSweep.setRadians(-prevSweep.radians); // Reverse direction...
1001
+ if (sweep.isAlmostZero)
1002
+ sweep.setDegrees(prevSweep.radians < 0.0 ? -360.0 : 360.0); // Create full sweep...
1003
+ if (this.useAngle) {
1004
+ if ((sweep.radians < 0.0 && this.angle > 0.0) || (sweep.radians > 0.0 && this.angle < 0.0))
1005
+ sweep.setRadians(-this.angle);
1006
+ else
1007
+ sweep.setRadians(this.angle);
1008
+ }
1009
+ else {
1010
+ if (sweep.radians < 0.0 && prevSweep.radians > 0.0)
1011
+ sweep.setRadians(core_geometry_1.Angle.pi2Radians + sweep.radians);
1012
+ else if (sweep.radians > 0.0 && prevSweep.radians < 0.0)
1013
+ sweep.setRadians(-(core_geometry_1.Angle.pi2Radians - sweep.radians));
1014
+ this.angle = sweep.radians;
1015
+ this.syncToolSettingPropertyValue(this.angleProperty);
1016
+ }
1017
+ this.current = core_geometry_1.TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, secondaryRadius, sweep, this.capped);
1018
+ if (undefined === this.current) {
1019
+ this.clearGraphics();
1020
+ break;
1021
+ }
1022
+ if (!isDynamics)
1023
+ this.createPhase = CreateTorusPhase.AcceptResult;
1024
+ break;
1025
+ }
1026
+ }
1027
+ }
1028
+ getToolSettingPropertyLocked(property) {
1029
+ if (property === this.usePrimaryRadiusProperty)
1030
+ return this.primaryRadiusProperty;
1031
+ else if (property === this.useSecondaryRadiusProperty)
1032
+ return this.secondaryRadiusProperty;
1033
+ else if (property === this.useAngleProperty)
1034
+ return this.angleProperty;
1035
+ return undefined;
1036
+ }
1037
+ async applyToolSettingPropertyChange(updatedValue) {
1038
+ return this.changeToolSettingPropertyValue(updatedValue);
1039
+ }
1040
+ supplyToolSettingsProperties() {
1041
+ this.initializeToolSettingPropertyValues([this.primaryRadiusProperty, this.usePrimaryRadiusProperty, this.secondaryRadiusProperty, this.useSecondaryRadiusProperty, this.angleProperty, this.useAngleProperty, this.cappedProperty]);
1042
+ const toolSettings = new Array();
1043
+ this.primaryRadiusProperty.isDisabled = !this.usePrimaryRadius;
1044
+ const usePrimaryRadiusLock = this.usePrimaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
1045
+ toolSettings.push(this.primaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, usePrimaryRadiusLock));
1046
+ this.secondaryRadiusProperty.isDisabled = !this.useSecondaryRadius;
1047
+ const useSecondaryRadiusLock = this.useSecondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
1048
+ toolSettings.push(this.secondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useSecondaryRadiusLock));
1049
+ this.angleProperty.isDisabled = !this.useAngle;
1050
+ const useAngleLock = this.useAngleProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
1051
+ toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useAngleLock));
1052
+ toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
1053
+ return toolSettings;
1054
+ }
1055
+ async onRestartTool() {
1056
+ const tool = new CreateTorusTool();
1057
+ if (!await tool.run())
1058
+ return this.exitTool();
1059
+ }
1060
+ }
1061
+ exports.CreateTorusTool = CreateTorusTool;
1062
+ CreateTorusTool.toolId = "CreateTorus";
1063
+ CreateTorusTool.iconSpec = "icon-circle"; // TODO: Need better icon...
605
1064
  //# sourceMappingURL=SolidPrimitiveTools.js.map