Skip to content

Commit 576993f

Browse files
committed
Add densification option for Geometry and Graphical Watch and use it in periodic geometries.
1 parent 388367c commit 576993f

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

Visual_Studio_2015/GraphicalDebugging/ExpressionDrawer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public Settings CopyColored(System.Windows.Media.Color color)
5454
public bool showDir = true;
5555
public bool showLabels = true;
5656
public bool showDots = true;
57+
public bool densify = true;
5758
public bool valuePlot_enableBars = true;
5859
public bool valuePlot_enableLines = false;
5960
public bool valuePlot_enablePoints = false;
@@ -302,7 +303,7 @@ public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometr
302303
}
303304
else // Radian, Degree
304305
{
305-
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, this, false, traits.Unit);
306+
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, this, false, traits.Unit, settings.densify);
306307
Geometry.Interval interval = RelativeEnvelopeLon(this, false, traits.Unit);
307308
drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, false, settings.showDir, settings.showDots);
308309
}
@@ -334,7 +335,7 @@ private static void DrawLinestring(Geometry.Linestring linestring, Geometry.Box
334335
}
335336
else // Radian, Degree
336337
{
337-
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, linestring, false, traits.Unit);
338+
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, linestring, false, traits.Unit, settings.densify);
338339
Geometry.Interval interval = RelativeEnvelopeLon(linestring, false, traits.Unit);
339340
drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, false, settings.showDir, settings.showDots);
340341
}
@@ -385,7 +386,7 @@ public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometr
385386
}
386387
else
387388
{
388-
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, this, true, traits.Unit);
389+
Drawer.PeriodicDrawableRange pd = new Drawer.PeriodicDrawableRange(cs, this, true, traits.Unit, settings.densify);
389390
Geometry.Interval interval = RelativeEnvelopeLon(this, true, traits.Unit);
390391
drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, true, settings.showDir, settings.showDots);
391392

