public Feature(int oid, Shape geometry, string[] fieldnames, string[] fieldvalues, LabelLocation[] annotations) { _oid = oid; _geometry = geometry; _fieldNames = fieldnames; _fieldValues = fieldvalues; _annotations = annotations; _outsideIndicator = new OutsideIndicator(); }
internal bool _isfullInternal = false;//session,一次绘制会话内有效 public Grid(int gridNo, Envelope gridEnvelope, Feature[] features) { _gridEnvelope = gridEnvelope; _gridNo = gridNo; _features = new List <Feature>(features); UpdateEnvelope(); DoEstimateSize(); _outsideIndicator = new OutsideIndicator(); }
private void RenderFeatures(Graphics g, QuickTransformArgs quickTransfrom) { IFeatureClass fetclass = _class as IFeatureClass; IGrid[] grids = fetclass.Grids; if (grids == null || grids.Length == 0) { return; } try { fetclass.RepeatFeatureRecorder.BeginRender(); int gridCount = grids.Length; Envelope currentExtent = _environment.ExtentOfProjectionCoord; Grid gd = null; IOutsideIndicator outsideIndicator = null; // for (int i = 0; i < gridCount; i++) { gd = grids[i] as Grid; if (gd.IsEmpty()) { continue; } outsideIndicator = (gd as ISupportOutsideIndicator).OutsideIndicator; //test,draw grids //DrawTestGrid(gd, g, quickTransfrom); // /* 为了测试其他投影矢量绘制注释掉 * outsideIndicator.SetOutside(!currentExtent.IsInteractived(gd.GridEnvelope,ref gd._isfullInternal)); * if (outsideIndicator.IsOutside) * continue; */ outsideIndicator.SetOutside(!currentExtent.IsInteractived(gd.GridEnvelope, ref gd._isfullInternal)); if (outsideIndicator.IsOutside) { continue; } _featureRender.Render(_enabledDisplayLevel, quickTransfrom, gd, g, currentExtent, fetclass.RepeatFeatureRecorder); } } finally { fetclass.RepeatFeatureRecorder.EndRender(); } }
private void DrawAllLabels(ILayerContainer layerContainer, Graphics g) { IOutsideIndicator outsideIndicator = null; int currentScale = _scale; // foreach (ILayerDrawable lyr in layerContainer.Layers) { if (!lyr.Visible) { continue; } IFeatureLayer fetLayer = lyr as IFeatureLayer; if (fetLayer == null) { continue; } //如果图层未初始化 if (!fetLayer.IsReady) { continue; } //判断整个图层是否在可视区域之外 IFeatureClass fetclass = fetLayer.Class as IFeatureClass; if (!fetclass.FullEnvelope.IsInteractived(_viewportProjection)) { continue; } //判断几何形状是否显示,如果不显示,标注也不显示 if (!fetLayer.VisibleAtScale(currentScale)) { continue; } //判断在当前比例尺下标注是否显示 if (!fetLayer.LabelDef.VisibleAtScale(currentScale)) { continue; } //获取外部标识对象 outsideIndicator = (fetLayer as ISupportOutsideIndicator).OutsideIndicator; if (outsideIndicator.IsOutside) { continue; } //判断是否启用标注 if (fetLayer.LabelDef == null || !fetLayer.LabelDef.EnableLabeling) { continue; } //判断网格集合是否为空 if (fetclass == null || fetclass.Grids == null || fetclass.Grids.Length == 0) { continue; } //只对点层进行标注冲突检测 bool conflictIsChanged = false; if (_conflictorForLabel != null && _conflictorForLabel.Enabled) { conflictIsChanged = true; //如果线采用注记形式,那么不做冲突检测 _conflictorForLabel.Enabled = !(fetclass.ShapeType == enumShapeType.Polyline && fetLayer.LabelDef.LabelSource == enumLabelSource.Annotation); } //逐网格进行标注 int gridCount = fetclass.Grids.Length; for (int i = 0; i < gridCount; i++) { if (i > gridCount - 1) { continue; } //判断网格是否可见 outsideIndicator = (fetclass.Grids[i] as ISupportOutsideIndicator).OutsideIndicator; if (outsideIndicator.IsOutside) { continue; } //判断网格内要素是否为空 Feature[] fets = fetclass.Grids[i].VectorFeatures.ToArray(); if (fets == null || fets.Length == 0) { continue; } //解决透明背景下,绘制文本出现黑色杂点的问题 g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; foreach (Feature fet in fets) { //判断要素是否可见 outsideIndicator = (fet as ISupportOutsideIndicator).OutsideIndicator; if (outsideIndicator.IsOutside) { continue; } //画标注 _labelRender.Draw(_emptyRotateMatrix, g, fetLayer.LabelDef as LabelDef, fetLayer.Renderer.CurrentSymbol, fet, _quickTransfrom); } } // if (conflictIsChanged) { _conflictorForLabel.Enabled = true; } g.Flush(FlushIntention.Sync); } }
public FeatureLayer() { _displayScaleRange = new ScaleRange(-1, 1); _outsideIndicator = new OutsideIndicator(); }
public void Render(bool enableDisplayLevel, QuickTransformArgs quickTransformArgs, IGrid gd, Graphics g, Envelope rect, RepeatFeatureRecorder recorder) { if (g == null) { return; } _currentFeatureRects.Clear(); List <Feature> features = gd.VectorFeatures; if (features == null || features.Count == 0) { return; } _quickTransformArgs = quickTransformArgs; int fetCount = features.Count; Feature feature = null; IOutsideIndicator outsideIndicator = null; bool isfullInside = (gd as Grid)._isfullInternal; for (int i = 0; i < fetCount; i++) { feature = features[i]; if (feature == null || feature.Geometry == null) { continue; } outsideIndicator = feature.OutsideIndicator;// (feature as ISupportOutsideIndicator).OutsideIndicator; //判断是否在该级别显示 if (enableDisplayLevel && feature.DisplayLevel != -1) { if (feature.DisplayLevel > _environment.CurrentLevel) { outsideIndicator.SetOutside(true); continue; } } //可见性计算 if (!isfullInside) { if (feature.Geometry is ShapePoint) { outsideIndicator.SetOutside(!IsPointInCurrentExtent(feature, rect)); } else //Polyline,Polygon { outsideIndicator.SetOutside(!IsPolygonInCurrentExtent(feature, rect)); } if (outsideIndicator.IsOutside) { continue; } } else//整个网格都在可视区域内部 { outsideIndicator.SetOutside(false); } //是否已经在其他网格绘制过了 if (feature.IsRepeatedOverGrids) { if (recorder.IsRendered(feature.OID)) { continue; } else { recorder.AddRenderedOID(feature.OID); } } //为要素设置绘制符号 SetCurrentSymbolFromFeature(feature); if (_currentSymbol == null) { continue; } //为符号设置角度 SetAngleOfSymbol(feature); //画几何形状 try { if (feature.Geometry is ShapePoint) { PointF pt = ShapePoint2PixelPoint(feature.Geometry as ShapePoint); //位置冲突检测 if (_environment != null) { IConflictor conflictorForSymbol = _environment.ConflictorForSymbol; if (conflictorForSymbol != null && conflictorForSymbol.Enabled) { //符号冲突 if (conflictorForSymbol.IsConflicted(pt.X - _currentSymbol.SymbolHalfWidth, pt.Y - _currentSymbol.SymbolHalfHeight, _currentSymbol.SymbolSize)) { outsideIndicator.SetOutside(true); continue; } } } //画符号 DrawPointUseCurrentSymbol(g, pt); //记下要素符号矩形区域 _currentFeatureRects.Add(feature, new RectangleF((_currentSymbol as IMarkerSymbol).PixelLocation, _currentSymbol.SymbolSize)); //符号不冲突,在标注冲突检测网格中占位 #region debug //符号矩形 //PointF tpt = new PointF((pt.X - _currentSymbol.SymbolSize.Width / 2f), // (pt.Y - _currentSymbol.SymbolSize.Height / 2f)); //(_environment.ConflictorForLabel as PixelConflictor).DrawTestRectangleF(tpt, _currentSymbol.SymbolSize, Color.Yellow); #endregion if (_environment != null) { if (_environment.ConflictorForLabel != null && _environment.ConflictorForLabel.Enabled) { _environment.ConflictorForLabel.HoldPosition((pt.X - _currentSymbol.SymbolSize.Width / 2f), (pt.Y - _currentSymbol.SymbolSize.Height / 2f), _currentSymbol.SymbolSize); } } } else //Polyline,Polygon { SetGraphicsPathFromGeometry(feature.Geometry); if (_path.PointCount > 0) { DrawPathUseCurrentSymbol(g); _currentFeatureRects.Add(feature, RectangleF.Empty); } } } catch (Exception ex) { Log.WriterException("BaseFeatureRenderer", "Render(Layer:" + (_name != null ?_name : string.Empty) + ",OID:" + feature.OID.ToString() + ")", ex); } finally { _currentSymbol.Angle = 0; } } }