示例#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);
        }
示例#2
0
        public void AddCentroid()
        {
            Centroid cent = PlotterUtil.Centroid(DB.GetSelectedFigList());

            if (cent.IsInvalid)
            {
                return;
            }

            CadFigure pointFig = mDB.NewFigure(CadFigure.Types.POINT);

            pointFig.AddPoint((CadVertex)cent.Point);

            pointFig.EndCreate(DC);

            CadOpe ope = new CadOpeAddFigure(CurrentLayer.ID, pointFig.ID);

            HistoryMan.foward(ope);
            CurrentLayer.AddFigure(pointFig);

            string s = string.Format("({0:0.000},{1:0.000},{2:0.000})",
                                     cent.Point.X, cent.Point.Y, cent.Point.Z);

            ItConsole.println("Centroid:" + s);
            ItConsole.println("Area:" + (cent.Area / 100).ToString() + "(㎠)");
        }
示例#3
0
        public void SetLoop(bool isLoop)
        {
            List <uint> list = DB.GetSelectedFigIDList();

            CadOpeList opeRoot = new CadOpeList();
            CadOpe     ope;

            foreach (uint id in list)
            {
                CadFigure fig = DB.GetFigure(id);

                if (fig.Type != CadFigure.Types.POLY_LINES)
                {
                    continue;
                }

                if (fig.IsLoop != isLoop)
                {
                    fig.IsLoop = isLoop;

                    if (isLoop)
                    {
                        fig.RecalcNormal();
                    }

                    ope = new CadOpeSetClose(CurrentLayer.ID, id, isLoop);
                    opeRoot.OpeList.Add(ope);
                }
            }

            HistoryMan.foward(opeRoot);
        }
示例#4
0
        private void ChangeLayerFigList(CadLayer layer, List <CadFigure> newFigList)
        {
            HistoryMan.foward(new CadOpeChangeFigureList(layer, layer.FigureList, newFigList));

            layer.FigureList = newFigList;

            Callback.UpdateObjectTree(true);
        }
示例#5
0
        public void ClearAll()
        {
            PageSize = new PaperPageSize();

            mDB.ClearAll();
            HistoryMan.Clear();

            UpdateLayerList();
            UpdateObjectTree(true);
        }
示例#6
0
        public void ClearLayer(uint layerID)
        {
            if (layerID == 0)
            {
                layerID = CurrentLayer.ID;
            }

            CadLayer layer = mDB.GetLayer(layerID);

            if (layer == null)
            {
                return;
            }

            CadOpeList opeList = layer.Clear();

            HistoryMan.foward(opeList);
        }
示例#7
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);
        }
示例#8
0
        public void RemoveLayer(uint id)
        {
            if (mDB.LayerList.Count == 1)
            {
                return;
            }

            CadLayer layer = mDB.GetLayer(id);

            if (layer == null)
            {
                return;
            }

            int index = mDB.LayerIndex(id);

            int nextCurrentIdx = -1;

            if (CurrentLayer.ID == id)
            {
                nextCurrentIdx = mDB.LayerIndex(CurrentLayer.ID);
            }

            CadOpeRemoveLayer ope = new CadOpeRemoveLayer(layer, index);

            HistoryMan.foward(ope);

            mDB.RemoveLayer(id);

            if (nextCurrentIdx >= 0)
            {
                if (nextCurrentIdx > mDB.LayerList.Count - 1)
                {
                    nextCurrentIdx = mDB.LayerList.Count - 1;
                }

                CurrentLayer = mDB.LayerList[nextCurrentIdx];
            }

            UpdateLayerList();
            ItConsole.println("Layer removed.  Name:" + layer.Name + " ID:" + layer.ID);
        }
示例#9
0
        public void FlipNormal()
        {
            List <uint> ids = DB.GetSelectedFigIDList();

            CadOpeList opeList = new CadOpeList();

            foreach (uint id in ids)
            {
                CadFigure fig = mDB.GetFigure(id);
                Vector3d  old = fig.Normal;

                fig.Normal *= -1;

                CadOpe ope = new CadOpeChangeNormal(id, old, fig.Normal);
                opeList.Add(ope);
            }


            HistoryMan.foward(opeList);
        }
示例#10
0
        public void EndEdit(List <CadFigure> targetList)
        {
            foreach (CadFigure fig in targetList)
            {
                if (fig != null)
                {
                    fig.EndEdit();
                }
            }

            CadOpeList root = new CadOpeList();

            CadOpeList rmOpeList = RemoveInvalidFigure();

            root.Add(rmOpeList);

            mSnapShotList.StoreAfter(DB);
            root.Add(mSnapShotList);

            HistoryMan.foward(root);

            mSnapShotList = null;
        }
示例#11
0
        public bool ToBezier(MarkSegment seg)
        {
            if (seg.FigureID == 0)
            {
                return(false);
            }

            CadFigure fig = mDB.GetFigure(seg.FigureID);

            int num = CadUtil.InsertBezierHandle(fig, seg.PtIndexA, seg.PtIndexB);

            bool ret = num > 0;

            if (ret)
            {
                CadOpe ope = new CadOpeInsertPoints(
                    fig.LayerID, fig.ID, seg.PtIndexA + 1, num);

                HistoryMan.foward(ope);
            }

            return(ret);
        }