public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (TruckLength == 0 || TruckWidth == 0 || TruckHeight == 0) return; TruckProperties truckProperties = new TruckProperties(null, TruckLength, TruckWidth, TruckHeight); truckProperties.Color = TruckColor; Truck truck = new Truck(truckProperties); truck.DrawBegin(graphics); truck.DrawEnd(graphics); graphics.AddDimensions(new DimensionCube(TruckLength, TruckWidth, TruckHeight)); }
private void ProcessViewItem(viewItem vItem) { Graphics3DImage graphics = InitializeImageFromViewParameters(vItem.viewParameters); // load case BoxProperties bProperties = LoadCaseById(null, _root.data.items.library_cases, vItem.itemId); if (null != bProperties) { graphics.AddBox(new Box(0, bProperties)); if (vItem.viewParameters.showDimensions) graphics.AddDimensions(new DimensionCube(bProperties.Length, bProperties.Width, bProperties.Height)); } // load pallet PalletProperties palletProperties = LoadPalletById(null, _root.data.items.library_pallets, vItem.itemId); if (null != palletProperties) { Pallet pallet = new Pallet(palletProperties); pallet.Draw(graphics, Transform3D.Identity); if (vItem.viewParameters.showDimensions) graphics.AddDimensions(new DimensionCube(palletProperties.Length, palletProperties.Width, palletProperties.Height)); } // load interlayer InterlayerProperties interlayerProperties = LoadInterlayerById(null, _root.data.items.library_interlayers, vItem.itemId); if (null != interlayerProperties) { graphics.AddBox(new Box(0, interlayerProperties)); if (vItem.viewParameters.showDimensions) graphics.AddDimensions(new DimensionCube(interlayerProperties.Length, interlayerProperties.Width, interlayerProperties.Thickness)); } // load bundle BundleProperties bundleProperties = LoadBundleById(null, _root.data.items.library_bundles, vItem.itemId); if (null != bundleProperties) { graphics.AddBox(new Box(0, bundleProperties)); if (vItem.viewParameters.showDimensions) graphics.AddDimensions(new DimensionCube(bundleProperties.Length, bundleProperties.Width, bundleProperties.Height)); } // load truck TruckProperties truckProperties = null; if (null != truckProperties) { Truck truck = new Truck(truckProperties); truck.Draw(graphics); if (vItem.viewParameters.showDimensions) graphics.AddDimensions(new DimensionCube(truckProperties.Length, truckProperties.Width, truckProperties.Height)); } FinalizeImageFromViewParameters(vItem.viewParameters, graphics); }
private void AppendTruckElement(TruckAnalysis truckAnalysis, XmlElement elemTruckAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; // get PalletProperties TruckProperties truckProp = truckAnalysis.TruckProperties; if (null == truckProp) return; // create "truck" element XmlElement elemTruck = xmlDoc.CreateElement("truck", ns); elemTruckAnalysis.AppendChild(elemTruck); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = truckProp.Name; elemTruck.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = truckProp.Description; elemTruck.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemTruck, "length", UnitsManager.UnitType.UT_LENGTH, truckProp.Length); AppendElementValue(xmlDoc, elemTruck, "width", UnitsManager.UnitType.UT_LENGTH, truckProp.Width); AppendElementValue(xmlDoc, elemTruck, "height", UnitsManager.UnitType.UT_LENGTH, truckProp.Height); AppendElementValue(xmlDoc, elemTruck, "admissibleLoad", UnitsManager.UnitType.UT_MASS, truckProp.AdmissibleLoadWeight); // --- build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; Truck truck = new Truck(truckProp); truck.DrawBegin(graphics); truck.DrawEnd(graphics); DimensionCube dc = new DimensionCube(truckProp.Length, truckProp.Width, truckProp.Height); dc.FontSize = 6.0f; graphics.AddDimensions(dc); graphics.Flush(); // --- // view_truck_iso XmlElement elemImage = xmlDoc.CreateElement("view_truck_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); elemTruck.AppendChild(elemImage); // Save image ? SaveImageAs(graphics.Bitmap, "view_truck_iso.png"); }
public void Draw(Graphics3D graphics) { if (null == _truckSolution) throw new Exception("No trucksolution defined!"); // draw truck Truck truck = new Truck(_truckSolution.ParentTruckAnalysis.TruckProperties); truck.DrawBegin(graphics); truck.DrawEnd(graphics); // get pallet height CasePalletAnalysis analysis = _truckSolution.ParentTruckAnalysis.ParentAnalysis; double palletLength = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletLength; double palletWidth = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletWidth; double palletHeight = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletHeight; // get parent pallet solution CasePalletSolution sol = _truckSolution.ParentTruckAnalysis.ParentSolution; // draw solution uint pickIdGlobal = 0; for (int i = 0; i < _truckSolution.NoLayers; ++i) { foreach (BoxPosition bPositionLayer in _truckSolution.Layer) { BoxPosition bPalletPosition = new BoxPosition( new Vector3D( bPositionLayer.Position.X , bPositionLayer.Position.Y , bPositionLayer.Position.Z + palletHeight * i) , bPositionLayer.DirectionLength , bPositionLayer.DirectionWidth); if (_showDetails) { // build transformation Transform3D transformPallet = bPalletPosition.Transformation; // draw pallet Pallet pallet = new Pallet(analysis.PalletProperties); pallet.Draw(graphics, transformPallet); // draw solution uint pickId = 0; foreach (ILayer layer in sol) { BoxLayer bLayer = layer as BoxLayer; if (null != bLayer) { foreach (BoxPosition bPosition in bLayer) graphics.AddBox(new Box(pickId++, analysis.BProperties, BoxPosition.Transform(bPosition, transformPallet))); } InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { BoxPosition iPos = new BoxPosition(new Vector3D(0.0, 0.0, interlayerPos.ZLow), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); graphics.AddBox(new Box(pickId++, analysis.InterlayerProperties, BoxPosition.Transform(iPos, transformPallet))); } } } else { Box b = new Box(pickIdGlobal++, new BoxProperties(null, palletLength, palletWidth, palletHeight), bPalletPosition); b.SetAllFacesColor(Color.Chocolate); graphics.AddBox(b); } } } // fluch graphics.UseBoxelOrderer = false; // can not use boxel orderer for full truck view -> too slow... }