コード例 #1
0
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            // instantiate solution viewer
            CasePalletSolutionViewer sv = new CasePalletSolutionViewer(GetCurrentSolution());

            sv.Draw(graphics);
        }
コード例 #2
0
        private void Draw()
        {
            try
            {
                // get current descriptor
                PalletSolutionDesc desc = CurrentSolutionDesc;
                // sanity check
                if (null == desc ||
                    pictureBoxCase.Size.Width < 1 || pictureBoxCase.Size.Height < 1 ||
                    pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1)
                {
                    return;
                }

                // load document
                Document document = new Document(desc.FullFilePath, null);
                if (!document.AnalysesCasePallet.Any())
                {
                    return;
                }
                // get analysis and solution
                CasePalletAnalysis analysis = document.AnalysesCasePallet.First() as CasePalletAnalysis;
                {
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxCase.Size)
                    {
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    Box box = new Box(0, analysis.BProperties);
                    graphics.AddBox(box);
                    graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
                    graphics.Flush();
                    pictureBoxCase.Image = graphics.Bitmap;
                }

                {
                    // instantiate graphics
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size)
                    {
                        // set camera position
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    // instantiate solution viewer
                    CasePalletSolutionViewer sv = new CasePalletSolutionViewer(analysis.Solutions[0]);
                    sv.Draw(graphics);
                    graphics.Flush();
                    // show generated bitmap on picture box control
                    pictureBoxSolution.Image = graphics.Bitmap;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #3
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     try
     {
         // instantiate solution viewer
         CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution);
         sv.Draw(graphics);
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
コード例 #4
0
 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())
             {
                 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());
         }
     }
 }
コード例 #5
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (graphCtrlCaseSolution == ctrl)
     {
         // instantiate solution viewer
         BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(GetCurrentSolution());
         sv.Draw(graphics);
     }
     else if (graphCtrlPalletSolution == ctrl)
     {
         CasePalletSolution sol = GetCurrentSolution().PalletSolutionDesc.LoadPalletSolution();
         // instantial solution viewer
         CasePalletSolutionViewer svPallet = new CasePalletSolutionViewer(sol);
         svPallet.Draw(graphics);
     }
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (ctrl == graphCtrlPallet)
     {
         PalletProperties pp     = CurrentPallet;
         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);
     }
     else if (ctrl == graphCtrlSolution)
     {
         if (null == CurrentSolution)
         {
             return;
         }
         CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution);
         sv.Draw(graphics);
     }
 }
コード例 #8
0
        private void ProcessViewSolution(viewSolution vSol)
        {
            // instantiate graphics
            Graphics3DImage graphics = InitializeImageFromViewParameters(vSol.viewParameters);
            // load analysis
            CasePalletAnalysis analysis = LoadPalletAnalysis(null, vSol.solutionRef.analysisId);

            // compute solutions
            treeDiM.StackBuilder.Engine.CasePalletSolver solver = new treeDiM.StackBuilder.Engine.CasePalletSolver();
            solver.ProcessAnalysis(analysis);
            // retrieve wanted solution
            List <Basics.CasePalletSolution> solutions = analysis.Solutions;

            if (vSol.solutionRef.index >= solutions.Count)
            {
                throw new Exception(string.Format("Analysis {0} has no solution with index {1}", analysis.Name, vSol.solutionRef.index));
            }
            Basics.CasePalletSolution sol = solutions[(int)vSol.solutionRef.index];
            // display solution
            CasePalletSolutionViewer solViewer = new CasePalletSolutionViewer(sol);

            solViewer.Draw(graphics);
            FinalizeImageFromViewParameters(vSol.viewParameters, graphics);
        }
