Example #1
0
        /// <summary>
        /// Operations to perform on MouseMove:
        ///     If we're moving a waypoint, update the waypoint location (for rendering) to the mouse location
        ///     Otherwise, don't do anything
        /// </summary>
        /// <param name="r"></param>
        /// <param name="e"></param>
        #region Operations to perform on MouseMove
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            mousePoint = new PointF(e.X, e.Y);
            PointF p = r.ScreenToWorld(e.Location);

            if (shouldMove == true)
            {
                foreach (WaypointRenderer wp in newPath.WaypointList)
                {
                    if (movePointWP.Equals(wp))
                    {
                        WaypointRenderer mouseWP = wp;
                        mouseWP.X = p.X;
                        mouseWP.Y = p.Y;
                        clonePathWP.AddWaypoint(mouseWP);
                        movePointWP = mouseWP;
                    }
                    else
                    {
                        clonePathWP.AddWaypoint(wp);
                    }
                }
                newPath     = clonePathWP;
                clonePathWP = new PathToRobotRenderer();
            }
        }
Example #2
0
        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)"));
                }
            }
        }
Example #3
0
 /// <summary>
 /// Operations to perform on MouseUp:
 ///     If we just finished moving a waypoint, execute pathPointMoved event
 /// </summary>
 /// <param name="r"></param>
 /// <param name="e"></param>
 #region Operations to perform on MouseUp
 public void OnMouseUp(Renderer r, MouseEventArgs e)
 {
     //throw new NotImplementedException();
     if (shouldMove)
     {
         PointF p = r.ScreenToWorld(e.Location);
         foreach (WaypointRenderer wp in newPath.WaypointList)
         {
             if (wp.Equals(movePointWP))
             {
                 myToolManager.SelectTool.TempReactivate();
                 break;
             }
         }
         if (e.Button == MouseButtons.Right)
         {
             //if (GestureExpData != null)
             //    GestureExpData(this, new GestureExpPathToolEventArgs("Tool:PathTool right click up      " + e.X + ", " + e.Y + " (screen), " + p.X + ", " + p.Y + " (world)"));
         }
         else if (e.Button == MouseButtons.Left)
         {
             if (GestureExpData != null)
             {
                 GestureExpData(this, new GestureExpHRIEventArgs("Tool:PathTool|left click up|move waypoint to|" + e.X + "|" + e.Y + "|(screen)|" + p.X + "|" + p.Y + "|(world)"));
             }
         }
     }
     shouldMove = false;
 }
Example #4
0
 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));
         }
     }
 }
Example #5
0
        /// <summary>
        /// Operations to perform on MouseDown (takes: Renderer r, MouseEventArgs e)
        /// </summary>
        /// <param name="r"></param>
        /// <param name="e"></param>
        #region Operations to perform on MouseDown
        public void OnMouseDown(Renderer r, MouseEventArgs e)
        {
            #region Left Click
            //check that button was a left click
            if (e.Button == MouseButtons.Left)
            {
                PointF p = r.ScreenToWorld(e.Location);

                if (GestureExpData != null)
                {
                    GestureExpData(this, new GestureExpHRIEventArgs("Tool:SketchTool|new stroke"));
                }

                if (pixelListWorld.Count == 0)
                {
                    shouldDraw = true;
                    startTime  = DateTime.Now.DayOfYear * 1000 * 60 * 24 * 365 + DateTime.Now.Hour * 60000 * 24 + DateTime.Now.Minute * 60000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                    pixelListWorld.Add(new Vector4(p.X, p.Y, 0, 1));
                    pixelListScreen.Add(new Vector4(e.X, e.Y, 0, 1));
                    strokeCount = 1;
                }
                else
                {
                    shouldDraw = true;
                    nowTime    = DateTime.Now.DayOfYear * 1000 * 60 * 24 * 365 + DateTime.Now.Hour * 60000 * 24 + DateTime.Now.Minute * 60000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                    strokeCount++;                    // strokeCount = pixelListScreen.Last().W + 1;
                    pixelListWorld.Add(new Vector4(p.X, p.Y, nowTime - startTime, strokeCount));
                    pixelListScreen.Add(new Vector4(e.X, e.Y, nowTime - startTime, strokeCount));
                }
            }
            #endregion
        }
