Exemplo n.º 1
0
        internal BoxProperties ToCase(DataCase dtCase)
        {
            BoxProperties boxProperties = new BoxProperties(null
                                                            , dtCase.OuterDimensions[0], dtCase.OuterDimensions[1], dtCase.OuterDimensions[2]
                                                            , dtCase.InnerDimensions[0], dtCase.InnerDimensions[1], dtCase.InnerDimensions[2]);

            Color[] colors = Enumerable.Repeat(Color.Chocolate, 6).ToArray();
            boxProperties.ID.SetNameDesc(dtCase.Name, dtCase.Description);
            boxProperties.SetAllColors(colors);
            boxProperties.TapeColor = Color.Beige;
            boxProperties.TapeWidth = new OptDouble(true, UnitsManager.ConvertLengthFrom(50, UnitsManager.UnitSystem.UNIT_METRIC1));
            boxProperties.SetWeight(dtCase.Weight);
            boxProperties.SetNetWeight(new OptDouble(dtCase.NetWeight > 0.0, dtCase.NetWeight));
            return(boxProperties);
        }
Exemplo n.º 2
0
 /// <summary>
 /// constructor (from length, width, height)
 /// </summary>
 public FormEditBitmaps(double length, double width, double height, Color[] faceColors)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // set internal box properties
     _boxProperties = new BoxProperties(null, length, width, height);
     _boxProperties.SetAllColors(faceColors);
     // get textures
     _textures = _boxProperties.TextureListCopy;
     // set default face
     cbFace.SelectedIndex = 0;
     // set horizontal angle
     trackBarHorizAngle.Value = 225;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new BoxProperties object with MODE_CASE
        /// </summary>
        public void CreateNewCaseUI()
        {
            FormNewBox form = new FormNewBox(this, FormNewBox.Mode.MODE_CASE);

            if (DialogResult.OK == form.ShowDialog())
            {
                BoxProperties boxProperties = CreateNewCase(form.BoxName, form.Description
                                                            , form.BoxLength, form.BoxWidth, form.BoxHeight
                                                            , form.InsideLength, form.InsideWidth, form.InsideHeight
                                                            , form.Weight, form.Colors);
                boxProperties.TapeColor   = form.TapeColor;
                boxProperties.TapeWidth   = form.TapeWidth;
                boxProperties.TextureList = form.TextureList;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new BoxProperties object with MODE_BOX
 /// </summary>
 public void CreateNewBoxUI()
 {
     using (FormNewBox form = new FormNewBox(this, FormNewBox.Mode.BOX))
     {
         if (DialogResult.OK == form.ShowDialog())
         {
             BoxProperties boxProperties = CreateNewBox(form.BoxName, form.Description
                                                        , form.BoxLength, form.BoxWidth, form.BoxHeight
                                                        , form.Weight, form.Colors);
             boxProperties.Bulge = form.Bulge;
             boxProperties.SetNetWeight(form.NetWeight);
             boxProperties.TextureList = form.TextureList;
         }
     }
 }
Exemplo n.º 5
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());
             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());
         }
     }
 }
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _boxCaseSolution)
            {
                throw new Exception("No box/case solution defined!");
            }

            BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
            // retrieve case properties
            BProperties boxProperties = boxCaseAnalysis.BProperties;

            if (null == boxProperties)
            {
                return;
            }
            BoxProperties caseProperties = boxCaseAnalysis.CaseProperties;
            // draw case (inside)
            Case case_ = new Case(caseProperties);

            case_.DrawInside(graphics);
            // draw solution
            uint pickId = 0;

            foreach (ILayer layer in _boxCaseSolution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                    }
                }
            }
            // get case analysis
            if (_showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(
                                           Vector3D.Zero
                                           , caseProperties.Length, caseProperties.Width, caseProperties.Height
                                           , System.Drawing.Color.Black
                                           , true));
                graphics.AddDimensions(new DimensionCube(
                                           _boxCaseSolution.LoadBoundingBox
                                           , System.Drawing.Color.Red
                                           , false));
            }
        }
