public static void TransformDesignElement(double phi, double theta, DesignElement derect, double zbaseoffset) { // sanity check if (derect != null) { Point3D[] trimetric; // temporary array for the trimetric transform int tmpndx = 0; // set up trimetric parameters trimetric = lGetTrimetricArray(phi, theta); // produce the temporary figure and the projection for (tmpndx = 0; tmpndx < derect.Points.Length; tmpndx++) { derect.TempFigurePoints[tmpndx].X = lTransformPointX(derect.Points[tmpndx], zbaseoffset, trimetric); derect.TempFigurePoints[tmpndx].Y = lTransformPointY(derect.Points[tmpndx], zbaseoffset, trimetric); derect.TempFigurePoints[tmpndx].Z = lTransformPointZ(derect.Points[tmpndx], zbaseoffset, trimetric); derect.TempFigurePoints[tmpndx].M = lTransformPointM(derect.Points[tmpndx], zbaseoffset, trimetric); derect.ProjectedPoints[tmpndx].X = lProjectPointX(derect.TempFigurePoints[tmpndx]); derect.ProjectedPoints[tmpndx].Y = lProjectPointY(derect.TempFigurePoints[tmpndx]); derect.ProjectedPoints[tmpndx].Z = lProjectPointZ(derect.TempFigurePoints[tmpndx]); derect.ProjectedPoints[tmpndx].M = lProjectPointM(derect.TempFigurePoints[tmpndx]); } derect.UpdateProjectedPlanes(); } }
public void SetFromAttachmentPoint(DesignAttachmentParameters srcpt) { AttX.SetFromDesignPoint(srcpt.AttX); AttY.SetFromDesignPoint(srcpt.AttY); AttZ.SetFromDesignPoint(srcpt.AttZ); OwnX.SetFromDesignPoint(srcpt.OwnX); OwnY.SetFromDesignPoint(srcpt.OwnY); OwnZ.SetFromDesignPoint(srcpt.OwnZ); Attachment = srcpt.Attachment; }
public virtual DesignElement Duplicate() { DesignElement newde = new DesignElement(); newde.Name = Name; newde.ElementType = ElementType; newde.lMidpoint.SetPoint(lMidpoint); newde.lAttachmentPoint.SetFromAttachmentPoint(lAttachmentPoint); return(newde); }
public DesignElement DuplicateElement(string srcname, string newname) { DesignElement newelem = null; DesignElement srcelem = GetDesignElementByName(srcname); if (srcelem != null) { //newelem = } return(newelem); }
private static void lUpdateAttachmentPoints(DesignObject dobj, DesignElement delem) { if (delem.AttachmentPoint != null) { if (delem.AttachmentPoint.Attachment == null) { delem.AttachmentPoint.Attachment = dobj.GetDesignElementByName(delem.AttachmentPoint.AttachmentName); lUpdateAttachmentPoints(dobj, delem.AttachmentPoint.Attachment); delem.UpdatePoints(); } } }
public void UpdatePointsForElement(DesignElement delem) { delem.UpdatePoints(); foreach (DesignElement tmpdelem in Elements) { if ((tmpdelem.AttachmentPoint != null) && (tmpdelem.AttachmentPoint.Attachment == delem)) { UpdatePointsForElement(tmpdelem); } } }
public DesignElement GetDesignElementByName(string name) { DesignElement delem = null; if (Elements.Count > 0) { foreach (DesignElement tmpdelem in Elements) { if (tmpdelem.Name.Equals(name)) { delem = tmpdelem; break; } } } return(delem); }
private void lDrawDesignElement(Graphics gfx, DesignElement delement, int offsetx, int offsety) { int tmpndx; Graphics3D.TransformDesignElement(lPhi, lTheta, delement, 0.0F); foreach (RectPlane tmpplane in delement.ProjectedPlanes) { for (tmpndx = 0; tmpndx < tmpplane.Points.Length; tmpndx++) { lTempPanelPoints[tmpndx].X = (int)(tmpplane.Points[tmpndx].X * lScaling) + offsetx; lTempPanelPoints[tmpndx].Y = (int)(tmpplane.Points[tmpndx].Y * lScaling) + offsety; } gfx.FillPolygon(lFillbrush, lTempPanelPoints); gfx.DrawLine(lOutlinepen, lTempPanelPoints[0], lTempPanelPoints[1]); gfx.DrawLine(lOutlinepen, lTempPanelPoints[1], lTempPanelPoints[2]); gfx.DrawLine(lOutlinepen, lTempPanelPoints[2], lTempPanelPoints[3]); gfx.DrawLine(lOutlinepen, lTempPanelPoints[3], lTempPanelPoints[0]); } }
private string lGetAttachmentLVStringText(DesignElement delem) { string atttext = ""; if (delem.AttachmentPoint != null) { atttext = delem.AttachmentPoint.AttachmentName + ": at " + delem.AttachmentPoint.OwnX.GetTextForParameters() + ", " + delem.AttachmentPoint.OwnY.GetTextForParameters() + ", " + delem.AttachmentPoint.OwnZ.GetTextForParameters() + ", on own " + delem.AttachmentPoint.OwnX.GetTextForParameters() + ", " + delem.AttachmentPoint.OwnY.GetTextForParameters() + ", " + delem.AttachmentPoint.OwnZ.GetTextForParameters(); } else { atttext = "Midpoint: " + delem.Midpoint.X.ToString() + ", " + delem.Midpoint.Y.ToString() + ", " + delem.Midpoint.Z.ToString(); } return(atttext); }
public static DesignObject LoadDesignObject(string filename) { DesignObject dobj = null; string[] filetext = FileHandler.LoadFile(filename); if ((filetext != null) && (filetext.Length > 0)) { char[] eqdelim = new char[] { '=' }; char[] commadelim = new char[] { ',' }; char[] quotedelim = new char[] { '"' }; bool error = false; DesignElement currelement = null; int posndx = 0; dobj = new DesignObject(); foreach (string fileline in filetext) { string linetrim = fileline.Trim(); if ((linetrim.Length > 0) && (linetrim[0] != ';')) { string[] linetokens = linetrim.Split(eqdelim); if (linetokens.Length == 2) { string varname = linetokens[0].ToLower(); if (currelement != null) { if (varname.Equals("name")) { currelement.Name = linetokens[1]; } else if (varname.Equals("objectend")) { currelement = null; } else if (currelement.ElementType == DesignElement.ElementTypes.Rect) { DesignElementRect rectelem = (DesignElementRect)currelement; if (varname.Equals("dimensions")) { string[] dimstrs = linetokens[1].Split(commadelim); if (dimstrs.Length == 3) { try { rectelem.DimensionX = Convert.ToDouble(dimstrs[0]); rectelem.DimensionY = Convert.ToDouble(dimstrs[1]); rectelem.DimensionZ = Convert.ToDouble(dimstrs[2]); rectelem.UpdatePoints(); } catch (System.FormatException /*fex*/) { error = true; } } else { error = true; } } else if (varname.Equals("attach")) { string[] namestrs = linetokens[1].Split(quotedelim); if (namestrs.Length == 3) { string[] ownstrs = namestrs[0].Split(commadelim, StringSplitOptions.RemoveEmptyEntries); string[] attrstrs = namestrs[2].Split(commadelim, StringSplitOptions.RemoveEmptyEntries); if ((ownstrs.Length == 3) && (attrstrs.Length == 3)) { DesignAttachmentParameters dattach = new DesignAttachmentParameters(namestrs[1]); if (!dattach.SetAttachmentParametersFromStrings(attrstrs)) { error = true; } else if (!dattach.SetOwnParametersFromStrings(ownstrs)) { error = true; } rectelem.AttachmentPoint = dattach; } else { error = true; } } else { error = true; } } else if (varname.Equals("midpoint")) { string[] midstrs = linetokens[1].Split(commadelim); if (midstrs.Length == 3) { try { double midx = Convert.ToDouble(midstrs[0]); double midy = Convert.ToDouble(midstrs[1]); double midz = Convert.ToDouble(midstrs[2]); rectelem.Midpoint.SetPoint(midx, midy, midz); rectelem.UpdatePoints(); } catch (System.FormatException /*fex*/) { error = true; } } else { error = true; } } else if (varname.Equals("position")) { string[] posstrs = linetokens[1].Split(commadelim); if ((posstrs.Length == 3) && (posndx < rectelem.Points.Length)) { try { double midx = Convert.ToDouble(posstrs[0]); double midy = Convert.ToDouble(posstrs[1]); double midz = Convert.ToDouble(posstrs[2]); rectelem.Points[posndx].SetPoint(midx, midy, midz); posndx++; } catch (System.FormatException /*fex*/) { error = true; } } else { error = true; } } else { error = true; } } else { error = true; } } else if (varname.Equals("objectname")) { dobj.Name = linetokens[1]; } else if (varname.Equals("measure")) { Units unitval; if (Enum.TryParse(linetokens[1], true, out unitval) && Enum.IsDefined(typeof(Units), unitval)) { dobj.UnitType = unitval; } else { error = true; } } else if (varname.Equals("objectstart")) { if (currelement == null) { DesignElement.ElementTypes etype; if (Enum.TryParse(linetokens[1], true, out etype) && Enum.IsDefined(typeof(DesignElement.ElementTypes), etype)) { switch (etype) { case DesignElement.ElementTypes.Rect: currelement = new DesignElementRect(); break; default: error = true; break; } if (currelement != null) { dobj.Elements.Add(currelement); posndx = 0; } } else { error = true; } } else { error = true; } } } else { error = true; } } if (error) { break; } } if (error) { dobj = null; } else { // fill in any relative attachment point classes if (dobj.Elements.Count > 0) { List <DesignElement> attelems = new List <DesignElement>(); // make a list of all elements that have a primary attachment foreach (DesignElement tmpdelem in dobj.Elements) { lUpdateAttachmentPoints(dobj, tmpdelem); } } } } return(dobj); }