Exemple #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public FormNewCaseOfBoxes(Document document, CaseOfBoxesProperties caseOfBoxProperties)
 {
     InitializeComponent();
     // save document reference
     _document = document;
     // name / description
     if (null != caseOfBoxProperties)
     {
         tbName.Text        = caseOfBoxProperties.Name;
         tbDescription.Text = caseOfBoxProperties.Description;
     }
     else
     {
         tbName.Text        = _document.GetValidNewTypeName(Resources.ID_CASEOFBOXES);
         tbDescription.Text = tbName.Text;
     }
     // save CaseOfBoxesProperties
     _caseOfBoxesProperties = caseOfBoxProperties;
     // color : all faces set together / face by face
     chkAllFaces.Checked = caseOfBoxProperties.UniqueColor;
     chkAllFaces_CheckedChanged(this, null);
     // set colors
     for (int i = 0; i < 6; ++i)
     {
         _faceColors[i] = caseOfBoxProperties.Colors[i];
     }
     // set textures
     _textures = caseOfBoxProperties.TextureList;
     // set default face
     cbFace.SelectedIndex = 0;
     // disable Ok button
     UpdateButtonOkStatus();
 }
 private void btAddSolution_Click(object sender, EventArgs e)
 {
     try
     {
         // get selected box
         BoxProperties boxProperties = SelectedBox;
         // get selected pallet
         PalletProperties palletProperties = SelectedPallet;
         // get selected caseOptimSolution
         CaseOptimSolution    sol         = SelectedSolution;
         CaseOptimArrangement arrangement = sol.CaseDefinition.Arrangement;
         // build new case name
         string name = string.Format("{0}_{1}*{2}*{3}_{4}{5}"
                                     , boxProperties.Name
                                     , arrangement._iLength
                                     , arrangement._iWidth
                                     , arrangement._iHeight
                                     , sol.CaseDefinition.Dim0
                                     , sol.CaseDefinition.Dim1);
         // build new case description
         string description = string.Format("Case generated by case optimization for box {0} and pallet {1}"
                                            , boxProperties.Name
                                            , palletProperties.Name);
         // add new case
         CaseOfBoxesProperties caseProperties = _document.CreateNewCaseOfBoxes(
             name, description
             , boxProperties
             , sol.CaseDefinition
             , BuildCaseOptimConstraintSet());
         // set color
         caseProperties.SetColor(Color.Chocolate);
         // add new pallet analysis
         string analysisName = string.Format("OptimAnalysis{0}_{1}*{2}*{3}_{4}{5}"
                                             , boxProperties.Name
                                             , boxProperties.Name
                                             , arrangement._iLength
                                             , arrangement._iWidth
                                             , arrangement._iHeight
                                             , sol.CaseDefinition.Dim0
                                             , sol.CaseDefinition.Dim1);
         string analysisDescription = string.Format("Pallet analysis generated by case optimisation for box {0} and pallet {1}"
                                                    , boxProperties.Name
                                                    , palletProperties.Name);
         List <CasePalletSolution> palletSolutionList = new List <CasePalletSolution>();
         palletSolutionList.Add(sol.PalletSolution);
         CasePalletAnalysis analysis = _document.CreateNewCasePalletAnalysis(
             analysisName
             , analysisDescription
             , caseProperties
             , palletProperties
             , null, null
             , null, null, null
             , BuildPalletConstraintSet()
             , palletSolutionList);
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
        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);
            }
        }
        /// <summary>
        /// handles new type creation
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="itemProperties"></param>
        public void OnNewTypeCreated(Document doc, ItemBase itemProperties)
        {
            int iconIndex = 0;

            NodeTag.NodeType nodeType       = NodeTag.NodeType.NT_BOX;
            NodeTag.NodeType parentNodeType = NodeTag.NodeType.NT_LISTBOX;
            if (itemProperties.GetType() == typeof(CaseOfBoxesProperties))
            {
                iconIndex      = 17;
                nodeType       = NodeTag.NodeType.NT_CASEOFBOXES;
                parentNodeType = NodeTag.NodeType.NT_LISTCASE;
            }
            else if (itemProperties.GetType() == typeof(BoxProperties))
            {
                BoxProperties boxProperties = itemProperties as BoxProperties;
                if (boxProperties.HasInsideDimensions)
                {
                    iconIndex      = 4;
                    nodeType       = NodeTag.NodeType.NT_CASE;
                    parentNodeType = NodeTag.NodeType.NT_LISTCASE;
                }
                else
                {
                    iconIndex      = 3;
                    nodeType       = NodeTag.NodeType.NT_BOX;
                    parentNodeType = NodeTag.NodeType.NT_LISTBOX;
                }
            }
            else if (itemProperties.GetType() == typeof(BundleProperties))
            {
                iconIndex      = 5;
                nodeType       = NodeTag.NodeType.NT_BUNDLE;
                parentNodeType = NodeTag.NodeType.NT_LISTBUNDLE;
            }
            else if (itemProperties.GetType() == typeof(CylinderProperties))
            {
                iconIndex      = 6;
                nodeType       = NodeTag.NodeType.NT_CYLINDER;
                parentNodeType = NodeTag.NodeType.NT_LISTCYLINDER;
            }
            else if (itemProperties.GetType() == typeof(PalletProperties))
            {
                iconIndex      = 7;
                nodeType       = NodeTag.NodeType.NT_PALLET;
                parentNodeType = NodeTag.NodeType.NT_LISTPALLET;
            }
            else if (itemProperties.GetType() == typeof(InterlayerProperties))
            {
                iconIndex      = 8;
                nodeType       = NodeTag.NodeType.NT_INTERLAYER;
                parentNodeType = NodeTag.NodeType.NT_LISTINTERLAYER;
            }
            else if (itemProperties.GetType() == typeof(TruckProperties))
            {
                iconIndex      = 9;
                nodeType       = NodeTag.NodeType.NT_TRUCK;
                parentNodeType = NodeTag.NodeType.NT_LISTTRUCK;
            }
            else if (itemProperties.GetType() == typeof(PalletCornerProperties))
            {
                iconIndex      = 10;
                nodeType       = NodeTag.NodeType.NT_PALLETCORNERS;
                parentNodeType = NodeTag.NodeType.NT_LISTPALLETCORNERS;
            }
            else if (itemProperties.GetType() == typeof(PalletCapProperties))
            {
                iconIndex      = 11;
                nodeType       = NodeTag.NodeType.NT_PALLETCAP;
                parentNodeType = NodeTag.NodeType.NT_LISTPALLETCAP;
            }
            else if (itemProperties.GetType() == typeof(PalletFilmProperties))
            {
                iconIndex      = 12;
                nodeType       = NodeTag.NodeType.NT_PALLETFILM;
                parentNodeType = NodeTag.NodeType.NT_LISTPALLETFILM;
            }
            else if (itemProperties.GetType() == typeof(PackProperties))
            {
                iconIndex      = 13;
                nodeType       = NodeTag.NodeType.NT_PACK;
                parentNodeType = NodeTag.NodeType.NT_LISTPACK;
            }
            else
            {
                Debug.Assert(false);
                _log.Error("AnalysisTreeView.OnNewTypeCreated() -> unknown type!");
                return;
            }
            // get parent node
            TreeNode parentNode = FindNode(null, new NodeTag(parentNodeType, doc));

            if (null == parentNode)
            {
                _log.Error(string.Format("Failed to load parentNode for {0}", itemProperties.Name));
                return;
            }
            // instantiate node
            TreeNode nodeItem = new TreeNode(itemProperties.Name, iconIndex, iconIndex)
            {
                // set node tag
                Tag = new NodeTag(nodeType, doc, itemProperties)
            };

            // insert
            parentNode.Nodes.Add(nodeItem);
            parentNode.Expand();
            // if item is CaseOfBoxesProperties
            if (itemProperties is CaseOfBoxesProperties)
            {
                // insert sub node
                CaseOfBoxesProperties caseOfBoxesProperties = itemProperties as CaseOfBoxesProperties;
                TreeNode subNode = new TreeNode(caseOfBoxesProperties.InsideBoxProperties.Name, 3, 3)
                {
                    Tag = new NodeTag(NodeTag.NodeType.NT_BOX, doc, caseOfBoxesProperties.InsideBoxProperties)
                };
                nodeItem.Nodes.Add(subNode);
            }
        }