コード例 #9
0
        private void Draw()
        {
            try
            {
                // sanity check
                if (pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1)
                {
                    return;
                }
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size);
                // set camera position
                double angleHorizRad = trackBarAngleHoriz.Value * Math.PI / 180.0;
                double angleVertRad  = trackBarAngleVert.Value * Math.PI / 180.0;
                graphics.CameraPosition = new Vector3D(
                    _cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad)
                    , _cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad)
                    , _cameraDistance * Math.Sin(angleVertRad));
                // set camera target
                graphics.Target = Vector3D.Zero;
                // set viewport (not actually needed)
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // show images
                graphics.ShowTextures = true;
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution);
                sv.Draw(graphics);

                // show generated bitmap on picture box control
                pictureBoxSolution.Image = graphics.Bitmap;
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: zanxueyan/StackBuilder
        private static void RunBoxTest(bool useSingleColor, Document doc, PalletProperties palletProperties)
        {
            // define box properties
            var boxProperties = new BoxProperties(doc, 162, 210, 250);

            //boxProperties.Name = "Box1";
            boxProperties.SetWeight(3.0);
            if (!useSingleColor)
            {
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
            }
            else
            {
                boxProperties.SetColor(Color.Chocolate);
            }

            Console.WriteLine(boxProperties.ToString());


            InterlayerProperties interlayerProperties = null;

            // define constraints
            var constraintSet = new CasePalletConstraintSet();

            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
            constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

            constraintSet.SetAllowedPattern("Trilock");

            constraintSet.AllowAlignedLayers   = true;
            constraintSet.AllowAlternateLayers = false;

            constraintSet.MaximumPalletWeight             = 2000;
            constraintSet.MaximumNumberOfItems            = 2000;
            constraintSet.MaximumHeight                   = 2000.0;
            constraintSet.UseMaximumHeight                = true;
            constraintSet.UseMaximumPalletWeight          = true;
            constraintSet.UseMaximumWeightOnBox           = false;
            constraintSet.AllowLastLayerOrientationChange = true;
            Console.WriteLine("=== Constraint set ===");
            Console.WriteLine(constraintSet.ToString());

            // initialize analysis
            var analysis = new CasePalletAnalysis(
                boxProperties, palletProperties, interlayerProperties,
                null, null, null, null,
                constraintSet);

            // initialize solver
            var solver = new CasePalletSolver();

            solver.ProcessAnalysis(analysis);

            Console.WriteLine("=== Solutions ===");
            int solIndex = 0;

            foreach (CasePalletSolution sol in analysis.Solutions)
            {
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                graphics.Target         = Vector3D.Zero;
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                sv.Draw(graphics);
                graphics.Flush();
                // save
                string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                string filePath = Path.Combine(Path.GetTempPath(), fileName);
                Console.WriteLine("Saving file " + filePath + "...");
                graphics.SaveAs(filePath);
            }
        }
コード例 #11
0
        private void FillGrid()
        {
            // fill grid solution
            gridSolutions.Rows.Clear();

            // border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            // views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);

            viewNormal.Border = cellBorder;
            CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White);

            viewNormalCheck.Border = cellBorder;

            // column header view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor                   = Color.LightGray;
            backHeader.Border                      = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background            = backHeader;
            viewColumnHeader.ForeColor             = Color.White;
            viewColumnHeader.Font                  = new Font("Arial", 10, FontStyle.Bold);
            viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

            // create the grid
            gridSolutions.BorderStyle = BorderStyle.FixedSingle;

            gridSolutions.ColumnsCount = 7;
            gridSolutions.FixedRows    = 1;
            gridSolutions.Rows.Insert(0);

            // header
            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 0] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 1] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 2] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 3] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString));
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString));
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 5] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 6] = columnHeader;

            // handling check box click
            SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click);


            // data rows
            int iIndex = 0;

            foreach (CasePalletSolution sol in _analysis.Solutions)
            {
                ++iIndex;
                gridSolutions.Rows.Insert(iIndex);
                gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex));
                {
                    Graphics2DImage          graphics = new Graphics2DImage(new Size(100, 50));
                    CasePalletSolutionViewer sv       = new CasePalletSolutionViewer(sol);
                    sv.Draw(graphics);
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseCount));
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.VolumeEfficiencyCases));
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletWeight));
                gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletHeight));
                gridSolutions[iIndex, 6] = new SourceGrid.Cells.CheckBox(null, _analysis.HasSolutionSelected(iIndex - 1));

                gridSolutions[iIndex, 0].View = viewNormal;
                gridSolutions[iIndex, 1].View = viewNormal;
                gridSolutions[iIndex, 2].View = viewNormal;
                gridSolutions[iIndex, 3].View = viewNormal;
                gridSolutions[iIndex, 4].View = viewNormal;
                gridSolutions[iIndex, 5].View = viewNormal;
                gridSolutions[iIndex, 6].View = viewNormalCheck;

                gridSolutions[iIndex, 6].AddController(solCheckboxClickEvent);
            }
            gridSolutions.AutoStretchColumnsToFitWidth = true;
            gridSolutions.AutoSizeCells();
            gridSolutions.Columns.StretchToFit();

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            graphCtrlCase.Invalidate();
            graphCtrlPallet.Invalidate();
        }
