discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

rotateSymbolCommand function

CompoundCommand? rotateSymbolCommand(
  1. DraftDocument doc,
  2. Handle instance,
  3. double degrees
)

The Rotate step for instance (D7), or null when nothing changes.

Implementation

CompoundCommand? rotateSymbolCommand(
    DraftDocument doc, Handle instance, double degrees) {
  final node = doc.tree[instance];
  if (node is! InstanceNode || !degrees.isFinite) return null;
  final def = doc.tree.definition(node.definition);
  if (def == null) return null;
  // Already there, within the field's display step: the shown value
  // committed again is nothing.
  var diff = (degrees - rotationDegreesOf(node.transform)) % 360;
  if (diff < 0) diff += 360;
  final steps = diff * kRotationStepsPerDegree;
  if (steps < 1 || steps > 360 * kRotationStepsPerDegree - 1) return null;
  final next = rotatedTo(node.transform, def.basePoint, degrees);
  if (_same(next, node.transform)) return null;
  return CompoundCommand([TransformNodeCommand(instance, next)],
      label: 'Rotate');
}