Example #6
0
        /// <summary>
        /// OnMouseMove : log & draw pixel data if a gesture is being drawn
        /// </summary>
        /// <param name="r"></param>
        /// <param name="e"></param>
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            if (isDrawing)
            {
                mousePixel.X = e.X / pixelWidth;
                mousePixel.Y = e.Y / pixelHeight;
                if (mousePixel.X <= 100 + pixelWidth / 2 &&
                    mousePixel.Y <= 100 + pixelHeight / 2 &&
                    mousePixel.X >= 0 &&
                    mousePixel.Y >= 0)
                {
                    if (!lastPixel.Equals(mousePixel))
                    {
                        int currentTime = DateTime.Now.DayOfYear * 1000 * 60 * 24 * 365 + DateTime.Now.Hour * 60000 * 24 + DateTime.Now.Minute * 60000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                        int deltaTime   = (currentTime - startTime);
                        lastPixel      = mousePixel;
                        logPixelData.X = mousePixel.X;
                        logPixelData.Y = mousePixel.Y;
                        logPixelData.Z = deltaTime;                             // time
                        logPixelData.W = countStrokes;                          // stroke #

                        pixelList.Add(logPixelData);
                        worldPixel.X = mousePixel.X * pixelWidth + pixelWidth / 2;
                        worldPixel.Y = mousePixel.Y * pixelWidth + pixelHeight / 2;
                        PointF p = r.ScreenToWorld(worldPixel);
                        drawPixelList.Add(p);
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// This is called whenever the renderer is going to draw stuff. Essentially this is where you put your
 /// tool drawing code.
 /// </summary>
 /// <param name="r"></param>
 public void Draw(Renderer r)
 {
     #region ruler drawing code
     if (shouldDraw && isActive)
     {
         PointF p1  = r.ScreenToWorld(downPoint);
         PointF p2  = r.ScreenToWorld(movePoint);
         GLPen  pen = new GLPen(Color.Purple, 1.0f);
         GLUtility.DrawLine(pen, p1, p2);
         GLUtility.DrawEllipse(pen, new RectangleF(p1.X - .1f, p1.Y - .1f, .2f, .2f));
         GLUtility.DrawEllipse(pen, new RectangleF(p2.X - .1f, p2.Y - .1f, .2f, .2f));
         distance = Math.Sqrt(((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)));
         PointF m = new PointF((p1.X + p2.X) / 2.0f + .3f, (p1.Y + p2.Y) / 2.0f + .3f);
         GLUtility.DrawString(distance.ToString("F2") + "m", Color.Black, m);
     }
     #endregion
 }
Example #8
0
        public void Draw(Renderer r)
        {
            #region angle drawing code
            if (IsActive)
            {
                if (angleState == 1)
                {
                    PointF p1  = r.ScreenToWorld(clickPoint);
                    PointF p2  = r.ScreenToWorld(movePoint);
                    GLPen  pen = new GLPen(Color.Purple, 1.0f);
                    GLUtility.DrawLine(pen, Vector2.FromPointF(p1), Vector2.FromPointF(p2));
                    GLUtility.DrawEllipse(pen, new RectangleF(p1.X - .1f, p1.Y - .1f, .2f, .2f));
                    GLUtility.DrawEllipse(pen, new RectangleF(p2.X - .1f, p2.Y - .1f, .2f, .2f));
                    dist12 = Math.Sqrt(((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)));
                    PointF m12 = new PointF((p1.X + p2.X) / 2.0f, (p1.Y + p2.Y) / 2.0f);
                    GLUtility.DrawString(dist12.ToString("F2") + "m", Color.Black, m12);
                }
                if (angleState == 2)
                {
                    PointF p1  = r.ScreenToWorld(clickPoint);
                    PointF p2  = r.ScreenToWorld(clickPoint2);
                    PointF p3  = r.ScreenToWorld(movePoint);
                    GLPen  pen = new GLPen(Color.Purple, 1.0f);
                    GLUtility.DrawLine(pen, p1, p2);
                    GLUtility.DrawLine(pen, p2, p3);
                    GLUtility.DrawEllipse(pen, new RectangleF(p1.X - .1f, p1.Y - .1f, .2f, .2f));
                    GLUtility.DrawEllipse(pen, new RectangleF(p2.X - .1f, p2.Y - .1f, .2f, .2f));
                    GLUtility.DrawEllipse(pen, new RectangleF(p3.X - .1f, p3.Y - .1f, .2f, .2f));
                    dist12 = Math.Sqrt(((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)));
                    PointF m12 = new PointF((p1.X + p2.X) / 2.0f, (p1.Y + p2.Y) / 2.0f);
                    GLUtility.DrawString(dist12.ToString("F2") + "m", Color.Black, m12);
                    dist23 = Math.Sqrt(((p2.X - p3.X) * (p2.X - p3.X)) + ((p2.Y - p3.Y) * (p2.Y - p3.Y)));
                    PointF m23 = new PointF((p2.X + p3.X) / 2.0f, (p2.Y + p3.Y) / 2.0f);
                    GLUtility.DrawString(dist23.ToString("F2") + "m", Color.Black, m23);
                    dist13 = Math.Sqrt(((p1.X - p3.X) * (p1.X - p3.X)) + ((p1.Y - p3.Y) * (p1.Y - p3.Y)));

                    cosangle = (dist12 * dist12 + dist23 * dist23 - dist13 * dist13) / (2 * dist12 * dist23);
                    angleDEG = Math.Acos(cosangle) * (180.0 / Math.PI);
                    p2.X    += .5f; p2.Y += .5f;
                    GLUtility.DrawString(angleDEG.ToString("F2") + " deg", Color.Black, p2);
                }
            }
            #endregion
        }
Example #9
0
        /// <summary>
        /// Operations to perform on MouseMove:
        /// </summary>
        /// <param name="r"></param>
        /// <param name="e"></param>
        #region Operations to perform on MouseMove
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            if (shouldDraw)
            {
                PointF p = r.ScreenToWorld(e.Location);

                nowTime = DateTime.Now.DayOfYear * 1000 * 60 * 24 * 365 + DateTime.Now.Hour * 60000 * 24 + DateTime.Now.Minute * 60000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
                pixelListWorld.Add(new Vector4(p.X, p.Y, nowTime - startTime, strokeCount));
                pixelListScreen.Add(new Vector4(e.X, e.Y, nowTime - startTime, strokeCount));
            }
        }
Example #10
0
 public void OnMouseDown(Renderer r, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         currentPoints.Add(Vector2.FromPointF(r.ScreenToWorld(e.Location)));
     }
     else if (e.Button == MouseButtons.Right)
     {
         ToolCompleted(this, new PolygonToolCompletedEventArgs(currentPoints));
         currentPoints.Clear();
     }
 }
Example #11
0
        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;
                    }
                }
            }
        }
