Esempio n. 1
0
        private void glCanvas1_MouseDown(object sender, MouseEventArgs e)
        {
            this.lastMousePosition     = e.Location;
            this.lastMouseDownPosition = e.Location;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.SetBounds(this.glCanvas1.Width, this.glCanvas1.Height);
                //rotator.MouseDown(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                if (pickedGeometry != null)
                {
                    ViewPort viewPort  = pickedGeometry.FromViewPort;
                    ICamera  camera    = viewPort.Camera;
                    var      dragParam = new DragParam(
                        camera.GetPerspectiveProjectionMatrix(),
                        camera.GetViewMatrix(),
                        viewPort.Rect.ToViewport(),
                        new Point(e.X, glCanvas1.Height - e.Y - 1));
                    dragParam.pickedVertexIds.AddRange(pickedGeometry.VertexIds);
                    this.dragParam = dragParam;
                }
            }
        }
        private void glCanvas1_MouseMove(object sender, MouseEventArgs e)
        {
            if (lastMousePosition == e.Location)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseMove(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                DragParam dragParam = this.dragParam;
                if (dragParam != null)
                {
                    var   current            = new Point(e.X, glCanvas1.Height - e.Y - 1);
                    Point differenceOnScreen = new Point(
                        current.X - dragParam.lastMousePositionOnScreen.X,
                        current.Y - dragParam.lastMousePositionOnScreen.Y);
                    dragParam.lastMousePositionOnScreen = current;
                    this.rendererDict[this.selectedModel].PickableRenderer.MovePositions(
                        differenceOnScreen,
                        dragParam.viewMatrix, dragParam.projectionMatrix,
                        dragParam.viewport,
                        dragParam.pickedIndexes);
                }
            }
            else
            {
                UpdateColorInformationAtMouse(e.X, e.Y);

                PickedGeometry pickedGeometry = RunPicking(
                    new RenderEventArgs(
                        RenderModes.ColorCodedPicking,
                        this.glCanvas1.ClientRectangle,
                        this.camera, this.PickingGeometryType),
                    e.X, e.Y);
                if (pickedGeometry != null)
                {
                    this.rendererDict[this.selectedModel].Highlighter.SetHighlightIndexes(
                        this.PickingGeometryType.ToDrawMode(),
                        pickedGeometry.Indexes);
                }
                else
                {
                    this.rendererDict[this.selectedModel].Highlighter.ClearHighlightIndexes();
                }

                this.pickedGeometry = pickedGeometry;
                UpdatePickingBoard(pickedGeometry);
            }



            this.lastMousePosition = e.Location;
        }
Esempio n. 3
0
        private void glCanvas1_MouseMove(object sender, MouseEventArgs e)
        {
            if (lastMousePosition == e.Location)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseMove(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                DragParam dragParam = this.dragParam;
                if (dragParam != null)
                {
                    var   current            = new Point(e.X, glCanvas1.Height - e.Y - 1);
                    Point differenceOnScreen = new Point(
                        current.X - dragParam.lastMousePositionOnScreen.X,
                        current.Y - dragParam.lastMousePositionOnScreen.Y);
                    dragParam.lastMousePositionOnScreen = current;
                    PickableRenderer renderer = null;
                    {
                        var tmp = this.pickedGeometry.FromRenderer as HighlightedPickableRenderer;
                        if (tmp != null)
                        {
                            renderer = tmp.PickableRenderer;
                        }
                    }

                    if (renderer == null)
                    {
                        renderer = this.pickedGeometry.FromRenderer as PickableRenderer;
                    }

                    renderer.MovePositions(
                        differenceOnScreen,
                        dragParam.viewMatrix, dragParam.projectionMatrix,
                        dragParam.viewport,
                        dragParam.pickedVertexIds);
                }
            }
            else
            {
                MouseMoveFree(e);
            }

            UpdateColorInformationAtMouse(e.X, e.Y);

            this.lastMousePosition = e.Location;
        }
