/// <summary>
        /// draws the active view
        /// </summary>
        /// <param name="size">actual size in pixel, not dpi independent size</param>
        public void Repaint(Size size)
        {
            var dev = Device.Get();

            var visible = models.GetEnabledPipelines();

            var scissorsPos = new Point(mousePosition.X, mousePosition.Y);

            if (visible.Count < 2)
            {
                fixedMousePosition = null;
            }
            if (fixedMousePosition != null)
            {
                scissorsPos = new Point(fixedMousePosition.Value.X, fixedMousePosition.Value.Y);
            }

            if (visible.Count == 1)
            {
                // draw single image
                currentView.Draw(models.Pipelines[visible[0]].Image);
            }
            else if (visible.Count == 2)
            {
                // draw two images in split view

                scissorsPos.X = Math.Min(size.Width - 1, Math.Max(0, scissorsPos.X));
                scissorsPos.Y = Math.Min(size.Height - 1, Math.Max(0, scissorsPos.Y));

                if (models.Display.Split == DisplayModel.SplitMode.Vertical)
                {
                    dev.Rasterizer.SetScissorRectangle(0, 0, scissorsPos.X, size.Height);
                }
                else
                {
                    dev.Rasterizer.SetScissorRectangle(0, 0, size.Width, scissorsPos.Y);
                }

                // first image
                currentView.Draw(models.Pipelines[visible[0]].Image);

                if (models.Display.Split == DisplayModel.SplitMode.Vertical)
                {
                    dev.Rasterizer.SetScissorRectangle(scissorsPos.X, 0, size.Width, size.Height);
                }
                else
                {
                    dev.Rasterizer.SetScissorRectangle(0, scissorsPos.Y, size.Width, size.Height);
                }

                // second image
                currentView.Draw(models.Pipelines[visible[1]].Image);
            }
            else if (visible.Count == 3 || visible.Count == 4)
            {
                scissorsPos.X = Math.Min(size.Width - 1, Math.Max(0, scissorsPos.X));
                scissorsPos.Y = Math.Min(size.Height - 1, Math.Max(0, scissorsPos.Y));

                // upper left
                dev.Rasterizer.SetScissorRectangle(0, 0, scissorsPos.X, scissorsPos.Y);
                currentView.Draw(models.Pipelines[visible[0]].Image);

                // upper right
                dev.Rasterizer.SetScissorRectangle(scissorsPos.X, 0, size.Width, scissorsPos.Y);
                currentView.Draw(models.Pipelines[visible[1]].Image);

                // draw third texture (entire bottom if only 3 are visible, lower left if 4 are visible)
                dev.Rasterizer.SetScissorRectangle(0, scissorsPos.Y, visible.Count == 3 ? size.Width : scissorsPos.X, size.Height);
                currentView.Draw(models.Pipelines[visible[2]].Image);

                if (visible.Count == 4)
                {
                    dev.Rasterizer.SetScissorRectangle(scissorsPos.X, scissorsPos.Y, size.Width, size.Height);
                    currentView.Draw(models.Pipelines[visible[3]].Image);
                }
            }
        }
예제 #2
0
        public void Paint()
        {
            // draw visible equations
            var visible = models.Equations.GetVisibles();

            if (visible.Count == 1)
            {
                // draw a single image
                currentView.Draw(models.FinalImages.Get(visible[0]).Texture);
            }
            else if (visible.Count == 2)
            {
                // draw two images in split view
                GL.Enable(EnableCap.ScissorTest);

                var clientX = models.GlContext.ClientSize.Width;
                var clientY = models.GlContext.ClientSize.Height;
                // clamp mouse position to avoid out of range
                var scissorsPos = new Point(mousePosition.X, mousePosition.Y);
                scissorsPos.X = Math.Min(clientX - 1, Math.Max(0, scissorsPos.X));
                scissorsPos.Y = Math.Min(clientY - 1, Math.Max(0, scissorsPos.Y));

                if (models.Display.Split == DisplayModel.SplitMode.Vertical)
                {
                    GL.Scissor(0, 0, scissorsPos.X, clientY);
                }
                else
                {
                    GL.Scissor(0, clientY - scissorsPos.Y, clientX, clientY);
                }

                // first part
                currentView.Draw(models.FinalImages.Get(visible[0]).Texture);

                if (models.Display.Split == DisplayModel.SplitMode.Vertical)
                {
                    GL.Scissor(scissorsPos.X, 0, clientX, clientY);
                }
                else
                {
                    GL.Scissor(0, 0, clientX, clientY - scissorsPos.Y);
                }

                // second part
                currentView.Draw(models.FinalImages.Get(visible[1]).Texture);

                GL.Disable(EnableCap.ScissorTest);
            }
            else if (visible.Count == 3 || visible.Count == 4)
            {
                // draw two images in split view
                GL.Enable(EnableCap.ScissorTest);

                var clientX = models.GlContext.ClientSize.Width;
                var clientY = models.GlContext.ClientSize.Height;
                // clamp mouse position to avoid out of range
                var scissorsPos = new Point(mousePosition.X, mousePosition.Y);
                scissorsPos.X = Math.Min(clientX - 1, Math.Max(0, scissorsPos.X));
                scissorsPos.Y = Math.Min(clientY - 1, Math.Max(0, scissorsPos.Y));
                // opengl coordinates start up down
                scissorsPos.Y = clientY - scissorsPos.Y - 1;

                // draw first in upper left, second uper right, third lower (left, fourth lower right)

                // first (upper left)
                GL.Scissor(0, scissorsPos.Y, scissorsPos.X, clientY);
                currentView.Draw(models.FinalImages.Get(visible[0]).Texture);

                // second (upper right)
                GL.Scissor(scissorsPos.X, scissorsPos.Y, clientX, clientY);
                currentView.Draw(models.FinalImages.Get(visible[1]).Texture);

                // draw third texture (entire bottom if only 3 are visible, lower left if 4 are visible)
                GL.Scissor(0, 0, visible.Count == 3 ? clientX : scissorsPos.X, scissorsPos.Y);
                currentView.Draw(models.FinalImages.Get(visible[2]).Texture);

                if (visible.Count == 4)
                {
                    // draw fourth texture (lower right)
                    GL.Scissor(scissorsPos.X, 0, clientX, scissorsPos.Y);
                    currentView.Draw(models.FinalImages.Get(visible[3]).Texture);
                }

                GL.Disable(EnableCap.ScissorTest);
            }
        }