Example #12
0
        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)"));
            }
        }
Example #13
0
 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;
                 }
             }
         }
     }
 }
Example #14
0
        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);
            }
        }
Example #15
0
 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 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)"));
         }
     }
 }
Example #17
0
 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));
         }
     }
 }
Example #18
0
        /// <summary>
        /// Draw the waypoints & path (circles & lines)
        /// </summary>
        /// <param name="r"></param>
        #region path drawing code

        public void Draw(Renderer r)
        {
            //if only one waypoint, draw the waypoint
            if (newPath.WaypointList.Count == 1 && shouldDraw)
            {
                WaypointRenderer wpFirst   = newPath.WaypointList[0];
                PointF           drawPoint = new PointF((float)wpFirst.X, (float)wpFirst.Y);
                GLUtility.DrawCircle(new GLPen(wpFirst.Color, 1.0f), drawPoint, 0.2f);
                if (!shouldMove && tempActive)
                {
                    GLUtility.DrawLine(new GLPen(Color.LawnGreen, 1.0f), drawPoint, r.ScreenToWorld(mousePoint));
                }
            }

            // if more than one waypoint, draw waypoints and connect subsequent waypoints with a line
            else if (newPath.WaypointList.Count > 1 && shouldDraw)
            {
                WaypointRenderer wpLast = newPath.WaypointList.First();

                foreach (WaypointRenderer wp in newPath.WaypointList)
                {
                    PointF pathPoint = new PointF((float)wp.X, (float)wp.Y);

                    if (shouldMove && wp.Equals(movePointWP))
                    {
                        GLUtility.DrawCircle(new GLPen(Color.Red, 1.0f), pathPoint, 0.2f);
                    }
                    else
                    {
                        GLUtility.DrawCircle(new GLPen(wp.Color, 1.0f), pathPoint, 0.2f);
                    }
                    if (!wp.Equals(newPath.WaypointList.First()))
                    {
                        PointF dummyLast = new PointF((float)wpLast.X, (float)wpLast.Y);
                        GLUtility.DrawLine(new GLPen(newPath.Color, 1.0f), dummyLast, pathPoint);
                    }
                    wpLast = wp;
                }
                // if we are not moving a waypoint, draw a light green line between last waypoint and current mouse location
                if (!shouldMove && tempActive)
                {
                    PointF dummyLast = new PointF((float)wpLast.X, (float)wpLast.Y);
                    GLUtility.DrawLine(new GLPen(Color.LawnGreen, 1.0f), dummyLast, r.ScreenToWorld(mousePoint));
                }
            }

            if (newPath.WaypointList.Count > 0)
            {
                foreach (ISelectable selectable in r.Selectables)
                {
                    PointF        dummyFirst = new PointF();
                    RobotRenderer robot      = selectable as RobotRenderer;
                    if (robot == null)
                    {
                        continue;
                    }
                    else if (robot.IsSelected)
                    {
                        Polygon p = robot.GetBoundingPolygon();
                        if (p.points.Count > 0)
                        {
                            dummyFirst = new PointF((float)newPath.WaypointList[0].X, (float)newPath.WaypointList[0].Y);
                            GLUtility.DrawLine(new GLPen(Color.Green, 1.0f), p.Center.ToPointF(), dummyFirst);
                        }
                    }
                }
            }
        }
