Esempio n. 1
0
        public void Dimensions(ParameterStack stack, out double width, out double height, out double lengthCut, out double lengthFold)
        {
            // build factory
            PicFactory factory = new PicFactory();

            Component.CreateFactoryEntities(factory, stack);
            if (ReflexionX)
            {
                factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
            }
            if (ReflexionY)
            {
                factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));
            }
            // get bounding box
            PicVisitorBoundingBox visitorBoundingBox = new PicVisitorBoundingBox();

            factory.ProcessVisitor(visitorBoundingBox, ShowCotations ? PicFilter.FilterNone : !PicFilter.FilterCotation);
            Box2D box = visitorBoundingBox.Box;

            width  = box.Width;
            height = box.Height;
            // get length
            PicVisitorDieCutLength visitorLength = new PicVisitorDieCutLength();

            factory.ProcessVisitor(visitorLength, PicFilter.FilterNone);
            lengthCut  = visitorLength.Lengths.ContainsKey(PicGraphics.LT.LT_CUT) ? visitorLength.Lengths[PicGraphics.LT.LT_CUT] : 0.0;
            lengthFold = visitorLength.Lengths.ContainsKey(PicGraphics.LT.LT_CREASING) ? visitorLength.Lengths[PicGraphics.LT.LT_CREASING] : 0.0;
        }
        public override void Refresh()
        {
            try
            {
                // create entities
                if (this.Parent is IEntitySupplier)
                {
                    _entitySupplier = this.Parent as IEntitySupplier;
                }
                if (null != _entitySupplier)
                {
                    // clear factory
                    _factory.Clear();
                    // update factory
                    _entitySupplier.CreateEntities(_factory);
                }

                // get selected tab and compute data accordingly
                switch (tabControlData.SelectedIndex)
                {
                case 0:
                    // compute length
                    PicVisitorDieCutLength visitorLengthes = new PicVisitorDieCutLength();
                    _factory.ProcessVisitor(visitorLengthes);
                    // update controls
                    double lengthCut = 0.0, lengthFold = 0.0;
                    if (visitorLengthes.Lengths.ContainsKey(PicGraphics.LT.LT_CUT))
                    {
                        lengthCut = visitorLengthes.Lengths[PicGraphics.LT.LT_CUT];
                    }
                    lblValueLengthCut.Text = string.Format(": {0:0.###} m", lengthCut / 1000.0);
                    if (visitorLengthes.Lengths.ContainsKey(PicGraphics.LT.LT_CREASING))
                    {
                        lengthFold = visitorLengthes.Lengths[PicGraphics.LT.LT_CREASING];
                    }
                    lblValueLengthFold.Text  = string.Format(": {0:0.###} m", lengthFold / 1000.0);
                    lblValueLengthTotal.Text = string.Format(": {0:0.###} m", (lengthCut + lengthFold) / 1000.0);
                    break;

                case 1:
                    // compute bounding box
                    PicVisitorBoundingBox visitorBB = new PicVisitorBoundingBox();
                    _factory.ProcessVisitor(visitorBB, !PicFilter.FilterCotation);
                    // update controls
                    lblValueLength.Text = string.Format(": {0:0.#} mm", visitorBB.Box.Width);
                    lblValueWidth.Text  = string.Format(": {0:0.#} mm", visitorBB.Box.Height);
                    break;

                case 2:
                    // compute area
                    try
                    {
                        PicToolArea picToolArea = new PicToolArea();
                        _factory.ProcessTool(picToolArea);
                        lblAreaValue.Text = string.Format(": {0:0.###} m²", (picToolArea.Area * 1.0E-06));

                        lblNameFormat.Visible     = lblValueFormat.Visible = _factory.HasCardboardFormat;
                        lblNameEfficiency.Visible = lblValueEfficiency.Visible = _factory.HasCardboardFormat;

                        if (_factory.HasCardboardFormat)
                        {
                            lblValueFormat.Text     = string.Format(": {0:0.#} x {1:0.#}", _factory.Format.Width, _factory.Format.Height);
                            lblValueEfficiency.Text = string.Format(": {0:0.#} %", 100.0 * picToolArea.Area / (_factory.Format.Width * _factory.Format.Height));
                        }
                    }
                    catch (PicToolTooLongException /*ex*/)
                    {
                        lblAreaValue.Text          = Pic.Factory2D.Control.Properties.Resources.ID_ABANDONPROCESSING;
                        lblNameEfficiency.Visible  = false;
                        lblValueEfficiency.Visible = false;
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Esempio n. 3
0
        public override void Refresh()
        {
            try
            {
                // create entities
                if (this.Parent is IEntitySupplier)
                    _entitySupplier = this.Parent as IEntitySupplier;
                if (null != _entitySupplier)
                {
                    // clear factory
                    _factory.Clear();
                    // update factory
                    _entitySupplier.CreateEntities(_factory);
                }

                // get selected tab and compute data accordingly
                switch (tabControlData.SelectedIndex)
                {
                    case 0:
                        // compute length
                        PicVisitorDieCutLength visitorLengthes = new PicVisitorDieCutLength();
                        _factory.ProcessVisitor(visitorLengthes);
                        // update controls
                        double lengthCut = 0.0, lengthFold = 0.0;
                        if (visitorLengthes.Lengths.ContainsKey(PicGraphics.LT.LT_CUT))
                            lengthCut = visitorLengthes.Lengths[PicGraphics.LT.LT_CUT];
                        lblValueLengthCut.Text = string.Format(": {0:0.###} m", lengthCut / 1000.0);
                        if (visitorLengthes.Lengths.ContainsKey(PicGraphics.LT.LT_CREASING))
                            lengthFold = visitorLengthes.Lengths[PicGraphics.LT.LT_CREASING];
                        lblValueLengthFold.Text = string.Format(": {0:0.###} m", lengthFold / 1000.0);
                        lblValueLengthTotal.Text = string.Format(": {0:0.###} m", (lengthCut + lengthFold) / 1000.0);
                        break;
                    case 1:
                        // compute bounding box
                        PicVisitorBoundingBox visitorBB = new PicVisitorBoundingBox();
                        _factory.ProcessVisitor(visitorBB, PicFilter.FilterCotation);
                        // update controls
                        lblValueLength.Text = string.Format(": {0:0.#} mm", visitorBB.Box.Width);
                        lblValueWidth.Text = string.Format(": {0:0.#} mm", visitorBB.Box.Height);
                        break;
                    case 2:
                        // compute area
                        try
                        {
                            PicToolArea picToolArea = new PicToolArea();
                            _factory.ProcessTool(picToolArea);
                            lblAreaValue.Text = string.Format(": {0:0.###} m²", (picToolArea.Area * 1.0E-06));
 
                        lblNameFormat.Visible = lblValueFormat.Visible = _factory.HasCardboardFormat;
                        lblNameEfficiency.Visible = lblValueEfficiency.Visible = _factory.HasCardboardFormat;

                        if (_factory.HasCardboardFormat)
                        {
                            lblValueFormat.Text = string.Format(": {0:0.#} x {1:0.#}", _factory.Format.Width, _factory.Format.Height);
                            lblValueEfficiency.Text = string.Format(": {0:0.#} %", 100.0 * picToolArea.Area / (_factory.Format.Width * _factory.Format.Height));
                        }
                       }
                        catch (PicToolTooLongException /*ex*/)
                        {
                            lblAreaValue.Text = Pic.Factory2D.Control.Properties.Resources.ID_ABANDONPROCESSING;
                            lblNameEfficiency.Visible = false;
                            lblValueEfficiency.Visible = false;
                        }
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }