Example #1
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;

            InstanceGroup sel = stage.Selection;

            stage.RemoveInstancesById(instanceIds);
            sel.Set(prevSelected);
            stage.ResetTransformHandles();
            stage.InvalidateTransformedSelection();
        }
Example #2
0
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;
            //DDW.Display.DesignTimeline curEditItem = stage.CurrentEditItem;
            InstanceGroup sel = stage.Selection;

            stage.RemoveInstancesById(newInstances);

            for (int i = 0; i < prevInstances.Length; i++)
            {
                stage.InsertExistingInstance(prevDepths[i], MainForm.CurrentInstanceManager[prevInstances[i]]);
            }

            sel.Set(prevSelection);
            stage.ResetTransformHandles();
            stage.InvalidateSelection();
        }
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            // store old selection
            prevSelected = stage.Selection.IdsByDepth;// SelectedIds;
            prevOffset   = stage.Selection.StrokeBounds.Point;


            // create symbol from selected
            Vex.Timeline tl = new Vex.Timeline(stage.Library.NextLibraryId());

            tl.Name         = stage.Library.GetNextDefaultName();
            tl.StrokeBounds = stage.Selection.StrokeBounds.TranslatedRectangle(-prevOffset.X, -prevOffset.Y);

            // delete old symbols
            DesignInstance[] oldInstances = stage.RemoveInstancesById(prevSelected);

            for (int i = 0; i < prevSelected.Length; i++)
            {
                DesignInstance inst = oldInstances[i];// instMgr[prevSelected[i]];
                Vex.Matrix     m    = inst.GetMatrix();
                m.TranslateX -= prevOffset.X;
                m.TranslateY -= prevOffset.Y;
                inst.SetMatrix(m);
                tl.AddInstance(inst.Instance);
                stage.InstanceManager.AddInstance(inst); // reusing, so must readd (todo: don't  reuse ids?)
            }

            LibraryItem li = stage.CreateLibraryItem(tl, true);

            newLibraryItemId = li.DefinitionId;
            stage.Library.AddLibraryItem(li);
            LibraryView.CurrentLibraryView.AddItemToLibrary(li);

            // add new symbol to stage
            DesignInstance di = stage.AddInstance(tl.Id, prevOffset);

            newInstanceId = di.InstanceHash;

            // select new symbol
            stage.Selection.Set(new uint[] { di.InstanceHash });
            stage.ResetTransformHandles();
            stage.InvalidateSelection();
        }
Example #4
0
        public void Execute()
        {
            StageView     stage = MainForm.CurrentStage;
            InstanceGroup sel   = stage.Selection;

            prevSelected = sel.SelectedIds;
            if (instanceIds == null)
            {
                instanceIds = stage.AddInstances(libraryIds, locations);
            }
            else
            {
                stage.AddInstancesById(instanceIds);
            }

            sel.Set(instanceIds);
            stage.ResetTransformHandles();
            stage.InvalidateTransformedSelection();
        }
