예제 #1
0
        /// <summary>
        /// creates new box/case analysis view
        /// </summary>
        public DockContentBoxCaseAnalysis CreateNewBoxCaseAnalysisView(BoxCaseAnalysis analysis)
        {
            DockContentBoxCaseAnalysis form = new DockContentBoxCaseAnalysis(this, analysis);

            AddView(form);
            return(form);
        }
예제 #2
0
        /// <summary>
        /// edit box / case analysis
        /// </summary>
        public void EditBoxCaseAnalysis(BoxCaseAnalysis boxCaseAnalysis)
        {
            bool recomputeRequired = false;

            if (boxCaseAnalysis.IsBoxAnalysis)
            {
                FormNewBoxCaseAnalysis form = new FormNewBoxCaseAnalysis(boxCaseAnalysis.ParentDocument, boxCaseAnalysis);
                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    boxCaseAnalysis.ID.SetNameDesc(form.AnalysisName, form.AnalysisDescription);
                    // selected box
                    boxCaseAnalysis.BProperties    = form.SelectedBox;
                    boxCaseAnalysis.CaseProperties = form.SelectedCase;
                    // constraint set
                    BCaseConstraintSet   constraintSet        = boxCaseAnalysis.ConstraintSet;
                    BoxCaseConstraintSet boxCaseConstraintSet = constraintSet as BoxCaseConstraintSet;
                    if (null != boxCaseConstraintSet)
                    {
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ);
                    }
                    // use maximum case weight
                    constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                    constraintSet.MaximumCaseWeight    = form.MaximumCaseWeight;
                    // use maximum number of items
                    constraintSet.UseMaximumNumberOfBoxes = form.UseMaximumNumberOfBoxes;
                    constraintSet.MaximumNumberOfBoxes    = form.MaximumNumberOfBoxes;
                }
            }
            else if (boxCaseAnalysis.IsBundleAnalysis)
            {
                FormNewAnalysisBundleCase form = new FormNewAnalysisBundleCase(boxCaseAnalysis.ParentDocument, boxCaseAnalysis);
                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    boxCaseAnalysis.ID.SetNameDesc(form.ItemName, form.ItemDescription);
                    // selected bundle
                    boxCaseAnalysis.BProperties    = form.SelectedBundle;
                    boxCaseAnalysis.CaseProperties = form.SelectedCase;
                    // constraint set
                    BCaseConstraintSet constraintSet = boxCaseAnalysis.ConstraintSet;
                    // use maximum case weight
                    constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                    constraintSet.MaximumCaseWeight    = form.MaximumCaseWeight;
                    // use maximum number of items
                    constraintSet.UseMaximumNumberOfBoxes = form.UseMaximumNumberOfBoxes;
                    constraintSet.MaximumNumberOfBoxes    = form.MaximumNumberOfBoxes;
                }
            }
            if (recomputeRequired)
            {
                boxCaseAnalysis.OnEndUpdate(null);
            }
        }
예제 #3
0
 public FormNewAnalysisBundleCase(Document document, BoxCaseAnalysis analysis)
     : base(document, analysis)
 {
     InitializeComponent();
     // units
     UnitsManager.AdaptUnitLabels(this);
     // analysis
     _analysis = analysis;
 }
예제 #4
0
        public SelBoxCaseSolution(Document document, BoxCaseAnalysis analysis, BoxCaseSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            ID.Name   = sol.Title;
        }
예제 #5
0
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Analysis</param>
 public FormNewBoxCaseAnalysis(Document document, BoxCaseAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
 }
예제 #6
0
        public DockContentBoxCaseAnalysis(IDocument document, BoxCaseAnalysis analysis)
        {
            _document = document;
            _analysis = analysis;
            _analysis.AddListener(this);

            _analysis.SolutionSelected         += new BoxCaseAnalysis.SelectSolution(onSolutionSelectionChanged);
            _analysis.SolutionSelectionRemoved += new BoxCaseAnalysis.SelectSolution(onSolutionSelectionChanged);

            InitializeComponent();
        }
예제 #7
0
        public void ProcessAnalysis(BoxCaseAnalysis analysis)
        {
            _bProperties    = analysis.BProperties;
            _caseProperties = analysis.CaseProperties;
            _constraintSet  = analysis.ConstraintSet;

            if (!_constraintSet.IsValid)
            {
                throw new EngineException("Constraint set is invalid!");
            }

            analysis.Solutions = GenerateSolutions();
        }
        /// <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));
            }
        }
        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());
            }
        }
예제 #10
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));
                }
            }
        }
예제 #11
0
 public void OnNewBoxCaseAnalysisCreated(Document doc, BoxCaseAnalysis analysis)
 {
     _log.Info(string.Format("Loaded box/case analysis {0}", analysis.Name));
 }