コード例 #12
0
        private void FillGrid()
        {
            // fill grid solutions
            gridSolutions.Rows.Clear();

            // border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            // views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);

            viewNormal.Border = cellBorder;

            // column header view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor                   = Color.LightGray;
            backHeader.Border                      = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background            = backHeader;
            viewColumnHeader.ForeColor             = Color.White;
            viewColumnHeader.Font                  = new Font("Arial", 10, FontStyle.Bold);
            viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

            // create the grid
            gridSolutions.BorderStyle = BorderStyle.FixedSingle;

            gridSolutions.ColumnsCount = 5;
            gridSolutions.FixedRows    = 1;
            gridSolutions.Rows.Insert(0);

            // header
            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 0] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 1] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_BUNDLECOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 2] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 3] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETWEIGHT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;

            // data rows
            int iIndex = 0;

            foreach (CasePalletSolution sol in _analysis.Solutions)
            {
                // build case count string
                string sBoxCount = string.Empty;
                sBoxCount = string.Format("{0}\n({1} * {2})", sol.CaseCount, sol.CasePerLayerCount, sol.Count);
                // insert row
                gridSolutions.Rows.Insert(++iIndex);
                // filling columns
                gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex));
                {
                    Graphics2DImage          graphics = new Graphics2DImage(new Size(80, 40));
                    CasePalletSolutionViewer sv       = new CasePalletSolutionViewer(sol);
                    sv.Draw(graphics);
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sBoxCount);
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.VolumeEfficiencyCases));
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletWeight));

                gridSolutions[iIndex, 0].View = viewNormal;
                gridSolutions[iIndex, 1].View = viewNormal;
                gridSolutions[iIndex, 2].View = viewNormal;
                gridSolutions[iIndex, 3].View = viewNormal;
                gridSolutions[iIndex, 4].View = viewNormal;
            }

            gridSolutions.AutoStretchColumnsToFitWidth = true;
            gridSolutions.AutoSizeCells();
            gridSolutions.Columns.StretchToFit();

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            // redraw
            graphCtrlSolution.Invalidate();
        }
コード例 #13
0
 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());
         }
     }
 }
コード例 #14
0
        private void FillGrid()
        {
            // fill grid solution
            gridSolutions.Rows.Clear();

            // border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            // views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);

            viewNormal.Border = cellBorder;
            CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White);

            viewNormalCheck.Border = cellBorder;

            // column header view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor                   = Color.LightGray;
            backHeader.Border                      = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background            = backHeader;
            viewColumnHeader.ForeColor             = Color.White;
            viewColumnHeader.Font                  = new Font("Arial", 8, FontStyle.Regular);
            viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

            // create the grid
            gridSolutions.BorderStyle = BorderStyle.FixedSingle;

            gridSolutions.ColumnsCount = 9;
            gridSolutions.FixedRows    = 1;
            gridSolutions.Rows.Insert(0);

            // header
            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 0] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT);
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 1]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASEPERLAYERCOUNT);
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 2]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERCOUNT);
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 3]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY);
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 4]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 5]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View         = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 6]       = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETLIMIT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 7] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View   = viewColumnHeader;
            gridSolutions[0, 8] = columnHeader;

            // handling check box click
            SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click);

            // data rows
            int iIndex = 0;

            foreach (CasePalletSolution sol in _analysis.Solutions)
            {
                // build case count string
                string sCaseCount = string.Empty;
                if (sol.HasSameCountLayers && sol.LimitReached == CasePalletSolution.Limit.LIMIT_MAXHEIGHTREACHED)
                {
                    sCaseCount = string.Format("{0}\n({1} * {2})", sol.CaseCount, sol.CasePerLayerCount, sol.CaseLayersCount);
                }
                else
                {
                    sCaseCount = string.Format("{0}", sol.CaseCount);
                }

                // insert row
                gridSolutions.Rows.Insert(++iIndex);
                gridSolutions.Rows[iIndex].Tag = sol;

                // filling columns
                {
                    Graphics2DImage          graphics = new Graphics2DImage(new Size(100, 50));
                    CasePalletSolutionViewer sv       = new CasePalletSolutionViewer(sol);
                    sv.Draw(graphics);
                    gridSolutions[iIndex, 0] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(sol.CaseCount);
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sol.CasePerLayerCount);
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(sol.CaseLayersCount);
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(Math.Round(sol.VolumeEfficiencyCases, 1));
                gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletWeight, 3));
                gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletHeight, 1));
                gridSolutions[iIndex, 7] = new SourceGrid.Cells.Cell(PalletSolutionLimitToString(sol.LimitReached));
                gridSolutions[iIndex, 8] = new SourceGrid.Cells.CheckBox(null, _analysis.HasSolutionSelected(iIndex - 1));

                gridSolutions[iIndex, 0].View = viewNormal;
                gridSolutions[iIndex, 1].View = viewNormal;
                gridSolutions[iIndex, 2].View = viewNormal;
                gridSolutions[iIndex, 3].View = viewNormal;
                gridSolutions[iIndex, 4].View = viewNormal;
                gridSolutions[iIndex, 5].View = viewNormal;
                gridSolutions[iIndex, 6].View = viewNormal;
                gridSolutions[iIndex, 7].View = viewNormal;
                gridSolutions[iIndex, 8].View = viewNormalCheck;

                gridSolutions[iIndex, 8].AddController(solCheckboxClickEvent);
            }
            gridSolutions.AutoStretchColumnsToFitWidth = true;
            gridSolutions.AutoSizeCells();
            gridSolutions.Columns.StretchToFit();

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            graphCtrlSolution.Invalidate();
        }
