Exemple #1
0
 public void Dimensions(ParameterStack stack, out double width, out double height, out double lengthCut, out double lengthFold)
 {
     // build factory
     Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory();
     _component.CreateFactoryEntities(factory, stack);
     if (_reflexionX)
     {
         factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
     }
     if (_reflexionY)
     {
         factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));
     }
     // get bounding box
     Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox();
     factory.ProcessVisitor(visitorBoundingBox, _showCotations ? PicFilter.FilterNone : !PicFilter.FilterCotation);
     Pic.Factory2D.Box2D box = visitorBoundingBox.Box;
     width  = box.Width;
     height = box.Height;
     // get length
     Pic.Factory2D.PicVisitorDieCutLength visitorLength = new Pic.Factory2D.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;
 }
Exemple #2
0
        public byte[] GenerateExportFile(string fileFormat, ParameterStack stack)
        {
            // build factory
            Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory();
            _component.CreateFactoryEntities(factory, stack);
            if (_reflexionX)
            {
                factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
            }
            if (_reflexionY)
            {
                factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));
            }

            // instantiate filter
            PicFilter filter = (_showCotations ? PicFilter.FilterNone : !PicFilter.FilterCotation) & PicFilter.FilterNoZeroEntities;

            // get bounding box
            Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox();
            factory.ProcessVisitor(visitorBoundingBox, filter);
            Pic.Factory2D.Box2D box = visitorBoundingBox.Box;
            // add margins : 5 % of the smallest value among height
            box.AddMarginHorizontal(box.Width * 0.05);
            box.AddMarginVertical(box.Height * 0.05);
            // get file content
            if ("des" == fileFormat)
            {
                Pic.Factory2D.PicVisitorDesOutput visitor = new Pic.Factory2D.PicVisitorDesOutput();
                visitor.Author = "treeDiM";
                // process visitor
                factory.ProcessVisitor(visitor, filter);
                return(visitor.GetResultByteArray());
            }
            else if ("dxf" == fileFormat)
            {
                Pic.Factory2D.PicVisitorOutput visitor = new Pic.Factory2D.PicVisitorDxfOutput();
                visitor.Author = "treeDiM";
                // process visitor
                factory.ProcessVisitor(visitor, filter);
                return(visitor.GetResultByteArray());
            }
            else if ("pdf" == fileFormat)
            {
                PicGraphicsPdf graphics = new PicGraphicsPdf(box);
                graphics.Author = "treeDiM";
                graphics.Title  = "Pdf Export";
                // draw
                factory.Draw(graphics, filter);
                return(graphics.GetResultByteArray());
            }
            else
            {
                throw new Exception("Invalid file format : " + fileFormat);
            }
        }
        public static void ShowProcessor(Pic.Factory2D.PicFactory factory, string fileName)
        {
            // sanity checks
            if (!File.Exists(Properties.Settings.Default.SettingsFilePath))
            {
                MessageBox.Show(string.Format("Exporter settings file ({0}) could not be found!", Properties.Settings.Default.SettingsFilePath));
                return;
            }

            // show form
            FormExporterSettings form = new FormExporterSettings();

            form.Factory  = factory;
            form.FileName = fileName;
            if (DialogResult.OK == form.ShowDialog())
            {
            }
        }
Exemple #4
0
        public byte[] GetExportFile(string fileExt, Pic.Plugin.ParameterStack stack)
        {
            // build factory
            Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory();
            Component.CreateFactoryEntities(factory, stack);
            if (_reflectionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
            if (_reflectionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));

            // instantiate filter
            PicFilter filter = (_showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation) & PicFilter.FilterNoZeroEntities;

            // get bounding box
            Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox();
            factory.ProcessVisitor(visitorBoundingBox, filter);
            Pic.Factory2D.Box2D box = visitorBoundingBox.Box;
            // add margins : 5 % of the smallest value among height 
            box.AddMarginHorizontal(box.Width * 0.05);
            box.AddMarginVertical(box.Height * 0.05);

            string author = Application.ProductName + " (" + Application.CompanyName + ")";
            string title = Application.ProductName + " export";
            string fileFormat = fileExt.StartsWith(".") ? fileExt.Substring(1) : fileExt;
            fileFormat = fileFormat.ToLower();

            // get file content
            if (string.Equals("des", fileFormat))
            {
                Pic.Factory2D.PicVisitorDesOutput visitor = new Pic.Factory2D.PicVisitorDesOutput();
                visitor.Author = author;
                factory.ProcessVisitor(visitor, filter);
                return visitor.GetResultByteArray();
            }
            else if (string.Equals("dxf", fileFormat))
            {
                Pic.Factory2D.PicVisitorOutput visitor = new Pic.Factory2D.PicVisitorDxfOutput();
                visitor.Author = author;
                factory.ProcessVisitor(visitor, filter);
                return visitor.GetResultByteArray();
            }
            else if (string.Equals("pdf", fileFormat))
            {
                Pic.Factory2D.PicGraphicsPdf graphics = new PicGraphicsPdf(box);
                graphics.Author = author;
                graphics.Title = title;
                factory.Draw(graphics, filter);
                return graphics.GetResultByteArray();
            }
            else if (string.Equals("ai", fileFormat) || string.Equals("cf2", fileFormat))
            {
                Pic.Factory2D.PicVisitorDiecutOutput visitor = new Pic.Factory2D.PicVisitorDiecutOutput(fileFormat);
                visitor.Author = author;
                visitor.Title = title;
                factory.ProcessVisitor(visitor, filter);
                return visitor.GetResultByteArray();
            }
            else
                throw new Exception("Invalid file format:" + fileFormat);
        }
