Skip to main content

StencilAreas

IntensityGridSeries, IntensityMeshSeries and Maps have StencilArea feature which allows masking in or out areas of drawn data. For instance, if data is shown above a map, stencils can be used to limit the visible data to certain map areas, such as countries. StencilArea can be applied by creating a new StencilArea object, then defining its size as PointDouble2D -array via AddPolygon() or as a map layer via AddMapLayerIndex(), and finally adding them to the series that should be masked.

There are two types of StencilAreas:

  • AdditiveAreas creates a positive stencil mask - only data inside the area is drawn, while the outside is clipped.
  • SubtractiveAreas creates a negative stencil mask - data inside the area is clipped, while the outside is drawn.
tip

Note that SubtractiveAreas are designed to work only together with AdditiveAreas - without them no clipping is applied.

Whenever a StencilArea object is added to the list (AdditiveAreas or SubtractiveAreas), InvalidateStencil() or InvalidateData() should be called for the respective series. It is also recommended that the array of points defining the stencil is set in clockwise order.

AdditiveAreas

Use AdditiveAreas to define the area that should be drawn. Everything outside it will be clipped.

// Defining an additive StencilArea to an IntensityGrid

PointDouble2D[] stencilPoints = new PointDouble2D[] {
new PointDouble2D(30, 5),
new PointDouble2D(30, 95),
new PointDouble2D(195, 95),
new PointDouble2D(195, 5)
};
StencilArea stencilArea = new StencilArea(_intensityGrid.Stencil);
stencilArea.AddPolygon(StencilPoints);
_intensityGrid.Stencil.AdditiveAreas.Add(stencilArea);
_intensityGrid.InvalidateStencil();

IntensityGrid AdditiveArea
An IntensityGrid without any stencils on the top. On the bottom, the same grid with an AdditiveArea created by using the code above.

SubstractiveAreas

Use SubstractiveAreas to define areas which should not be drawn inside an AdditiveArea.

/// Defining two substractive StencilAreas to an IntensityGrid
PointDouble2D[] pnt2 = new PointDouble2D[] {
new PointDouble2D(130, 70),
new PointDouble2D(130, 90),
new PointDouble2D(160, 90),
new PointDouble2D(160, 70),
};
StencilArea stencilArea2 = new StencilArea(_heatMap.Stencil);
stencilArea2.AddPolygon(pnt2);
_heatMap.Stencil.SubtractiveAreas.Add(stencilArea2);
_heatMap.InvalidateStencil();
PointDouble2D[] pnt3 = new PointDouble2D[] {
new PointDouble2D(50, 10),
new PointDouble2D(50, 25),
new PointDouble2D(90, 25),
new PointDouble2D(90, 10),
};
StencilArea stencilArea3 = new StencilArea(_heatMap.Stencil);
stencilArea3.AddPolygon(pnt3);
_heatMap.Stencil.SubtractiveAreas.Add(stencilArea3);
_heatMap.InvalidateStencil();

IntensityGrid SubstractiveAreas
An IntensityGrid with two SubstractiveAreas, set by using the code above. Note that an AdditiveArea has to be set before using SubstractiveAreas.

Multiple StencilAreas

It is possible to set multiple StencilAreas, both additive and substractive ones. In case two or more areas overlap, the areas are joined.

IntensityGrid Multiple StencilAreas
Multiple StencilAreas are used. Some SubstractiveAreas overlap so the areas are joined. Transparent polygons with visible borders are also drawn to mark the locations of the stencils.

info

To see feature demonstration as an example, check ExampleMapStencil, Chromaticity diagram, ExampleSiliconWaferMap from our Demo.