Exemplo n.º 1
0
        private void SetProtectionMethods(List <SlopeLine> slopeLines, string protMethod, int[] slopeLevels)
        {
            // 提取规则
            var fp = new ForceProtection(protMethod, slopeLevels);
            var es = EditStateIdentifier.GetCurrentEditState(_docMdf);

            es.CurrentBTR.UpgradeOpen();
            //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope);
            //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform);

            // 先修改内存中的防护
            foreach (var slp in slopeLines)
            {
                slp.ForceProtect(fp);
            }
            // 再刷新到 AutoCAD 文档与界面中
            var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, slopeLines);

            foreach (var slp in slopeLines)
            {
                // 将数据刷新到界面与边坡线中
                slp.Pline.UpgradeOpen();
                slp.PrintProtectionMethod(es.CurrentBTR, protLayers);
                slp.FlushXData();
                slp.Pline.DowngradeOpen();
            }
            _docMdf.acEditor.UpdateScreen();
        }
Exemplo n.º 2
0
 private void PF_ModifyProtText_Load(object sender, EventArgs e)
 {
     // 列出所有的防护图层
     _protLayers = ProtectionTags.GetProtLayersInDatabase(_docMdf.acDataBase);
     _protLayers.Add(@"所有", "");
     //
     protLayerLister1.ImportItems(_protLayers.Keys.ToArray(), _protLayers.Values.ToArray());
 }
Exemplo n.º 3
0
        /// <summary> 将分割开的多个子边坡进行合并 </summary>
        public ExternalCmdResult MergeSlopeSegs(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;
            SQUtils.SubgradeEnvironmentConfiguration(docMdf);
            //
            var selectedSlopes = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true);

            if (selectedSlopes == null || selectedSlopes.Count == 0)
            {
                return(ExternalCmdResult.Cancel);
            }
            //
            MergeProtectionDirection dir;
            var succ = GetProtectionDirection(docMdf, out dir);

            if (!succ)
            {
                return(ExternalCmdResult.Cancel);
            }
            //
            //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope);
            //var layer_WaterLine = Utils.GetOrCreateLayer_WaterLine(_docMdf);
            //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform);
            var es = EditStateIdentifier.GetCurrentEditState(_docMdf);

            es.CurrentBTR.UpgradeOpen();

            bool haveSegsMerged = false;
            int  mergedCount    = 0;

            docMdf.WriteLineIntoDebuger("合并的边坡对象:");

            var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, selectedSlopes);

            foreach (var slp in selectedSlopes)
            {
                haveSegsMerged = MergeSlope(slp.XData, dir);
                if (haveSegsMerged)
                {
                    // 将刷新后的数据保存到 AutoCAD 文档与界面中
                    slp.Pline.UpgradeOpen();
                    //
                    slp.ClearAllWaterlines(_docMdf.acDataBase);
                    SlopeConstructor.SetSlopeUI(slp);
                    slp.PrintProtectionMethod(es.CurrentBTR, protLayers);
                    slp.FlushXData();
                    //
                    slp.Pline.DowngradeOpen();
                    mergedCount += 1;
                    docMdf.WriteLineIntoDebuger(slp);
                }
            }
            docMdf.WriteLineIntoDebuger($"总计:{mergedCount} 个");
            //
            return(ExternalCmdResult.Commit);
        }