Example #5
0
        public void Execute()
        {
            StageView stage = MainForm.CurrentStage;

            InstanceGroup sel = stage.Selection;

            this.prevSelected = sel.SelectedIds;

            Vex.Point selRotCent = sel.GlobalRotationCenter.Translate(sel.Location.Negate());

            uint[]      libraryIds = new uint[prevSelected.Length];
            Vex.Point[] locations  = new Vex.Point[prevSelected.Length];
            for (int i = 0; i < prevSelected.Length; i++)
            {
                DesignInstance di = MainForm.CurrentInstanceManager[prevSelected[i]];
                libraryIds[i] = di.LibraryItem.DefinitionId;
                locations[i]  = new Vex.Point(di.Location.X + offset.X, di.Location.Y + offset.Y);
            }

            if (newInstanceIds == null)
            {
                newInstanceIds = stage.AddInstances(libraryIds, locations);
                for (int i = 0; i < newInstanceIds.Length; i++)
                {
                    DesignInstance oldDi = MainForm.CurrentInstanceManager[prevSelected[i]];
                    DesignInstance newDi = MainForm.CurrentInstanceManager[newInstanceIds[i]];
                    Vex.Matrix     m     = oldDi.GetMatrix();
                    stage.SetDesignInstanceMatrix(newDi, new Vex.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, newDi.Location.X, newDi.Location.Y));

                    newDi.RotationCenter = oldDi.RotationCenter;
                }
            }
            else
            {
                stage.AddInstancesById(newInstanceIds);
            }

            sel.Set(newInstanceIds);
            sel.GlobalRotationCenter = selRotCent.Translate(sel.Location);
            stage.ResetTransformHandles();
            stage.InvalidateTransformedSelection();
        }
        public void UnExecute()
        {
            StageView stage = MainForm.CurrentStage;

            stage.Selection.Clear();
            stage.RemoveInstancesById(new uint[] { newInstanceId });
            LibraryView.CurrentLibraryView.RemoveItemFromLibrary(newLibraryItemId);

            stage.AddInstancesById(prevSelected);

            for (int i = 0; i < prevSelected.Length; i++)
            {
                DesignInstance inst = stage.InstanceManager[prevSelected[i]];
                Vex.Matrix     m    = inst.GetMatrix();
                m.TranslateX += prevOffset.X;
                m.TranslateY += prevOffset.Y;
                stage.SetDesignInstanceMatrix(inst, m);
            }

            stage.Selection.Set(prevSelected);
            stage.ResetTransformHandles();
        }
Example #7
0
        public void Execute()
        {
            StageView       stage   = MainForm.CurrentStage;
            InstanceGroup   sel     = stage.Selection;
            InstanceManager instMgr = stage.InstanceManager;

            prevSelection = sel.IdsByDepth;
            List <uint> addedInstances = new List <uint>();

            List <uint> newSelection   = new List <uint>();
            List <uint> toBreakApart   = new List <uint>();
            List <int>  originalDepths = new List <int>();

            for (int i = 0; i < prevSelection.Length; i++)
            {
                DesignInstance di = instMgr[prevSelection[i]];
                if (CanBreakApart(di))
                {
                    toBreakApart.Add(prevSelection[i]);
                    originalDepths.Add(di.Depth);
                }
                else
                {
                    newSelection.Add(prevSelection[i]);
                }
            }

            prevInstances = toBreakApart.ToArray();
            prevDepths    = originalDepths.ToArray();

            sel.Clear();
            for (int i = 0; i < toBreakApart.Count; i++)
            {
                uint           id        = toBreakApart[i];
                DesignInstance di        = instMgr[id];
                int            orgDepth  = di.Depth;
                Matrix         orgMatrix = di.GetSysMatrix();

                Vex.Point offset    = di.Location;
                uint[]    instances = ((DesignTimeline)di).InstanceIds;

                for (int j = instances.Length - 1; j >= 0; j--)
                {
                    DesignInstance orgInstance = instMgr[instances[j]];
                    uint           subLibId    = orgInstance.LibraryItem.DefinitionId;
                    DesignInstance inst        = stage.AddInstance(subLibId, Vex.Point.Zero);
                    stage.CurrentEditItem.ChangeDepth(inst.Depth, orgDepth);

                    using (Matrix m = orgInstance.GetSysMatrix().Clone())
                    {
                        m.Multiply(orgMatrix, MatrixOrder.Append);
                        stage.SetDesignInstanceMatrix(inst, m.VexMatrix());
                    }

                    addedInstances.Add(inst.InstanceHash);
                    newSelection.Add(inst.InstanceHash);
                }
                stage.RemoveInstancesById(new uint[] { id });
            }

            newInstances = addedInstances.ToArray();
            sel.Set(newSelection.ToArray());
            stage.ResetTransformHandles();
        }