Example #1
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());
            }        
        }
Example #2
0
        private void RePaint(PaintEventArgs e, ParameterStack stack)
        {
            try
            {
                SplitterPanel panel1 = splitContHorizLeft.Panel1;

                // instantiate PicGraphics
                if (_picGraphics == null)
                {
                    _picGraphics = new PicGraphicsCtrlBased(panel1.ClientSize, e.Graphics)
                    {
                        BackgroundColor = Factory2D.Control.Properties.Settings.Default.BackgroundColor
                    };
                }
                _picGraphics.GdiGraphics = e.Graphics;
                _picGraphics.Size        = panel1.ClientSize;

                // build factory
                using (PicFactory factory = new 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
                    if (!_showCotationCode)
                    {
                        factory.Remove(PicFilter.FilterCotation);
                    }
                    // build auto quotations
                    if (_showCotationAuto)
                    {
                        PicAutoQuotation.BuildQuotation(factory);
                    }

                    // filter
                    PicFilter filter = _showAxes ? PicFilter.FilterNone
                        : PicFilter.FilterCotation | !(new PicFilterLineType(PicGraphics.LT.LT_COTATION) | new PicFilterLineType(PicGraphics.LT.LT_AXIS));

                    // update drawing box?
                    if (_computeBbox)
                    {
                        PicVisitorBoundingBox visitor = new PicVisitorBoundingBox();
                        factory.ProcessVisitor(visitor, filter);
                        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 (PluginException ex) { _picGraphics.ShowMessage(ex.Message); }
            catch (ComponentSearchException ex) { _picGraphics.ShowMessage(ex.Message); }
            catch (Exception ex) { _picGraphics.ShowMessage(ex.ToString()); log.Error(ex.ToString()); }
        }