Пример #1
0
        private void RenderUseDummyBitmap(RenderArgs arg)
        {
            _dummyPoints[0].X = (float)_dummyEnvelope.MinX;
            _dummyPoints[0].Y = (float)_dummyEnvelope.MaxY;
            _dummyPoints[1].X = (float)_dummyEnvelope.MaxX;
            _dummyPoints[1].Y = (float)_dummyEnvelope.MinY;
            _worldTransform.TransformPoints(_dummyPoints);
            PointF lt = _dummyPoints[0];
            PointF rb = _dummyPoints[1];

            arg.Graphics.DrawImage(_dummyBitmap, lt.X, lt.Y, rb.X - lt.X, rb.Y - lt.Y);
        }
Пример #2
0
        private void ReRender(RenderArgs arg, bool needComputeViewport)
        {
            if (_dummyBitmap != null)
            {
                _dummyBitmap.Dispose();
            }
            _dummyBitmap = new Bitmap(_environment.CanvasSize.Width, _environment.CanvasSize.Height);
            if (needComputeViewport) //for web
            {
                ComputeViewportProjection();
            }
            _dummyEnvelope = ExtentOfProjectionCoord.Clone() as Envelope;
            //
            ILayerContainer layerContainer = _map.LayerContainer;

            //计算用于快速坐标变换的参数
            ComputeQuickArgs();
            //构造缓存画布
            using (Graphics g = Graphics.FromImage(_dummyBitmap))
            {
                g.SmoothingMode = _map.MapArguments.SmoothingMode;
                g.Clear(_map.MapArguments.BackColor);
                //重置冲突检测
                if (_conflictorForSymbol != null && _conflictorForSymbol.Enabled)
                {
                    _conflictorForSymbol.Reset();
                }
                //
                if (_conflictorForLabel != null && _conflictorForLabel.Enabled)
                {
                    _conflictorForLabel.Reset();
                    _labelRender.Begin(_conflictorForLabel, this as IFeatureRenderEnvironment);
                }
                else
                {
                    _labelRender.Begin(null, this as IFeatureRenderEnvironment);
                }
                //绘制影像层
                DrawRasterlayers(g);

                //绘制几何形状
                DrawAllGeometries(layerContainer, g);
                //绘制标注
                DrawAllLabels(layerContainer, g);
                #region debug
                //(_conflictorForLabel as PixelConflictor).Save();
                #endregion
            }
            arg.Graphics.DrawImage(_dummyBitmap, 0, 0);
        }
Пример #3
0
        private void DrawBubbleImage(RenderArgs arg, PointF pt)
        {
            if (_bubbleImage == null)
            {
                return;
            }
            float x = pt.X - _bubbleOffsetX;
            float y = pt.Y - _bubbleOffsetY;

            _bubbleRect = new RectangleF(x, y, _bubbleImage.Width, _bubbleImage.Height);
            arg.Graphics.DrawImage(_bubbleImage, x, y);
            if (!string.IsNullOrEmpty(_labelString))
            {
                SizeF fontsize = arg.Graphics.MeasureString(_labelString, _font);
                arg.Graphics.DrawString(_labelString, _font, Brushes.Red, x + _bubbleImage.Width, y + _bubbleImage.Height / 2 - fontsize.Height / 2);
            }
        }
