public override void Save(SaveContext saveContext) { var utility = saveContext.Utility; base.Save(saveContext); utility.Write(Unknown1); utility.Write(BranchVisible); // FIXME according to SPICA this is an arbitrary list of child "GfxObjects" (AKA ChunkDICTObject in my world) // Dunno if it's freeform (unlikely) or has context to specific types (in which case we'll need some clever implementation) utility.Write(ChildCount); // ??? utility.Write(ChildOffset); // Offset to pointer list (?) of children I assume if (ChildCount != 0 && ChildOffset != 0) { throw new NotImplementedException("Child objects not implemented"); } saveContext.WriteDICTPointerPlaceholder(AnimGroup); TransformScale.Write(utility); TransformRotate.Write(utility); TransformTranslate.Write(utility); LocalMatrix.Write(utility); WorldMatrix.Write(utility); }
private void btnDoRotate_Click(object sender, EventArgs e) { int angle = 0; Page page = Globals.Root.CurrentPage; if (txtAngle.IsValidAndNotEmpty) { angle = txtAngle.Value; } if (angle == 0 || angle <= -360 || angle >= 360) { MessageBox.Show(Strings.Item("SAW_Rotate_BadAngle")); return; } // this can use the point in the page, rather than the GUI, since the GUI updates the page automatically if (rdoPoint.Checked && !page.RecentRotationPoints.Any()) { MessageBox.Show(Strings.Item("SAW_Rotate_NoPosition")); return; } if (page.SelectedShapes.Any(s => (s.Allows & Shape.AllowedActions.TransformRotate) == 0)) { MessageBox.Show(Strings.Item("SAW_Rotate_Cannot")); return; } TransformRotate rotate = new TransformRotate(page.RecentRotationPoints.FirstOrDefault(), Geometry.Radians(angle)); Transaction transaction = new Transaction(); if (rdoPoint.Checked) { page.RotationPointUsed = true; } foreach (Shape s in page.SelectedShapes) { transaction.Edit(s); rotate.DoTransform(s); } Globals.Root.StoreNewTransaction(transaction, true); }
private void Globals_ApplicabilityChanged() { btnDoRotate.Enabled = (Globals.Root.CurrentPage?.SelectedCount ?? 0) > 0 && (TransformRotate.IncludeText || Globals.Root.CurrentPage.Any(s => !TransformRotate.ShapeCountsAsText(s))); }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { if (CurrentPage == null || CurrentPage.SelectedCount < 1) { return; } bool reflect = false; bool rotate = false; switch (Code) { case Codes.FlipHorizontal: case Codes.FlipVertical: reflect = true; break; case Codes.RotateLeft: case Codes.RotateRight: rotate = true; break; default: Utilities.LogSubError("Unexpected verb in DoQuickTransform"); return; } RectangleF bounds = RectangleF.Empty; // not using Page.SelectedBounds as I think it might be better to use the minimal bounds SizeF totalSize = SizeF.Empty; foreach (Shape shape in CurrentPage.SelectedShapes) { RectangleF shapeBounds = shape.MinimalBounds; Geometry.Extend(ref bounds, shapeBounds); if (reflect && (shape.Allows & (Shape.AllowedActions.TransformMirror | Shape.AllowedActions.MirrorFlipOnly)) == 0) { MessageBox.Show(Strings.Item("Cannot_Reflect")); return; } if (rotate && (shape.Allows & Shape.AllowedActions.TransformRotate) == 0) { MessageBox.Show(Strings.Item("Cannot_Rotate")); return; } totalSize += shapeBounds.Size; } Transformation transformation; PointF middle = new PointF((bounds.Left + bounds.Right) / 2, (bounds.Top + bounds.Bottom) / 2); switch (Code) { case Codes.FlipHorizontal: transformation = new TransformMirror(middle, middle + new SizeF(0, 100)); break; // second point is arbitrary as long as it is on the necessary vertical line case Codes.FlipVertical: transformation = new TransformMirror(middle, middle + new SizeF(100, 0)); break; case Codes.RotateLeft: transformation = new TransformRotate(middle, -Geometry.ANGLE90); break; case Codes.RotateRight: transformation = new TransformRotate(middle, Geometry.ANGLE90); break; default: Utilities.LogSubError("Unexpected verb in DoQuickTransform"); return; } DoTransformForVerb(transformation, transaction); }