public void Draw(Graphics2D graphics)
        {
            if (null == _truckSolution)
            {
                throw new Exception("No trucksolution defined!");
            }

            // get analysis
            CasePalletAnalysis analysis = _truckSolution.ParentTruckAnalysis.ParentAnalysis;
            double             length   = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletLength;
            double             width    = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletWidth;
            double             height   = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletHeight;

            // initialize Graphics2D object
            graphics.NumberOfViews = 1;
            graphics.SetViewport(
                0.0f, 0.0f
                , (float)_truckSolution.ParentTruckAnalysis.TruckProperties.Length
                , (float)_truckSolution.ParentTruckAnalysis.TruckProperties.Width);

            graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_truckSolution.ParentTruckAnalysis.TruckProperties.Length, _truckSolution.ParentTruckAnalysis.TruckProperties.Width), Color.Black);

            uint pickId = 0;

            foreach (BoxPosition bPositionLayer in _truckSolution.Layer)
            {
                Box b = new Box(pickId++, length, width, height, bPositionLayer);
                graphics.DrawBox(b);
            }
        }
        public void Draw(Graphics2D graphics, Packable packable, double height, bool selected)
        {
            graphics.NumberOfViews = 1;
            graphics.Graphics.Clear(selected ? Color.LightBlue : Color.White);
            graphics.SetViewport(0.0f, 0.0f, (float)_layer.PalletLength, (float)_layer.PalletWidth);

            if (_layer != null)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_layer.PalletLength, _layer.PalletWidth), Color.Black);
                uint pickId = 0;
                foreach (LayerPosition bPosition in _layer)
                {
                    Box b = null;
                    if (packable is PackProperties)
                    {
                        b = new Pack(pickId++, packable as PackProperties, bPosition);
                    }
                    else
                    {
                        b = new Box(pickId++, packable, bPosition);
                    }
                    b.Draw(graphics);
                }

                // draw axes
                bool showAxis = false;
                if (showAxis)
                {
                    // draw axis X
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(_layer.PalletLength, 0.0), Color.Red);
                    // draw axis Y
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _layer.PalletWidth), Color.Green);
                }
            }

            Size s = graphics.Size;

            // *** Annotate : begin ***
            if (height > 0)
            {
                string annotation = string.Format(
                    "{0}*{1}={2}"
                    , _layer.Count
                    , _layer.NoLayers(height)
                    , _layer.CountInHeight(height));
                Font         tfont           = new Font("Arial", _fontSize);
                Color        brushColor      = Color.White;
                Color        backgroundColor = Color.Black;
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Far;
                sf.LineAlignment = StringAlignment.Far;
                System.Drawing.Graphics g = graphics.Graphics;
                Size txtSize = g.MeasureString(annotation, tfont).ToSize();
                g.FillRectangle(new SolidBrush(backgroundColor), new Rectangle(s.Width - txtSize.Width - 2, s.Height - txtSize.Height - 2, txtSize.Width + 2, txtSize.Height + 2));
                g.DrawString(annotation, tfont, new SolidBrush(brushColor), new Point(s.Width - 3, s.Height - 3), sf);
            }
            // *** Annotate : end ***
        }