Пример #4
0
        public void Render(RenderArgs arg)
        {
            if (_location == null)
            {
                return;
            }
            PointF[] pts = new PointF[] { _location.ToPointF() };
            (_runtime as IFeatureRenderEnvironment).CoordinateTransform.PrjCoord2PixelCoord(pts);
            PointF pt = pts[0];

            if (_isShowBubble)
            {
                DrawBubbleImage(arg, pt);
            }
            if (!_isFlash)
            {
                return;
            }
            int halfw = 6;
            int w     = 2 * halfw;

            if (_needRender)
            {
                SmoothingMode oldM = arg.Graphics.SmoothingMode;
                try
                {
                    using (Pen p = new Pen(Color.Gray, 2))
                    {
                        arg.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                        arg.Graphics.DrawLine(p, pt.X, 0, pt.X, _runtime.Host.CanvasSize.Height);
                        arg.Graphics.DrawLine(p, 0, pt.Y, _runtime.Host.CanvasSize.Width, pt.Y);
                        arg.Graphics.FillEllipse(Brushes.Green, (float)pt.X - halfw, (float)pt.Y - halfw, w, w);
                    }
                }
                finally
                {
                    arg.Graphics.SmoothingMode = oldM;
                }
            }
        }
Пример #5
0
 private void DrawHandinessLayers(RenderArgs arg)
 {
     //用户自定义临时层
     if (_handinessLayerContainer != null && _handinessLayerContainer.Layers != null)
     {
         foreach (ILightLayer lyr in _handinessLayerContainer.Layers)
         {
             if (lyr.Enabled)
             {
                 lyr.Render(arg);
             }
         }
     }
     //系统临时层
     if (_locationIconLayer != null)
     {
         _locationIconLayer.Render(arg);
     }
     if (_locatingFocusLayer != null)
     {
         _locatingFocusLayer.Render(arg);
     }
 }
Пример #6
0
        public void Render(RenderArgs arg)
        {
            if (_map == null || _isDisposed)
            {
                return;
            }
            ILayerContainer layerContainer = _map.LayerContainer;

            if (layerContainer.IsEmpty() || _environment.CanvasSize == Size.Empty)
            {
                return;
            }
#if DEBUG
            int time = Environment.TickCount;
#endif
            bool transformIsChanged = _preMapTransform == null || !MathHelper.MatrixIsSame(_preMapTransform, arg.Graphics.Transform);
            bool envelopeIsChanged  = _preFocusEnvelope == null || !_preFocusEnvelope.IsEquals(_environment.FocusEnvelope);
            transformIsChanged = transformIsChanged || envelopeIsChanged;
            bool needComputeViewportPrjAgain = true;
            //for web
            transformIsChanged = true;
            //
            if (transformIsChanged)
            {
                if (_transformChanged != null)
                {
                    _transformChanged(this, null, null);
                }
                UpdateViewportAndTransformMatrix();
                needComputeViewportPrjAgain = false;
            }
            Matrix oldM       = arg.Graphics.Transform;
            bool   needRember = false;
            try
            {
                arg.Graphics.Transform = _transformIdentity;
                if (_environment.UseDummyMap && _dummyBitmap != null)
                {
                    RenderUseDummyBitmap(arg);
                }
                else
                {
                    if (transformIsChanged || layerContainer.LayerIsChanged || arg.IsReRender || _dummyBitmap == null)
                    {
                        ReRender(arg, needComputeViewportPrjAgain);
                        needRember = true;
                        (layerContainer as LayerContainer).ResetLayerIsChanged();
                    }
                    else
                    {
                        RenderUseDummyBitmap(arg);
                    }
                }
            }
            finally
            {
                //画比例尺条
                if (_scaleBarArgs != null && _scaleBarArgs.Enabled)
                {
                    DrawScaleBar(arg.Graphics);
                }
                //画临时图层
                DrawHandinessLayers(arg);
                //
                arg.Graphics.Transform = oldM;
                arg.IsReRender         = false;
                arg.IsRendering        = false;
            }
            if (needRember)
            {
                RemeberPreTransform(arg);
            }
            if (envelopeIsChanged)
            {
                if (_onViewExtentChanged != null)
                {
                    _onViewExtentChanged.BeginInvoke(this, _environment.FocusEnvelope, null, null);
                }
            }
#if DEBUG
            time = Environment.TickCount - time;
            //Console.WriteLine("lost:" + time.ToString());
            //_environment.Container.FindForm().Text = time.ToString();
#endif
        }