コード例 #15
0
 private void Draw()
 {
     // ### draw case definition
     try
     {
         // sanity check
         if (pbBoxesLayout.Size.Width < 1 || pbBoxesLayout.Size.Height < 1)
         {
             return;
         }
         // instantiate graphics
         Graphics3DImage graphics = new Graphics3DImage(pbBoxesLayout.Size);
         // set camera position
         graphics.CameraPosition = Graphics3D.Corner_0;
         // set camera target
         graphics.Target = new Vector3D(0.0, 0.0, 0.0);
         // set viewport (not actually needed)
         graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
         // show images
         graphics.ShowTextures = true;
         // 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);
         // show generated bitmap on picture box control
         pbBoxesLayout.Image = graphics.Bitmap;
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
     // ### draw associated pallet solution
     try
     {
         // sanity check
         if (pbPalletSolution.Size.Width < 1 || pbPalletSolution.Size.Height < 1)
         {
             return;
         }
         // instantiate graphics
         Graphics3DImage graphics = new Graphics3DImage(pbPalletSolution.Size);
         // set camera position
         graphics.CameraPosition = Graphics3D.Corner_0;
         // set camera target
         graphics.Target = new Vector3D(0.0, 0.0, 0.0);
         // set viewport (not actually needed)
         graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
         // show images
         graphics.ShowTextures = true;
         // 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);
         }
         // show generated bitmap or picture box control
         pbPalletSolution.Image = graphics.Bitmap;
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: wkumanuvong/StackBuilder
        static int Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));

            XmlConfigurator.Configure();

            try
            {
                bool useSingleColor = false;
                // instantiate document
                Document doc = new Document("Test", "Test", "fga", DateTime.Now, null);

                // define pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150);
                Console.WriteLine("=== Pallet properties ===");
                Console.WriteLine(palletProperties.ToString());

                bool testCylinder = false;
                if (!testCylinder)
                {
                    // define box properties
                    BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250);
                    boxProperties.Name   = "Box1";
                    boxProperties.Weight = 3.0;
                    if (!useSingleColor)
                    {
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
                    }
                    else
                    {
                        boxProperties.SetColor(Color.Chocolate);
                    }

                    Console.WriteLine(boxProperties.ToString());


                    InterlayerProperties interlayerProperties = null;

                    // define constraints
                    CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                    constraintSet.SetAllowedPattern("Trilock");

                    constraintSet.AllowAlignedLayers   = true;
                    constraintSet.AllowAlternateLayers = false;

                    constraintSet.MaximumPalletWeight             = 2000;
                    constraintSet.MaximumNumberOfItems            = 2000;
                    constraintSet.MaximumHeight                   = 2000.0;
                    constraintSet.UseMaximumHeight                = true;
                    constraintSet.UseMaximumPalletWeight          = true;
                    constraintSet.UseMaximumWeightOnBox           = false;
                    constraintSet.AllowLastLayerOrientationChange = true;
                    Console.WriteLine("=== Constraint set ===");
                    Console.WriteLine(constraintSet.ToString());

                    // initialize analysis
                    CasePalletAnalysis analysis = new CasePalletAnalysis(
                        boxProperties, palletProperties, interlayerProperties,
                        null, null, null, null,
                        constraintSet);

                    // initialize solver
                    CasePalletSolver solver = new CasePalletSolver();
                    solver.ProcessAnalysis(analysis);

                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CasePalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target         = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        graphics.Flush();
                        // save
                        string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
                else
                {
                    // cylinder
                    Console.WriteLine("=== Cylinder properties ===");
                    CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder",
                                                                              90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue);
                    Console.WriteLine(cylProperties.ToString());
                    // constraint set
                    Console.WriteLine("=== Constraint set ===");
                    CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet();
                    constraintSet.UseMaximumPalletHeight  = true;
                    constraintSet.MaximumPalletHeight     = 1200.0;
                    constraintSet.UseMaximumPalletWeight  = true;
                    constraintSet.MaximumPalletWeight     = 2000;
                    constraintSet.UseMaximumNumberOfItems = true;
                    constraintSet.MaximumNumberOfItems    = 2000;
                    Console.WriteLine(constraintSet.ToString());
                    // cylinder analysis
                    CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet);
                    // initialize solver
                    CylinderSolver solver = new CylinderSolver();
                    solver.ProcessAnalysis(analysis);
                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CylinderPalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target         = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        string fileName = string.Format("Pallet_{0}.jpg", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(0);
        }