@@ -440,7 +441,7 @@ private static void DrawPolygon(Geometry.Polygon polygon, Geometry.Box box, Grap
440441
}
441442
else
442443
{
443-
Drawer.PeriodicDrawablePolygon pd = new Drawer.PeriodicDrawablePolygon(cs, polygon.Outer, polygon.Inners, traits.Unit);
444+
Drawer.PeriodicDrawablePolygon pd = new Drawer.PeriodicDrawablePolygon(cs, polygon.Outer, polygon.Inners, traits.Unit, settings.densify);
444445
Geometry.Interval interval = RelativeEnvelopeLon(polygon.Outer, polygon.Inners, traits.Unit);
445446
drawer.DrawPeriodic(cs, box, interval, traits.Unit, pd, true, settings.showDir, settings.showDots);
446447

Visual_Studio_2015/GraphicalDebugging/GeometryWatchControl.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ private void UpdateItems(bool load, int modified_index = -1)
224224
GeometryWatchOptionPage optionPage = Util.GetDialogPage<GeometryWatchOptionPage>();
225225
if (optionPage != null)
226226
{
227+
referenceSettings.densify = optionPage.Densify;
227228
referenceSettings.showDir = optionPage.EnableDirections;
228229
referenceSettings.showLabels = optionPage.EnableLabels;
229230
referenceSettings.showDots = true;

Visual_Studio_2015/GraphicalDebugging/GeometryWatchOptionPage.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ namespace GraphicalDebugging
1111
{
1212
public class GeometryWatchOptionPage : DialogPage
1313
{
14+
private bool densify = true;
1415
private bool enableDirs = true;
1516
private bool enableLabels = true;
1617

18+
[Category("Display")]
19+
[DisplayName("Densify Non-Cartesian Geometries")]
20+
[Description("Enable/disable densification to reflect curvature of the globe.")]
21+
public bool Densify
22+
{
23+
get { return densify; }
24+
set { densify = value; }
25+
}
26+
1727
[Category("Display")]
1828
[DisplayName("Enable Directions")]
1929
[Description("Enable/disable drawing directions of segments.")]

Visual_Studio_2015/GraphicalDebugging/GraphicalWatchControl.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private void UpdateItem(bool load, int index)
159159
{
160160
// Empty color - use default
161161
ExpressionDrawer.Settings settings = new ExpressionDrawer.Settings();
162+
settings.densify = true;
162163
settings.showDir = false;
163164
settings.showLabels = false;
164165
settings.showDots = false;
@@ -181,6 +182,7 @@ private void UpdateItem(bool load, int index)
181182
settings.pointPlot_enableLines = optionPage.PointPlot_EnableLines;
182183
settings.pointPlot_enablePoints = optionPage.PointPlot_EnablePoints;
183184
}
185+
settings.densify = optionPage.Densify;
184186
settings.showDir = optionPage.EnableDirections;
185187
settings.showLabels = optionPage.EnableLabels;
186188
settings.showDots = false;

Visual_Studio_2015/GraphicalDebugging/GraphicalWatchOptionPage.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace GraphicalDebugging
1212
{
1313
public class GraphicalWatchOptionPage : DialogPage
1414
{
15+
private bool densify = true;
1516
private bool enableDirs = false;
1617
private bool enableLabels = false;
1718
private int imageHeight = 100;
@@ -33,6 +34,15 @@ public enum MultiPointDisplayModeValue
3334
PointPlot
3435
};
3536

37+
[Category("Display")]
38+
[DisplayName("Densify Non-Cartesian Geometries")]
39+
[Description("Enable/disable densification to reflect curvature of the globe.")]
40+
public bool Densify
41+
{
42+
get { return densify; }
43+
set { densify = value; }
44+
}
45+
3646
[Category("Display")]
3747
[DisplayName("Enable Directions")]
3848
[Description("Enable/disable drawing directions of segments.")]

Visual_Studio_2015/GraphicalDebugging/Viewport.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ protected PeriodicDrawableRange(bool closed)
232232
public PeriodicDrawableRange(LocalCS cs,
233233
Geometry.IRandomAccessRange<Geometry.Point> points,
234234
bool closed,
235-
Geometry.Unit unit)
235+
Geometry.Unit unit,
236+
bool densify)
236237
{
237238
this.closed = closed;
238239
this.containsPole = ContainsPole.No;
@@ -249,7 +250,8 @@ public PeriodicDrawableRange(LocalCS cs,
249250

250251
xs_orig = new float[count];
251252
points_rel = new PointF[count];
252-
dens_points_rel = new PointF[points.Count][];
253+
if (densify)
254+
dens_points_rel = new PointF[points.Count][];
253255

254256
xs_orig[0] = cs.ConvertX(points[0][0]);
255257
points_rel[0] = cs.Convert(points[0]);
@@ -265,7 +267,8 @@ public PeriodicDrawableRange(LocalCS cs,
265267
p1[0] = p0[0] + distNorm;
266268
points_rel[i] = cs.Convert(p1);
267269

268-
dens_points_rel[i-1] = DensifyAndConvert(cs, p0, p1, densLength, unit);
270+
if (dens_points_rel != null)
271+
dens_points_rel[i-1] = DensifyAndConvert(cs, p0, p1, densLength, unit);
269272

270273
p0 = p1;
271274
}
@@ -509,14 +512,15 @@ public class PeriodicDrawablePolygon : IPeriodicDrawable
509512
public PeriodicDrawablePolygon(LocalCS cs,
510513
Geometry.IRandomAccessRange<Geometry.Point> outer,
511514
IEnumerable<Geometry.IRandomAccessRange<Geometry.Point>> inners,
512-
Geometry.Unit unit)
515+
Geometry.Unit unit,
516+
bool densify)
513517
{
514-
this.outer = new PeriodicDrawableRange(cs, outer, true, unit);
518+
this.outer = new PeriodicDrawableRange(cs, outer, true, unit, densify);
515519

516520
this.inners = new List<PeriodicDrawableRange>();
517521
foreach (var inner in inners)
518522
{
519-
PeriodicDrawableRange pd = new PeriodicDrawableRange(cs, inner, true, unit);
523+
PeriodicDrawableRange pd = new PeriodicDrawableRange(cs, inner, true, unit, densify);
520524
this.inners.Add(pd);
521525
}
522526
}

0 commit comments

Comments
 (0)