Example #19
0
        public void OnMouseDown(Renderer r, MouseEventArgs e)
        {
            bool deletedPDF = false;

            if (modeDeletePDF)
            {
                int             enumer           = 0;
                int             pointtype        = 0;
                PDFFormRenderer clonePDFRenderer = new PDFFormRenderer();
                foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                {
                    if ((movePoint.X - pdfRP.X < 0.25) && (movePoint.Y - pdfRP.Y < 0.25) &&
                        (movePoint.X - pdfRP.X > -0.25) && (movePoint.Y - pdfRP.Y > -0.25))
                    {
                        deletedPDF = true;
                        pointtype  = enumer % 3;
                        int enumer2 = 0;
                        foreach (PDFReferencePointRenderer pdfRP2 in PDFrenderer.PDFReferencePointList)
                        {
                            if (enumer2 < enumer - pointtype || enumer2 > enumer - pointtype + 2)
                            {
                                clonePDFRenderer.PDFReferencePointList.Add(pdfRP2);
                            }
                            enumer2++;
                        }
                        myToolManager.SelectTool.TempDeactivate();
                        break;
                    }
                    enumer++;
                }
                if (deletedPDF)
                {
                    PDFrenderer = clonePDFRenderer;

                    if (PDFrenderer.PDFReferencePointList.Count > 0)
                    {
                        defaultMode     = "Send PDF peak";
                        modeNewPDF      = true;
                        firstpointmode  = true;
                        secondpointmode = false;
                        thirdpointmode  = false;
                        UpdateDefault(this, new EventArgs());
                    }
                    else
                    {
                        modeList.Remove("Remove PDF peak");
                        modeList.Remove("Edit PDF points");
                        modeList.Remove("Send PDF peak");
                        modeList.Remove("Move PDF peak");

                        defaultMode     = "Add new PDF peak";
                        modeNewPDF      = true;
                        firstpointmode  = true;
                        secondpointmode = false;
                        thirdpointmode  = false;
                        UpdateDefault(this, new EventArgs());

                        isDrawing = false;
                    }
                }
            }
            else if (modeEditPDF)
            {
                foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                {
                    if ((movePoint.X - pdfRP.X < 0.25) && (movePoint.Y - pdfRP.Y < 0.25) &&
                        (movePoint.X - pdfRP.X > -0.25) && (movePoint.Y - pdfRP.Y > -0.25))
                    {
                        shouldEdit    = true;
                        movePDFPoint  = pdfRP;
                        ghostPoint    = pdfRP;
                        currentCursor = Cursors.Hand;
                        myToolManager.SelectTool.TempDeactivate();
                        break;
                    }
                }
            }
            else if (modeMovePDF)
            {
                /*
                 * foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                 * {
                 *      if ((movePoint.X - pdfRP.X < 0.25) && (movePoint.Y - pdfRP.Y < 0.25) &&
                 *              (movePoint.X - pdfRP.X > -0.25) && (movePoint.Y - pdfRP.Y > -0.25))
                 *      {
                 *              shouldEdit = true;
                 *              movePDFPoint = pdfRP;
                 *              ghostPoint = pdfRP;
                 *              currentCursor = Cursors.Hand;
                 *              ToolManager.SelectTool.TempDeactivate();
                 *              break;
                 *      }
                 * }*/
                int enumer    = 0;
                int pointtype = 0;
                //PDFFormRenderer clonePDFRenderer = new PDFFormRenderer();
                foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                {
                    if ((movePoint.X - pdfRP.X < 0.25) && (movePoint.Y - pdfRP.Y < 0.25) &&
                        (movePoint.X - pdfRP.X > -0.25) && (movePoint.Y - pdfRP.Y > -0.25))
                    {
                        shouldMove = true;
                        //deletedPDF = true;
                        pointtype = enumer % 3;
                        int enumer2 = 0;
                        MoveReferencePoint = pdfRP;
                        foreach (PDFReferencePointRenderer pdfRP2 in PDFrenderer.PDFReferencePointList)
                        {
                            if (enumer2 == enumer - pointtype)
                            {
                                GhostMovePoint1            = pdfRP2;
                                MoveDeltaReferencePoint1.X = GhostMovePoint1.X - MoveReferencePoint.X;
                                MoveDeltaReferencePoint1.Y = GhostMovePoint1.Y - MoveReferencePoint.Y;
                            }
                            else if (enumer2 == enumer - pointtype + 1)
                            {
                                GhostMovePoint2            = pdfRP2;
                                MoveDeltaReferencePoint2.X = GhostMovePoint2.X - MoveReferencePoint.X;
                                MoveDeltaReferencePoint2.Y = GhostMovePoint2.Y - MoveReferencePoint.Y;
                            }
                            else if (enumer2 == enumer - pointtype + 2)
                            {
                                GhostMovePoint3            = pdfRP2;
                                MoveDeltaReferencePoint3.X = GhostMovePoint3.X - MoveReferencePoint.X;
                                MoveDeltaReferencePoint3.Y = GhostMovePoint3.Y - MoveReferencePoint.Y;
                            }
                            enumer2++;
                        }
                        myToolManager.SelectTool.TempDeactivate();
                        break;
                    }
                    enumer++;
                }
            }
            else if (e.Button == MouseButtons.Left && quickPointMode && modeNewPDF)
            {
                if (isGenerating == false && isEditing == false && modeNewPDF)
                {
                    isDrawing = true;
                    //isGenerating = true;
                }
                double radius = 0.5;
                centerPoint = r.ScreenToWorld(e.Location);
                PDFReferencePointRenderer quickpoint1 = new PDFReferencePointRenderer();
                quickpoint1.X = centerPoint.X - radius;
                quickpoint1.Y = centerPoint.Y;
                PDFrenderer.AddReferencePoint(quickpoint1);
                PDFReferencePointRenderer quickpoint2 = new PDFReferencePointRenderer();
                quickpoint2.X = centerPoint.X + radius;
                quickpoint2.Y = centerPoint.Y;
                PDFrenderer.AddReferencePoint(quickpoint2);
                PDFReferencePointRenderer quickpoint3 = new PDFReferencePointRenderer();
                quickpoint3.X = centerPoint.X;
                quickpoint3.Y = centerPoint.Y + radius;
                PDFrenderer.AddReferencePoint(quickpoint3);
                Console.WriteLine("added quickpoint");

                if (!(modeList.Contains("Remove PDF peak")))
                {
                    modeList.Add("Remove PDF peak");
                    modeList.Add("Edit PDF points");
                    modeList.Add("Send PDF peak");
                    modeList.Add("Move PDF peak");
                    defaultMode = "Send PDF peak";
                    UpdateDefault(this, new EventArgs());
                }
            }
            else if (e.Button == MouseButtons.Left && firstpointmode && modeNewPDF)
            {
                if (isGenerating == false && isEditing == false && modeNewPDF)
                {
                    isDrawing       = true;
                    isGenerating    = true;
                    centerPoint     = r.ScreenToWorld(e.Location);
                    movePoint       = r.ScreenToWorld(e.Location);
                    firstPDFPoint.X = centerPoint.X;
                    firstPDFPoint.Y = centerPoint.Y;
                }
                secondpointmode = true;
                firstpointmode  = false;
                Console.WriteLine("secondpointmode");
                PDFReferencePointRenderer point1 = new PDFReferencePointRenderer();
                point1.X = firstPDFPoint.X;
                point1.Y = firstPDFPoint.Y;
                PDFrenderer.AddReferencePoint(point1);
            }
            else if (e.Button == MouseButtons.Left && secondpointmode && modeNewPDF)
            {
                thirdpointmode  = true;
                secondpointmode = false;
                Console.WriteLine("thirdpointmode");
                PDFReferencePointRenderer point2 = new PDFReferencePointRenderer();
                point2.X = secondPDFPoint.X;
                point2.Y = secondPDFPoint.Y;
                PDFrenderer.AddReferencePoint(point2);
            }
            else if (e.Button == MouseButtons.Left && thirdpointmode && modeNewPDF)
            {
                isGenerating   = false;
                firstpointmode = true;
                thirdpointmode = false;
                Console.WriteLine("firstpointmode");
                PDFReferencePointRenderer point3 = new PDFReferencePointRenderer();
                point3.X = thirdPDFPoint.X;
                point3.Y = thirdPDFPoint.Y;
                PDFrenderer.AddReferencePoint(point3);

                if (!(modeList.Contains("Remove PDF peak")))
                {
                    modeList.Add("Remove PDF peak");
                    modeList.Add("Edit PDF points");
                    modeList.Add("Send PDF peak");
                    modeList.Add("Move PDF peak");
                }

                defaultMode = "Send PDF peak";
                UpdateDefault(this, new EventArgs());
            }
            else if (e.Button == MouseButtons.Right)
            {
                //isDrawing = false;
            }
        }
