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

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.
@@ -832,10 +832,12 @@ export var CreateTorusPhase;
832
832
  CreateTorusPhase[CreateTorusPhase["AcceptStart"] = 0] = "AcceptStart";
833
833
  /** Current tool phase to define center point */
834
834
  CreateTorusPhase[CreateTorusPhase["AcceptCenter"] = 1] = "AcceptCenter";
835
- /** Current tool phase to define sweep angle and secondary radius */
836
- CreateTorusPhase[CreateTorusPhase["AcceptAngle"] = 2] = "AcceptAngle";
835
+ /** Current tool phase to define secondary radius */
836
+ CreateTorusPhase[CreateTorusPhase["AcceptSecondaryRadius"] = 2] = "AcceptSecondaryRadius";
837
+ /** Current tool phase to define sweep angle */
838
+ CreateTorusPhase[CreateTorusPhase["AcceptAngle"] = 3] = "AcceptAngle";
837
839
  /** Current tool phase to accept result */
838
- CreateTorusPhase[CreateTorusPhase["AcceptResult"] = 3] = "AcceptResult";
840
+ CreateTorusPhase[CreateTorusPhase["AcceptResult"] = 4] = "AcceptResult";
839
841
  })(CreateTorusPhase || (CreateTorusPhase = {}));
840
842
  /** @alpha Creates a torus pipe. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
841
843
  export class CreateTorusTool extends SolidPrimitiveTool {
@@ -851,6 +853,9 @@ export class CreateTorusTool extends SolidPrimitiveTool {
851
853
  case CreateTorusPhase.AcceptCenter:
852
854
  mainInstrText = EditTools.translate("CreateTorus.Prompts.CenterPoint");
853
855
  break;
856
+ case CreateTorusPhase.AcceptSecondaryRadius:
857
+ mainInstrText = EditTools.translate("CreateTorus.Prompts.SecondaryRadiusPoint");
858
+ break;
854
859
  default:
855
860
  mainInstrText = EditTools.translate("CreateTorus.Prompts.AnglePoint");
856
861
  break;
@@ -865,6 +870,13 @@ export class CreateTorusTool extends SolidPrimitiveTool {
865
870
  if (CreateTorusPhase.AcceptCenter === this.createPhase) {
866
871
  hints.setOrigin(this.accepted[0]);
867
872
  }
873
+ else if (CreateTorusPhase.AcceptSecondaryRadius === this.createPhase) {
874
+ hints.setModePolar();
875
+ hints.setOrigin(this.accepted[0]);
876
+ hints.setOriginFixed = true;
877
+ if (undefined !== this.baseRotation)
878
+ hints.setMatrix(Matrix3d.createColumns(this.baseRotation.getColumn(0), this.baseRotation.getColumn(2), this.baseRotation.getColumn(1)));
879
+ }
868
880
  else if (CreateTorusPhase.AcceptAngle === this.createPhase && 2 === nPts) {
869
881
  hints.setModePolar();
870
882
  hints.setOrigin(this.accepted[1]);
@@ -973,18 +985,38 @@ export class CreateTorusTool extends SolidPrimitiveTool {
973
985
  if (isDynamics)
974
986
  break;
975
987
  this.accepted.push(arc.center); // Add center to accepted points for AccuDraw hints...
976
- this.createPhase = CreateTorusPhase.AcceptAngle;
988
+ this.createPhase = (this.useSecondaryRadius ? CreateTorusPhase.AcceptAngle : CreateTorusPhase.AcceptSecondaryRadius);
977
989
  break;
978
990
  }
979
- case CreateTorusPhase.AcceptAngle: {
980
- const vector90 = Vector3d.createStartEnd(this.accepted[1], ev.point);
981
- const secondaryRadius = (this.useSecondaryRadius ? this.secondaryRadius : Math.min(this.primaryRadius, Math.abs(this.primaryRadius - vector90.magnitude())));
991
+ case CreateTorusPhase.AcceptSecondaryRadius: {
992
+ const vector0 = Vector3d.createStartEnd(this.accepted[0], ev.point);
993
+ const secondaryRadius = (this.useSecondaryRadius ? this.secondaryRadius : Math.min(this.primaryRadius, vector0.magnitude()));
982
994
  if (!this.useSecondaryRadius) {
983
995
  this.secondaryRadius = secondaryRadius;
984
996
  this.syncToolSettingPropertyValue(this.secondaryRadiusProperty);
985
997
  }
986
998
  const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
987
999
  const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
1000
+ if (undefined === vector0.scaleToLength(secondaryRadius, vector0)) {
1001
+ xAxis.scaleToLength(this.primaryRadius, xAxis);
1002
+ yAxis.scaleToLength(this.primaryRadius, yAxis);
1003
+ this.current = Arc3d.create(this.accepted[1], xAxis, yAxis);
1004
+ return;
1005
+ }
1006
+ const sweep = Angle.createRadians(this.useAngle ? this.angle : 2 * Math.PI);
1007
+ this.current = TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, secondaryRadius, sweep, this.capped);
1008
+ if (undefined === this.current) {
1009
+ this.clearGraphics();
1010
+ break;
1011
+ }
1012
+ if (!isDynamics)
1013
+ this.createPhase = ((this.useAngle && (2 * Math.PI) === this.angle) ? CreateTorusPhase.AcceptResult : CreateTorusPhase.AcceptAngle);
1014
+ break;
1015
+ }
1016
+ case CreateTorusPhase.AcceptAngle: {
1017
+ const vector90 = Vector3d.createStartEnd(this.accepted[1], ev.point);
1018
+ const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
1019
+ const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
988
1020
  const zAxis = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
989
1021
  const prevSweep = Angle.createRadians(this.angle);
990
1022
  const sweep = xAxis.planarAngleTo(vector90, zAxis);
@@ -1006,7 +1038,7 @@ export class CreateTorusTool extends SolidPrimitiveTool {
1006
1038
  this.angle = sweep.radians;
1007
1039
  this.syncToolSettingPropertyValue(this.angleProperty);
1008
1040
  }
1009
- this.current = TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, secondaryRadius, sweep, this.capped);
1041
+ this.current = TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, this.secondaryRadius, sweep, this.capped);
1010
1042
  if (undefined === this.current) {
1011
1043
  this.clearGraphics();
1012
1044
  break;