public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { // ### draw pallet if (graphCtrlPallet == ctrl) { PalletProperties pp = SelectedPallet; Pallet pallet = new Pallet(pp); pallet.Draw(graphics, Transform3D.Identity); DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f }; graphics.AddDimensions(dc); } // ### draw case definition else if (ctrl == graphCtrlBoxesLayout) { // ### draw case definition try { // get selected solution CaseOptimSolution solution = SelectedSolution; if (null == solution) return; // instantiate case definition viewer CaseDefinitionViewer cdv = new CaseDefinitionViewer(SelectedSolution.CaseDefinition, SelectedBox, BuildCaseOptimConstraintSet()); cdv.Orientation = SelectedSolution.PalletSolution.FirstCaseOrientation; cdv.Draw(graphics); } catch (Exception ex) { _log.Error(ex.ToString()); } } // ### draw associated pallet solution else if (ctrl == graphCtrlPalletLayout) { try { // get selected solution CaseOptimSolution solution = SelectedSolution; // get selected box BoxProperties boxProperties = SelectedBox; // get selected pallet PalletProperties palletProperties = SelectedPallet; if (null != solution && null != boxProperties && null != palletProperties) { Vector3D outerDim = solution.CaseDefinition.OuterDimensions(boxProperties, BuildCaseOptimConstraintSet()); BoxProperties caseProperties = new BoxProperties(null, outerDim.X, outerDim.Y, outerDim.Z); caseProperties.SetColor(Color.Chocolate); CasePalletSolutionViewer.Draw(graphics, solution.PalletSolution, caseProperties, null, palletProperties); } } catch (Exception ex) { _log.Error(ex.ToString()); } } }
private void AppendCaseOfBoxesElement(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; // get CaseOfBoxProperties CaseOfBoxesProperties caseOfBoxes = analysis.BProperties as CaseOfBoxesProperties; if (null == caseOfBoxes) return; // elemCaseOfBoxes XmlElement elemCaseOfBoxes = xmlDoc.CreateElement("caseOfBoxes", ns); elemPalletAnalysis.AppendChild(elemCaseOfBoxes); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = caseOfBoxes.Name; elemCaseOfBoxes.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = caseOfBoxes.Description; elemCaseOfBoxes.AppendChild(elemDescription); // length XmlElement elemNoX = xmlDoc.CreateElement("noX", ns); elemNoX.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iLength); elemCaseOfBoxes.AppendChild(elemNoX); // width XmlElement elemNoY = xmlDoc.CreateElement("noY", ns); elemNoY.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iWidth); elemCaseOfBoxes.AppendChild(elemNoY); // height XmlElement elemNoZ = xmlDoc.CreateElement("noZ", ns); elemNoZ.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iHeight); elemCaseOfBoxes.AppendChild(elemNoZ); // number of boxes XmlElement elemNoBoxes = xmlDoc.CreateElement("numberOfBoxes", ns); elemNoBoxes.InnerText = string.Format("{0}", caseOfBoxes.NumberOfBoxes); elemCaseOfBoxes.AppendChild(elemNoBoxes); // dim0 XmlElement eltDim0 = xmlDoc.CreateElement("dim0", ns); eltDim0.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim0); elemCaseOfBoxes.AppendChild(eltDim0); // dim1 XmlElement eltDim1 = xmlDoc.CreateElement("dim1", ns); eltDim1.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim1); elemCaseOfBoxes.AppendChild(eltDim1); AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideLength); AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideWidth); AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideHeight); AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.InsideVolume * UnitsManager.FactorCubeLengthToVolume); AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Length); AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Width); AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Height); AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.Volume * UnitsManager.FactorCubeLengthToVolume); AppendElementValue(xmlDoc, elemCaseOfBoxes, "emptyWeight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.WeightEmpty); AppendElementValue(xmlDoc, elemCaseOfBoxes, "weight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.Weight); // type converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); // view case of boxes iso1 Graphics3DImage graphics1 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics1.CameraPosition = Graphics3D.Corner_0; CaseDefinitionViewer viewer = new CaseDefinitionViewer(caseOfBoxes.CaseDefinition, caseOfBoxes.InsideBoxProperties, caseOfBoxes.CaseOptimConstraintSet); viewer.CaseProperties = caseOfBoxes; viewer.Orientation = sol.FirstCaseOrientation; viewer.Draw(graphics1); graphics1.Flush(); // view case of boxes iso2 Graphics3DImage graphics2 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics2.CameraPosition = Graphics3D.Corner_0; Box box = new Box(0, caseOfBoxes); graphics2.AddBox(box); graphics2.AddDimensions(new DimensionCube(caseOfBoxes.Length, caseOfBoxes.Width, caseOfBoxes.Height)); graphics2.Flush(); // view_caseOfBoxes_iso1 XmlElement elemImage1 = xmlDoc.CreateElement("view_caseOfBoxes_iso1", ns); elemImage1.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics1.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute1 = xmlDoc.CreateAttribute("style"); styleAttribute1.Value = string.Format("width:{0}pt;height:{1}pt", graphics1.Bitmap.Width / 3, graphics1.Bitmap.Height / 3); elemImage1.Attributes.Append(styleAttribute1); elemCaseOfBoxes.AppendChild(elemImage1); // save image SaveImageAs(graphics1.Bitmap, "view_caseOfBoxes_iso1.png"); // view_caseOfBoxes_iso2 XmlElement elemImage2 = xmlDoc.CreateElement("view_caseOfBoxes_iso2", ns); elemImage2.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics2.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute2 = xmlDoc.CreateAttribute("style"); styleAttribute2.Value = string.Format("width:{0}pt;height:{1}pt", graphics2.Bitmap.Width / 3, graphics2.Bitmap.Height / 3); elemImage2.Attributes.Append(styleAttribute2); elemCaseOfBoxes.AppendChild(elemImage2); // save image SaveImageAs(graphics2.Bitmap, "view_caseOfBoxes_iso2.png"); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (graphCtrlBoxCase == ctrl) { BoxProperties boxProperties = new BoxProperties(null , _caseOfBoxesProperties.Length, _caseOfBoxesProperties.Width, _caseOfBoxesProperties.Height); boxProperties.SetAllColors(_faceColors); boxProperties.TextureList = _textures; Box box = new Box(0, boxProperties); graphics.AddBox(box); graphics.AddDimensions(new DimensionCube(_caseOfBoxesProperties.Length, _caseOfBoxesProperties.Width, _caseOfBoxesProperties.Height)); } else if (graphCtrlCaseDefinition == ctrl) { CaseDefinitionViewer viewer = new CaseDefinitionViewer(_caseOfBoxesProperties.CaseDefinition, _caseOfBoxesProperties.InsideBoxProperties, _caseOfBoxesProperties.CaseOptimConstraintSet); viewer.CaseProperties = _caseOfBoxesProperties; viewer.Orientation = new Basics.Orientation(HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); viewer.Draw(graphics); } }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (ctrl == graphCtrlPallet) { // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(GetCurrentSolution()); sv.Draw(graphics); } else if (ctrl == graphCtrlCase) { // get case of boxes CaseOfBoxesProperties caseOfBoxes = _analysis.BProperties as CaseOfBoxesProperties; // draw CaseDefinitionViewer cdv = new CaseDefinitionViewer(caseOfBoxes.CaseDefinition, caseOfBoxes.InsideBoxProperties, caseOfBoxes.CaseOptimConstraintSet); cdv.CaseProperties = caseOfBoxes; cdv.Orientation = GetCurrentSolution().FirstCaseOrientation; cdv.Draw(graphics); } }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (ctrl == graphCtrlBoxesLayout) { // ### draw case definition try { // get selected solution CaseOptimSolution solution = SelectedSolution; if (null == solution) return; // instantiate case definition viewer CaseDefinitionViewer cdv = new CaseDefinitionViewer(SelectedSolution.CaseDefinition, SelectedBox, BuildCaseOptimConstraintSet()); cdv.Orientation = SelectedSolution.PalletSolution.FirstCaseOrientation; cdv.Draw(graphics); } catch (Exception ex) { _log.Error(ex.ToString()); } } if (ctrl == graphCtrlPallet) { // ### draw associated pallet solution try { // get selected solution CaseOptimSolution solution = SelectedSolution; // get selected box BoxProperties boxProperties = SelectedBox; // get selected pallet PalletProperties palletProperties = SelectedPallet; if (null != solution && null != boxProperties && null != palletProperties) { Vector3D outerDim = solution.CaseDefinition.OuterDimensions(boxProperties, BuildCaseOptimConstraintSet()); BoxProperties caseProperties = new BoxProperties(null, outerDim.X, outerDim.Y, outerDim.Z); caseProperties.SetColor(Color.Chocolate); CasePalletSolutionViewer.Draw(graphics, solution.PalletSolution, caseProperties, null, palletProperties); } } catch (Exception ex) { _log.Error(ex.ToString()); } } }