Skip to content

Commit 714d37a

Browse files
committed
Draw any DrawableContainers using color of the elements.
1 parent 2ebc4d4 commit 714d37a

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Visual_Studio_2017/GraphicalDebugging/Colors.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public void Update()
7171
MultiLinestringColor = Color.DarkGreen;
7272
MultiPolygonColor = Color.FromArgb(0xFF, 0, 0, 128);
7373
TurnColor = Color.DarkOrange;
74-
GeometriesContainerColor = Color.SaddleBrown;
7574
}
7675
else
7776
{
@@ -95,7 +94,6 @@ public void Update()
9594
MultiLinestringColor = Color.FromArgb(0xFF, 128, 172, 128);
9695
MultiPolygonColor = Color.FromArgb(0xFF, 128, 128, 172);
9796
TurnColor = Color.FromArgb(0xFF, 255, 197, 128);
98-
GeometriesContainerColor = Color.Tan;
9997
}
10098
}
10199

@@ -139,7 +137,6 @@ private float GetBrightness()
139137
public Color MultiLinestringColor { get; set; }
140138
public Color MultiPolygonColor { get; set; }
141139
public Color TurnColor { get; set; }
142-
public Color GeometriesContainerColor { get; set; }
143140

144141
private void CreateColors(uint[] colorValues)
145142
{

Visual_Studio_2017/GraphicalDebugging/ExpressionDrawer.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,24 @@ public class DrawablesContainer : List<IDrawable>, IDrawable
739739
{
740740
public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits)
741741
{
742-
// TODO: Draw using IDrawable color?
743742
for (int i = 0; i < this.Count; ++i)
744743
{
745744
this[i].Draw(box, graphics, settings, traits);
746745
}
747746
}
748747

748+
// TODO: This overload is defined to allow drawing elements using their specific colors
749+
// Incorporate this into the IDrawable interface?
750+
public void Draw(Geometry.Box box, Graphics graphics, Settings settings, Geometry.Traits traits, Colors colors)
751+
{
752+
for (int i = 0; i < this.Count; ++i)
753+
{
754+
IDrawable drawable = this[i];
755+
settings.color = DefaultColor(drawable, colors);
756+
drawable.Draw(box, graphics, settings, traits);
757+
}
758+
}
759+
749760
public Geometry.Box Aabb(Geometry.Traits traits, bool calculateEnvelope)
750761
{
751762
Geometry.Box result = null;
@@ -1211,7 +1222,7 @@ static Color DefaultColor(IDrawable drawable, Colors colors)
12111222
return colors.BoxColor;
12121223
else if (drawable is NSphere)
12131224
return colors.NSphereColor;
1214-
else if (drawable is Segment)
1225+
else if (drawable is Segment) // Ray, Line
12151226
return colors.SegmentColor;
12161227
else if (drawable is Linestring)
12171228
return colors.LinestringColor;
@@ -1227,8 +1238,6 @@ static Color DefaultColor(IDrawable drawable, Colors colors)
12271238
return colors.MultiPolygonColor;
12281239
else if (drawable is Turn || drawable is TurnsContainer)
12291240
return colors.TurnColor;
1230-
else if (drawable is DrawablesContainer)
1231-
return colors.GeometriesContainerColor;
12321241
else
12331242
return colors.DrawColor;
12341243
}
@@ -1254,7 +1263,11 @@ public static bool Draw(Graphics graphics,
12541263
bool fill = (traits == null);
12551264
if (drawable.DrawAxes())
12561265
Drawer.DrawAxes(graphics, aabb, unit, colors, fill);
1257-
drawable.Draw(aabb, graphics, settings, traits);
1266+
// TODO: This is ugly, it should probably be changed
1267+
if (drawable is DrawablesContainer)
1268+
(drawable as DrawablesContainer).Draw(aabb, graphics, settings, traits, colors);
1269+
else
1270+
drawable.Draw(aabb, graphics, settings, traits);
12581271
}
12591272
return true;
12601273
}

0 commit comments

Comments
 (0)