Пример #3
0
        public void Draw(Graphics2D graphics, Packable packable, double height, bool selected, bool annotate)
        {
            graphics.NumberOfViews = 1;
            graphics.Clear(selected ? Color.LightBlue : Color.White);
            graphics.SetViewport(0.0f, 0.0f, (float)_layer.Length, (float)_layer.Width);
            graphics.SetCurrentView(0);
            graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_layer.Length, _layer.Width), Color.Black);

            // draw layer (brick)
            if (_layer is Layer2D)
            {
                Layer2D layer2D = _layer as Layer2D;
                uint    pickId  = 0;
                foreach (LayerPosition bPosition in layer2D)
                {
                    Box b = null;
                    if (packable is PackProperties)
                    {
                        b = new Pack(pickId++, packable as PackProperties, bPosition);
                    }
                    else if (packable is PackableBrick)
                    {
                        b = new Box(pickId++, packable as PackableBrick, bPosition);
                    }
                    if (null != b)
                    {
                        b.Draw(graphics);
                    }
                }
            }
            // draw layer (cylinder)
            else if (_layer is Layer2DCyl)
            {
                Layer2DCyl layer2DCyl = _layer as Layer2DCyl;
                uint       pickId     = 0;
                foreach (Vector2D pos in layer2DCyl)
                {
                    Cylinder c = new Cylinder(pickId++, packable as CylinderProperties, new CylPosition(new Vector3D(pos.X, pos.Y, 0.0), HalfAxis.HAxis.AXIS_Z_P));
                    graphics.DrawCylinder(c);
                }
            }
            // draw axes
            bool showAxis = false;

            if (showAxis)
            {
                // draw axis X
                graphics.DrawLine(Vector2D.Zero, new Vector2D(_layer.Length, 0.0), Color.Red);
                // draw axis Y
                graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _layer.Width), Color.Green);
            }
            // annotate thumbnail
            if (annotate)
            {
                Annotate(graphics.Graphics, graphics.Size, height);
            }
        }
Пример #4
0
        public void Draw(Graphics2D graphics, BProperties bProperties, double height, bool selected)
        {
            graphics.NumberOfViews = 1;
            graphics.Graphics.Clear(selected ? Color.LightBlue : Color.White);
            graphics.SetViewport(0.0f, 0.0f, (float)_layer.PalletLength, (float)_layer.PalletWidth);

            if (_layer != null)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_layer.PalletLength, _layer.PalletWidth), Color.Black);
                uint pickId = 0;
                foreach (LayerPosition bPosition in _layer)
                    graphics.DrawBox(new Box(pickId++, bProperties, bPosition));

                // draw axes
                bool showAxis = false;
                if (showAxis)
                {
                    // draw axis X
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(_layer.PalletLength, 0.0), Color.Red);
                    // draw axis Y
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _layer.PalletWidth), Color.Green);
                }
            }

            Size s = graphics.Size;

            // *** Annotate : begin ***
            string annotation = string.Format(
                "{0}*{1}={2}"
                , _layer.Count
                , _layer.NoLayers(height)
                , _layer.CountInHeight(height) );
            Font tfont = new Font("Arial", _fontSize);
            Color brushColor = Color.White;
            Color backgroundColor = Color.Black;
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Far;
            sf.LineAlignment = StringAlignment.Far;
            System.Drawing.Graphics g = graphics.Graphics; 
            Size txtSize = g.MeasureString(annotation, tfont).ToSize();
            g.FillRectangle(new SolidBrush(backgroundColor), new Rectangle(s.Width - txtSize.Width - 2, s.Height - txtSize.Height - 2, txtSize.Width + 2, txtSize.Height + 2));
            g.DrawString(annotation, tfont, new SolidBrush(brushColor), new Point(s.Width - 3, s.Height - 3), sf);
            // *** Annotate : end ***
        }
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.LayerCount == 0)
                return;

            BoxLayer blayer = _solution.Layer;
            if (blayer != null)
            {
                // initialize Graphics2D object
                graphics.NumberOfViews = 1;
                BBox3D bbox = blayer.BoundingBox(_analysis.PackProperties);
                graphics.SetViewport(0.0f, 0.0f, (float)bbox.Length, (float)bbox.Width);
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                uint pickId = 0;
                foreach (BoxPosition bPosition in blayer)
                    graphics.DrawBox(new Box(pickId++, _analysis.PackProperties, bPosition));
            }
        }
Пример #6
0
        public void Draw(Graphics2D graphics, IEnumerable <Box> boxes, bool selected, bool annotate)
        {
            graphics.NumberOfViews = 1;
            graphics.Clear(selected ? Color.LightBlue : Color.White);
            graphics.SetViewport(0.0f, 0.0f, (float)Dimensions.X, (float)Dimensions.Y);
            graphics.SetCurrentView(0);
            graphics.DrawRectangle(Vector2D.Zero, Dimensions, Color.Black);

            foreach (var b in boxes)
            {
                b.Draw(graphics);
            }

            // annotate thumbnail
            if (annotate)
            {
                Annotate(graphics.Graphics, graphics.Size);
            }
        }