Example #20
0
        public void OnMouseMove(Renderer r, MouseEventArgs e)
        {
            movePoint = r.ScreenToWorld(e.Location);
            if (shouldMove)
            {
                int enumer = 0;
                //enumerstop = 0;
                PDFReferencePointRenderer newpoint1        = new PDFReferencePointRenderer();
                PDFReferencePointRenderer newpoint2        = new PDFReferencePointRenderer();
                PDFReferencePointRenderer newpoint3        = new PDFReferencePointRenderer();
                PDFFormRenderer           clonePDFRenderer = new PDFFormRenderer();
                foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                {
                    if (GhostMovePoint1 == pdfRP)
                    {
                        //enumerstop = enumer;
                        newpoint1.X = movePoint.X + MoveDeltaReferencePoint1.X;
                        newpoint1.Y = movePoint.Y + MoveDeltaReferencePoint1.Y;
                        //ghostPoint = newpoint1;
                        clonePDFRenderer.AddReferencePoint(newpoint1);
                    }

                    else if (GhostMovePoint2 == pdfRP)
                    {
                        //enumerstop = enumer;
                        newpoint2.X = movePoint.X + MoveDeltaReferencePoint2.X;
                        newpoint2.Y = movePoint.Y + MoveDeltaReferencePoint2.Y;
                        //ghostPoint = newpoint2;
                        clonePDFRenderer.AddReferencePoint(newpoint2);
                    }
                    else if (GhostMovePoint3 == pdfRP)
                    {
                        newpoint3.X = movePoint.X + MoveDeltaReferencePoint3.X;
                        newpoint3.Y = movePoint.Y + MoveDeltaReferencePoint3.Y;
                        //ghostPoint = newpoint3;
                        clonePDFRenderer.AddReferencePoint(newpoint3);
                        enumerstop = enumer;
                    }
                    else
                    {
                        clonePDFRenderer.AddReferencePoint(PDFrenderer.PDFReferencePointList[enumer]);
                    }
                    enumer++;
                }
                int test = enumerstop;
                //clonePDFRenderer.PDFReferencePointList[enumerstop - 2] = newpoint1;
                //clonePDFRenderer.PDFReferencePointList[enumerstop - 1] = newpoint2;
                //clonePDFRenderer.PDFReferencePointList[enumerstop - 0] = newpoint3;

                //if (newpoint1 != null || newpoint2 != null || newpoint3 != null)
                //{
                PDFrenderer = clonePDFRenderer;
                //}
                int test2 = enumerstop;
                //shouldMove = false;
            }
            else if (shouldEdit)
            {
                int enumer     = 0;
                int enumerstop = 0;
                int pointtype  = 0;
                PDFReferencePointRenderer newpoint = new PDFReferencePointRenderer();
                foreach (PDFReferencePointRenderer pdfRP in PDFrenderer.PDFReferencePointList)
                {
                    if (ghostPoint == pdfRP)
                    {
                        enumerstop = enumer;
                        newpoint.X = movePoint.X;
                        newpoint.Y = movePoint.Y;
                        ghostPoint = newpoint;
                        pointtype  = enumer % 3;
                    }
                    enumer++;
                }
                if (newpoint != null)
                {
                    Vector2 first        = new Vector2(PDFrenderer.PDFReferencePointList[enumerstop - pointtype].X, PDFrenderer.PDFReferencePointList[enumerstop - pointtype].Y);
                    Vector2 second       = new Vector2(PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 1].X, PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 1].Y);
                    Vector2 third        = new Vector2(PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 2].X, PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 2].Y);
                    Vector2 muHolder     = new Vector2(first.X + (second.X - first.X) / 2, first.Y + (second.Y - first.Y) / 2);
                    double  heightHolder = -muHolder.DistanceTo(third);
                    bool    test         = true;
                    if (pointtype == 0)
                    {
                        first    = new Vector2(newpoint.X, newpoint.Y);
                        muHolder = new Vector2(first.X + (second.X - first.X) / 2, first.Y + (second.Y - first.Y) / 2);
                        Vector2 delta           = new Vector2(second.X - first.X, second.Y - first.Y);
                        double  thirdPointAngle = delta.ToRadians();

                        third = new Vector2(muHolder.X + Math.Sin(thirdPointAngle) * heightHolder, muHolder.Y - Math.Cos(thirdPointAngle) * heightHolder);
                    }
                    else if (pointtype == 1)
                    {
                        second   = new Vector2(newpoint.X, newpoint.Y);
                        muHolder = new Vector2(first.X + (second.X - first.X) / 2, first.Y + (second.Y - first.Y) / 2);
                        Vector2 delta2          = new Vector2(second.X - first.X, second.Y - first.Y);
                        double  thirdPointAngle = delta2.ToRadians();

                        third = new Vector2(muHolder.X + Math.Sin(thirdPointAngle) * heightHolder, muHolder.Y - Math.Cos(thirdPointAngle) * heightHolder);
                    }
                    else if (pointtype == 2)
                    {
                        Vector2 delta           = new Vector2(second.X - first.X, second.Y - first.Y);
                        double  thirdPointAngle = delta.ToRadians();
                        Vector2 delta1          = new Vector2(movePoint.X - first.X, movePoint.Y - first.Y);
                        angle1       = delta1.ToRadians();
                        heightHolder = (float)(Math.Sin(thirdPointAngle - angle1) * firstPDFPoint.DistanceTo(new Vector2(movePoint.X, movePoint.Y)));
                        third        = new Vector2(muHolder.X + Math.Sin(thirdPointAngle) * heightHolder, muHolder.Y - Math.Cos(thirdPointAngle) * heightHolder);
                    }
                    PDFReferencePointRenderer firstRP = new PDFReferencePointRenderer();
                    firstRP.X = first.X;
                    firstRP.Y = first.Y;
                    PDFReferencePointRenderer secondRP = new PDFReferencePointRenderer();
                    secondRP.X = second.X;
                    secondRP.Y = second.Y;
                    PDFReferencePointRenderer thirdRP = new PDFReferencePointRenderer();
                    thirdRP.X = third.X;
                    thirdRP.Y = third.Y;
                    PDFrenderer.PDFReferencePointList[enumerstop - pointtype]     = firstRP;
                    PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 1] = secondRP;
                    PDFrenderer.PDFReferencePointList[enumerstop - pointtype + 2] = thirdRP;
                    if (pointtype == 0)
                    {
                        ghostPoint = firstRP;
                    }
                    else if (pointtype == 1)
                    {
                        ghostPoint = secondRP;
                    }
                    else
                    {
                        ghostPoint = thirdRP;
                    }
                }
            }
            else
            {
                if (firstpointmode && isGenerating)
                {
                    firstPDFPoint  = new Vector2(movePoint.X, movePoint.Y);
                    secondPDFPoint = new Vector2(movePoint.X, movePoint.Y);
                    height2        = -1;
                }
                else if (secondpointmode && isGenerating)
                {
                    secondPDFPoint = new Vector2(movePoint.X, movePoint.Y);
                    height2        = -1;
                }
                else if (thirdpointmode && isGenerating)
                {
                    Vector2 delta1 = new Vector2(movePoint.X - firstPDFPoint.X, movePoint.Y - firstPDFPoint.Y);
                    Vector2 delta2 = new Vector2(secondPDFPoint.X - firstPDFPoint.X, secondPDFPoint.Y - firstPDFPoint.Y);
                    angle1  = delta1.ToRadians();
                    angle2  = delta2.ToRadians();
                    height2 = (float)(Math.Sin(angle2 - angle1) * firstPDFPoint.DistanceTo(new Vector2(movePoint.X, movePoint.Y)));
                }
            }
        }
        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;
                    }
                }
            }
        }
