Example #1
0
        public void SeparateFigures(CadFigure fig, int pointIdx)
        {
            var res = CadFigureCutter.Cut(mDB, fig, pointIdx);

            if (!res.isValid())
            {
                return;
            }

            CadOpeList opeRoot = new CadOpeList();
            CadOpe     ope;

            foreach (EditResult.Item ri in res.AddList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeAddFigure(ri.LayerID, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.AddFigure(ri.Figure);
            }

            foreach (EditResult.Item ri in res.RemoveList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeRemoveFigure(layer, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.RemoveFigureByID(ri.FigureID);
            }

            HistoryMan.foward(opeRoot);
        }
Example #2
0
        public void CutSegment(MarkSegment ms)
        {
            if (!ms.Valid)
            {
                return;
            }

            if (!ms.CrossPoint.IsValid())
            {
                return;
            }

            var res = CadSegmentCutter.CutSegment(mDB, ms, ms.CrossPoint);

            if (!res.isValid())
            {
                return;
            }

            CadOpeList opeRoot = new CadOpeList();
            CadOpe     ope;

            foreach (EditResult.Item ri in res.AddList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeAddFigure(ri.LayerID, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.AddFigure(ri.Figure);
            }

            foreach (EditResult.Item ri in res.RemoveList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeRemoveFigure(layer, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.RemoveFigureByID(ri.FigureID);
            }

            HistoryMan.foward(opeRoot);
        }