Exemplo n.º 4
0
        /// <summary> 按标高将边坡对象进行分割,以实现同一级边坡中分别设置不同的防护形式 </summary>
        private void CutSlopes(DocumentModifier docMdf, SlopeLine[] selectedSlopes, CutMethod method, double elev,
                               double waterLineLength)
        {
            // ProtectionUtils.SubgradeEnvironmentConfiguration(docMdf);

            //
            //var layer_Slope = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope);
            var layer_WaterLine = eZcad.SubgradeQuantity.Utility.SQUtils.GetOrCreateLayer_WaterLine(docMdf);
            //var layer_Platform = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform);
            var es = EditStateIdentifier.GetCurrentEditState(docMdf);

            es.CurrentBTR.UpgradeOpen();

            //
            Point2d intersPt;
            Slope   intersSlopeSeg;
            int     cutCount = 0;

            docMdf.WriteLineIntoDebuger("被分割的边坡对象:");
            var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, selectedSlopes);

            foreach (var slp in selectedSlopes)
            {
                var inters = ValidateElevation(slp, method, elev, out intersPt, out intersSlopeSeg);
                if (inters)
                {
                    // 将子边坡按指定的交点进行剪切
                    var newSegs = CutSlopeSegment(slp.XData, intersSlopeSeg, new Point3d(intersPt.X, intersPt.Y, 0));
                    slp.XData.Slopes = newSegs;

                    // 将被剪切掉的子边坡所绑定的文字删除
                    SlopeLine.EraseText(intersSlopeSeg, docMdf.acDataBase);

                    // 绘制水位线
                    var line = new Line(new Point3d(intersPt.X - waterLineLength / 2, intersPt.Y, 0),
                                        new Point3d(intersPt.X + waterLineLength / 2, intersPt.Y, 0));
                    line.LayerId = layer_WaterLine.Id;
                    es.CurrentBTR.AppendEntity(line);
                    docMdf.acTransaction.AddNewlyCreatedDBObject(line, true);
                    slp.XData.Waterlines.Add(line.Handle);

                    // 将刷新后的数据保存到 AutoCAD 文档与界面中
                    slp.Pline.UpgradeOpen();
                    SlopeConstructor.SetSlopeUI(slp);
                    slp.PrintProtectionMethod(es.CurrentBTR, protLayers);
                    slp.FlushXData();
                    slp.Pline.DowngradeOpen();
                    //
                    cutCount += 1;
                    docMdf.WriteLineIntoDebuger(slp);
                }
            }
            es.CurrentBTR.DowngradeOpen();
            docMdf.WriteLineIntoDebuger($"总计:{cutCount} 个");
        }
Exemplo n.º 5
0
        private List <DBText> SelectAllProtTexts()
        {
            var filter   = ProtectionTags.GetProtTextFilter(_protLayers.Values.ToArray(), _wantedProtLayer);
            var selected = new List <DBText>();
            //
            var res = _docMdf.acEditor.SelectAll(new SelectionFilter(filter));

            if (res.Status == PromptStatus.OK)
            {
                foreach (var id in res.Value.GetObjectIds())
                {
                    selected.Add(id.GetObject(OpenMode.ForRead) as DBText);
                }
            }
            return(selected);
        }
Exemplo n.º 6
0
        /// <summary> 根据边坡多段线进行道路边坡的筛选、信息提取、防护方式的设置等操作 </summary>
        public void ConfigerSlopes(IList <Polyline> slopeLines, bool justModifyCalculated)
        {
            if (slopeLines == null || slopeLines.Count == 0)
            {
                return;
            }
            //
            var app = SymbolTableUtils.GetOrCreateAppName(_docMdf.acDataBase, _docMdf.acTransaction, SlopeData.AppName);

            var    selectedSlpLines = new List <SlopeLine>();
            string errMsg;

            foreach (var sl in slopeLines)
            {
                var slpLine = SlopeLine.Create(_docMdf, sl, out errMsg);
                if (slpLine != null)
                {
                    // 将存储的数据导入边坡对象
                    slpLine.ImportSlopeData(slpLine.XData);
                    //
                    if (!slpLine.XData.FullyCalculated || !justModifyCalculated)
                    {
                        slpLine.CalculateXData();
                    }
                    selectedSlpLines.Add(slpLine);
                }
                else
                {
                    _docMdf.WriteNow(errMsg);
                }
            }
            if (selectedSlpLines.Count == 0)
            {
                return;
            }

            var slopesWithSlopesegs    = new List <SlopeLine>();
            var slopesWithoutSlopesegs = new List <SlopeLine>();

            foreach (var slp in selectedSlpLines)
            {
                if (slp.XData.Slopes.Count + slp.XData.Platforms.Count > 0)
                {
                    slopesWithSlopesegs.Add(slp);
                }
                else
                {
                    slopesWithoutSlopesegs.Add(slp);
                }
            }
            //
            var es = EditStateIdentifier.GetCurrentEditState(_docMdf);

            es.CurrentBTR.UpgradeOpen();
            //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope);
            //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform);
            // _docMdf.acDataBase.Clayer = layer_Slope.ObjectId;
            //
            // 1. 对有子边坡的边坡对象进行操作:显示界面,以进行填挖方与防护设置
            var listerForm = new SlopeSegLister(slopesWithSlopesegs);

            listerForm.ShowDialog(null);
            if (listerForm.ValueChanged)
            {
                var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, slopesWithSlopesegs);
                foreach (var slp in slopesWithSlopesegs)
                {
                    slp.Pline.UpgradeOpen();
                    SetSlopeUI(slp);
                    slp.PrintProtectionMethod(es.CurrentBTR, protLayers);
                    //
                    slp.FlushXData();
                    slp.Pline.DowngradeOpen();

                    if (slp.XDataToBeCleared)
                    {
                        slp.ClearXData();
                    }
                }
            }
            // 2. 对没有子边坡的边坡对象进行操作
            foreach (var slp in slopesWithoutSlopesegs)
            {
                slp.Pline.UpgradeOpen();
                SetSlopeUI(slp);
                slp.FlushXData();
                slp.Pline.DowngradeOpen();
            }

            es.CurrentBTR.DowngradeOpen();
        }