Пример #7
0
 /// <summary>
 /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
 /// The images produced are used in 
 /// </summary>
 public void Draw(Graphics2D graphics)
 {
     // access case properties
     BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
     BoxProperties caseProperties = boxCaseAnalysis.CaseProperties;
     BProperties boxProperties = boxCaseAnalysis.BProperties;
     // initialize Graphics2D object
     graphics.NumberOfViews = 1;
     graphics.SetViewport(0.0f, 0.0f, (float)caseProperties.Length, (float)caseProperties.Width);
     // access first layer
     BoxLayer blayer = _boxCaseSolution.BoxLayerFirst;
     if (null != blayer)
     {
         graphics.SetCurrentView(0);
         graphics.DrawRectangle(Vector2D.Zero, new Vector2D(caseProperties.InsideLength, caseProperties.InsideWidth), Color.Black);
         uint pickId = 0;
         foreach (BoxPosition bPosition in blayer)
             graphics.DrawBox(new Box(pickId++, boxProperties, bPosition));
     }
 }
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.Count == 0)
            {
                return;
            }

            bool showAxis = false;

            // initialize Graphics2D object
            graphics.NumberOfViews = 1;
            graphics.SetViewport(0.0f, 0.0f, (float)_solution.PalletLength, (float)_solution.PalletWidth);

            CylinderLayer cylLayer = _solution.CylinderLayerFirst;

            if (cylLayer != null)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                uint pickId = 0;
                foreach (Vector3D pos in cylLayer)
                {
                    graphics.DrawCylinder(
                        new Cylinder(pickId++, _analysis.CylinderProperties, new CylPosition(pos, HalfAxis.HAxis.AXIS_Z_P))
                        );
                }

                // draw axes
                if (showAxis)
                {
                    // draw axis X
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                    // draw axis Y
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
        /// The images produced are used in
        /// </summary>
        public void Draw(Graphics2D graphics)
        {
            // access case properties
            BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
            BoxProperties   caseProperties  = boxCaseAnalysis.CaseProperties;
            BProperties     boxProperties   = boxCaseAnalysis.BProperties;

            // initialize Graphics2D object
            graphics.NumberOfViews = 1;
            graphics.SetViewport(0.0f, 0.0f, (float)caseProperties.Length, (float)caseProperties.Width);
            // access first layer
            Layer3DBox blayer = _boxCaseSolution.BoxLayerFirst;

            if (null != blayer)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(caseProperties.InsideLength, caseProperties.InsideWidth), Color.Black);
                uint pickId = 0;
                foreach (BoxPosition bPosition in blayer)
                {
                    graphics.DrawBox(new Box(pickId++, boxProperties, bPosition));
                }
            }
        }