Exemplo n.º 7
0
        public static void GetLayers(Vector3D caseDim, double caseWeight, int palletIndex, double palletWeight, int layerNumber, bool bestLayersOnly, ref List <LayerDetails> listLayers)
        {
            // case
            var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z)
            {
                TapeColor = Color.Tan,
                TapeWidth = new OptDouble(true, 50.0)
            };

            boxProperties.SetWeight(caseWeight);
            boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray());
            // pallet
            Vector3D palletDim        = PalletIndexToDim3D(palletIndex);
            var      palletProperties = new PalletProperties(null, PalletIndexToPalletType(palletIndex), palletDim.X, palletDim.Y, palletDim.Z)
            {
                Weight = palletWeight,
                Color  = Color.Yellow
            };
            // ### define a constraintset object
            var constraintSet = new ConstraintSetCasePallet()
            {
                OptMaxNumber = new OptInt(false, 0),
                OptMaxWeight = new OptDouble(true, 1000.0),
                Overhang     = Vector2D.Zero,
            };

            constraintSet.SetAllowedOrientations(new bool[] { false, false, true });
            constraintSet.OptMaxLayerNumber = layerNumber;
            Vector3D vPalletDim = palletProperties.GetStackingDimensions(constraintSet);
            // ###

            // get a list of all possible layers and fill ListView control
            ILayerSolver solver = new LayerSolver();
            var          layers = solver.BuildLayers(boxProperties.OuterDimensions, new Vector2D(vPalletDim.X, vPalletDim.Y), 0.0, constraintSet, bestLayersOnly);

            foreach (var layer in layers)
            {
                listLayers.Add(
                    new LayerDetails(
                        layer.Name,
                        layer.LayerDescriptor.ToString(),
                        layer.Count,
                        layer.NoLayers(caseDim.Z),
                        caseDim.X, caseDim.Y, caseDim.Z,
                        palletIndex)
                    );
            }
        }