Exemple #5
0
        private bool GenerateProject(out Document doc, out CasePalletAnalysis analysis, out CasePalletSolution casePalletSolution)
        {
            doc                = null;
            analysis           = null;
            casePalletSolution = null;

            try
            {
                // build solution
                doc = new Document(
                    _boxName,
                    string.Format(Properties.Resources.ID_OPTDOCUMENTDESCRIPTION, _boxName),
                    string.Empty,
                    DateTime.Now,
                    null);
                // box
                BoxProperties boxProperties = doc.CreateNewBox(SelectedBox);
                // pallet
                PalletProperties palletProperties = doc.CreateNewPallet(SelectedPallet);
                // get selected caseOptimSolution
                CaseOptimSolution sol         = SelectedSolution;
                PackArrangement   arrangement = sol.CaseDefinition.Arrangement;
                // build new case name
                string arrangName = string.Format("{0}_{1}x{2}x{3}_{4}{5}"
                                                  , boxProperties.Name
                                                  , arrangement._iLength
                                                  , arrangement._iWidth
                                                  , arrangement._iHeight
                                                  , sol.CaseDefinition.Dim0
                                                  , sol.CaseDefinition.Dim1);
                // build new case description
                string description = string.Format(
                    Properties.Resources.ID_OPTCASEDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                // add new case
                CaseOfBoxesProperties caseProperties = doc.CreateNewCaseOfBoxes(
                    arrangName, description
                    , boxProperties
                    , sol.CaseDefinition
                    , BuildCaseOptimConstraintSet());
                // set color
                caseProperties.SetColor(Color.Chocolate);
                // add new pallet analysis
                string analysisName = string.Format(
                    Properties.Resources.ID_OPTANALYSISNAME
                    , boxProperties.Name
                    , boxProperties.Name
                    , arrangement._iLength
                    , arrangement._iWidth
                    , arrangement._iHeight
                    , sol.CaseDefinition.Dim0
                    , sol.CaseDefinition.Dim1);
                string analysisDescription = string.Format(
                    Properties.Resources.ID_OPTANALYSISDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                List <CasePalletSolution> palletSolutionList = new List <CasePalletSolution>();
                palletSolutionList.Add(sol.PalletSolution);
                analysis = doc.CreateNewCasePalletAnalysis(
                    analysisName
                    , analysisDescription
                    , caseProperties
                    , palletProperties
                    , null
                    , null
                    , null
                    , null
                    , null
                    , BuildPalletConstraintSet()
                    , palletSolutionList);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
                return(false);
            }
            return(true);
        }