Esempio n. 4
0
        private void glCanvas1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseUp(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex

                PickedGeometry geometry = this.pickedGeometry;
                if (geometry != null && this.lastMouseDownPosition == e.Location)
                {
                    var frm = new FormProperyGrid(geometry.FromRenderer);
                    frm.Show();
                    var frmIndexBufferBoard = new FormIndexBufferBoard();
                    HighlightedPickableRenderer renderer = this.highlightedRenderer;
                    if (renderer != null)
                    {
                        frmIndexBufferBoard.SetTarget(renderer.PickableRenderer.IndexBuffer);
                    }
                    else
                    {
                        var tmp = geometry.FromRenderer as PickableRenderer;
                        if (tmp != null)
                        {
                            frmIndexBufferBoard.SetTarget(tmp.IndexBuffer);
                            //frmIndexBufferBoard.SetTarget((geometry.From as PickableRenderer).IndexBuffer);
                        }
                    }
                    frmIndexBufferBoard.Show();
                }
                {
                    HighlightedPickableRenderer renderer = this.highlightedRenderer;
                    if (renderer != null)
                    {
                        renderer.Highlighter.ClearHighlightIndexes();
                        this.highlightedRenderer = null;
                    }
                }
                this.dragParam = null;
            }

            this.lastMousePosition = e.Location;
        }
        private void glCanvas1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseUp(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                this.dragParam = null;
                this.rendererDict[this.selectedModel].Highlighter.ClearHighlightIndexes();
            }

            UpdateColorInformationAtMouse(e.X, e.Y);

            this.lastMousePosition = e.Location;
        }
        private void glCanvas1_MouseDown(object sender, MouseEventArgs e)
        {
            this.lastMousePosition = e.Location;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.SetBounds(this.glCanvas1.Width, this.glCanvas1.Height);
                //rotator.MouseDown(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                UpdateColorInformationAtMouse(e.X, e.Y);

                PickedGeometry pickedGeometry = RunPicking(
                    new RenderEventArgs(
                        RenderModes.ColorCodedPicking,
                        this.glCanvas1.ClientRectangle,
                        this.camera,
                        this.PickingGeometryType),
                    e.X, e.Y);
                if (pickedGeometry != null)
                {
                    this.rendererDict[this.selectedModel].Highlighter.SetHighlightIndexes(
                        this.PickingGeometryType.ToDrawMode(),
                        pickedGeometry.Indexes);
                    var dragParam = new DragParam(
                        camera.GetProjectionMat4(),
                        camera.GetViewMat4(),
                        new Point(e.X, glCanvas1.Height - e.Y - 1));
                    dragParam.pickedIndexes.AddRange(pickedGeometry.Indexes);
                    this.dragParam = dragParam;
                }

                this.pickedGeometry = pickedGeometry;
            }
        }
        private void glCanvas1_MouseDown(object sender, MouseEventArgs e)
        {
            this.lastMousePosition = e.Location;
            this.lastMouseDownPosition = e.Location;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.SetBounds(this.glCanvas1.Width, this.glCanvas1.Height);
                //rotator.MouseDown(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                if (pickedGeometry != null)
                {
                    ViewPort viewPort = pickedGeometry.FromViewPort;
                    ICamera camera = viewPort.Camera;
                    var dragParam = new DragParam(
                        camera.GetPerspectiveProjectionMatrix(),
                        camera.GetViewMatrix(),
                        viewPort.Rect.ToViewport(),
                        new Point(e.X, glCanvas1.Height - e.Y - 1));
                    dragParam.pickedVertexIds.AddRange(pickedGeometry.VertexIds);
                    this.dragParam = dragParam;
                }
            }
        }
        private void glCanvas1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseUp(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex

                PickedGeometry geometry = this.pickedGeometry;
                if (geometry != null && this.lastMouseDownPosition == e.Location)
                {
                    var frm = new FormProperyGrid(geometry.FromRenderer);
                    frm.Show();
                    var frmIndexBufferBoard = new FormIndexBufferBoard();
                    HighlightedPickableRenderer renderer = this.highlightedRenderer;
                    if (renderer != null)
                    {
                        frmIndexBufferBoard.SetTarget(renderer.PickableRenderer.IndexBuffer);
                    }
                    else
                    {
                        var tmp = geometry.FromRenderer as PickableRenderer;
                        if (tmp != null)
                        {
                            frmIndexBufferBoard.SetTarget(tmp.IndexBuffer);
                            //frmIndexBufferBoard.SetTarget((geometry.From as PickableRenderer).IndexBuffer);
                        }
                    }
                    frmIndexBufferBoard.Show();
                }
                {
                    HighlightedPickableRenderer renderer = this.highlightedRenderer;
                    if (renderer != null)
                    {
                        renderer.Highlighter.ClearHighlightIndexes();
                        this.highlightedRenderer = null;
                    }
                }
                this.dragParam = null;
            }

            this.lastMousePosition = e.Location;
        }
        private void glCanvas1_MouseMove(object sender, MouseEventArgs e)
        {
            if (lastMousePosition == e.Location)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //// operate camera
                //rotator.MouseMove(e.X, e.Y);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // move vertex
                DragParam dragParam = this.dragParam;
                if (dragParam != null)
                {
                    var   current            = new Point(e.X, glCanvas1.Height - e.Y - 1);
                    Point differenceOnScreen = new Point(
                        current.X - dragParam.lastMousePositionOnScreen.X,
                        current.Y - dragParam.lastMousePositionOnScreen.Y);
                    dragParam.lastMousePositionOnScreen = current;
                    PickableRenderer renderer = null;
                    {
                        var tmp = this.pickedGeometry.From as HighlightedPickableRenderer;
                        if (tmp != null)
                        {
                            renderer = tmp.PickableRenderer;
                        }
                    }

                    if (renderer == null)
                    {
                        renderer = this.pickedGeometry.From as PickableRenderer;
                    }

                    renderer.MovePositions(
                        differenceOnScreen,
                        dragParam.viewMatrix, dragParam.projectionMatrix,
                        dragParam.viewport,
                        dragParam.pickedVertexIds);
                }
            }
            else
            {
                UpdateColorInformationAtMouse(e.X, e.Y);

                PickedGeometry pickedGeometry = this.scene.ColorCodedPicking(
                    e.Location, this.PickingGeometryType);
                if (pickedGeometry != null)
                {
                    PickableRenderer pickableRenderer = null;
                    var renderer = pickedGeometry.From as HighlightedPickableRenderer;
                    if (renderer != null)
                    {
                        renderer.Highlighter.SetHighlightIndexes(
                            this.PickingGeometryType.ToDrawMode(), pickedGeometry.VertexIds);
                        this.highlightedRenderer = renderer;
                        pickableRenderer         = renderer.PickableRenderer;
                    }
                    else
                    {
                        pickableRenderer = pickedGeometry.From as PickableRenderer;
                    }

                    FormBulletinBoard bulletinBoard = this.bulletinBoard;
                    if ((bulletinBoard != null) && (!bulletinBoard.IsDisposed))
                    {
                        ICamera camera     = this.scene.Camera;
                        mat4    projection = camera.GetProjectionMatrix();
                        mat4    view       = camera.GetViewMatrix();
                        mat4    model      = pickableRenderer.GetModelMatrix();
                        this.bulletinBoard.SetContent(pickedGeometry.ToString(
                                                          projection, view, model));
                    }

                    this.glCanvas1.Cursor = Cursors.Hand;
                }
                else
                {
                    HighlightedPickableRenderer renderer = this.highlightedRenderer;
                    if (renderer != null)
                    {
                        renderer.Highlighter.ClearHighlightIndexes();
                    }
                    this.bulletinBoard.SetContent("picked nothing.");

                    this.glCanvas1.Cursor = Cursors.Default;
                }
                this.pickedGeometry = pickedGeometry;
            }

            this.lastMousePosition = e.Location;
        }