Exemple #5
0
        private void RePaint(PaintEventArgs e, ParameterStack stack)
        { 
            try
            {
                // instantiate PicGraphics
                if (_picGraphics == null)
                    _picGraphics = new PicGraphicsCtrlBased(this.Panel1.ClientSize, e.Graphics);
                _picGraphics.GdiGraphics = e.Graphics;
                _picGraphics.Size = this.Panel1.ClientSize;

                // instantiate filter
                PicFilter filter = _showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation;

                // build factory
                using (Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory())
                {
                    // create entities
                    Component.CreateFactoryEntities(factory, stack);
                    if (_reflectionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
                    if (_reflectionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));

                    // remove existing quotations
                    factory.Remove((new PicFilterCode(PicEntity.eCode.PE_COTATIONDISTANCE))
                                    | (new PicFilterCode(PicEntity.eCode.PE_COTATIONHORIZONTAL))
                                    | (new PicFilterCode(PicEntity.eCode.PE_COTATIONVERTICAL))
                                    );
                    // build auto quotation
                    if (_showCotations)
                        PicAutoQuotation.BuildQuotation(factory);

                    // update drawing box?
                    if (_computeBbox)
                    {
                        Pic.Factory2D.PicVisitorBoundingBox visitor = new Pic.Factory2D.PicVisitorBoundingBox();
                        factory.ProcessVisitor(visitor);
                        _box = new Box2D(visitor.Box);
                        Box2D box = visitor.Box;
                        box.AddMarginRatio(0.05);
                        _picGraphics.DrawingBox = box;

                        // update factory data
                        if (null != factoryDataCtrl)
                            factoryDataCtrl.Factory = factory;

                        _computeBbox = false;
                    }
                    // draw
                    factory.Draw(_picGraphics, filter);
                }
            }
            catch (Pic.Plugin.PluginException ex)
            {
                // might happen
                _picGraphics.ShowMessage(ex.Message);
            }
            catch (Exception ex)
            {
                _picGraphics.ShowMessage(ex.ToString());
                _log.Error(ex.ToString());
            }        
        }
Exemple #6
0
 public void Dimensions(ParameterStack stack, out double width, out double height, out double lengthCut, out double lengthFold)
 { 
     // build factory
     Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory();
     _component.CreateFactoryEntities(factory, stack);
     if (_reflexionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
     if (_reflexionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));
     // get bounding box
     Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox();
     factory.ProcessVisitor(visitorBoundingBox, _showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation);
     Pic.Factory2D.Box2D box = visitorBoundingBox.Box;
     width = box.Width;
     height = box.Height;
     // get length
     Pic.Factory2D.PicVisitorDieCutLength visitorLength = new Pic.Factory2D.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;
 }
Exemple #7
0
        public byte[] GenerateExportFile(string fileFormat, ParameterStack stack)
        {
            // build factory
            Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory();
            _component.CreateFactoryEntities(factory, stack);
            if (_reflexionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
            if (_reflexionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));

            // instantiate filter
            PicFilter filter = (_showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation) & PicFilter.FilterNoZeroEntities;

            // get bounding box
            Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox();
            factory.ProcessVisitor(visitorBoundingBox, filter);
            Pic.Factory2D.Box2D box = visitorBoundingBox.Box;
            // add margins : 5 % of the smallest value among height 
            box.AddMarginHorizontal(box.Width * 0.05);
            box.AddMarginVertical(box.Height * 0.05);
            // get file content
            if ("des" == fileFormat)
            {
                Pic.Factory2D.PicVisitorDesOutput visitor = new Pic.Factory2D.PicVisitorDesOutput();
                visitor.Author = "treeDiM";
                // process visitor
                factory.ProcessVisitor(visitor, filter);
                return visitor.GetResultByteArray();
            } 
            else if ("dxf" == fileFormat)
            {
                Pic.Factory2D.PicVisitorOutput visitor = new Pic.Factory2D.PicVisitorDxfOutput();
                visitor.Author = "treeDiM";
                // process visitor
                factory.ProcessVisitor(visitor, filter);
                return visitor.GetResultByteArray();

            }
            else if ("pdf" == fileFormat)
            {
                PicGraphicsPdf graphics = new PicGraphicsPdf(box);
                graphics.Author = "treeDiM";
                graphics.Title = "Pdf Export";
                // draw
                factory.Draw(graphics, filter);
                return graphics.GetResultByteArray();
            }
            else
                throw new Exception("Invalid file format : " + fileFormat);
        }
 // private constructor
 private DESQuerier(PicFactory factory)
 {
     _factory = factory;
 }
Exemple #9
0
 // private constructor
 private DESQuerier(PicFactory factory)
 {
     _factory = factory;
 }