public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (CornerLength > 0 && CornerWidth > 0 && CornerThickness > 0 && CornerThickness < CornerWidth) { // draw PalletCornerProperties palletCornerProperties = new PalletCornerProperties( null, ItemName, ItemDescription, CornerLength, CornerWidth, CornerThickness, CornerWeight, CornerColor); Corner palletCap = new Corner(0, palletCornerProperties); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(CornerWidth, CornerWidth, CornerLength)); } }
private void AppendPalletCornerElement(PalletCornerProperties palletCornerProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { // sanity check if (null == palletCornerProp) return; // namespace string ns = xmlDoc.DocumentElement.NamespaceURI; // interlayer XmlElement elemPalletCorner = xmlDoc.CreateElement("palletCorner", ns); elemPalletAnalysis.AppendChild(elemPalletCorner); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = palletCornerProp.Name; elemPalletCorner.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = palletCornerProp.Description; elemPalletCorner.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemPalletCorner, "length", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Length); AppendElementValue(xmlDoc, elemPalletCorner, "width", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Width); AppendElementValue(xmlDoc, elemPalletCorner, "thickness", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Thickness); AppendElementValue(xmlDoc, elemPalletCorner, "weight", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Weight); // --- // view_palletCorner_iso // build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; Corner corner = new Corner(0, palletCornerProp); corner.Draw(graphics); graphics.Flush(); // save image ? SaveImageAs(graphics.Bitmap, "view_palletCorner_iso.png"); // --- // view_palletCorner_iso XmlElement elemImage = xmlDoc.CreateElement("view_palletCorner_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); elemPalletCorner.AppendChild(elemImage); }
/// <summary> /// Use this method when drawing a solution that belongs an analysis /// </summary> public void Draw(Graphics3D graphics) { if (null == _solution) return; // initialize Graphics3D object if (!graphics.ShowBoxIds) { // draw pallet Pallet pallet = new Pallet(_analysis.PalletProperties); pallet.Draw(graphics, Transform3D.Identity); } // load bounding box BBox3D loadBBox = _solution.LoadBoundingBox; BBox3D loadBBoxWDeco = _solution.LoadBoundingBoxWDeco; #region Pallet film : begin // draw film Film film = null; if (_solution.Analysis.HasPalletFilm) { PalletFilmProperties palletFilmProperties = _solution.Analysis.PalletFilmProperties; film = new Film( palletFilmProperties.Color, palletFilmProperties.UseTransparency, palletFilmProperties.UseHatching, palletFilmProperties.HatchSpacing, palletFilmProperties.HatchAngle); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis + loadBBoxWDeco.Width * Vector3D.YAxis, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Width * Vector3D.YAxis, HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Height * Vector3D.ZAxis, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Width), UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1))); film.DrawBegin(graphics); } #endregion #region Pallet corners // *** pallet corners // positions Vector3D[] cornerPositions = { loadBBox.PtMin , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMin.Y, loadBBox.PtMin.Z) , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z) , new Vector3D(loadBBox.PtMin.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z) }; // length axes HalfAxis.HAxis[] lAxes = { HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N }; // width axes HalfAxis.HAxis[] wAxes = { HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_P }; // corners Corner[] corners = new Corner[4]; if (_solution.Analysis.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i] = new Corner(0, _solution.Analysis.PalletCornerProperties); corners[i].Height = Math.Min(_solution.Analysis.PalletCornerProperties.Length, loadBBox.Height); corners[i].SetPosition(cornerPositions[i], lAxes[i], wAxes[i]); corners[i].DrawBegin(graphics); } } // *** pallet corners : end #endregion // draw solution uint pickId = 0; foreach (ILayer layer in _solution) { BoxLayer blayer = layer as BoxLayer; if (null != blayer) { foreach (BoxPosition bPosition in blayer) graphics.AddBox(new Box(pickId++, _analysis.BProperties, bPosition)); } InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { InterlayerProperties currInterlayerProperties = (0 == interlayerPos.TypeId) ? _analysis.InterlayerProperties : _analysis.InterlayerPropertiesAntiSlip; Box box = new Box(pickId++, currInterlayerProperties); // set position box.Position = new Vector3D( 0.5 * (_analysis.PalletProperties.Length - currInterlayerProperties.Length) , 0.5 * (_analysis.PalletProperties.Width - currInterlayerProperties.Width) , interlayerPos.ZLow); // draw graphics.AddBox(box); } } if (_showDimensions) { graphics.AddDimensions( new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1) , Color.Black, false)); graphics.AddDimensions( new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2) , Color.Red, true)); } // pallet corners if (_solution.Analysis.HasPalletCorners) { for (int i = 0; i < 4; ++i) corners[i].DrawEnd(graphics); } // pallet cap if (_solution.HasPalletCap) { PalletCapProperties capProperties = _solution.Analysis.PalletCapProperties; Vector3D pos = new Vector3D( 0.5 * (_analysis.PalletProperties.Length - capProperties.Length), 0.5 * (_analysis.PalletProperties.Width - capProperties.Width), loadBBox.PtMax.Z - capProperties.InsideHeight); PalletCap cap = new PalletCap(0, capProperties, pos); cap.DrawEnd(graphics); } // pallet film if (_solution.Analysis.HasPalletFilm) { film.DrawEnd(graphics); } graphics.EnableFaceSorting = false; }