Exemplo n.º 8
0
        private void OnNext(object sender, EventArgs e)
        {
            try
            {
                Close();

                List <LayerDesc> layerDescs = new List <LayerDesc>();
                foreach (ILayer2D layer2D in uCtrlLayerList.Selected)
                {
                    layerDescs.Add(layer2D.LayerDescriptor);
                }


                string userName = string.Empty;

                Document      doc            = new Document(DocumentName, DocumentDescription, userName, DateTime.Now, null);
                Packable      packable       = doc.CreateNewPackable(BundleProp);
                BoxProperties caseProperties = doc.CreateNewCase(
                    CaseName, CaseName
                    , CaseInsideLength, CaseInsideWidth, CaseInsideHeight
                    , CaseInsideLength, CaseInsideWidth, CaseInsideHeight
                    , CaseWeight
                    , new Color[] { Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate }
                    );

                if (null == packable || null == caseProperties)
                {
                    return;
                }

                Solution.SetSolver(new LayerSolver());
                AnalysisHomo analysis = doc.CreateNewAnalysisBoxCase(
                    DocumentName, DocumentDescription
                    , packable, caseProperties
                    , new List <InterlayerProperties>()
                    , BuildConstraintSet()
                    , layerDescs);
                FormBrowseSolution form = new FormBrowseSolution(doc, analysis);
                if (DialogResult.OK == form.ShowDialog())
                {
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// FormNewBox constructor used to edit existing boxes
        /// </summary>
        /// <param name="document">Document that contains the edited box</param>
        /// <param name="boxProperties">Edited box</param>
        public FormNewBox(Document document, BoxProperties boxProperties)
            : base(document, boxProperties)
        {
            InitializeComponent();
            if (!DesignMode)
            {
                // set unit labels
                UnitsManager.AdaptUnitLabels(this);
                // save document reference
                _mode = boxProperties.HasInsideDimensions ? Mode.CASE : Mode.BOX;
                // set colors
                for (int i = 0; i < 6; ++i)
                {
                    _faceColors[i] = boxProperties.Colors[i];
                }
                // set textures
                _textures = boxProperties.TextureListCopy;
                // set caption text
                Text = string.Format(Properties.Resources.ID_EDIT, boxProperties.Name);
                // initialize value
                uCtrlDimensionsOuter.ValueX  = boxProperties.Length;
                uCtrlDimensionsOuter.ValueY  = boxProperties.Width;
                uCtrlDimensionsOuter.ValueZ  = boxProperties.Height;
                uCtrlDimensionsInner.Value   = new Vector3D(boxProperties.InsideLength, boxProperties.InsideWidth, boxProperties.InsideHeight);
                uCtrlDimensionsInner.Checked = boxProperties.HasInsideDimensions;
                // weight
                vcWeight.Value = boxProperties.Weight;
                // net weight
                uCtrlNetWeight.Value = boxProperties.NetWeight;
                // max weight
                uCtrlMaxWeight.Value = boxProperties.MaxWeight;
                // color : all faces set together / face by face
                chkAllFaces.Checked = boxProperties.UniqueColor;
                OnAllFacesColorCheckedChanged(this, null);
                // tape
                uCtrlTapeWidth.Value = boxProperties.TapeWidth;
                cbTapeColor.Color    = boxProperties.TapeColor;
                // set default face
                cbFace.SelectedIndex = 0;
                // set StrapperSet
                StrapperSet = boxProperties.StrapperSet.Clone();
                ctrlStrapperSet.StrapperSet = StrapperSet;

                // disable Ok button
                UpdateStatus(string.Empty);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a new BoxProperties object with MODE_CASE
 /// </summary>
 public void CreateNewCaseUI()
 {
     using (FormNewBox form = new FormNewBox(this, FormNewBox.Mode.CASE))
     {
         if (DialogResult.OK == form.ShowDialog())
         {
             BoxProperties boxProperties = CreateNewCase(form.BoxName, form.Description
                                                         , form.BoxLength, form.BoxWidth, form.BoxHeight
                                                         , form.InsideLength, form.InsideWidth, form.InsideHeight, form.HasInsideDimensions
                                                         , form.Weight, form.Colors);
             boxProperties.TapeColor   = form.TapeColor;
             boxProperties.TapeWidth   = form.TapeWidth;
             boxProperties.TextureList = form.TextureList;
             boxProperties.StrapperSet = form.StrapperSet;
         }
     }
 }
Exemplo n.º 11
0
        internal BoxProperties ToBox(DataBox dtBox)
        {
            BoxProperties boxProperties = new BoxProperties(null
                                                            , dtBox.Dimensions[0], dtBox.Dimensions[1], dtBox.Dimensions[2]);

            boxProperties.ID.SetNameDesc(dtBox.Name, dtBox.Description);
            Color[] colors = new Color[6];
            for (int i = 0; i < 6; ++i)
            {
                colors[i] = Color.Turquoise;
            }
            boxProperties.SetAllColors(colors);
            boxProperties.ShowTape = false;
            boxProperties.SetWeight(dtBox.Weight);
            boxProperties.SetNetWeight(new OptDouble(dtBox.NetWeight > 0, dtBox.NetWeight));
            return(boxProperties);
        }
Exemplo n.º 12
0
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            var boxProperties = new BoxProperties(
                null, uCtrlDimensionsOuter.ValueX, uCtrlDimensionsOuter.ValueY, uCtrlDimensionsOuter.ValueZ)
            {
                TextureList = _textures,
                TapeWidth   = TapeWidth,
                TapeColor   = TapeColor,
                StrapperSet = StrapperSet
            };

            boxProperties.SetAllColors(_faceColors);
            graphics.AddBox(new Box(0, boxProperties));
            graphics.AddDimensions(
                new DimensionCube(uCtrlDimensionsOuter.ValueX, uCtrlDimensionsOuter.ValueY, uCtrlDimensionsOuter.ValueZ)
                );
        }
Exemplo n.º 13
0
        private void OnBestCombinationClicked(object sender, EventArgs e)
        {
            try
            {
                // get case
                BoxProperties caseProperties = cbCases.SelectedType as BoxProperties;
                if (!(cbBoxes.SelectedType is PackableBrick packable) || null == caseProperties)
                {
                    return;
                }
                var constraintSet = BuildConstraintSet();
                // get best combination
                List <KeyValuePair <LayerDesc, int> > listLayer = new List <KeyValuePair <LayerDesc, int> >();
                LayerSolver.GetBestCombination(
                    packable.OuterDimensions,
                    caseProperties.GetStackingDimensions(constraintSet),
                    constraintSet,
                    ref listLayer);
                if (0 == listLayer.Count)
                {
                    _log.Warn("Failed to find a single valid layer");
                    return;
                }
                // select best layer
                List <LayerDesc> layerDesc = new List <LayerDesc>();
                foreach (KeyValuePair <LayerDesc, int> kvp in listLayer)
                {
                    layerDesc.Add(kvp.Key);
                }
                uCtrlLayerList.SelectLayers(layerDesc);

                _item = _document.CreateNewAnalysisBoxCase(
                    ItemName, ItemDescription
                    , SelectedBoxProperties, SelectedCase
                    , new List <InterlayerProperties>()
                    , BuildConstraintSet()
                    , listLayer
                    );
                Close();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 14
0
 public List <CasePalletSolution> Process(
     BoxProperties boxProperties, PalletProperties palletProperties,
     InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip,
     PalletConstraintSet constraintSet)
 {
     _bProperties                  = boxProperties;
     _palletProperties             = palletProperties;
     _interlayerProperties         = interlayerProperties;
     _interlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     _constraintSet                = constraintSet;
     // check constraint set validity
     if (!_constraintSet.IsValid)
     {
         throw new EngineException("Constraint set is invalid!");
     }
     // generate solutions
     return(GenerateSolutions());
 }
Exemplo n.º 15
0
 public bool Accept(Control ctrl, ItemBase itemBase)
 {
     if (ctrl == cbBoxes)
     {
         PackableBrick packable = itemBase as PackableBrick;
         if (null == packable)
         {
             return(false);
         }
         BoxProperties bProperties = packable as BoxProperties;
         if (null != bProperties)
         {
             return(!bProperties.HasInsideDimensions);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 16
0
 /// <summary>
 /// FormNewBox constructor used to edit existing boxes
 /// </summary>
 /// <param name="document">Document that contains the edited box</param>
 /// <param name="boxProperties">Edited box</param>
 public FormNewBox(Document document, BoxProperties boxProperties)
 {
     InitializeComponent();
     if (!DesignMode)
     {
         // set unit labels
         UnitsManager.AdaptUnitLabels(this);
         // save document reference
         _document      = document;
         _boxProperties = boxProperties;
         _mode          = boxProperties.HasInsideDimensions ? Mode.MODE_CASE : Mode.MODE_BOX;
         // set colors
         for (int i = 0; i < 6; ++i)
         {
             _faceColors[i] = _boxProperties.Colors[i];
         }
         // set textures
         _textures = _boxProperties.TextureListCopy;
         // set caption text
         Text = string.Format(Properties.Resources.ID_EDIT, _boxProperties.Name);
         // initialize value
         tbName.Text                  = _boxProperties.Name;
         tbDescription.Text           = _boxProperties.Description;
         uCtrlDimensionsOuter.ValueX  = _boxProperties.Length;
         uCtrlDimensionsOuter.ValueY  = _boxProperties.Width;
         uCtrlDimensionsOuter.ValueZ  = _boxProperties.Height;
         uCtrlDimensionsInner.Value   = new Vector3D(_boxProperties.InsideLength, _boxProperties.InsideWidth, _boxProperties.InsideHeight);
         uCtrlDimensionsInner.Checked = _boxProperties.HasInsideDimensions;
         // weight
         vcWeight.Value = _boxProperties.Weight;
         // net weight
         uCtrlNetWeight.Value = _boxProperties.NetWeight;
         // color : all faces set together / face by face
         chkAllFaces.Checked = _boxProperties.UniqueColor;
         chkAllFaces_CheckedChanged(this, null);
         // tape
         uCtrlTapeWidth.Value = _boxProperties.TapeWidth;
         cbTapeColor.Color    = _boxProperties.TapeColor;
         // set default face
         cbFace.SelectedIndex = 0;
         // disable Ok button
         UpdateButtonOkStatus();
     }
 }
Exemplo n.º 17
0
        private void FormNewBoxCaseAnalysis_Load(object sender, EventArgs e)
        {
            try
            {
                // name / description
                if (null != _analysis)
                {
                    tbName.Text        = _analysis.Name;
                    tbDescription.Text = _analysis.Description;

                    BoxProperties boxProperties = _analysis.BProperties as BoxProperties;
                    if (null != _analysis)
                    {
                        IncludeCaseAsBoxes = boxProperties.HasInsideDimensions;
                    }
                }
                // fill boxes combo
                ComboBoxHelpers.FillCombo(Boxes, cbBox, null == _analysis ? null : _analysis.BProperties);
                // fill case properties
                ComboBoxHelpers.FillCombo(Cases, cbCase, null == _analysis ? null : _analysis.CaseProperties);
                // allowed position box + allowed patterns
                if (null == _analysis)
                {
                    AllowVerticalX     = Settings.Default.AllowVerticalX;
                    AllowVerticalY     = Settings.Default.AllowVerticalY;
                    AllowVerticalZ     = Settings.Default.AllowVerticalZ;
                    IncludeCaseAsBoxes = Settings.Default.IncludeCaseAsBoxes;
                }
                else
                {
                    BoxCaseConstraintSet constraintSet = _analysis.ConstraintSet as BoxCaseConstraintSet;
                    if (null != constraintSet)
                    {
                        AllowVerticalX = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_P);
                        AllowVerticalY = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_P);
                        AllowVerticalZ = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_P);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public static void Draw(Graphics3D graphics
                                , CasePalletSolution solution
                                , BoxProperties boxProperties, InterlayerProperties interlayerProperties, PalletProperties palletProperties)
        {
            // draw pallet
            Pallet pallet = new Pallet(palletProperties);

            pallet.Draw(graphics, Transform3D.Identity);
            // draw solution
            uint pickId = 0;

            foreach (ILayer layer in solution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                    }
                }

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos && null != interlayerProperties)
                {
                    Box box = new Box(pickId++, interlayerProperties);
                    // set position
                    box.Position = new Vector3D(
                        0.5 * (palletProperties.Length - interlayerProperties.Length)
                        , 0.5 * (palletProperties.Width - interlayerProperties.Width)
                        , interlayerPos.ZLow);
                    // draw
                    graphics.AddBox(box);
                }
            }

            // always show dimensions
            BoxLayer bLayer       = solution[solution.Count - 1] as BoxLayer;
            double   palletHeight = solution[solution.Count - 1].ZLow + (null != bLayer ? bLayer.Thickness(boxProperties) : 0.0);

            // show dimensions
            graphics.AddDimensions(new DimensionCube(solution.BoundingBox, Color.Black, false));
            graphics.AddDimensions(new DimensionCube(solution.LoadBoundingBox, Color.Red, true));
        }
Exemplo n.º 19
0
        public void StartCaseOptimization(string name, double length, double width, double height)
        {
            FormDefineCaseOptimization formCaseOptimization = new FormDefineCaseOptimization();
            formCaseOptimization.BoxName = name;
            formCaseOptimization.BoxLength = length;
            formCaseOptimization.BoxWidth = width;
            formCaseOptimization.BoxHeight = height;

            if (DialogResult.OK != formCaseOptimization.ShowDialog())
                return;

            // create document
            Document doc = new Document(name, name + "_on_" + formCaseOptimization.SelectedPallet.Name, "from extension component", DateTime.Now, null);
            // create case in document
            BoxProperties boxInDoc = doc.CreateNewBox(formCaseOptimization.SelectedBox);
            // create pallet in document
            PalletProperties palletInDoc = doc.CreateNewPallet(formCaseOptimization.SelectedPallet);

        }
Exemplo n.º 20
0
        /// <summary>
        /// Use box dimensions to set min case dimensions
        /// </summary>
        private void SetMinCaseDimensions()
        {
            BoxProperties boxProperties = SelectedBox;

            if (null == boxProperties)
            {
                return;
            }
            double minDim = Math.Min(boxProperties.Length, Math.Min(boxProperties.Width, boxProperties.Height));

            if ((int)nudNumber.Value > 8)
            {
                minDim *= 2;
            }
            // set min dimension
            uCtrlPackDimensionsMin.ValueX = minDim;
            uCtrlPackDimensionsMin.ValueY = minDim;
            uCtrlPackDimensionsMin.ValueZ = minDim;
        }
Exemplo n.º 21
0
        private void OnSelChangeGrid(object sender, SourceGrid.RangeRegionChangedEventArgs e)
        {
            try
            {
                SourceGrid.Selection.RowSelection select = sender as SourceGrid.Selection.RowSelection;
                SourceGrid.Grid g = select.Grid as SourceGrid.Grid;

                SourceGrid.RangeRegion region = g.Selection.GetSelectionRegion();
                int[] indexes = region.GetRowsIndex();
                if (indexes.Length < 1 || indexes[0] < 1)
                {
                    _selectedAnalysis = null;
                }
                else
                {
                    _selectedAnalysis = _analyses[indexes[0] - 1];
                    // analysis name/description
                    if (null != _selectedAnalysis)
                    {
                        BoxProperties  box  = SelectedBox;
                        PackProperties pack = _selectedAnalysis.Content as PackProperties;
                        AnalysisName = string.Format("Analysis_{0}x{1}x{2}_{3}_on_{4}",
                                                     pack.Dim0, pack.Dim1, pack.Dim2, box.Name, _selectedAnalysis.Container.Name);
                        AnalysisDescription = string.Format("Packing {0}x{1}x{2} {3} on {4}",
                                                            pack.Dim0, pack.Dim1, pack.Dim2, box.Name, _selectedAnalysis.Container.Name);

                        UpdateStatus(string.Empty);
                    }
                    else
                    {
                        AnalysisName        = string.Empty;
                        AnalysisDescription = string.Empty;
                    }
                }

                graphCtrlPack.Invalidate();
                graphCtrlSolution.Invalidate();
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
Exemplo n.º 22
0
        public void StartPalletization(string name, double length, double width, double height)
        {
            // show analysis details dialog
            FormDefineAnalysis formDefinition = new FormDefineAnalysis();
            formDefinition.CaseName = name;
            formDefinition.CaseLength = length;
            formDefinition.CaseWidth = width;
            formDefinition.CaseHeight = height;

            if (DialogResult.OK != formDefinition.ShowDialog())
                return;

            // create document
            Document doc = new Document(name, name + "_on_" + formDefinition.Pallet.Name, "from extension component", DateTime.Now, null);
            // create case in document
            BoxProperties caseInDoc = doc.CreateNewCase(formDefinition.Case);
            // create pallet in document
            PalletProperties palletInDoc = doc.CreateNewPallet(formDefinition.Pallet);
            // create interlayer in document
            InterlayerProperties interlayerInDoc = formDefinition.Interlayer == null ? null : doc.CreateNewInterlayer(formDefinition.Interlayer);

            // solver
            CasePalletSolver solver = new CasePalletSolver();
            // build list of solutions
            CasePalletAnalysis analysis = doc.CreateNewCasePalletAnalysis(
                string.Format(Resources.ID_ANALYSISNAME, name, formDefinition.Pallet.Name)
                , string.Format(Resources.ID_ANALYSISDESCRIPTION, name, formDefinition.Pallet.Name)
                , caseInDoc
                , palletInDoc
                , interlayerInDoc
                , null
                , null
                , null
                , null
                , formDefinition.Constraints
                , solver);
             
            // select solution / generate report / generate StackBuilder file
            FormSelectSolution formSolutions = new FormSelectSolution(doc, analysis);
            if (DialogResult.OK == formSolutions.ShowDialog())
                return;        
        }
Exemplo n.º 23
0
        public Box(uint pickId, Packable packable)
        {
            _pickId = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;

            _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            BProperties bProperties = packable as BProperties;

            if (null != bProperties)
            {
                _colors = bProperties.Colors;

                // IsBundle ?
                _isBundle = bProperties.IsBundle;
                if (_isBundle)
                {
                    _noFlats = (bProperties as BundleProperties).NoFlats;
                }
                // textures
                BoxProperties boxProperties = bProperties as BoxProperties;
                if (null != boxProperties)
                {
                    List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                    foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                    {
                        int iIndex = (int)tex.first;
                        if (null == _textureLists[iIndex])
                        {
                            _textureLists[iIndex] = new List <Texture>();
                        }
                        _textureLists[iIndex].Add(tex.second);
                    }
                    // tape
                    _showTape  = boxProperties.ShowTape;
                    _tapeWidth = boxProperties.TapeWidth;
                    _tapeColor = boxProperties.TapeColor;
                }
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            BoxProperties bProperties = new BoxProperties(null, 1000, 750, 500);
            Box           b           = new Box(0, bProperties);

            Vector3D vNear = new Vector3D(400.0, 1000.0, 0.0);
            Vector3D vFar  = new Vector3D(500.0, -1000.0, 250.0);
            Ray      r     = new Ray(vNear, vFar);

            Vector3D ptInter;

            if (b.RayIntersect(r, out ptInter))
            {
                Console.WriteLine("Point inter : {0}", ptInter);
            }
            else
            {
                Console.WriteLine("No intersection found");
            }
        }
Exemplo n.º 25
0
        internal BoxProperties ToCase(DataCase dtCase)
        {
            BoxProperties boxProperties = new BoxProperties(null
                                                            , dtCase.OuterDimensions[0], dtCase.OuterDimensions[1], dtCase.OuterDimensions[2]
                                                            , dtCase.InnerDimensions[0], dtCase.InnerDimensions[1], dtCase.InnerDimensions[2]);

            Color[] colors = new Color[6];
            for (int i = 0; i < 6; ++i)
            {
                colors[i] = Color.Chocolate;
            }
            boxProperties.ID.SetNameDesc(dtCase.Name, dtCase.Description);
            boxProperties.SetAllColors(colors);
            boxProperties.ShowTape  = true;
            boxProperties.TapeColor = Color.Beige;
            boxProperties.TapeWidth = UnitsManager.ConvertLengthFrom(50, UnitsManager.UnitSystem.UNIT_METRIC1);
            boxProperties.SetWeight(dtCase.Weight);
            boxProperties.SetNetWeight(new OptDouble(dtCase.NetWeight > 0.0, dtCase.NetWeight));
            return(boxProperties);
        }
Exemplo n.º 26
0
 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);
     }
 }
        protected void Compute()
        {
            try
            {
                const double thickness = 4.0;
                _doc = new Document(_name, "", "", DateTime.Now, null);
                // colors
                Color[] colors = new Color[6];
                for (int i = 0; i < 6; ++i)
                {
                    colors[i] = Color.Chocolate;
                }
                // bundle
                BundleProperties bundleProperties = _doc.CreateNewBundle(_name, _name, BundleLength, BundleWidth, FlatThickness, FlatWeight, Color.Beige, NoFlats);
                // case
                BoxProperties caseProperties = _doc.CreateNewCase(_name, _name
                                                                  , CaseInsideLength + 2.0 * thickness, CaseInsideWidth + 2.0 * thickness, CaseInsideHeight + 2.0 * thickness
                                                                  , CaseInsideLength, CaseInsideWidth, CaseInsideHeight
                                                                  , CaseWeight, colors);
                // constraint set
                BundleCaseConstraintSet constraintSet = new BundleCaseConstraintSet();
                // maximum case weight
                constraintSet.UseMaximumCaseWeight = false;
                constraintSet.MaximumCaseWeight    = 0.0;
                // maximum number of items
                constraintSet.UseMaximumNumberOfBoxes = false;
                constraintSet.MaximumNumberOfBoxes    = 0;

                _analysis = _doc.CreateNewBoxCaseAnalysis(
                    _name, _name
                    , bundleProperties, caseProperties
                    , constraintSet
                    , new BoxCaseSolver());
                // fill grid
                FillGrid();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 28
0
        private void InsertPictogram(ref BoxProperties boxProperties)
        {
            string pictoPath = Properties.Settings.Default.pictoTOP;

            if (File.Exists(pictoPath))
            {
                // load image
                Bitmap bmp = new Bitmap(pictoPath);
                // case dimensions
                double length = boxProperties.Length;
                double width  = boxProperties.Width;
                double height = boxProperties.Height;
                // dimensions and margins
                double margin    = 2;
                double pictoSize = 10;
                double minDim    = Math.Min(Math.Min(length, width), Math.Min(width, height));
                if (minDim < pictoSize)
                {
                    margin = 0.0; pictoSize = minDim;
                }
                // top position
                double topPos = boxProperties.Height - margin - pictoSize;
                // insert picto as a texture
                boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_N
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(width - margin - pictoSize, topPos), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(pictoSize, pictoSize), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , 0, bmp);
                boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_P
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(width - margin - pictoSize, topPos), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(pictoSize, pictoSize), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , 0, bmp);
                boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_N
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(length - margin - pictoSize, topPos), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(pictoSize, pictoSize), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , 0, bmp);
                boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_P
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(length - margin - pictoSize, topPos), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , UnitsManager.ConvertLengthFrom(new Vector2D(pictoSize, pictoSize), UnitsManager.UnitSystem.UNIT_METRIC2)
                                         , 0, bmp);
            }
        }
Exemplo n.º 29
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var bProperties = new BoxProperties(null, 400.0, 300.0, 200.0);

            bProperties.SetAllColors(Enumerable.Repeat <Color>(Color.Beige, 6).ToArray());
            bProperties.TapeColor = Color.Orange;
            bProperties.TapeWidth = new treeDiM.Basics.OptDouble(true, 50.0);
            Content = bProperties;

            BoxPositions.Add(new BoxPosition(Vector3D.Zero, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P));
            BoxPositions.Add(new BoxPosition(new Vector3D(400.0, 0.0, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P));
            BoxPositions.Add(new BoxPosition(new Vector3D(1100.0, 0.0, 0.0), HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N));
            BoxPositions.Add(new BoxPosition(new Vector3D(300.0, 300.0, 0.0), HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N));
            BoxPositions.Add(new BoxPosition(new Vector3D(700.0, 300.0, 0.0), HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N));
            BoxPositions.Add(new BoxPosition(new Vector3D(700.0, 400.0, 0.0), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P));

            layerEditor.Content = Content;
            layerEditor.Invalidate();
        }
Exemplo n.º 30
0
 /// <summary>
 /// FormNewBox constructor used to edit existing boxes
 /// </summary>
 /// <param name="document">Document that contains the edited box</param>
 /// <param name="boxProperties">Edited box</param>
 public FormNewBox(Document document, BoxProperties boxProperties)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document      = document;
     _boxProperties = boxProperties;
     _mode          = boxProperties.HasInsideDimensions ? Mode.MODE_CASE : Mode.MODE_BOX;
     // set colors
     for (int i = 0; i < 6; ++i)
     {
         _faceColors[i] = _boxProperties.Colors[i];
     }
     // set textures
     _textures = _boxProperties.TextureListCopy;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _boxProperties.Name);
     // initialize value
     tbName.Text           = _boxProperties.Name;
     tbDescription.Text    = _boxProperties.Description;
     nudLength.Value       = (decimal)_boxProperties.Length;
     nudInsideLength.Value = (decimal)_boxProperties.InsideLength;
     nudWidth.Value        = (decimal)_boxProperties.Width;
     nudInsideWidth.Value  = (decimal)_boxProperties.InsideWidth;
     nudHeight.Value       = (decimal)_boxProperties.Height;
     nudInsideHeight.Value = (decimal)_boxProperties.InsideHeight;
     nudWeight.Value       = (decimal)_boxProperties.Weight;
     // color : all faces set together / face by face
     chkAllFaces.Checked = _boxProperties.UniqueColor;
     chkAllFaces_CheckedChanged(this, null);
     // tape
     checkBoxTape.Checked = _boxProperties.ShowTape;
     nudTapeWidth.Value   = (decimal)_boxProperties.TapeWidth;
     cbTapeColor.Color    = _boxProperties.TapeColor;
     // set default face
     cbFace.SelectedIndex = 0;
     // disable Ok button
     UpdateButtonOkStatus();
 }
Exemplo n.º 31
0
 public void SetProperties(BoxProperties properties)
 {
     _properties = properties;
 }