Example #22
0
 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;
                 }
             }
         }
     }
 }
Example #23
0
        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;
                            }
                        }
                    }
                }
            }
        }
Example #24
0
        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);
            }
        }
Example #25
0
        /// <summary>
        /// Drawing code
        /// </summary>
        /// <param name="r"></param>
        public void Draw(Renderer r)
        {
            if (pointList.Count == 0)
            {
                UpdatePointList();
            }

            if ((gestureName == "CIRCLE") || (gestureName == "SQUARE") || (gestureName == "TRIANGLE"))
            {
                //DrawToolOld.ResetRefPoints();
                ctrPtWorld = r.ScreenToWorld(pointList.ElementAt(0));
                GLUtility.DrawCircle(new GLPen(Color.Blue, 0.2f), ctrPtWorld, 0.3f);
            }

            else if (gestureName == "X")
            {
                //DrawToolOld.ResetRefPoints();
                ctrPtWorld = r.ScreenToWorld(pointList.ElementAt(0));
                GLUtility.DrawCross(new GLPen(Color.Red, 0.2f), new Vector2(ctrPtWorld.X, ctrPtWorld.Y), 0.5f);
            }

            else if ((gestureName == "ARROW") || (gestureName == "PATH") || (gestureName == "SENTENCE"))
            {
                //DrawToolOld.ResetRefPoints();
                pthStartWorld = r.ScreenToWorld(pointList.ElementAt(0));
                pthEndWorld   = r.ScreenToWorld(pointList.ElementAt(1));
                GLUtility.DrawCircle(new GLPen(Color.Blue, 0.2f), pthStartWorld, 0.3f);
                GLUtility.DrawCross(new GLPen(Color.Red, 0.2f), new Vector2(pthEndWorld.X, pthEndWorld.Y), 0.5f);
            }
            else
            {
                //DrawToolOld.ResetRefPoints();
            }
            if ((gestureName == "PATH") || (gestureName == "SENTENCE"))
            {
                //DrawToolOld.ResetRefPoints();
                ln1StartWorld = r.ScreenToWorld(pointList.ElementAt(2));
                ln1EndWorld   = r.ScreenToWorld(pointList.ElementAt(3));
                ln2StartWorld = r.ScreenToWorld(pointList.ElementAt(4));
                ln2EndWorld   = r.ScreenToWorld(pointList.ElementAt(5));
                ln3StartWorld = r.ScreenToWorld(pointList.ElementAt(6));
                ln3EndWorld   = r.ScreenToWorld(pointList.ElementAt(7));
                GLUtility.DrawLine(new GLPen(Color.Black, 1.0f), ln1StartWorld, ln1EndWorld);
                GLUtility.DrawLine(new GLPen(Color.Black, 1.0f), ln2StartWorld, ln2EndWorld);
                GLUtility.DrawLine(new GLPen(Color.Black, 1.0f), ln3StartWorld, ln3EndWorld);
            }

            // draw pixels
            if (pixelList.Count > 0)
            {
                foreach (PointF v3 in drawPixelList)
                {
                    drawPixel.X = ((float)v3.X - (w / 2));
                    drawPixel.Y = ((float)v3.Y - (h / 2));

                    drawPixel2.X = ((float)v3.X - (w / 4));
                    drawPixel2.Y = ((float)v3.Y - (h / 4));

                    float scale = r.Scale();

                    pixelRect = new RectangleF((float)drawPixel.X, (float)drawPixel.Y, w, h);
                    RectangleF pixelRect2 = new RectangleF((float)drawPixel2.X, (float)drawPixel2.Y, w / 2, h / 2);

                    GLUtility.DrawRectangle(new GLPen(Color.Black, 0.1f), pixelRect);
                    GLUtility.DrawRectangle(new GLPen(Color.Black, 0.1f), pixelRect2);
                }
            }
        }
