public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (null == _dt) return; DataCase dtCase = _dt as DataCase; if (null != dtCase) { Box b = new Box(0, ToCase(dtCase)); graphics.AddBox(b); graphics.AddDimensions(new DimensionCube(dtCase.OuterDimensions)); } DataBox dtBox = _dt as DataBox; if (null != dtBox) { Box b = new Box(0, ToBox(dtBox)); graphics.AddBox(b); graphics.AddDimensions(new DimensionCube(dtBox.Dimensions)); } DataPallet dtPallet = _dt as DataPallet; if (null != dtPallet) { Pallet pallet = new Pallet(ToPallet(dtPallet)); pallet.Draw(graphics, Sharp3D.Math.Core.Transform3D.Identity); graphics.AddDimensions(new DimensionCube(dtPallet.Dimensions)); } DataInterlayer dtInterlayer = _dt as DataInterlayer; if (null != dtInterlayer) { graphics.AddBox(new Box(0, ToInterlayer(dtInterlayer))); graphics.AddDimensions(new DimensionCube(dtInterlayer.Dimensions)); } DataPalletCap dtPalletCap = _dt as DataPalletCap; if (null != dtPalletCap) { PalletCap palletCap = new PalletCap(0, ToPalletCap(dtPalletCap), Sharp3D.Math.Core.Vector3D.Zero); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(dtPalletCap.Dimensions)); } DataCylinder dtCylinder = _dt as DataCylinder; if (null != dtCylinder) { Cylinder cyl = new Cylinder(0, ToCylinder(dtCylinder)); graphics.AddCylinder(cyl); } }
private void AppendPalletCapElement(PalletCapProperties palletCapProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { // sanity check if (null == palletCapProp) return; // namespace string ns = xmlDoc.DocumentElement.NamespaceURI; // interlayer XmlElement elemPalletCap = xmlDoc.CreateElement("palletCap", ns); elemPalletAnalysis.AppendChild(elemPalletCap); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = palletCapProp.Name; elemPalletCap.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = palletCapProp.Description; elemPalletCap.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemPalletCap, "length", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Length); AppendElementValue(xmlDoc, elemPalletCap, "width", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Width); AppendElementValue(xmlDoc, elemPalletCap, "height", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Height); AppendElementValue(xmlDoc, elemPalletCap, "innerLength", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideLength); AppendElementValue(xmlDoc, elemPalletCap, "innerWidth", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideWidth); AppendElementValue(xmlDoc, elemPalletCap, "innerHeight", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideHeight); AppendElementValue(xmlDoc, elemPalletCap, "weight", UnitsManager.UnitType.UT_MASS, palletCapProp.Weight); // --- // view_palletCap_iso // build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; PalletCap palletCap = new PalletCap(0, palletCapProp, Vector3D.Zero); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(palletCapProp.Length, palletCapProp.Width, palletCapProp.Height)); graphics.Flush(); // save image ? SaveImageAs(graphics.Bitmap, "view_palletCap_iso.png"); // --- // view_palletCap_iso XmlElement elemImage = xmlDoc.CreateElement("view_palletCap_iso", ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4); elemImage.Attributes.Append(styleAttribute); elemPalletCap.AppendChild(elemImage); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (CapLength > 0 && CapWidth > 0 && CapHeight > 0) { // draw PalletCapProperties palletCapProperties = new PalletCapProperties( null, ItemName, ItemDescription, CapLength, CapWidth, CapHeight, CapInnerLength, CapInnerWidth, CapInnerHeight, CapWeight, CapColor); PalletCap palletCap = new PalletCap(0, palletCapProperties, Vector3D.Zero); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(CapLength, CapWidth, CapHeight)); } }