public void DrawPipeDetails(vdDocument doc, DisNetPipeDetails pipeDetails) { //Pipe = 1 //Length = 195.185 m. //Diameter = 0.15 m. //Discharge = 0.0228 m3/s. //POINTS = 54020.713,50675.57,99.228 string txtStr = ""; txtStr = "Pipe = " + pipeDetails.PipeNo.ToString() + "\n\r" + "Length = " + pipeDetails.Length.ToString("0.000") + " m." + "\n\r" + "Diameter = " + pipeDetails.Diameter.ToString("0.00") + " m3/s." + "\n\r" + "Discharge = " + pipeDetails.Discharge.ToString("0.0000") + " m." + "\n\r"; txtStr = "Pipe No: " + pipeDetails.PipeNo.ToString(); vdText txt = new vdText(); txt.Style = new vdTextstyle(); txt.TextString = "Pipe No: " + pipeDetails.PipeNo.ToString(); txt.SetUnRegisterDocument(doc); txt.setDocumentDefaults(); txt.Height = 5.0d; txt.InsertionPoint = new gPoint(pipeDetails.Point.x, pipeDetails.Point.y, pipeDetails.Point.z + 15.0d); //txt.PenColor = new vdColor(Color.Red); txt.Layer = doc.Layers.FindName("PipeData"); doc.ActiveLayOut.Entities.AddItem(txt); }
public void DrawMember(MemberIncidence mi, vdDocument doc, double txtSize) { double length, factor; doc.Palette.Background = Color.White; vdLine line = new vdLine(); vdText vtxtMemberNo = new vdText(); line.SetUnRegisterDocument(doc); line.setDocumentDefaults(); vtxtMemberNo.SetUnRegisterDocument(doc); vtxtMemberNo.setDocumentDefaults(); line.PenColor = new vdColor(Color.Black); line.Layer = doc.Layers[0]; doc.Layers[0].Frozen = false; line.StartPoint = mi.StartNode.Point; line.EndPoint = mi.EndNode.Point; line.ToolTip = string.Format("Member No : {0} [Nodes ({1}, {2})]", mi.MemberNo, mi.StartNode.NodeNo, mi.EndNode.NodeNo); doc.ActionLayout.Entities.AddItem(line); length = line.Length(); //factor = 22.2222d; //factor = length / 0.9d; //txtSize = length / factor; //txtSize = GetTextSize(); vtxtMemberNo.TextString = mi.MemberNo.ToString(); vtxtMemberNo.Layer = membersLay; vtxtMemberNo.Height = txtSize; vtxtMemberNo.PenColor = new vdColor(Color.Blue); vtxtMemberNo.InsertionPoint = (mi.StartNode.Point + mi.EndNode.Point) / 2; vtxtMemberNo.Layer = membersLay; vtxtMemberNo.ToolTip = string.Format("Member No : {0} [Nodes ({1}, {2})]", mi.MemberNo, mi.StartNode.NodeNo, mi.EndNode.NodeNo); doc.ActionLayout.Entities.AddItem(vtxtMemberNo); //doc.ZoomAll(); //doc.Redraw(true); }
public Texts(String context, String font, int height) { this.context = context; this.font = font; this.height = height; text = new vdText(); }
public Texts(vdText text) { this.text = text; this.setContext(text.TextString); this.setFont(text.Style.FontFile); this.setHeight(text.Height); }
public void DrawJointsText(vdDocument doc, double txtSize) { nodalLay = doc.Layers.FindName("Nodes"); if (nodalLay == null) { nodalLay = new vdLayer(); nodalLay.Name = "Nodes"; nodalLay.SetUnRegisterDocument(doc); nodalLay.setDocumentDefaults(); doc.Layers.AddItem(nodalLay); } nodalLay.PenColor = new vdColor(Color.Magenta); //nodalLay.PenColor = new vdColor(Color.Green); nodalLay.Update(); for (int i = 0; i < list.Count; i++) { //vdMText vTxt = new vdMText(); //vTxt.SetUnRegisterDocument(doc); //vTxt.setDocumentDefaults(); //vTxt.InsertionPoint = list[i].Point; //vTxt.Height = txtSize; //vTxt.HorJustify = VdConstHorJust.VdTextHorCenter; //vTxt.VerJustify = VdConstVerJust.VdTextVerCen; //vTxt.TextString = list[i].NodeNo.ToString(); //vTxt.Layer = nodalLay; //doc.ActiveLayOut.Entities.AddItem(vTxt); vdText vTxt = new vdText(); vTxt.SetUnRegisterDocument(doc); vTxt.setDocumentDefaults(); vTxt.InsertionPoint = list[i].Point; vTxt.Height = txtSize; //vTxt.HorJustify = VdConstHorJust.VdTextHorCenter; //vTxt.VerJustify = VdConstVerJust.VdTextVerCen; vTxt.TextString = list[i].NodeNo.ToString(); vTxt.ToolTip = string.Format("Joint No : {0} [X:{1:f4}, Y:{2:f4}, Z:{3:f4}", list[i].NodeNo, list[i].Point.x, list[i].Point.y, list[i].Point.z); vTxt.Layer = nodalLay; doc.ActiveLayOut.Entities.AddItem(vTxt); //vdCircle vcir = new vdCircle(); //vcir.SetUnRegisterDocument(doc); //vcir.setDocumentDefaults(); //vcir.Center = list[i].Point; //vcir.Radius = txtSize; //vcir.Layer = nodalLay; //doc.ActiveLayOut.Entities.AddItem(vcir); } doc.Update(); doc.Redraw(true); }
public void RemoveAllTexts(vdDocument doc) { for (int i = 0; i < doc.ActiveLayOut.Entities.Count; i++) { vdText txt = doc.ActiveLayOut.Entities[i] as vdText; if (txt != null) { txt.Deleted = true; } } doc.Redraw(true); }
public void SetTextSize(double txtSize) { for (int i = 0; i < this.doc.ActiveLayOut.Entities.Count; i++) { vdText txt = this.doc.ActiveLayOut.Entities[i] as vdText; if (txt != null) { txt.Height = txtSize / 10.0d; txt.Update(); } } this.doc.Redraw(true); }
public void find_depth() { vdEntities arr = this.vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; List <vdLine> list = new List <vdLine>(); //arr[arr.Count - 2], arr[arr.Count - 1] vdLine line1 = (vdLine)arr[arr.Count - 2]; vdLine line2 = (vdLine)arr[arr.Count - 1]; if (line1.StartPoint.y >= line2.StartPoint.y) { //line1ÔÚÉÏÃæ list.Add(line1); list.Add(line2); } else { list.Add(line2); list.Add(line1); } // DrawCommonData.startDepth1 List <vdText> depthList = new List <vdText>(); foreach (vdFigure figure in arr) { if (figure is vdText) { vdText text = figure as vdText; try { int depth = int.Parse(text.TextString); if (depth >= DrawCommonData.upperdepth && depth <= DrawCommonData.lowerdepth) { depthList.Add(text); } } catch { continue; } } } int upper = this.find_nearest_depth(depthList, list[0]); //Éî¶ÈÉϽç int lower = this.find_nearest_depth(depthList, list[1]); //Éî¶ÈϽç MessageBox.Show("ÉϽç:" + upper.ToString()); MessageBox.Show("Ͻç:" + lower.ToString()); }
private void AddGridText(gPoint position, string name, GridData grid) { vdText txt = new vdText(); txt.SetUnRegisterDocument(vDraw.ActiveDocument); txt.setDocumentDefaults(); txt.InsertionPoint = position; txt.TextString = name; txt.Height = 500; txt.AlignToView = true; txt.PenColor.ColorIndex = 2; vDraw.ActiveDocument.ActiveLayOut.Entities.Add(txt); SetEntityLayer(txt, _gGridLayerName); AddXPropertiesToEntity(grid.Properties, txt); }
public void DrawNodes(vdDocument doc, DisNetNode nd) { //Node = 1 //Elevation = 99.228 m. //Head = 21.000 m. //POINTS = 54005.587,50772.821,100.228 string txtStr = ""; txtStr = "Node = " + nd.NodeNo.ToString() + "\n\r" + "Elevation = " + nd.Elevation.ToString("0.000") + " m." + "\n\r" + "Head = " + nd.Head.ToString("0.000") + " m." + "\n\r"; txtStr = "Node No: " + nd.NodeNo.ToString(); if (nd.IsPump) { txtStr += " [ PUMP INPUT ]"; } vdText txt = new vdText(); txt.TextString = txtStr; txt.SetUnRegisterDocument(doc); txt.setDocumentDefaults(); txt.Height = 9.0d; txt.InsertionPoint = new gPoint(nd.Point.x, nd.Point.y, nd.Point.z + 15.0d); txt.PenColor = new vdColor(Color.White); txt.Layer = doc.Layers.FindName("NodalData"); doc.ActiveLayOut.Entities.AddItem(txt); //if (nd.IsPump) //{ // vdText pump = new vdText(); // pump.TextString = " [ PUMP INPUT ]"; // pump.SetUnRegisterDocument(doc); // pump.setDocumentDefaults(); // pump.Height = 4.0d; // //pump.InsertionPoint = new gPoint(nd.Point.x + txt.WidthFactor, nd.Point.y, nd.Point.z + 15.0d); // pump.InsertionPoint = new gPoint(nd.Point.x + txt.WidthFactor, nd.Point.y - txt.Height + 5.0d , nd.Point.z + 15.0d); // pump.PenColor = new vdColor(Color.LightSkyBlue); // pump.Layer = doc.Layers.FindName("NodalData"); // doc.ActiveLayOut.Entities.AddItem(pump); //} }
public static bool Set_Drawing_File(string file_name, vdDocument doc) { List <string> lst_content = new List <string>(File.ReadAllLines(file_name)); MyStrings mList = null; Hashtable h_table = new Hashtable(); string kStr = ""; int i = 0; for (i = 0; i < lst_content.Count; i++) { kStr = lst_content[i].Trim().TrimEnd().TrimStart(); mList = new MyStrings(kStr, '='); if (mList.Count == 2) { h_table.Add(mList.StringList[0], mList.StringList[1]); } else if (mList.Count > 2) { kStr = mList.StringList[1]; for (int K = 2; K < mList.Count; K++) { kStr += " = " + mList.StringList[K].TrimStart().TrimEnd(); } h_table.Add(mList.StringList[0], kStr); } } for (i = 0; i < doc.ActiveLayOut.Entities.Count; i++) { vdText txt = doc.ActiveLayOut.Entities[i] as vdText; if (txt != null) { if (h_table.Contains(txt.TextString)) { txt.TextString = h_table[txt.TextString].ToString(); //if (txt.TextString == "0") // txt.TextString = "-"; } } } //doc.Palette.Background = Color.White; doc.Redraw(true); h_table.Clear(); lst_content.Clear(); return(true); }
private void Set_TextSize() { foreach (var item in VDoc.ActionLayout.Entities) { if (item is vdMText) { vdMText t = item as vdMText; t.Height = TXT_SIZE; t.Update(); } if (item is vdText) { vdText t = item as vdText; t.Height = TXT_SIZE; t.Update(); } } VDoc.Redraw(true); }
/// <summary> /// 处理车位编号 /// </summary> /// <returns></returns> void ProCarNum(vdDocument doc, string PropName, double width, double height) { foreach (vdFigure vdf in doc.ActiveLayOut.Entities) { if (vdf is vdInsert) { vdInsert vdi = vdf as vdInsert; vdXProperty vdx = vdi.XProperties.FindName(PropName); if (vdx != null) { //删除原来的文字 vdBlock vdb = vdi.Block; for (int i = vdb.Entities.Count - 1; i >= 0; i--) { if (vdb.Entities[i] is vdText) { vdb.Entities.RemoveAt(i); } } //文字样式 vdTextstyle vdts = doc.TextStyles.FindName("车位编号"); if (vdts == null) { vdts = new vdTextstyle(doc); vdts.Height = height / 5.0; } //字体 vdText vdt = new vdText(doc); vdt.Style = vdts; vdt.TextString = vdx.PropValue.ToString(); vdt.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter; vdt.VerJustify = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen; Box bb = vdb.BoundingBox(); vdt.InsertionPoint = new gPoint(bb.MidPoint.x, bb.Min.y + height / 2.0, bb.Min.z); vdb.Entities.Add(vdt); } } } }
public void DrawLoops(vdDocument doc, DisNetLoop loop) { //Loop = 1 //POINTS = 54098.236595,50363.406415,54098.236595 string txtStr = "Loop No: " + loop.LoopNo.ToString(); vdText txt = new vdText(); txt.TextString = txtStr; txt.SetUnRegisterDocument(doc); txt.setDocumentDefaults(); txt.Height = 15.0d; txt.InsertionPoint = loop.Point; //txt.PenColor = new vdColor(Color.Red); txt.Layer = loopLay; doc.ActiveLayOut.Entities.AddItem(txt); }
//Chiranjit [2011 12 14] void ResizeText(double text_size) { for (int i = 0; i < MainDoc.ActiveLayOut.Entities.Count; i++) { vdText t = MainDoc.ActiveLayOut.Entities[i] as vdText; vdMText m = MainDoc.ActiveLayOut.Entities[i] as vdMText; if (t != null) { t.Height = text_size; t.Update(); } else if (m != null) { m.Height = text_size; m.Update(); } } MainDoc.Redraw(true); MainDoc.Update(); }
public static bool WriteLineCoordinates(string fileName, vdDocument doc) { bool success = false; using (StreamWriter sw = new StreamWriter(new FileStream(fileName, FileMode.Create))) { try { for (int i = 0; i < doc.ActiveLayOut.Entities.Count; i++) { vdLine ln = doc.ActiveLayOut.Entities[i] as vdLine; if (ln != null) { sw.WriteLine("VD_LINE"); sw.WriteLine("SP={0}", ln.StartPoint.ToString()); sw.WriteLine("EP={0}", ln.EndPoint.ToString()); } else { vdText txt = doc.ActiveLayOut.Entities[i] as vdText; if (txt != null) { sw.WriteLine("VD_TEXT"); sw.WriteLine("IP={0}", txt.InsertionPoint.ToString()); sw.WriteLine("TEXT={0}", txt.TextString); sw.WriteLine("HEIGHT={0}", txt.Height); } } } success = true; } catch (Exception ex) { success = false; } finally { sw.Flush(); sw.Close(); } } return(success); }
public static void CmdPipe3DFromText(vdDocument doc, string txtFileName) { Color pipeColor = Color.Green; double pipeSize = 100.0d; vdLayer pipeLay = new vdLayer(); pipeLay.Name = "Pipes"; pipeLay.SetUnRegisterDocument(doc); pipeLay.setDocumentDefaults(); doc.Layers.AddItem(pipeLay); doc.ActiveLayer = pipeLay; vdLayer nodeBallLay = new vdLayer(); nodeBallLay.Name = "NodalData"; nodeBallLay.SetUnRegisterDocument(doc); nodeBallLay.setDocumentDefaults(); doc.Layers.AddItem(nodeBallLay); nodeBallLay.PenColor = new vdColor(Color.Red); string fName = txtFileName; ReadPipes(fName); HEADSNeed.DisNet.frmDrawPipe fdp = new HEADSNeed.DisNet.frmDrawPipe(); if (fdp.ShowDialog() == DialogResult.OK) { pipeColor = fdp.PipeColor; pipeSize = fdp.PipeSize; //doc.ActiveLayer.PenColor = new vdColor(pipeColor); pipeLay.PenColor = new vdColor(pipeColor); } else { return; } for (int i = 0; i < lstPipe.Count; i++) { try { DisNetPipe dnPipe = lstPipe[i]; vdCircle cir = new vdCircle(); cir.Center = dnPipe.StartPoint; cir.Radius = dnPipe.Diameter * pipeSize; //cir.Radius = dnPipe.Diameter; cir.ExtrusionVector = Vector.CreateExtrusion(dnPipe.StartPoint, dnPipe.EndPoint); cir.SetUnRegisterDocument(doc); cir.setDocumentDefaults(); cir.Layer = pipeLay; doc.ActionLayout.Entities.AddItem(cir); cir.Thickness = dnPipe.Length; //cir.PenColor = new vdColor(cl); doc.CommandAction.CmdSphere(dnPipe.EndPoint, cir.Radius, 10, 10); doc.ActiveLayer = nodeBallLay; doc.CommandAction.CmdSphere(dnPipe.EndPoint, cir.Radius + 5.0d, 15, 10); doc.ActiveLayer = pipeLay; doc.CommandAction.Zoom("E", 100, 100); if (i == 0) { vdPolyline pline = new vdPolyline(); pline.VertexList.Add(new gPoint(cir.Center.x - 35.0d, cir.Center.y + 25.0d, cir.Center.z)); pline.VertexList.Add(new gPoint(cir.Center.x - 35.0d, cir.Center.y, cir.Center.z)); pline.VertexList.Add(new gPoint(cir.Center.x + 35.0d, cir.Center.y, cir.Center.z)); pline.VertexList.Add(new gPoint(cir.Center.x + 35.0d, cir.Center.y + 25.0d, cir.Center.z)); pline.SetUnRegisterDocument(doc); pline.setDocumentDefaults(); pline.PenColor = new vdColor(Color.LightPink); pline.PenWidth = 2.0d; doc.ActionLayout.Entities.AddItem(pline); vdLine ln = new vdLine(); ln.SetUnRegisterDocument(doc); ln.setDocumentDefaults(); ln.StartPoint = (pline.VertexList[0] + pline.VertexList[1]) / 2; ln.EndPoint = (pline.VertexList[2] + pline.VertexList[3]) / 2; ln.PenColor = new vdColor(Color.LightPink); ln.PenWidth = 2.0d; doc.ActionLayout.Entities.AddItem(ln); vdText tx = new vdText(); tx.SetUnRegisterDocument(doc); tx.setDocumentDefaults(); tx.InsertionPoint = new gPoint(ln.StartPoint.x + 2.0d, ln.StartPoint.y + 3.0d, ln.StartPoint.z); tx.TextString = "SOURCE"; tx.PenColor = new vdColor(Color.LightPink); tx.Height = 10.0d; doc.ActionLayout.Entities.AddItem(tx); } //doc.Redraw(true); } catch (Exception exx) { } } doc.RenderMode = vdRender.Mode.Wire2dGdiPlus; doc.CommandAction.RegenAll(); doc.Redraw(true); }
public override void FillShapeEntities(ref vdEntities entities) { //calculate shape entities in ecs gPoint cen = new gPoint(); vdText text = new vdText(); //entities.AddItem(text); //text.MatchProperties(this, Document); text.Style = TextStyle; text.TextString = TextString; text.VerJustify = VdConstVerJust.VdTextVerCen; text.HorJustify = VdConstHorJust.VdTextHorCenter; text.Height = TextHeight; text.InsertionPoint = cen; vdPolyline pl = new vdPolyline(); entities.AddItem(cirStart); entities.AddItem(pl); //entities.AddItem(pl2); pl.MatchProperties(this, Document); cirStart.MatchProperties(this, Document); cirEnd.MatchProperties(this, Document); Vertexes verts = new Vertexes(); double stepangle = Globals.VD_TWOPI / this.NumSides; double sang = 0.0d; for (int i = 0; i < NumSides; i++) { verts.Add(gPoint.Polar(cen, sang, Radius)); sang += stepangle; } pl.VertexList = verts; pl.Flag = VdConstPlineFlag.PlFlagCLOSE; //entities.AddItem(cirEnd); cirStart.Center = cen; cirStart.Radius = mRadius; cirStart.Thickness = PipeHeight; //cirStart.Thickness = cirStart.Center.Distance3D(EndPoint); //cirStart.ExtrusionVector = new Vector(0.0, 1.0, 0.0); //cirStart.ExtrusionVector = Vector.CreateExtrusion(EndPoint, StartPoint); cirStart.ExtrusionVector = Vector.CreateExtrusion(StartPoint, EndPoint); cirEnd.Center = EndPoint; cirEnd.Radius = mRadius; //cirEnd.ExtrusionVector = Vector.CreateExtrusion(cen, EndPoint); //cirEnd.ExtrusionVector = cirStart.ExtrusionVector; // Draw DisNet Pipe gPoints gPts = GetDisNetPipePoints(); //vdPolyline plDisNet = new vdPolyline(); pl.VertexList = new Vertexes(gPts); //entities.AddItem(pl); }
public void DrawMember(MemberIncidence mi, vdDocument doc) { double length, factor, txtSize; doc.Palette.Background = Color.White; vdLine line = new vdLine(); vdText vtxtStartNode = new vdText(); vdText vtxtEndNode = new vdText(); vdText vtxtMemberNo = new vdText(); line.SetUnRegisterDocument(doc); line.setDocumentDefaults(); vtxtStartNode.SetUnRegisterDocument(doc); vtxtStartNode.setDocumentDefaults(); vtxtEndNode.SetUnRegisterDocument(doc); vtxtEndNode.setDocumentDefaults(); vtxtMemberNo.SetUnRegisterDocument(doc); vtxtMemberNo.setDocumentDefaults(); line.PenColor = new vdColor(Color.Black); line.StartPoint = mi.StartNode.Point; line.EndPoint = mi.EndNode.Point; //line.ToolTip = string.Format("Member No : {0} \nStart Node = {1} [X={2}, Y={3}, Z={4}]\nEnd Node = {5} [X={6}, Y={7}, Z={8}]", // mi.MemberNo, // mi.StartNode.NodeNo, // mi.StartNode.Point.x, // mi.StartNode.Point.y, // mi.StartNode.Point.z, // mi.EndNode.NodeNo, // mi.EndNode.Point.x, // mi.EndNode.Point.y, // mi.EndNode.Point.z); line.ToolTip = string.Format("Member No : {0} [Nodes ({1}, {2})]", mi.MemberNo, mi.StartNode.NodeNo, mi.EndNode.NodeNo); doc.ActionLayout.Entities.AddItem(line); // Chiranjit Modified [2010 04 16], Kolkata, TechSOFT object jc_no = hash_joint_no[mi.StartNode.NodeNo]; if (jc_no == null) { hash_joint_no.Add(mi.StartNode.NodeNo, mi.StartNode.NodeNo); vtxtEndNode.ToolTip = string.Format("Node No : {0} [X={1}, Y={2}, Z={3}]", mi.StartNode.NodeNo, mi.StartNode.Point.x, mi.StartNode.Point.y, mi.StartNode.Point.z); doc.ActionLayout.Entities.AddItem(vtxtStartNode); } jc_no = hash_joint_no[mi.EndNode.NodeNo]; if (jc_no == null) { hash_joint_no.Add(mi.EndNode.NodeNo, mi.EndNode.NodeNo); vtxtEndNode.ToolTip = string.Format("Node No : {0} [X={1}, Y={2}, Z={3}]", mi.EndNode.NodeNo, mi.EndNode.Point.x, mi.EndNode.Point.y, mi.EndNode.Point.z); doc.ActionLayout.Entities.AddItem(vtxtEndNode); } //doc.ActionLayout.Entities.AddItem(vtxtStartNode); //doc.ActionLayout.Entities.AddItem(vtxtEndNode); doc.ActionLayout.Entities.AddItem(vtxtMemberNo); length = line.Length(); //factor = 22.2222d; //factor = length / 0.9d; //txtSize = length / factor; txtSize = GetTextSize(); vtxtStartNode.TextString = mi.StartNode.NodeNo.ToString(); vtxtStartNode.Height = txtSize; //vtxtStartNode.Height = 0.9d; //vtxtStartNode.PenColor = new vdColor(Color.Green); vtxtStartNode.InsertionPoint = mi.StartNode.Point; vtxtStartNode.Layer = nodesLay; vtxtEndNode.TextString = mi.EndNode.NodeNo.ToString(); vtxtEndNode.Height = txtSize; //vtxtEndNode.Height = 0.9d; //vtxtEndNode.PenColor = new vdColor(Color.Green); vtxtEndNode.InsertionPoint = mi.EndNode.Point; vtxtEndNode.Layer = nodesLay; vtxtMemberNo.TextString = mi.MemberNo.ToString(); //vtxtMemberNo.Height = 0.9d; vtxtMemberNo.Height = txtSize; vtxtMemberNo.PenColor = new vdColor(Color.Blue); vtxtMemberNo.InsertionPoint = (mi.StartNode.Point + mi.EndNode.Point) / 2; vtxtMemberNo.Layer = membersLay; vtxtMemberNo.ToolTip = string.Format("Member No : {0} [Nodes ({1}, {2})]", mi.MemberNo, mi.StartNode.NodeNo, mi.EndNode.NodeNo); //doc.ZoomAll(); //doc.Redraw(true); }
public void Draw_StructureGraph(vdDocument document, int SpanNo, int LoadCase, bool IsShear) { //Jay Shree Krishna //Jay Shree Ganesh document.ActiveLayOut.Entities.RemoveAll(); #region MainLIne vdLine mainLine = new vdLine(); mainLine.SetUnRegisterDocument(document); mainLine.setDocumentDefaults(); mainLine.StartPoint = new gPoint(10.0d, 10.0d); mainLine.EndPoint = new gPoint(30.0d, 10.0d); document.ActiveLayOut.Entities.AddItem(mainLine); #endregion #region Side Line 1 vdLine sideLine1 = new vdLine(); sideLine1.SetUnRegisterDocument(document); sideLine1.setDocumentDefaults(); sideLine1.StartPoint = new gPoint(10, 5); sideLine1.EndPoint = new gPoint(10, 15); document.ActiveLayOut.Entities.AddItem(sideLine1); #endregion #region Side Line 2 vdLine sideLine2 = new vdLine(); sideLine2.SetUnRegisterDocument(document); sideLine2.setDocumentDefaults(); sideLine2.StartPoint = new gPoint(30, 5); sideLine2.EndPoint = new gPoint(30, 15); document.ActiveLayOut.Entities.AddItem(sideLine2); #endregion #region Draw PolyLine vdPolyline pLine = new vdPolyline(); pLine.SetUnRegisterDocument(document); pLine.setDocumentDefaults(); //pLine.VertexList.Add(mainLine.StartPoint); double st, en, highest; st = en = highest = 0.0d; if (IsShear) { highest = MaxShear(SpanNo); } else { highest = MaxMoment(SpanNo); } double xIncr = 0.0d; for (int i = 0; i < list.Count; i++) { if (list[i].SpanNo == SpanNo) { if (IsShear) { st = list[i].Shear; } else { st = list[i].Moment; } gPoint gp = new gPoint(); gp.x = mainLine.StartPoint.x + xIncr; xIncr += 2.0d; st = -st; if (st > 0) { gp.y = mainLine.StartPoint.y + (sideLine1.EndPoint.y - mainLine.StartPoint.y) * (st / highest); } else { gp.y = mainLine.StartPoint.y - (sideLine1.StartPoint.y - mainLine.StartPoint.y) * (st / highest); } pLine.VertexList.Add(gp); vdLine vLine = new vdLine(); vLine.SetUnRegisterDocument(document); vLine.setDocumentDefaults(); vLine.StartPoint = gp; vLine.EndPoint = new gPoint(gp.x, mainLine.StartPoint.y); document.ActiveLayOut.Entities.AddItem(vLine); vdText yValue = new vdText(); yValue.SetUnRegisterDocument(document); yValue.setDocumentDefaults(); yValue.InsertionPoint = vLine.EndPoint; yValue.TextString = st.ToString(); if (st > 0) { yValue.Rotation = 270.0d * Math.PI / 180.0d; yValue.InsertionPoint.x -= 0.25d; yValue.InsertionPoint.y -= 0.5d; } else { yValue.Rotation = 90.0d * Math.PI / 180.0d; yValue.InsertionPoint.x += 0.25d; yValue.InsertionPoint.y += 0.5d; } yValue.Height = 1.0d; document.ActiveLayOut.Entities.AddItem(yValue); } } document.ShowUCSAxis = false; document.ActiveLayOut.Entities.AddItem(pLine); //if (st > 0) //{ // beamLine.StartPoint.x = midLine.StartPoint.x + (line1.EndPoint.x - midLine.StartPoint.x) * (st / highest); // beamLine.StartPoint.y = midLine.StartPoint.y + (line1.EndPoint.y - midLine.StartPoint.y) * (st / highest); // beamLine.StartPoint.z = midLine.StartPoint.z + (line1.EndPoint.z - midLine.StartPoint.z) * (st / highest); //} //else //{ // beamLine.StartPoint.x = midLine.StartPoint.x - (line1.StartPoint.x - midLine.StartPoint.x) * (st / highest); // beamLine.StartPoint.y = midLine.StartPoint.y - (line1.StartPoint.y - midLine.StartPoint.y) * (st / highest); // beamLine.StartPoint.z = midLine.StartPoint.z - (line1.StartPoint.z - midLine.StartPoint.z) * (st / highest); //} //if (en > 0) //{ // beamLine.EndPoint.x = midLine.EndPoint.x + (line2.EndPoint.x - midLine.EndPoint.x) * (en / highest); // beamLine.EndPoint.y = midLine.EndPoint.y + (line2.EndPoint.y - midLine.EndPoint.y) * (en / highest); // beamLine.EndPoint.z = midLine.EndPoint.z + (line2.EndPoint.z - midLine.EndPoint.z) * (en / highest); //} //else //{ // beamLine.EndPoint.x = midLine.EndPoint.x - (line2.StartPoint.x - midLine.EndPoint.x) * (en / highest); // beamLine.EndPoint.y = midLine.EndPoint.y - (line2.StartPoint.y - midLine.EndPoint.y) * (en / highest); // beamLine.EndPoint.z = midLine.EndPoint.z - (line2.StartPoint.z - midLine.EndPoint.z) * (en / highest); //} #endregion #region Draw Rectangle vdRect rect = new vdRect(); rect.SetUnRegisterDocument(document); rect.setDocumentDefaults(); rect.InsertionPoint = new gPoint(sideLine1.StartPoint.x - 2, sideLine1.StartPoint.y - 2); rect.Width = 23.0d; rect.Height = 13.0d; document.ActiveLayOut.Entities.AddItem(rect); #endregion document.Redraw(true); VectorDraw.Professional.ActionUtilities.vdCommandAction.View3D_VTop(document); }
private void find_depth_gap() { vdEntities arr = ((Childform)this.ActiveMdiChild).vdScrollableControl1.BaseControl.ActiveDocument.ActiveLayOut.Entities; List <vdLine> list = new List <vdLine>(); //arr[arr.Count - 2], arr[arr.Count - 1] vdLine line1; vdLine line2; try { line1 = (vdLine)arr[arr.Count - 2]; line2 = (vdLine)arr[arr.Count - 1]; } catch { MessageBox.Show("还没有画线或者线的数目不够2个"); return; } if (line1.StartPoint.y >= line2.StartPoint.y) { //line1在上面 list.Add(line1); list.Add(line2); } else { list.Add(line2); list.Add(line1); } // DrawCommonData.startDepth1 List <vdText> depthList = new List <vdText>(); foreach (vdFigure figure in arr) { if (figure is vdText) { vdText text = figure as vdText; try { int depth = int.Parse(text.TextString); if (depth >= DrawCommonData.upperdepth && depth <= DrawCommonData.lowerdepth) { depthList.Add(text); } } catch { continue; } } } int upper = this.find_nearest_depth(depthList, list[0]); //深度上界 int lower = this.find_nearest_depth(depthList, list[1]); //深度下界 if (upper < 0) { upper = lower - 2; } //MessageBox.Show("上界:" + upper.ToString()); //MessageBox.Show("下界:" + lower.ToString()); MessageBox.Show(upper.ToString() + "-" + lower.ToString()); BaseLineForm.depthmin = upper; BaseLineForm.depthmax = lower; }
public void Draw_Boq(vdDocument doc) { for (int i = 0; i < doc.ActiveLayOut.Entities.Count; i++) { vdText txt = doc.ActiveLayOut.Entities[i] as vdText; if (txt != null) { #region SWITCH switch (txt.TextString) { case "size1": txt.TextString = size1; break; case "bgd": txt.TextString = bgd; break; case "d1": txt.TextString = d1.ToString(); break; case "d2": txt.TextString = d2.ToString(); break; case "dist1": txt.TextString = dist1.ToString(); break; case "dist2": txt.TextString = dist2.ToString(); break; case "dist3": txt.TextString = dist3.ToString(); break; case "dist4": txt.TextString = dist4.ToString(); break; case "bno1": txt.TextString = bno1.ToString(); break; case "bno2": txt.TextString = bno2.ToString(); break; case "bno3": txt.TextString = bno3.ToString(); break; case "bno4": txt.TextString = bno4.ToString(); break; case "bno5": txt.TextString = bno5.ToString(); break; case "bwt1": txt.TextString = bwt1.ToString(); break; case "bwt2": txt.TextString = bwt2.ToString(); break; case "bwt3": txt.TextString = bwt3.ToString(); break; case "bwt4": txt.TextString = bwt4.ToString(); break; case "bwt5": txt.TextString = bwt5.ToString(); break; case "depth": txt.TextString = depth.ToString(); break; case "shape1": txt.TextString = shape1.ToString(); break; case "shape2": txt.TextString = shape2.ToString(); break; case "shape3": txt.TextString = shape3.ToString(); break; case "shape4": txt.TextString = shape4.ToString(); break; } #endregion txt.Update(); } } }
/// <summary> /// 替换字体 /// </summary> /// <param name="vdbs"></param> private void ReplaceText(vdBlocks vdbs, vdDocument doc, double width, double height, string PropName) { //doc.Purge(); Dictionary <string, string> BlksMap = new Dictionary <string, string>(); Dictionary <string, string> BlksMapTmp = new Dictionary <string, string>(); //删除车位编号 foreach (vdFigure vdf in doc.ActiveLayOut.Entities) { if (vdf is vdInsert) { vdInsert vdi = vdf as vdInsert; vdXProperty vdx = vdi.XProperties.FindName(PropName); if (vdx != null) { string strName = vdx.PropValue.ToString(); vdBlock vdb = vdi.Block; Box box = vdb.BoundingBox(); Box textbox = new Box(new gPoint(box.MidPoint.x - width / 2.0, box.Min.y), new gPoint(box.MidPoint.x + width / 2.0, box.Min.y + height)); vdArray <vdFigure> vda = new vdArray <vdFigure>(); foreach (vdFigure vdff in vdb.Entities) { if (vdff is vdPolyface) { if (vdff.BoundingBox.BoxInBox(textbox)) { vda.AddItem(vdff); } } } Box b = new Box(); foreach (vdFigure vdf1 in vda) { b.AddBox(vdf1.BoundingBox); vdb.Entities.RemoveItem(vdf1); } //文字样式 vdTextstyle vdts = doc.TextStyles.FindName("车位编号"); if (vdts == null) { vdts = new vdTextstyle(doc); vdts.Name = "车位编号"; vdts.Height = b.Height; //MessageBox.Show(b.Height.ToString()); doc.TextStyles.Add(vdts); } //文字 vdText vdt = new vdText(doc); vdt.Style = vdts; vdt.TextString = vdx.PropValue.ToString(); vdt.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter; vdt.VerJustify = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen; vdt.InsertionPoint = b.MidPoint; vdb.Entities.AddItem(vdt); vdf.Invalidate(); vdf.Update(); string ssss = GetBlkMd5(vdi.Block); if (!BlksMap.ContainsKey(vdi.Block.Name)) { BlksMap.Add(vdi.Block.Name, ssss); } else { MessageBox.Show("可能存在重复编号的车位,请仔细查看!"); } } } } //查找md5的计数 Dictionary <string, int> md5count = new Dictionary <string, int>(); foreach (KeyValuePair <string, string> kv in BlksMap) { if (!md5count.ContainsKey(kv.Value)) { md5count.Add(kv.Value, 1); } else { md5count[kv.Value]++; } } foreach (KeyValuePair <string, string> kv in BlksMap) { if (md5count[kv.Value] > 1) { vdBlock vdb2 = doc.Blocks.FindName(kv.Value); vdBlock vdb = doc.Blocks.FindName(kv.Key); if (vdb2 == null) //md5码的块不存在的话 { if (vdb != null) { vdBlock vdb1 = vdb.Clone(doc) as vdBlock; for (int i = vdb1.Entities.Count - 1; i >= 0; i--) { if (vdb1.Entities[i] is vdText) { vdb1.Entities.RemoveItem(vdb1.Entities[i]); } } vdb1.Name = kv.Value; doc.Blocks.Add(vdb1); } } //原来的内容作为一个块,加进去 for (int i = vdb.Entities.Count - 1; i >= 0; i--) { if (!(vdb.Entities[i] is vdText)) { vdb.Entities.RemoveItem(vdb.Entities[i]); } } //vdb.Entities.RemoveAll(); vdInsert vdi = new vdInsert(doc); vdi.Block = doc.Blocks.FindName(kv.Value); // vdb.Entities.Add(vdi); //将字体加上去 vdb.Update(); } } //ProCarNum(doc, PropName, width, height); //处理车位编号 }
public CVcadText(vdText vdtext) { this.vdobj = vdtext; }
public static bool ReadLineCoordinates(string fileName, vdDocument doc) { //vdArray<vdLine> line_arr = new vdArray<vdLine>(); List <string> lstStr = new List <string>(File.ReadAllLines(fileName)); string kStr = ""; string option = ""; string SP, EP, TEXT, IP, Height; SP = EP = IP = TEXT = Height = ""; MyStrings mList = null; for (int i = 0; i < lstStr.Count; i++) { kStr = lstStr[i].Trim().TrimEnd().TrimStart(); if (kStr == "VD_LINE") { option = "VD_LINE"; i++; SP = lstStr[i].Replace("SP=", ""); i++; EP = lstStr[i].Replace("EP=", ""); } else if (kStr == "VD_TEXT") { option = "VD_TEXT"; i++; IP = lstStr[i].Replace("IP=", ""); i++; TEXT = lstStr[i].Replace("TEXT=", ""); i++; Height = lstStr[i].Replace("HEIGHT=", ""); } switch (option) { case "VD_LINE": mList = new MyStrings(MyStrings.RemoveAllSpaces(SP), ','); vdLine ln = new vdLine(); ln.SetUnRegisterDocument(doc); ln.setDocumentDefaults(); ln.StartPoint.x = mList.GetDouble(0); ln.StartPoint.y = mList.GetDouble(1); ln.StartPoint.z = mList.GetDouble(2); mList = new MyStrings(MyStrings.RemoveAllSpaces(EP), ','); ln.EndPoint.x = mList.GetDouble(0); ln.EndPoint.y = mList.GetDouble(1); ln.EndPoint.z = mList.GetDouble(2); doc.ActiveLayOut.Entities.AddItem(ln); break; case "VD_TEXT": mList = new MyStrings(MyStrings.RemoveAllSpaces(IP), ','); vdText txt = new vdText(); txt.SetUnRegisterDocument(doc); txt.setDocumentDefaults(); txt.InsertionPoint.x = mList.GetDouble(0); txt.InsertionPoint.y = mList.GetDouble(1); txt.InsertionPoint.z = mList.GetDouble(2); txt.TextString = TEXT; txt.Height = MyStrings.StringToDouble(Height, 0.01); doc.ActiveLayOut.Entities.AddItem(txt); break; } } lstStr.Clear(); //doc.ShowUCSAxis = false; //VectorDraw.Professional.ActionUtilities.vdCommandAction.View3D_VTop(doc); //doc.Redraw(true); return(true); }