public static void Generate(string pluginPath, out Image bmp, Size size, PicFilter filter)
        {
            // instantiate factory
            PicFactory factory = new PicFactory();
            factory.Clear();

            // instantiate plugin
            Pic.Plugin.PluginServices pluginHost = new Pic.Plugin.PluginServices(pluginPath);
            IPlugin plugin = pluginHost.GetFirstPlugin();

            // generate entities
            ParameterStack stack = plugin.Parameters;
            plugin.CreateFactoryEntities(factory, stack);

            // get bounding box
            PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
            factory.ProcessVisitor(visitor);

            // draw image
            PicGraphicsImage picImage = new PicGraphicsImage();
            picImage.ImageSize = size;
            PicBox2D box = visitor.Box;
            box.AddMarginRatio(0.05);
            picImage.DrawingBox = box;
            factory.Draw(picImage, filter);

            bmp = picImage.Bitmap;
        }
Exemplo n.º 2
0
        public static void GenerateImage(Size size, PicFactory factory, bool showCotations, out Image bmp)
        {
            // get bounding box
            Box2D box = Tools.BoundingBox(factory, 0.05);
            // draw image
            PicGraphicsImage picImage = new PicGraphicsImage(size, box);

            factory.Draw(picImage, showCotations ? PicFilter.FilterNone : !PicFilter.FilterCotation);

            bmp = picImage.Bitmap;
        }
Exemplo n.º 3
0
        public static void GenerateImage(Size size, PicFactory factory, bool showCotations, out Image bmp)
        {
            // get bounding box
            PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
            factory.ProcessVisitor(visitor);
            Box2D box = visitor.Box;
            box.AddMarginRatio(0.05);
            // draw image
            PicGraphicsImage picImage = new PicGraphicsImage(size, box);
            factory.Draw(picImage, showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation);

            bmp = picImage.Bitmap;            
        }
Exemplo n.º 4
0
 public void GenerateThumbnail()
 {
     using (PicFactory factory = new PicFactory())
     {
         CreateEntities(factory);
         // insert format
         factory.InsertCardboardFormat(CardboardPosition, CardboardDimensions);
         // draw thumbnail
         PicGraphicsImage picImage = new PicGraphicsImage(new Size(ThumbnailWidth, ThumbnailWidth), Tools.BoundingBox(factory, PicFilter.FilterNone, 0.01));
         factory.Draw(picImage);
         // save thumbnail
         Thumbnail = picImage.Bitmap;
     }
 }
Exemplo n.º 5
0
        public static void GenerateImage(Size size, PicFactory factory, bool showCotations, out Image bmp)
        {
            // get bounding box
            PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();

            factory.ProcessVisitor(visitor);
            Box2D box = visitor.Box;

            box.AddMarginRatio(0.05);
            // draw image
            PicGraphicsImage picImage = new PicGraphicsImage(size, box);

            factory.Draw(picImage, showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation);

            bmp = picImage.Bitmap;
        }
 public void GenerateThumbnail()
 {
     using (PicFactory factory = new PicFactory())
     {
         CreateEntities(factory);
         // compute bounding box without format
         PicVisitorBoundingBox visitor0 = new PicVisitorBoundingBox();
         factory.ProcessVisitor(visitor0);
         _box = visitor0.Box;
         // insert format
         factory.InsertCardboardFormat(CardboardPosition, CardboardDimensions);
         // compute bounding box with format
         PicVisitorBoundingBox visitor1 = new PicVisitorBoundingBox();
         factory.ProcessVisitor(visitor1);
         // draw thumbnail
         PicGraphicsImage picImage = new PicGraphicsImage(new System.Drawing.Size(50, 50), visitor1.Box);
         factory.Draw(picImage);
         // save thumbnail
         _thumbnail = picImage.Bitmap;
     }
 }