예제 #12
0
        public bool onFileNew(ref string fileName)
        {
            // INTEX data are in cms
            UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2;

            string dbPath = Properties.Settings.Default.DatabasePathINTEX;

            if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath))
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.DefaultExt       = "xls";
                fd.AddExtension     = false;
                fd.Filter           = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*";
                fd.FilterIndex      = 0;
                fd.RestoreDirectory = true;
                fd.CheckFileExists  = true;
                if (DialogResult.OK != fd.ShowDialog())
                {
                    return(false);
                }

                dbPath = fd.FileName;
                Properties.Settings.Default.DatabasePathINTEX = dbPath;
                Properties.Settings.Default.Save();
            }
            // load INTEX excel file
            List <DataItemINTEX>   listItems   = null;
            List <DataPalletINTEX> listPallets = null;
            List <DataCaseINTEX>   listCases   = null;

            try
            {
                // Set cursor as hourglass
                Cursor.Current = Cursors.WaitCursor;
                // load excel file
                if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases))
                {
                    Cursor.Current = Cursors.Default;
                    string message = string.Empty;
                    if (null == listItems || listItems.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles");
                    }
                    else if (null == listPallets || listPallets.Count < 1)
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes");
                    }
                    else
                    {
                        message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath);
                    }
                    if (!string.IsNullOrEmpty(message))
                    {
                        MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.Message
                    , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                _log.Error(ex.Message);
            }
            finally
            { Cursor.Current = Cursors.Default; }
            // do we have a valid list
            if (null == listItems || 0 == listItems.Count)
            {
                return(false);
            }
            // proceed : buid project file
            try
            {
                FormNewINTEX form = new FormNewINTEX();
                form._listItems   = listItems;
                form._listPallets = listPallets;
                form._listCases   = listCases;
                if (DialogResult.OK != form.ShowDialog())
                {
                    return(false);
                }
                // create document
                DataItemINTEX item     = form._currentItem;
                Document      document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null);
                // create box properties
                Color[] colorsCase = new Color[6];
                for (int i = 0; i < 6; ++i)
                {
                    colorsCase[i] = Color.Chocolate;
                }
                BoxProperties itemProperties = null;
                if (!form.UseIntermediatePacking)
                {
                    itemProperties = document.CreateNewCase(
                        item._ref
                        , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB)
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._length - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                else
                {
                    itemProperties = document.CreateNewBox(
                        item._ref
                        , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB)
                        , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , colorsCase);
                }
                itemProperties.ShowTape  = true;
                itemProperties.TapeColor = Color.Beige;
                itemProperties.TapeWidth = 5.0;
                InsertPictogram(ref itemProperties);

                BoxProperties currentCase = null;
                if (form.UseIntermediatePacking)
                {
                    // create cases
                    foreach (DataCaseINTEX dataCase in listCases)
                    {
                        double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness;
                        double widthInt  = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness;
                        double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness;

                        BoxProperties intercaseProperties = document.CreateNewCase(
                            dataCase._ref
                            , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt)
                            , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2)
                            , colorsCase);
                        intercaseProperties.ShowTape  = true;
                        intercaseProperties.TapeColor = Color.Beige;
                        intercaseProperties.TapeWidth = 5.0;

                        if (string.Equals(form._currentCase._ref, intercaseProperties.Name))
                        {
                            currentCase = intercaseProperties;
                        }
                    }
                }

                if (form.UseIntermediatePacking)
                {
                    // Case constraint set
                    BoxCaseConstraintSet boxCaseConstraintSet = new BoxCaseConstraintSet();
                    boxCaseConstraintSet.SetAllowedOrthoAxisAll();
                    if (boxCaseConstraintSet.IsValid)
                    {
                        // create case analysis
                        BoxCaseAnalysis analysis = document.CreateNewBoxCaseAnalysis(
                            string.Format(Properties.Resources.ID_PACKING, item._ref)
                            , item._description
                            , itemProperties
                            , currentCase
                            , boxCaseConstraintSet
                            , new BoxCaseSolver());
                    }
                }

                // create pallets
                PalletProperties currentPallet = null;
                foreach (DataPalletINTEX pallet in listPallets)
                {
                    PalletProperties palletProperties = document.CreateNewPallet(
                        pallet._type, pallet._type, "EUR"
                        , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2)
                        , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2));
                    if (string.Equals(form._currentPallet._type, pallet._type))
                    {
                        currentPallet = palletProperties;
                    }
                }

                // *** pallet analysis ***
                // constraint set
                CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight    = UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2);
                constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);
                constraintSet.AllowAlignedLayers   = true;
                constraintSet.AllowAlternateLayers = true;
                constraintSet.SetAllowedPattern("Column");
                constraintSet.SetAllowedPattern("Diagonale");
                constraintSet.SetAllowedPattern("Interlocked");
                constraintSet.SetAllowedPattern("Trilock");
                constraintSet.SetAllowedPattern("Spirale");
                constraintSet.SetAllowedPattern("Enlarged spirale");
                if (constraintSet.IsValid)
                {
                    // create analysis
                    CasePalletSolver   solver         = new CasePalletSolver();
                    CasePalletAnalysis palletAnalysis = document.CreateNewCasePalletAnalysis(
                        item._ref, item.ToString()
                        , form.UseIntermediatePacking ? currentCase : itemProperties
                        , currentPallet,
                        null, null,
                        null, null, null,
                        constraintSet, solver);
                }
                // save document
                fileName = form.FilePath;
                document.Write(form.FilePath);
                // return true to let application open
                return(File.Exists(fileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
예제 #13
0
 void onSolutionSelectionChanged(BoxCaseAnalysis analysis, SelBoxCaseSolution selSolution)
 {
     UpdateSelectButtonText();
     UpdateGridCheckBoxes();
 }