Пример #10
0
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.LayerCount == 0)
            {
                return;
            }

            BoxLayer blayer = _solution.Layer;

            if (blayer != null)
            {
                // initialize Graphics2D object
                graphics.NumberOfViews = 1;
                BBox3D bbox = blayer.BoundingBox(_analysis.PackProperties);
                graphics.SetViewport(0.0f, 0.0f, (float)bbox.Length, (float)bbox.Width);
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                uint pickId = 0;
                foreach (BoxPosition bPosition in blayer)
                {
                    graphics.DrawBox(new Box(pickId++, _analysis.PackProperties, bPosition));
                }
            }
        }
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.Count == 0)
                return;

            bool showAxis = false;

            // initialize Graphics2D object
            graphics.NumberOfViews = 1;
            graphics.SetViewport(0.0f, 0.0f, (float)_solution.PalletLength, (float)_solution.PalletWidth);

            CylinderLayer cylLayer = _solution.CylinderLayerFirst;
            if (cylLayer != null)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                uint pickId = 0;
                foreach (Vector3D pos in cylLayer)
                    graphics.DrawCylinder(
                        new Cylinder(pickId++, _analysis.CylinderProperties, new CylPosition(pos, HalfAxis.HAxis.AXIS_Z_P))
                        );

                // draw axes
                if (showAxis)
                {
                    // draw axis X
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                    // draw axis Y
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
        /// </summary>
        public void Draw(Graphics2D graphics)
        {
            if (null == _caseSolution)
            {
                throw new Exception("No case solution defined!");
            }

            BoxCasePalletAnalysis caseAnalysis = _caseSolution.ParentCaseAnalysis;

            if (_caseSolution.HasHomogeneousLayers)
            {
                graphics.NumberOfViews = 1;
                graphics.SetViewport(0.0f, 0.0f, (float)_caseSolution.CaseLength, (float)_caseSolution.CaseWidth);

                BoxLayer blayer = _caseSolution[0] as BoxLayer;
                if (blayer != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                    }
                }
            }
            else
            {
                graphics.NumberOfViews = 2;
                graphics.SetViewport(0.0f, 0.0f, (float)_caseSolution.CaseLength, (float)_caseSolution.CaseWidth);

                // get first box layer
                if (_caseSolution.Count < 1)
                {
                    return;
                }
                BoxLayer blayer0 = _caseSolution[0] as BoxLayer;
                if (blayer0 != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer0)
                    {
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                    }
                }

                // get second box layer
                if (_caseSolution.Count < 2)
                {
                    return;
                }
                BoxLayer blayer1 = _caseSolution[1] as BoxLayer;
                if (null == blayer1 && _caseSolution.Count > 2)
                {
                    blayer1 = _caseSolution[2] as BoxLayer;
                }
                if (blayer1 != null)
                {
                    graphics.SetCurrentView(1);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer1)
                    {
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                    }
                }
            }
        }
        /// <summary>
        /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
        /// The images produced are used in
        /// </summary>
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.Count == 0)
            {
                return;
            }

            bool showAxis = false;

            if (_solution.HasHomogeneousLayers)
            {
                // initialize Graphics2D object
                graphics.NumberOfViews = 1;
                graphics.SetViewport(0.0f, 0.0f, (float)_solution.PalletLength, (float)_solution.PalletWidth);

                Layer3DBox blayer = _solution.CaseLayerFirst;
                if (blayer != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));
                    }

                    // draw axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }
            }
            else
            {
                graphics.NumberOfViews = 2;
                graphics.SetViewport(0.0f, 0.0f, (float)_analysis.PalletProperties.Length, (float)_analysis.PalletProperties.Width);

                // get first box layer
                if (_solution.CaseLayersCount < 1)
                {
                    return;
                }
                Layer3DBox blayer0 = _solution.CaseLayerFirst;
                if (blayer0 != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer0)
                    {
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));
                    }

                    // show axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }

                // get second box layer
                if (_solution.CaseLayersCount < 2)
                {
                    return;
                }
                Layer3DBox blayer1 = _solution.CaseLayerSecond;
                if (null == blayer1 && _solution.Count > 2)
                {
                    blayer1 = _solution[2] as Layer3DBox;
                }
                if (blayer1 != null)
                {
                    graphics.SetCurrentView(1);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer1)
                    {
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));
                    }
                    // show axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }
            }
        }
        /// <summary>
        /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
        /// The images produced are used in 
        /// </summary>
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.Count == 0)
                return;

            bool showAxis = false;

            if (_solution.HasHomogeneousLayers)
            {
                // initialize Graphics2D object
                graphics.NumberOfViews = 1;
                graphics.SetViewport(0.0f, 0.0f, (float)_solution.PalletLength, (float)_solution.PalletWidth);

                BoxLayer blayer = _solution.CaseLayerFirst;
                if (blayer != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer)
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));

                    // draw axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }
            }
            else
            {
                graphics.NumberOfViews = 2;
                graphics.SetViewport(0.0f, 0.0f, (float)_analysis.PalletProperties.Length, (float)_analysis.PalletProperties.Width);

                // get first box layer
                if (_solution.CaseLayersCount < 1) return;
                BoxLayer blayer0 = _solution.CaseLayerFirst;
                if (blayer0 != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer0)
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));

                    // show axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }

                // get second box layer
                if (_solution.CaseLayersCount < 2) return;
                BoxLayer blayer1 = _solution.CaseLayerSecond;
                if (null == blayer1 && _solution.Count > 2)
                    blayer1 = _solution[2] as BoxLayer;
                if (blayer1 != null)
                {
                    graphics.SetCurrentView(1);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer1)
                        graphics.DrawBox(new Box(pickId++, _analysis.BProperties, bPosition));
                    // show axes
                    if (showAxis)
                    {
                        // draw axis X
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, 0.0), Color.Red);
                        // draw axis Y
                        graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _analysis.PalletProperties.Width), Color.Green);
                    }
                }
            }
        }
        /// <summary>
        /// Draw a 2D representation of first (and second, if solution does not have homogeneous layers) layer(s)
        /// </summary>
        public void Draw(Graphics2D graphics)
        {
            if (null == _caseSolution)
                throw new Exception("No case solution defined!");

            BoxCasePalletAnalysis caseAnalysis = _caseSolution.ParentCaseAnalysis;

            if (_caseSolution.HasHomogeneousLayers)
            {
                graphics.NumberOfViews = 1;
                graphics.SetViewport(0.0f, 0.0f, (float)_caseSolution.CaseLength, (float)_caseSolution.CaseWidth);

                BoxLayer blayer = _caseSolution[0] as BoxLayer;
                if (blayer != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer)
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                }
            }
            else 
            {
                graphics.NumberOfViews = 2;
                graphics.SetViewport(0.0f, 0.0f, (float)_caseSolution.CaseLength, (float)_caseSolution.CaseWidth);

                // get first box layer
                if (_caseSolution.Count < 1) return;
                BoxLayer blayer0 = _caseSolution[0] as BoxLayer;
                if (blayer0 != null)
                {
                    graphics.SetCurrentView(0);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer0)
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                }

                // get second box layer
                if (_caseSolution.Count < 2) return;
                BoxLayer blayer1 = _caseSolution[1] as BoxLayer;
                if (null == blayer1 && _caseSolution.Count > 2)
                    blayer1 = _caseSolution[2] as BoxLayer;
                if (blayer1 != null)
                {
                    graphics.SetCurrentView(1);
                    graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_caseSolution.CaseLength, _caseSolution.CaseWidth), Color.Black);
                    uint pickId = 0;
                    foreach (BoxPosition bPosition in blayer1)
                        graphics.DrawBox(new Box(pickId++, caseAnalysis.BoxProperties, bPosition));
                }
            }
        }