Exemplo n.º 7
0
        public void GenerateImage(Size size, ParameterStack stack, out Image bmp)
        {
            // check if plugin was instantiated
            if (null == _component)
                throw new Exception("No valid plugin instance loaded!");

            // instantiate factory
            PicFactory factory = new PicFactory();
            // generate entities
            _component.CreateFactoryEntities(factory, stack);
            // apply any needed transformation
            if (_reflexionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX));
            if (_reflexionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY));
            // get bounding box
            PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
            factory.ProcessVisitor(visitor);
            Pic.Factory2D.Box2D box = visitor.Box;
            box.AddMarginRatio(0.05);
            // draw image
            PicGraphicsImage picImage = new PicGraphicsImage(size, box);
            factory.Draw(picImage, _showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation);

            bmp = picImage.Bitmap;
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            try
            {
                // instantiate factory
                PicFactory factory = new PicFactory();
                
                // load plugins
                PluginPathData configData = ConfigurationManager.GetSection("PluginSettings") as PluginPathData;
                if (null == configData)
                    throw new Exception("Failed to load valid PluinPathData object!");
                if (!Directory.Exists(configData.Path))
                    throw new Exception(string.Format("Directory \"{0}\" does not exist.", configData.Path));

                ComponentLoader loader = new ComponentLoader();
                DirectoryInfo dir = new DirectoryInfo(configData.Path);
                foreach (FileInfo fileInfo in dir.GetFiles())
                {
					try
					{
                        Component component = loader.LoadComponent(fileInfo.FullName);
                        if (null == component)
                            continue;
                        System.Console.WriteLine("Name = " + component.Name);
                        System.Console.WriteLine("Description = " + component.Description);
                        System.Console.WriteLine("Author = " + component.Author);
                        System.Console.WriteLine("Source code = " + component.SourceCode);
                        System.Console.WriteLine("------------");
                        // get thumbnail
                        if (component.HasEmbeddedThumbnail)
                        {
                            string thumbPath = Path.Combine(Path.GetTempPath(), component.Name + "_thumbnail.bmp");
                            System.Drawing.Bitmap thumbnail = component.Thumbnail;
                            thumbnail.Save(thumbPath);
                            if (launchPaint)
                                System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), "\"" + thumbPath + "\"");
                        }

                        // generate entities
                        ParameterStack stack = component.BuildParameterStack(null);
						factory.Clear();
						component.CreateFactoryEntities(factory, stack);

						// get bounding box
						PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
						factory.ProcessVisitor(visitor);

						// save
						string filePath = Path.Combine(Path.GetTempPath(), component.Name + ".jpeg");
						PicGraphicsImage picImage = new PicGraphicsImage();
						picImage.ImageSize = new System.Drawing.Size(512, 512);
						Box2D box = visitor.Box;
						box.AddMargin(5);
						picImage.DrawingBox = box;
						factory.Draw(picImage);
						picImage.SaveAs(filePath);

                        if (launchPaint)
						    System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), "\"" + filePath + "\"");
					}
					catch (System.Exception ex)
					{
                        _log.Debug(ex.Message);
					}
                }
            }
            catch (System.Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 9
0
 public Image GetImage(int leadingDimension, bool showDimensions, List<short> groups, List<short> layers)
 { 
     // computing bounding box
     Box2D box = BoundingBox(showDimensions);
     box.AddMarginRatio(0.05);
     Size imageSize = box.GetSizeFromLeading(leadingDimension);
     // build filter
     PicFilter filter = new PicFilterListGroup(groups)
         & new PicFilterListLayer(layers)
         & (showDimensions ? PicFilter.FilterNone : PicFilter.FilterCotation);
     // cotations with long lines
     PicGlobalCotationProperties.ShowShortCotationLines = false;
     // drawing
     PicGraphicsImage picGraph = new PicGraphicsImage(imageSize, box);
     _factory.Draw(picGraph, showDimensions ? PicFilter.FilterNone : PicFilter.FilterCotation);
     return picGraph.Bitmap;
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // set up a simple configuration that logs on the console.
            XmlConfigurator.Configure();

            try
            {
                _log.Info("Pic.Factory2D.Test.exe starting...");
                // testing Sharp3D.Math.Core.Matrix3D
                Transform2D transf0 = Transform2D.Translation(new Vector2D(10.0, 10.0)) * Transform2D.Rotation(45.0);
                Vector2D pt0 = transf0.transform(new Vector2D(100.0, 100.0));
                _log.Info(pt0.ToString());
                Transform2D transf1 = transf0.Inverse();
                Vector2D pt1 = transf1.transform(pt0);
                _log.Info(pt1.ToString());

                // instantiate factory1
                PicFactory factory0 = new PicFactory();
                factory0.AddPoint(PicGraphics.LT.LT_CUT, new Vector2D(0.0, 0.0));
                factory0.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(50.0, 50.0), new Vector2D(100.0, 100.0));
                factory0.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(-100.0, 100.0), new Vector2D(100.0, -100.0));
                factory0.AddArc(PicGraphics.LT.LT_CUT, new Vector2D(50.0, 50.0), 50.0 * Math.Sqrt(2.0), 0.0, 360.0);
                factory0.AddArc(PicGraphics.LT.LT_CUT, new Vector2D(75.0, 75.0), 25.0 * Math.Sqrt(2.0), 0.0, 360.0);
                factory0.AddNurb(PicGraphics.LT.LT_CUT);
                _log.Debug(factory0.ToString());

                // get bounding box + draw
                using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox())
                {
                    factory0.ProcessVisitor(visitor);
                    _log.Info(visitor.Box.ToString());

                    // save as image
                    string filePath = Path.Combine(Path.GetTempPath(), "PicImage0.jpeg");
                    PicGraphicsImage picImage = new PicGraphicsImage();
                    picImage.ImageSize = new System.Drawing.Size(512, 512);
                    Box2D box = visitor.Box;
                    box.AddMargin(5);
                    picImage.DrawingBox = box;
                    factory0.Draw(picImage);
                    picImage.SaveAs(filePath);
                    _log.Debug("File path = " + filePath);
                    _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe"));
                    System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath);
                }

                // output to dxf file
                Pic.Factory2D.PicVisitorDxfOutput dxfOutputVisitor = new Pic.Factory2D.PicVisitorDxfOutput();
                factory0.ProcessVisitor(dxfOutputVisitor);

                // load dxf file
                PicFactory factory1 = new PicFactory();
                PicLoaderDxf loaderDxf = new PicLoaderDxf(factory1);
                loaderDxf.Load(@"K:\Codesion\PicSharp\Samples\F1034.EV.DXF");
                loaderDxf.FillFactory();
                // save as image
                // get bounding box + draw
                using (PicVisitorBoundingBox visitor1 = new PicVisitorBoundingBox())
                {
                    factory1.ProcessVisitor(visitor1);
                    _log.Info(visitor1.Box.ToString());
                    string filePath1 = Path.Combine(Path.GetTempPath(), "PicImage1.jpeg");
                    PicGraphicsImage picImage1 = new PicGraphicsImage();
                    picImage1.ImageSize = new System.Drawing.Size(512, 512);
                    Box2D box1 = visitor1.Box;
                    box1.AddMargin(5);
                    picImage1.DrawingBox = box1;
                    factory1.Draw(picImage1);
                    picImage1.SaveAs(filePath1);
                    _log.Debug("File path = " + filePath1);
                    _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe"));
                    System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath1);
                }

                // instantiate factory2
                PicFactory factory2 = new PicFactory();
                PicBlock block = factory2.AddBlock(factory0);
                factory2.AddBlockRef(block, new Vector2D(0.0, 0.0), 0.0);
                factory2.AddBlockRef(block, new Vector2D(400.0, 0.0), 0.0);
                factory2.AddBlockRef(block, new Vector2D(0.0, 400.0), 0.0);
                factory2.AddBlockRef(block, new Vector2D(400.0, 400.0), 45.0);

                // get bounding box of factory2
                using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox())
                {
                    factory2.ProcessVisitor(visitor);
                    _log.Info(visitor.Box.ToString());

                    // save as image
                    string filePath = Path.Combine(Path.GetTempPath(), "PicImage2.jpeg");
                    PicGraphicsImage picImage = new PicGraphicsImage();
                    picImage.ImageSize = new System.Drawing.Size(512, 512);
                    Box2D box = visitor.Box;
                    box.AddMargin(5);
                    picImage.DrawingBox = box;
                    factory2.Draw(picImage);
                    picImage.SaveAs(filePath);
                    _log.Debug("File path = " + filePath);
                    _log.Debug("Path = " + Path.Combine(Environment.SystemDirectory, "mspaint.exe"));
                    System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath);
                }

                // compute area
                PicFactory factory3 = new PicFactory();
                factory3.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(-100.0, -100.0), new Vector2D(100.0, -100.0));
                factory3.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(100.0, -100.0), new Vector2D(100.0, 100.0));
                factory3.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(100.0, 100.0), new Vector2D(-100.0, 100.0));
                factory3.AddSegment(PicGraphics.LT.LT_CUT, new Vector2D(-100.0, 100.0), new Vector2D(-100.0, -100.0));

                PicToolArea picToolArea = new PicToolArea();
                factory3.ProcessTool(picToolArea);
                _log.Info(string.Format("Area of factory3 is {0}", picToolArea.Area));

                _log.Info("Pic.Factory2D.Test.exe finishing...");
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            // set up a simple configuration that logs on the console.
            XmlConfigurator.Configure();

            string assemblyName = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
            try
            {
                _log.Info(assemblyName + " starting...");

                const PicGraphics.LT ltCut = PicGraphics.LT.LT_CUT;

                // instantiate factory
                PicFactory initialFactory = new PicFactory();

                ParameterStack stack = Program.Parameters;
                Program.CreateFactoryEntities(initialFactory, stack, Transform2D.Identity);
                // imposition
                double width = 1000.0, height = 1000.0;
                ImpositionTool impositionTool = new ImpositionToolCardboardFormat(initialFactory, new CardboardFormat(0, "Format1", "Format1", width, height));
                impositionTool.SpaceBetween = new Vector2D(0.0, 0.0);
                impositionTool.Margin = new Vector2D(0.0, 0.0);

                List<ImpositionSolution> solutions;
                impositionTool.GenerateSortedSolutionList(null, out solutions);
                _log.Info(string.Format("{0} : Solutions", solutions.Count));
                if (solutions.Count <= 0)
                    return;

                foreach (ImpositionSolution chosenSolution in solutions)
                {
                    _log.Info(string.Format("NoRows={0}, NoCols={1}", chosenSolution.Rows, chosenSolution.Cols));

                    PicFactory factoryOut = new PicFactory();
                    chosenSolution.CreateEntities(factoryOut);
                    factoryOut.AddSegment(ltCut, new Vector2D(0.0, 0.0), new Vector2D(width, 0.0));
                    factoryOut.AddSegment(ltCut, new Vector2D(width, 0.0), new Vector2D(width, height));
                    factoryOut.AddSegment(ltCut, new Vector2D(width, height), new Vector2D(0.0, height));
                    factoryOut.AddSegment(ltCut, new Vector2D(0.0, height), new Vector2D(0.0, 0.0));

                    // get bounding box
                    Box2D box = new Box2D();
                    using (PicVisitorBoundingBox visitor = new PicVisitorBoundingBox())
                    {
                        factoryOut.ProcessVisitor(visitor);
                        box = visitor.Box;
                    }

                    string filePath = Path.Combine(Path.GetTempPath(), "Imposition.bmp");
                    PicGraphicsImage picImage = new PicGraphicsImage();
                    picImage.ImageSize = new System.Drawing.Size(4096, 4096);
                    box.AddMargin(1.0);
                    picImage.DrawingBox = box;
                    factoryOut.Draw(picImage);
                    picImage.SaveAs(filePath);

                    System.Diagnostics.Process.Start(Path.Combine(Environment.SystemDirectory, "mspaint.exe"), filePath);

                    _log.Info(assemblyName + " ending...");
                }
             }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
             
        }