Example #26
0
        /// <summary>
        /// Operations to perform on MouseDown (takes: Renderer r, MouseEventArgs e)
        ///     On single left click:
        ///         - If not on an existing waypoint, make a new waypoint & execute pathPointAdded event
        ///         - If on an existing waypoint, change shouldMove to true and keep track of waypoint to move
        ///     On double left click:
        ///         - Send path (execute ToolCompleted event) and clear renderer
        ///     On single right click:
        ///         - If on an existing waypoint, delete the waypoint
        ///     On double right click:
        ///         - delete and clear the entire path
        /// </summary>
        /// <param name="r"></param>
        /// <param name="e"></param>
        #region Operations to perform on MouseDown
        public void OnMouseDown(Renderer r, MouseEventArgs e)
        {
            #region Left Click
            //check that button was a left click
            PointF p = r.ScreenToWorld(e.Location);
            if (e.Button == MouseButtons.Left)
            {
                //PointF p = r.ScreenToWorld(e.Location);

                if ((newVersion == true) && (tempActive == true))                 // (new version)
                {
                    if (modeNewWaypoint == true)
                    {
                        if (newPath.WaypointList.Count > 0)
                        {
                            if (!defaultMode.Equals("Send path"))
                            {
                                defaultMode = "Send path";
                                if (UpdateDefault != null)
                                {
                                    UpdateDefault(this, new EventArgs());
                                }
                            }
                            if (modeMoveWaypoint == true)
                            {
                                foreach (WaypointRenderer wp in newPath.WaypointList)
                                {
                                    // move an existing waypoint if we click sufficiently close to it
                                    if ((p.X - wp.X < 0.25) && (p.Y - wp.Y < 0.25) &&
                                        (p.X - wp.X > -0.25) && (p.Y - wp.Y > -0.25))
                                    {
                                        shouldMove      = true;
                                        movePointWP     = wp;
                                        origMovePointWP = wp;
                                        currentCursor   = Cursors.Hand;
                                        myToolManager.SelectTool.TempDeactivate();
                                        if (GestureExpData != null)
                                        {
                                            GestureExpData(this, new GestureExpHRIEventArgs("Tool:PathTool|left click down|move waypoint from|" + e.X + "|" + e.Y + "|(screen)|" + p.X + "|" + p.Y + "|(world)"));
                                        }
                                        break;
                                        //Tool: SelectTool, mode: Select/Deselect, activated using context menu
                                    }
                                }
                            }
                        }
                        if (((newPath.WaypointList.Count > 0) && (shouldMove == false)) || (newPath.WaypointList.Count == 0))
                        {
                            WaypointRenderer newPoint = new WaypointRenderer();

                            if (newPath.WaypointList.Count > 0)
                            {
                                if (GestureExpData != null)
                                {
                                    GestureExpData(this, new GestureExpHRIEventArgs("Tool:PathTool|left click down|add waypoint|" + e.X + "|" + e.Y + "|(screen)|" + p.X + "|" + p.Y + "|(world)"));
                                }
                            }
                            else
                            {
                                if (GestureExpData != null)
                                {
                                    GestureExpData(this, new GestureExpHRIEventArgs("Tool:PathTool|left click down|new path|" + e.X + "|" + e.Y + "|(screen)|" + p.X + "|" + p.Y + "|(world)"));
                                }
                            }
                            newPoint.X = p.X;
                            newPoint.Y = p.Y;
                            newPath.AddWaypoint(newPoint);

                            modeMoveWaypoint = true;
                            if (!defaultMode.Equals("Send path"))
                            {
                                defaultMode = "Send path";
                                if (UpdateDefault != null)
                                {
                                    UpdateDefault(this, new EventArgs());
                                }
                            }
                        }
                        shouldDraw = true;
                    }
                    else if (modeDeleteWaypoint == true)
                    {
                        if (newPath.WaypointList.Count > 0)
                        {
                            foreach (WaypointRenderer wp in newPath.WaypointList)
                            {
                                // if right click is sufficiently close to an existing waypoint, delete it and excecute pathPointRemoved event
                                Vector2 v = new Vector2((float)wp.X, (float)wp.Y);
                                if (!((wp.X - p.X > -.25) && (wp.Y - p.Y > -.25) &&
                                      (wp.X - p.X < .25) && (wp.Y - p.Y < .25)))
                                {
                                    clonePathWP.AddWaypoint(wp);
                                }
                            }
                            newPath = clonePathWP;
                            if (GestureExpData != null)
                            {
                                GestureExpData(this, new GestureExpHRIEventArgs("Tool:PathTool|left click down|delete waypoint|" + e.X + "|" + e.Y + "|(screen)|" + p.X + "|" + p.Y + "|(world)"));
                            }
                            clonePathWP = new PathToRobotRenderer();
                        }
                        if (newPath.WaypointList.Count == 0)
                        {
                            //defaultMode = "Add new waypoint";
                            //modeDeleteWaypoint = false;
                            //modeNewWaypoint = true;
                            if (UpdateDefault != null)
                            {
                                UpdateDefault(this, new EventArgs());
                            }
                        }
                    }
                }
            }
            #endregion

            if (e.Button == MouseButtons.Right)
            {
                //if (GestureExpData != null)
                //    GestureExpData(this, new GestureExpPathToolEventArgs("Tool:PathTool    right click   ---     " + e.X + " " + e.Y + " (screen)    " + p.X + " " + p.Y + " (world)"));
            }
        }
 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;
                     }
                 }
             }
         }
     }
 }