Пример #16
0
        public void Draw(Graphics2D graphics)
        {
            if (null == _truckSolution)
                throw new Exception("No trucksolution defined!");

            // get analysis
            CasePalletAnalysis analysis = _truckSolution.ParentTruckAnalysis.ParentAnalysis;
            double length = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletLength;
            double width = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletWidth;
            double height = _truckSolution.ParentTruckAnalysis.ParentSolution.PalletHeight;

            // initialize Graphics2D object
            graphics.NumberOfViews = 1;
            graphics.SetViewport(
                0.0f, 0.0f
                , (float)_truckSolution.ParentTruckAnalysis.TruckProperties.Length
                , (float)_truckSolution.ParentTruckAnalysis.TruckProperties.Width);

            graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_truckSolution.ParentTruckAnalysis.TruckProperties.Length, _truckSolution.ParentTruckAnalysis.TruckProperties.Width), Color.Black);

            uint pickId = 0;
            foreach (BoxPosition bPositionLayer in _truckSolution.Layer)
            {
                Box b = new Box(pickId++, length, width, height);
                b.Position = bPositionLayer.Position;
                b.LengthAxis = HalfAxis.ToVector3D(bPositionLayer.DirectionLength);
                b.WidthAxis = HalfAxis.ToVector3D(bPositionLayer.DirectionWidth);
                graphics.DrawBox(b);
            }
        }