3using System.Collections.Generic;
7using System.Threading.Tasks;
41 System.Drawing.Drawing2D.GraphicsState m_gstate =
null;
52 public GeomObj(
float fL,
float fR,
float fT,
float fB, Color clrFill, Color clrBorder)
92 public void SetColors(Color clrFill, Color clrBorder)
109 return rg[2].X - rg[0].X;
122 return rg[0].Y - rg[1].Y;
257 public GeomLine(
float fL,
float fR,
float fT,
float fB, Color clrFill, Color clrBorder)
258 : base(fL, fR, fT, fB, clrFill, clrBorder)
291 public GeomEllipse(
float fL,
float fR,
float fT,
float fB, Color clrFill, Color clrBorder)
292 : base(fL, fR, fT, fB, clrFill, clrBorder)
307 g.FillEllipse(br, rc);
308 g.DrawEllipse(p, rc);
333 : base(fL, fR, fT, fB, clrFill, clrBorder)
349 g.FillRectangle(br, rc);
351 if (m_clrMap !=
null)
354 float fWid = rc.Width / 20;
356 for (
int i = 0; i < 20; i++)
358 RectangleF rc2 =
new RectangleF(fX, rc.Y, fWid, rc.Height);
360 Brush br1 =
new SolidBrush(clr);
361 g.FillRectangle(br1, rc2);
367 g.DrawRectangle(p, rc.X, rc.Y, rc.Width, rc.Height);
388 public GeomPolygon(
float fL,
float fR,
float fT,
float fB, Color clrFill, Color clrBorder)
389 : base(fL, fR, fT, fB, clrFill, clrBorder)
406 g.FillPolygon(br, rg);
407 g.DrawPolygon(p, rg);
421 int m_nMaxPlots =
int.MaxValue;
433 public GeomPolyLine(
float fL,
float fR,
float fT,
float fB, Color clrFill, Color clrBorder,
int nMaxPlots =
int.MaxValue)
434 : base(fL, fR, fT, fB, clrFill, clrBorder)
436 m_nMaxPlots = nMaxPlots;
439 private void clipAndShift()
477 List<GeomObj> m_rgObj =
new List<GeomObj>();
503 public void RenderText(Graphics g,
string str,
float fX,
float fY, Brush br =
null)
508 Font font =
new Font(
"Century Gothic", 9.0f);
509 g.DrawString(str, font, br,
new PointF(fX, fY));
521 RectangleF rc = g.VisibleClipBounds;
522 Font fontStep =
new Font(
"Century Gothic", 7.0f);
523 string strStep = nSteps.ToString();
524 string strMax = nMax.ToString();
525 string strSteps =
"Steps";
526 SizeF szStep = g.MeasureString(strStep, fontStep);
527 SizeF szSteps = g.MeasureString(strSteps, fontStep);
528 SizeF szMax = g.MeasureString(strMax, fontStep);
531 float fY = rc.Bottom - (szSteps.Height * 2);
533 g.DrawString(strSteps, fontStep, Brushes.Black,
new PointF(fX, fY));
536 float fMaxWid = Math.Max(nMax, nSteps);
537 float fStepWid = nSteps;
539 if (fMaxWid + fX + 20 > rc.Width)
541 fMaxWid = rc.Width - (fX + 20);
542 fStepWid = ((float)nSteps / (
float)Math.Max(nMax, nSteps)) * fMaxWid;
545 Rectangle rcMax =
new Rectangle((
int)fX, (
int)fY, (
int)fMaxWid, (
int)(szStep.Height));
546 Rectangle rcStep =
new Rectangle((
int)fX, (
int)fY, (
int)fStepWid, (
int)(szStep.Height));
547 Brush br = (nSteps < nMax) ? Brushes.Orange : Brushes.Lime;
548 Pen pen = (nSteps < nMax) ? Pens.Brown : Pens.DarkGreen;
550 g.FillRectangle(br, rcStep);
551 g.DrawRectangle(pen, rcMax);
553 fX = rcStep.Right - szStep.Width / 2;
556 g.DrawString(strStep, fontStep, Brushes.Brown,
new PointF(fX, fY));
558 fX = rcMax.Right - szMax.Width / 2;
561 g.DrawString(strMax, fontStep, Brushes.DarkGreen,
new PointF(fX, fY));
572 System.Drawing.Drawing2D.GraphicsState gstate = g.Save();
574 g.TranslateTransform(0, -g.VisibleClipBounds.Height);
575 g.ScaleTransform(1, -1,
System.Drawing.Drawing2D.MatrixOrder.Append);
577 g.DrawRectangle(Pens.SteelBlue, 1, 1, 2, 2);
578 g.DrawLine(Pens.SteelBlue, 1, 3, 1, 4);
579 g.DrawLine(Pens.SteelBlue, 3, 3, 4, 4);
580 g.DrawLine(Pens.SteelBlue, 3, 1, 4, 1);
582 foreach (
GeomObj obj
in m_rgObj)
The ColorMapper maps a value within a number range, to a Color within a color scheme.
Color GetColor(double dfVal)
Find the color using a binary search algorithm.
The GeomEllipse object is used to render an ellipse.
override void Render(Graphics g)
Renders the ellipse on the Graphics specified.
GeomEllipse(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder)
The constructor.
The GeomLine object is used to render a line.
override void Render(Graphics g)
Renders the line on the Graphics specified.
GeomLine(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder)
The constructor.
The GoomObj is the base class for all other gometric objects used to draw Gym objects.
virtual void SetLocation(float fX, float fY)
Sets the object location.
virtual void SetRotation(float fR)
Sets the rotation of the object.
Color m_clrBorder
Specifies the border color of the object.
float Height(PointF[] rg)
Returns the height of the points.
GeomObj(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder)
The constructor.
PointF LeftTop(PointF[] rg=null)
Returns the left top.
float m_fRotation
Specifies the rotation of the object.
PointF RightBottom(PointF[] rg=null)
Returns the right bottom.
PointF m_location
Specifies the location of the object.
PointF RightTop(PointF[] rg=null)
Returns the right top.
List< PointF > Polygon
Returns the bounds as a Polygon.
float Width(PointF[] rg)
Returns the width of the points.
Color BorderColor
Returns the border color.
List< PointF > m_rgPoints
Specifies the points of the object.
float Rotation
Returns the rotation of the object.
void prerender(Graphics g)
Called just before rendering the object.
PointF Location
Returns the location of the object.
abstract void Render(Graphics g)
Override used to render the object.
Color m_clrFill
Specifies the fill color of the object.
PointF LeftBottom(PointF[] rg=null)
Returns the left bottom.
bool m_bClrDirty
Specifies that the colors have changed.
void SetColors(Color clrFill, Color clrBorder)
Set the colors of the object.
void postrender(Graphics g)
Called just after rendering the object.
Color FillColor
Returns the fill color.
The GeomPolyLine object is used to render an spline.
GeomPolyLine(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder, int nMaxPlots=int.MaxValue)
The constructor.
override void Render(Graphics g)
Renders the rectangle on the Graphics specified.
The GeomPolygon object is used to render an polygon.
override void Render(Graphics g)
Renders the rectangle on the Graphics specified.
GeomPolygon(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder)
The constructor.
The GeomEllipse object is used to render an rectangle.
override void Render(Graphics g)
Renders the rectangle on the Graphics specified.
GeomRectangle(float fL, float fR, float fT, float fB, Color clrFill, Color clrBorder, ColorMapper clrMap=null)
The constructor.
The GeomView manages and renders a collection of Geometric objects.
void Render(Graphics g)
Renders the view.
void AddObject(GeomObj obj)
Add a new geometric object to the view.
void RenderText(Graphics g, string str, float fX, float fY, Brush br=null)
Render text at a location.
void RenderSteps(Graphics g, int nSteps, int nMax)
Renders the Gym step information.
GeomView()
The constructor.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...