public void AddTools(Renderer renderer) { renderer.AddTool(rulerTool); renderer.AddTool(angleTool); renderer.AddTool(selectTool); renderer.AddTool(pathTool); //renderer.AddTool(pdfTool); renderer.AddTool(sketchTool); renderer.AddTool(contextMenuTool); renderer.AddTool(pointInspectTool); }
/// <summary> /// Constructor for the renderer /// </summary> /// <param name="control">Gives the reference to the SimpleOpenGLControl you've created on a form</param> /// <param name="fps">The frames per second (max) to render at. Set this to be about 30 for good performance.</param> public Renderer(SimpleOpenGlControl control, double fps) { this.control = control; this.fps = fps; #region UI Initialization camOrtho = new GLUtility.GLCameraOrtho(w); camFree = new GLUtility.GLCameraFree(w); camChase = new GLUtility.GLCameraChase(w); camPrev = camCurrent = camOrtho; #endregion //This is baaaaad. Fix it. instance = this; }
public void AddNewRobot(int robotID, Renderer r) { Color color; try { color = colors[robotID - 1]; } catch (IndexOutOfRangeException e) { Random rand = new Random(); color = Color.FromArgb((int)(rand.NextDouble() * 255), (int)(rand.NextDouble() * 255), (int)(rand.NextDouble() * 255)); } Color colorBloated; try { colorBloated = colorsBloated[robotID - 1]; } catch (IndexOutOfRangeException e) { Random rand = new Random(); colorBloated = Color.FromArgb((int)(rand.NextDouble() * 255), (int)(rand.NextDouble() * 255), (int)(rand.NextDouble() * 255)); } if (robotID != 5) { RobotRenderer rr = new RobotRenderer("Robot " + robotID, color); //robots[robotID] = new Robot(rr, color, robotID); robots[robotID] = new Robot(rr, color, colorBloated, robotID); r.AddRenderable(rr); r.AddRenderable(robots[robotID].PathRenderer); r.AddRenderable(robots[robotID].LidarRendererFront); r.AddRenderable(robots[robotID].LidarRendererRear); r.AddRenderable(robots[robotID].PolygonRenderer); r.AddRenderable(robots[robotID].BloatedPolygonRenderer); r.UpdateRobotPose(robotID, new Magic.Common.RobotPose()); } }
public void OnMouseMove(Renderer r, MouseEventArgs e) { if ((tempActive == true) && (!((myToolManager.PathTool.IsActive) && (myToolManager.PathTool.TempActive)))) { Vector2 worldMouseLoc = Vector2.FromPointF( r.ScreenToWorld(e.Location)); if (r.CurrentCamera == r.CamOrtho) { if ((e.Button == MouseButtons.Left)&&(!zoomPanOnly)) { Vector2 topLeftPoint; Vector2 worldDownPoint = Vector2.FromPointF( r.ScreenToWorld(downPoint)); double width = Math.Abs( worldDownPoint.X - worldMouseLoc.X); double height = Math.Abs( worldDownPoint.Y - worldMouseLoc.Y); topLeftPoint = TopLeftPoint(worldDownPoint, worldMouseLoc); selectionRectangle = new Rect(topLeftPoint.X, topLeftPoint.Y, width, height); foreach (ISelectable renderable in r.Selectables) { if (renderable == null) continue; if ((selectionRectangle.Overlaps(renderable.GetBoundingPolygon().CalculateBoundingRectangle()))&& (!renderable.IsSelected)) { renderable.OnSelect(); GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|box drag|select using box|" + renderable.GetName() + "|" + renderable.GetBoundingPolygon().Center.X.ToString() + "|" + renderable.GetBoundingPolygon().Center.Y.ToString() + "|(world)")); } else if ((!selectionRectangle.Overlaps(renderable.GetBoundingPolygon().CalculateBoundingRectangle())) && (renderable.IsSelected)) { renderable.OnDeselect(); GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|box drag|deselect using box|" + renderable.GetName() + "|" + renderable.GetBoundingPolygon().Center.X.ToString() + "|" + renderable.GetBoundingPolygon().Center.Y.ToString() + "|(world)")); } } } else if (e.Button == MouseButtons.Right) { int dx = (int)(e.X - downPoint.X); int dy = (int)(-e.Y + downPoint.Y); PointF newTranslation = new PointF( origTrans.X - dx / r.WorldTransform.Scale, origTrans.Y - dy / r.WorldTransform.Scale); r.Translation = newTranslation; } } else if (r.CurrentCamera == r.CamFree && e.Button == MouseButtons.Left) { r.CamFree.Yaw((e.X - currentPoint.X) / 3); r.CamFree.Pitch((e.Y - currentPoint.Y) / 2); } else if (r.CurrentCamera == r.CamChase) { r.CamChase.Pitch((e.Y - currentPoint.Y) / 2); } currentPoint = new PointF(e.X, e.Y); } }
public void OnMouseDown(Renderer r, MouseEventArgs e) { if (tempActive == true) { downPoint = new Point(e.X, e.Y); origTrans = r.Translation; currentCursor = Cursors.NoMove2D; } Vector2 worldMouseLoc = Vector2.FromPointF(r.ScreenToWorld(new PointF(e.X, e.Y))); if (e.Button == MouseButtons.Right) { //if (GestureExpData != null) // GestureExpData(this, new GestureExpSelectToolEventArgs("right down click, at " + e.X + ", " + e.Y + " (screen), " + worldMouseLoc.X + ", " + worldMouseLoc.Y + " (world)")); } else if (e.Button == MouseButtons.Left) { //if (GestureExpData != null) // GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|left click down|no change|" + e.X + "|" + e.Y + "|(screen)|" + worldMouseLoc.X + "|" + worldMouseLoc.Y + "|(world)")); } }
public void Draw(Renderer r) { if (isActive) { GLUtility.DrawRectangle(new GLPen(Color.Red, 1.0f), new RectangleF((float)selectionRectangle.x, (float)selectionRectangle.y, (float)selectionRectangle.width, (float)selectionRectangle.height)); } }
public void Draw(Renderer r) { if (wallPoints.Count > 0) { for (int i = 0; i < wallPoints.Count; i++) { List<PointF> wallSegment = wallPoints[i]; for (int j = 0; j < wallSegment.Count - 1; j++) { GLUtility.DrawLine(new GLPen(color, 5), wallSegment[j], wallSegment[j + 1]); } } } if (homeBase.Count > 0) { GLUtility.DrawLine(new GLPen(color, 1), homeBase[0], homeBase[1]); GLUtility.DrawLine(new GLPen(color, 1), homeBase[1], homeBase[2]); GLUtility.DrawLine(new GLPen(color, 1), homeBase[2], homeBase[3]); GLUtility.DrawString("HOME BASE", Color.DarkSlateGray, new PointF(7.6f, -2.4f)); GLUtility.DrawString("HOME BASE", Color.DarkSlateGray, new PointF(8.7f, -0.6f)); } }
public void OnMouseUp(Renderer r, System.Windows.Forms.MouseEventArgs e) { if (this.isActive) { Vector2 worldMouseLoc = Vector2.FromPointF(r.ScreenToWorld( new PointF(e.X, e.Y))); if (e.Button == MouseButtons.Right) { bool context = false; foreach (IRender renderable in r.Drawables) { IProvideContextMenu crend = renderable as IProvideContextMenu; if (crend == null) continue; if (crend.GetBoundingPolygon().IsInside(worldMouseLoc)) { context = true; if (showContextMenu != null) showContextMenu(this, new ContextMenuArgs(crend.GetMenuItems(), e.Location)); } } //if (!context) showContextMenu(this, new ContextMenuArgs(defaultMenu, e.Location)); } } }
public void OnMouseMove(Renderer r, System.Windows.Forms.MouseEventArgs e) { }
public void Draw(Renderer cam) { }
public void Draw(Renderer cam) { GLUtility.DrawEllipse(new GLPen(Color.Red, 1.0f), new RectangleF((float)(currentPoint.X - .1), (float)(currentPoint.Y - .1), .2f, .2f)); GLUtility.DrawString(currentPoint.X.ToString("F2") + "," + currentPoint.Y.ToString("F2"), Color.Black, currentPoint.ToPointF()); //if (poiList.Count > 0) //{ // foreach (NotepointRenderer np in poiList) // { // PointF newPoint = new PointF((float)np.X,(float)np.Y); // if ((shouldMove == true) && np.Equals(pointToMove)) // { // GLUtility.DrawCircle(new GLPen(Color.Red, 0.25f), newPoint, 0.25f); // } // else // { // GLUtility.DrawCircle(new GLPen(np.Color, 0.25f), newPoint, 0.25f); // } // } //} }
public void OnMouseUp(Renderer r, MouseEventArgs e) { if (tempActive == true) { currentCursor = Cursors.Default; Vector2 worldMouseLoc = Vector2.FromPointF(r.ScreenToWorld( new PointF(e.X, e.Y))); if (e.Button == MouseButtons.Right) { //if (GestureExpData != null) // GestureExpData(this, new GestureExpSelectToolEventArgs("right up click, at " + e.X + ", " + e.Y + " (screen), " + worldMouseLoc.X + ", " + worldMouseLoc.Y + " (world)")); } else if ((e.Button == MouseButtons.Left) && (!zoomPanOnly)) { if (selectionRectangle.Equals(new Rect())) { // Send mouseUp to every IMouseInteract that intersects the mouse click location foreach (ISelectable renderable in r.Selectables) { if (renderable == null) { continue; } else if (!myToolManager.PathTool.TempActive)//if (!((ToolManager.PathTool.IsActive) && (ToolManager.PathTool.TempActive))) { if (renderable.GetBoundingPolygon().IsInside(worldMouseLoc)) { if (renderable.IsSelected) { renderable.OnDeselect(); if (GestureExpData != null) GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|left click up|deselect using click|" + e.X + "|" + e.Y + "|(screen)|" + worldMouseLoc.X + "|" + worldMouseLoc.Y + "|(world)")); } else { renderable.OnSelect(); if (GestureExpData != null) GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|left click up|select using click|" + e.X + "|" + e.Y + "|(screen)|" + worldMouseLoc.X + "|" + worldMouseLoc.Y + "|(world)")); } if ((myToolManager.PathTool.IsActive) && (!myToolManager.PathTool.TempActive)) { myToolManager.PathTool.TempReactivate(); tempActive = false; } } } } //if (GestureExpData != null) // GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool left click up no change " + e.X + " " + e.Y + " (screen) " + worldMouseLoc.X + " " + worldMouseLoc.Y + " (world)")); } else { selectionRectangle = new Rect(); //if (GestureExpData != null) // GestureExpData(this, new GestureExpHRIEventArgs("Tool:SelectTool|left click up|draw box|" + e.X + "|" + e.Y + "|(screen)|" + worldMouseLoc.X + "|" + worldMouseLoc.Y + "|(world)")); if ((myToolManager.PathTool.IsActive) && (!myToolManager.PathTool.TempActive)) { myToolManager.PathTool.TempReactivate(); tempActive = false; } } } } }
public void RemoveTools(Renderer renderer, IRenderTool tool) { renderer.RemoveTool(tool); }
public void BuildAllConflicts(Renderer renderer) { foreach (IRenderTool tool in renderer.Tools) { tool.BuildConflicts(renderer.Tools); } }
/// <summary> /// Some of these parameters are off /// TODO: adjust them for MAGIC /// </summary> /// <param name="cam"></param> public void Draw(Renderer cam) { if (grid == null) return; Vector3 camLoc = cam.CamFree.Location; //Gl.glLineWidth(10f); //Gl.glBegin(Gl.GL_LINES); if (grid.NumCellX > 300) { int xstart, ystart, xend, yend, numrings = 4; grid.GetIndicies(camLoc.X, camLoc.Y, out xstart, out ystart); Point lastBL, lastTR, currBL = new Point(xstart, ystart), currTR = currBL; int incrAmt, range; for (int i = 1; i <= numrings; i++) { switch (i) { case 1: incrAmt = 1; range = 50; break; case 2: incrAmt = 4; range = 120; break; case 3: incrAmt = 7; range = 290; break; case 4: default: incrAmt = 14; range = 800; break; } if (range > grid.NumCellX) break; lastBL = currBL; lastTR = currTR; grid.GetIndicies(camLoc.X - range, camLoc.Y - range, out xstart, out ystart); grid.GetIndicies(camLoc.X + range, camLoc.Y + range, out xend, out yend); currBL = new Point(xstart, ystart); currTR = new Point(xend, yend); IterDonutRegion(currBL, lastBL, lastTR, currTR, incrAmt); } } else IterDonutRegion2(new Point(), new Point(grid.NumCellX / 2, grid.NumCellY / 2), new Point(grid.NumCellX / 2, grid.NumCellY / 2), new Point(grid.NumCellX, grid.NumCellY), 1); //Gl.glEnd(); }
public void OnMouseUp(Renderer r, MouseEventArgs e) { Vector2 worldMouseLoc = Vector2.FromPointF(r.ScreenToWorld(new PointF(e.X, e.Y))); if (e.Button == MouseButtons.Right) { //if (GestureExpData != null) // GestureExpData(this, new GestureExpPointToolEventArgs("Tool:PointTool right click up " + e.X + ", " + e.Y + " (screen), " + worldMouseLoc.X + ", " + worldMouseLoc.Y + " (world)")); } else if(e.Button.Equals(MouseButtons.Left)) { if ((modeMovePOI == true) && (shouldMove == true)) { shouldMove = false; myToolManager.SelectTool.TempReactivate(); myToolManager.PathTool.TempReactivate(); modeMovePOI = false; if (GestureExpData != null) GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click up|drop point|" + e.X + "|" + e.Y + "|(screen)|" + worldMouseLoc.X + "|" + worldMouseLoc.Y + "|(world)")); } else if (modeNewPOI == true) { modeNewPOI = false; myToolManager.SelectTool.TempReactivate(); myToolManager.PathTool.TempReactivate(); //if (GestureExpData != null) // GestureExpData(this, new GestureExpPointToolEventArgs("Tool:PointTool left click up create point at " + e.X + ", " + e.Y + " (screen), " + worldMouseLoc.X + ", " + worldMouseLoc.Y + " (world)")); } } }
public void OnMouseMove(Renderer r, MouseEventArgs e) { currentPoint = Vector2.FromPointF(r.ScreenToWorld(e.Location)); if ((modeMovePOI == true) && (shouldMove == true)) { PointF p = r.ScreenToWorld(new PointF(e.X, e.Y)); foreach (NotepointRenderer np in poiList) { if (np.Equals(pointToMove)) { NotepointRenderer mousePoint = np; mousePoint.X = p.X; mousePoint.Y = p.Y; poiList.Remove(np); poiList.Add(mousePoint); pointToMove = mousePoint; break; } } } }
public void OnMouseDown(Renderer r, MouseEventArgs e) { PointF worldPoint = r.ScreenToWorld(e.Location); if (e.Button == MouseButtons.Right) { //if (GestureExpData != null) // GestureExpData(this, new GestureExpPointToolEventArgs("right down click, at " + e.X + ", " + e.Y + " (screen), " + worldPoint.X + ", " + worldPoint.Y + " (world)")); } else if(e.Button.Equals(MouseButtons.Left)) { //PointF worldPoint = r.ScreenToWorld(e.Location); if (modeNewPOI == true) { if (POItype == "PICTURE") { if (r.Selectables.Count() > 0) { foreach (ISelectable sel in r.Selectables) { RobotRenderer rr = sel as RobotRenderer; if (rr != null && rr.IsSelected) { r.AddRenderable(new FakeObjectRenderer("important", rr.GetBoundingPolygon().Center.ToPointF(), "picture")); if (GestureExpData != null) { GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|take picture|Robot " + rr.GetName().Substring(rr.GetName().Length-1) + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)")); } } } } } else { NotepointRenderer newPoint = new NotepointRenderer(); newPoint.Name = POItype; if (POItype == "SQUARE") { newPoint.Color = Color.DarkMagenta; } else if (POItype == "TRIANGLE") { newPoint.Color = Color.DarkGreen; } else if (POItype == "SPIRAL") { newPoint.Color = Color.DarkRed; } newPoint.X = worldPoint.X; newPoint.Y = worldPoint.Y; newPoint.Z = 0; poiList.Add(newPoint); r.AddRenderable(newPoint); if (GestureExpData != null) { GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|create|" + newPoint.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)")); } } } else if (modeDeletePOI == true) { if (poiList.Count > 0) { List<NotepointRenderer> pointsToRemove= new List<NotepointRenderer>(); foreach (NotepointRenderer np in poiList) { if ((worldPoint.X - np.X > -.25) && (worldPoint.Y - np.Y > -.25) && (worldPoint.X - np.X < .25) && (worldPoint.Y - np.Y < .25)) { pointsToRemove.Add(np); r.RemoveRenderable(np); if (GestureExpData != null) GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|remove|" + np.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)")); } } if (pointsToRemove.Count>0) { foreach (NotepointRenderer n in pointsToRemove) { poiList.Remove(n); } myToolManager.SelectTool.TempReactivate(); myToolManager.PathTool.TempReactivate(); modeDeletePOI = false; } } } else if (modeMovePOI == true) { if (poiList.Count > 0) { foreach (NotepointRenderer np in poiList) { if ((worldPoint.X - np.X > -.25) && (worldPoint.Y - np.Y > -.25) && (worldPoint.X - np.X < .25) && (worldPoint.Y - np.Y < .25)) { shouldMove = true; pointToMove = np; if (GestureExpData != null) GestureExpData(this, new GestureExpHRIEventArgs("Tool:PointTool|left click down|move|" + np.Name + "|" + e.X + "|" + e.Y + "|(screen)|" + worldPoint.X + "|" + worldPoint.Y + "|(world)")); break; } } } } } }
public void AddTools(Renderer renderer,IRenderTool tool) { renderer.AddTool(tool); }
public void Draw(Renderer r) { float lineWidth = selected ? 2.0f : 1.0f; PointF bodyPnt = new PointF(x, y); PointF bodyHeading = new PointF(bodyPnt.X + (float)Math.Cos(heading), bodyPnt.Y + (float)Math.Sin(heading)); GLUtility.DrawLineLoop(new GLPen(color, lineWidth), bodyPlygn.ToArray()); GLUtility.FillTriangle(color, 0.6f, bodyPlygn[0].ToPointF(), bodyPlygn[1].ToPointF(), bodyPlygn[2].ToPointF()); GLUtility.FillTriangle(color, 0.6f, bodyPlygn[2].ToPointF(), bodyPlygn[3].ToPointF(), bodyPlygn[0].ToPointF()); // Draw heading //GLUtility.DrawLine(new GLPen(Color.Red, lineWidth), Vector2.FromPointF(bodyPnt), Vector2.FromPointF(bodyHeading)); GLUtility.DrawLine(new GLPen(Color.Red, lineWidth), bodyPnt, bodyHeading); //// Draw the name //if (modeString.Equals("")) // GLUtility.DrawString(MythName + ": " + name, Color.Black, bodyPnt); //else if (modeQualifier.Equals("")) // GLUtility.DrawString(name + ": " + modeString, Color.Black, bodyPnt); //else// if (defaultRenderer != null) //{ // try // { // GLUtility.DrawStringMultiLine(name + ": " + modeString + '\n' + "NOTE: " + modeQualifier, Color.Black, bodyPnt, r.CurrentCamera); // } // catch { GLUtility.DrawString(name + ": " + modeString, Color.Black, bodyPnt); } //}//else //// GLUtility.DrawString(name + ": " + modeString + "(NOTE: " + modeQualifier + ")", Color.Black, bodyPnt); GLUtility.DrawString(name, Color.Black, bodyPnt); DrawFlagLine(x, y, color); if (drawCameraView && IsSelected) { PointF p1 = bodyPnt; PointF p2 = new PointF(bodyPnt.X + 5 * (float)Math.Cos(heading - 0.5 * (cameraFOVangle * Math.PI / 180)), bodyPnt.Y + 5 * (float)Math.Sin(heading - 0.5 * (cameraFOVangle * Math.PI / 180))); PointF p3 = new PointF(bodyPnt.X + 5 * (float)Math.Cos(heading - 0.167 * (cameraFOVangle * Math.PI / 180)), bodyPnt.Y + 5 * (float)Math.Sin(heading - 0.167 * (cameraFOVangle * Math.PI / 180))); PointF p4 = new PointF(bodyPnt.X + 5 * (float)Math.Cos(heading + 0.167 * (cameraFOVangle * Math.PI / 180)), bodyPnt.Y + 5 * (float)Math.Sin(heading + 0.167 * (cameraFOVangle * Math.PI / 180))); PointF p5 = new PointF(bodyPnt.X + 5 * (float)Math.Cos(heading + 0.5 * (cameraFOVangle * Math.PI / 180)), bodyPnt.Y + 5 * (float)Math.Sin(heading + 0.5 * (cameraFOVangle * Math.PI / 180))); GLUtility.FillTriangle(color, 0.1f, p1, p2, p3); GLUtility.FillTriangle(color, 0.1f, p1, p3, p4); GLUtility.FillTriangle(color, 0.1f, p1, p4, p5); //GLUtility.FillTriangle(Color.BlueViolet, 0.3f, p1, p2, p3); //GLUtility.FillTriangle(Color.Blue, 0.3f, p1, p3, p4); //GLUtility.FillTriangle(Color.Turquoise, 0.3f, p1, p4, p5); } }