Exemplo n.º 7
0
        /// <summary> 导出数据 </summary>
        public bool ExportData()
        {
            var slopeDatas = _slopesToHandle.Select(r => r.XData).ToArray();

            //// 所有设置的防护形式
            var protectionTypes    = ProtectionTags.GetProtectionTypes(slopeDatas);
            var categorizedProtMtd = ProtectionTags.CategorizeProtectionMethods(protectionTypes);

            _docMdf.WriteNow($"共检测到 {categorizedProtMtd.Count} 种防护方式");
            if (categorizedProtMtd.Count == 0)
            {
                return(false);
            }

            var sheet_Infos = new List <WorkSheetData>();

            // ---------------------------------------------------------------------------------------------------------------
            //// 1. 先将所有的数据进行一次性导出
            //var header = SlopeData.InfoHeader.Split('\t');
            //var allData = SlopeData.GetAllInfo(slopeDatas);
            //allData = allData.InsertVector<object, string, object>(true, new[] { header, }, new[] { -1f });

            //sheet_Infos.Add(new WorkSheetData(WorkSheetDataType.SourceData, "CAD原始数据", allData));

            // ---------------------------------------------------------------------------------------------------------------
            // 道路左侧边坡防护
            // 每一种防护形式所对应的要写入到Excel表中的信息
            var slopeOnleft = _slopesToHandle.Where(r => r.XData.OnLeft).ToArray();

            foreach (var cpm in categorizedProtMtd)
            {
                var leftRange = new List <DataRow>();
                foreach (var tp in cpm.Value) // 道路左边边坡中每一种不同的防护形式
                {
                    // 挂网喷锚_6 与 挂网喷锚_8
                    GetMatchedSlopeRanges(slopeOnleft, tp, true, ref leftRange);
                }
                if (leftRange.Count > 0)
                {
                    // 一个防护方式的工作表数据构造完成,下面对其进行排序
                    leftRange.Sort(SortRows);

                    // 将排序后的数据导出
                    var slopesArr = DataRow.ConvertToArray(leftRange);
                    slopesArr = slopesArr.InsertVector <object, string, object>(true, new[] { DataRow.GetTableHeader() }, new[] { -1f });
                    var sheetName = $"{cpm.Key}_{"左"}";
                    sheet_Infos.Add(new WorkSheetData(WorkSheetDataType.SlopeProtection, sheetName, slopesArr));
                }
            }

            // 道路右侧边坡防护
            var slopeOnRight = _slopesToHandle.Where(r => !r.XData.OnLeft).ToArray();

            foreach (var cpm in categorizedProtMtd)
            {
                var rightRange = new List <DataRow>();
                foreach (var tp in cpm.Value) // 道路左边边坡中每一种不同的防护形式
                {
                    // 挂网喷锚_6 与 挂网喷锚_8
                    GetMatchedSlopeRanges(slopeOnRight, tp, false, ref rightRange);
                }
                if (rightRange.Count > 0)
                {
                    // 一个防护方式的工作表数据构造完成,下面对其进行排序
                    rightRange.Sort(SortRows);

                    // 将排序后的数据导出
                    var slopesArr = DataRow.ConvertToArray(rightRange);
                    slopesArr = slopesArr.InsertVector <object, string, object>(true, new[] { DataRow.GetTableHeader() }, new[] { -1f });
                    var sheetName = $"{cpm.Key}_{"右"}";
                    sheet_Infos.Add(new WorkSheetData(WorkSheetDataType.SlopeProtection, sheetName, slopesArr));
                }
            }
            // ---------------------------------------------------------------------------------------------------------------

            // ---------------------------------------------------------------------------------------------------------------

            // 数据导出
            ExportWorkSheetDatas(sheet_Infos);

            return(true);
        }