Пример #1
0
        public void RenderBones()
        {
            if (VBN != null)
            {
                RenderTools.DrawVBN(VBN);
            }

            if (Bch != null)
            {
                foreach (BCH_Model mo in Bch.Models.Nodes)
                {
                    RenderTools.DrawVBN(mo.skeleton);
                }
            }

            if (Bfres != null)
            {
                foreach (var mo in Bfres.models)
                {
                    RenderTools.DrawVBN(mo.skeleton);
                }
            }

            if (DatMelee != null)
            {
                RenderTools.DrawVBN(DatMelee.bones);
            }
        }
Пример #2
0
        private void clearSettingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Try to cast the sender to a ToolStripItem
            ToolStripItem menuItem = sender as ToolStripItem;

            if (menuItem != null)
            {
                // Retrieve the ContextMenuStrip that owns this ToolStripItem
                ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
                if (owner != null)
                {
                    // Get the control that is displaying this context menu
                    Control sourceControl = owner.SourceControl;
                    switch (sourceControl.Name)
                    {
                    case "diffuseCubemapPathTB":
                        diffuseCubemapPathTB.Text      = "";
                        Runtime.PBR.DiffuseCubeMapPath = "";
                        RenderTools.ResetDiffuseCubeMap();
                        break;

                    case "specularCubemapPathTB":
                        specularCubemapPathTB.Text      = "";
                        Runtime.PBR.SpecularCubeMapPath = "";
                        RenderTools.ResetSpecularCubeMap();
                        break;

                    case "mk8DPathTB":
                        mk8DPathTB.Text      = "";
                        Runtime.Mk8dGamePath = "";
                        break;

                    case "mk8PathTB":
                        mk8PathTB.Text      = "";
                        Runtime.Mk8GamePath = "";
                        break;

                    case "SMOPathTB":
                        SMOPathTB.Text      = "";
                        Runtime.SmoGamePath = "";
                        break;

                    case "tpGamePathTB":
                        tpGamePathTB.Text  = "";
                        Runtime.TpGamePath = "";
                        break;

                    case "botwGamePathTB":
                        botwGamePathTB.Text  = "";
                        Runtime.BotwGamePath = "";
                        break;

                    case "pathPokemonSwShTB":
                        pathPokemonSwShTB.Text = "";
                        Runtime.PkSwShGamePath = "";
                        break;
                    }
                }
            }
        }
Пример #3
0
 private static CellDesc CreateData(string text, RenderTools rt)
 {
     return(new CellDesc(text, rt)
     {
         Align = StringAlignment.Far
     });
 }
Пример #4
0
        public Size RenderTip(Graphics g, Size sizeMax, bool draw)
        {
            var table = new TableDesc();

            using (var rt = new RenderTools())
            {
                if (_row.Peptide != null)
                {
                    table.AddDetailRow(Helpers.PeptideToMoleculeTextMapper.Translate(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Peptide, _row.Peptide.IsSmallMolecule()),
                                       _row.Peptide.ModifiedSequence == null ? _row.Peptide.ToString() : _row.Peptide.ModifiedSequence.ToString(), rt);
                }
                if (_row.Protein != null)
                {
                    table.AddDetailRow(Helpers.PeptideToMoleculeTextMapper.Translate(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Protein, _row.Protein.IsNonProteomic()),
                                       ProteinMetadataManager.ProteinModalDisplayText(_row.Protein.DocNode), rt);
                }

                table.AddDetailRow(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Fold_Change, _row.FoldChangeResult.FoldChange.ToString(Formats.FoldChange, CultureInfo.CurrentCulture), rt);
                table.AddDetailRow(GroupComparisonStrings.FoldChange_Log2_Fold_Change_, _row.FoldChangeResult.Log2FoldChange.ToString(Formats.FoldChange, CultureInfo.CurrentCulture), rt);
                table.AddDetailRow(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_P_Value, _row.FoldChangeResult.AdjustedPValue.ToString(Formats.PValue, CultureInfo.CurrentCulture), rt);
                table.AddDetailRow(GroupComparisonStrings.FoldChange__Log10_P_Value_, (-Math.Log10(_row.FoldChangeResult.AdjustedPValue)).ToString(Formats.PValue, CultureInfo.CurrentCulture), rt);

                var size = table.CalcDimensions(g);

                if (draw)
                {
                    table.Draw(g);
                }

                return(new Size((int)size.Width + 2, (int)size.Height + 2));
            }
        }
Пример #5
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            Vector2 topLeft = new Vector2(Position.X + (EdgeTexture.Height / 2.0f), Position.Y + (EdgeTexture.Height / 2.0f));
            float   right   = topLeft.X + (Dimensions.X - EdgeTexture.Height);
            float   bottom  = topLeft.Y + (Dimensions.Y - EdgeTexture.Height);

            RenderTools.Line(spriteBatch, EdgeTexture, topLeft, new Vector2(right, topLeft.Y), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, topLeft, new Vector2(topLeft.X, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(topLeft.X, bottom), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(right, topLeft.Y), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);

            topLeft = GameBase.ScreenPosition(topLeft);
            right   = topLeft.X + GameBase.ScreenScale(Dimensions.X - EdgeTexture.Height);
            bottom  = topLeft.Y + GameBase.ScreenScale(Dimensions.Y - EdgeTexture.Height);

            if (CornerTexture != null)
            {
                spriteBatch.Draw(CornerTexture, topLeft, null, EdgeTint, 0.0f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, topLeft.Y), null, EdgeTint, MathHelper.PiOver2, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, bottom), null, EdgeTint, MathHelper.Pi, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(topLeft.X, bottom), null, EdgeTint, MathHelper.Pi * 1.5f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
            }

            if (BackgroundTexture != null)
            {
                Rectangle area = new Rectangle((int)topLeft.X, (int)topLeft.Y, (int)(right - topLeft.X), (int)(bottom - topLeft.Y));
                spriteBatch.Draw(BackgroundTexture, area, null, BackgroundTint, 0.0f, Vector2.Zero, SpriteEffects.None, RenderDepth + 0.005f);
            }
        }
Пример #6
0
        private static CellDesc CreateIon(IonType type, int ordinal, TypedMass massH, Adduct charge,
                                          IEnumerable <DocNode> choices, ICollection <DocNode> chosen, Transition tranSelected,
                                          RenderTools rt)
        {
            double   mz   = SequenceMassCalc.GetMZ(massH, charge);
            CellDesc cell = CreateData(string.Format(@"{0:F02}", mz), rt);

            foreach (TransitionDocNode nodeTran in choices)
            {
                Transition tran = nodeTran.Transition;
                if (tran.IonType == type &&
                    tran.Ordinal == ordinal &&
                    tran.Adduct == charge)
                {
                    cell.Font = rt.FontBold;
                    if (Equals(tran, tranSelected))
                    {
                        cell.Brush = rt.BrushSelected; // Stop after selected
                        break;
                    }
                    if (!chosen.Contains(nodeTran))
                    {
                        cell.Brush = rt.BrushChoice;  // Keep looking
                    }
                    else
                    {
                        cell.Brush = rt.BrushChosen;  // Stop after chosen
                        break;
                    }
                }
            }

            return(cell);
        }
Пример #7
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            float left   = Position.X + (EdgeTexture.Height / 2.0f);
            float top    = Position.Y + (EdgeTexture.Height / 2.0f);
            float right  = left + Dimensions.X - EdgeTexture.Height;
            float bottom = top + Dimensions.Y - EdgeTexture.Height;

            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, top), new Vector2(right, top), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, top), new Vector2(left, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(left, bottom), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);
            RenderTools.Line(spriteBatch, EdgeTexture, new Vector2(right, top), new Vector2(right, bottom), 1.0f, EdgeTint, RenderDepth);

            if (CornerTexture != null)
            {
                spriteBatch.Draw(CornerTexture, new Vector2(left, top), null, EdgeTint, 0.0f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, top), null, EdgeTint, MathHelper.PiOver2, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(right, bottom), null, EdgeTint, MathHelper.Pi, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
                spriteBatch.Draw(CornerTexture, new Vector2(left, bottom), null, EdgeTint, MathHelper.Pi * 1.5f, new Vector2(CornerTexture.Width, CornerTexture.Height) / 2.0f, 1.0f, SpriteEffects.None, RenderDepth - 0.005f);
            }

            if (BackgroundTexture != null)
            {
                Rectangle area = new Rectangle((int)left, (int)top, (int)(right - left), (int)(bottom - top));
                spriteBatch.Draw(BackgroundTexture, area, null, BackgroundTint, 0.0f, Vector2.Zero, SpriteEffects.None, RenderDepth + 0.005f);
            }
        }
Пример #8
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            if (Selected)
            {
                RenderTools.Line(
                    spriteBatch,
                    TextureManager.Textures["pixel"],
                    (WorldPosition + new Vector2(0.0f, CollisionZoneTopOffset)) - CameraPosition,
                    (WorldPosition + new Vector2(Frame.Width, CollisionZoneTopOffset)) - CameraPosition,
                    3.0f,
                    Color.Crimson,
                    0.001f);

                RenderTools.Line(
                    spriteBatch,
                    TextureManager.Textures["pixel"],
                    (WorldPosition + new Vector2(0.0f, DimensionsInCells.Y * Definitions.CellSizeInPixels)) - CameraPosition,
                    (WorldPosition + new Vector2(Frame.Width, DimensionsInCells.Y * Definitions.CellSizeInPixels)) - CameraPosition,
                    3.0f,
                    Color.Crimson,
                    0.001f);

                RenderTools.Line(
                    spriteBatch,
                    TextureManager.Textures["pixel"],
                    (WorldPosition + new Vector2(Frame.Width / 2.0f, CollisionZoneTopOffset)) - CameraPosition,
                    (WorldPosition + new Vector2(Frame.Width / 2.0f, DimensionsInCells.Y * Definitions.CellSizeInPixels)) - CameraPosition,
                    3.0f,
                    Color.Crimson,
                    0.001f);
            }
        }
        public static void InitializeSharedResources()
        {
            // Only setup once. This is checked multiple times to prevent crashes.
            if (setupStatus == SharedResourceStatus.Initialized)
            {
                return;
            }

            try
            {
                // Make a permanent context to share resources.
                GraphicsContext.ShareContexts = true;
                var control = new OpenTK.GLControl();
                control.MakeCurrent();

                RenderTools.LoadTextures();
                GetOpenGLSystemInfo();
                ShaderTools.SetUpShaders();

                setupStatus = SharedResourceStatus.Initialized;
            }
            catch (AccessViolationException)
            {
                // Context creation failed.
                setupStatus = SharedResourceStatus.Failed;
            }
        }
Пример #10
0
 private static CellDesc CreateHead(string text, RenderTools rt)
 {
     return(new CellDesc(text, rt)
     {
         Font = rt.FontBold
     });
 }
Пример #11
0
        private void RenderCharacterLightGradient(LightColor topColor, LightColor bottomColor)
        {
            charDifColorGLControl.MakeCurrent();
            GL.Viewport(charDifColorGLControl.ClientRectangle);

            RenderTools.DrawQuadGradient(new Vector3(topColor.R, topColor.G, topColor.B), new Vector3(bottomColor.R, bottomColor.G, bottomColor.B));

            charDifColorGLControl.SwapBuffers();
        }
Пример #12
0
        private void RenderCharacterLightColor(Vector3 topColor, Vector3 bottomColor)
        {
            charDifColorGLControl.MakeCurrent();
            GL.Viewport(charDifColorGLControl.ClientRectangle);
            SetOpenGLSettings();

            RenderTools.DrawQuadGradient(topColor.X, topColor.Y, topColor.Z, bottomColor.X, bottomColor.Y, bottomColor.Z);

            charDifColorGLControl.SwapBuffers();
        }
Пример #13
0
        private void RenderAreaLightColor()
        {
            areaColorGLControl.MakeCurrent();
            GL.Viewport(areaColorGLControl.ClientRectangle);
            SetOpenGLSettings();

            RenderTools.DrawQuadGradient(selectedAreaLight.skyR, selectedAreaLight.skyG, selectedAreaLight.skyB, selectedAreaLight.groundR, selectedAreaLight.groundG, selectedAreaLight.groundB);

            areaColorGLControl.SwapBuffers();
        }
Пример #14
0
        public static void CreateContext()
        {
            // Make a permanent context to share resources.
            GraphicsContext.ShareContexts = true;
            var control = new OpenTK.GLControl();

            control.MakeCurrent();

            RenderTools.LoadTextures();
            Runtime.OpenTKInitialized = true;
        }
Пример #15
0
        private void RenderAreaLightColor()
        {
            areaColorGLControl.MakeCurrent();
            GL.Viewport(areaColorGLControl.ClientRectangle);

            Vector3 topColor    = new Vector3(selectedAreaLight.skyR, selectedAreaLight.skyG, selectedAreaLight.skyB);
            Vector3 bottomColor = new Vector3(selectedAreaLight.groundR, selectedAreaLight.groundG, selectedAreaLight.groundB);

            RenderTools.DrawQuadGradient(topColor, bottomColor);

            areaColorGLControl.SwapBuffers();
        }
Пример #16
0
        private void RenderLightMapColor()
        {
            lightMapGLControl.MakeCurrent();
            GL.Viewport(lightMapGLControl.ClientRectangle);

            Vector3 topColor    = new Vector3(1);
            Vector3 bottomColor = new Vector3(1);

            RenderTools.DrawQuadGradient(topColor, bottomColor);

            lightMapGLControl.SwapBuffers();
        }
Пример #17
0
        public LightSetEditor()
        {
            InitializeComponent();

            InitCharLightListBox();
            InitAreaLightListBox();
            InitLightMapListBox();
            InitFogListBox();
            InitStageLightListBox();

            RenderTools.SetupOpenTkRendering();
        }
Пример #18
0
        public static Size RenderTip(TransitionDocNode nodeTran, Graphics g, Size sizeMax, bool draw)
        {
            var table = new TableDesc();

            using (RenderTools rt = new RenderTools())
            {
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Ion, nodeTran.Transition.FragmentIonName, rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Charge, nodeTran.Transition.Adduct.AdductCharge.ToString(LocalizationHelper.CurrentCulture), rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Product_m_z, string.Format(@"{0:F04}", nodeTran.Mz), rt);
                int?decoyMassShift = nodeTran.Transition.DecoyMassShift;
                if (decoyMassShift.HasValue)
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                }

                if (nodeTran.HasLoss)
                {
                    // If there is only one loss, show its full description
                    var losses = nodeTran.Losses;
                    if (losses.Losses.Count == 1)
                    {
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, losses.ToStrings()[0], rt);
                    }
                    // Otherwise, just show the total mass for multiple losses
                    // followed by individual losses
                    else
                    {
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, string.Format(@"{0:F04}", losses.Mass), rt);
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Losses, TextUtil.LineSeparate(losses.ToStrings()), rt);
                    }
                }
                if (nodeTran.HasLibInfo)
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_rank, nodeTran.LibInfo.Rank.ToString(LocalizationHelper.CurrentCulture), rt);
                    float intensity = nodeTran.LibInfo.Intensity;
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_intensity, MathEx.RoundAboveZero(intensity,
                                                                                                                       (intensity < 10 ? 1 : 0), 4).ToString(LocalizationHelper.CurrentCulture), rt);
                }
                if (nodeTran.Transition.IsCustom() && !string.IsNullOrEmpty(nodeTran.Transition.CustomIon.Formula))
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeTran.Transition.CustomIon.Formula + nodeTran.Transition.Adduct.AdductFormula.ToString(LocalizationHelper.CurrentCulture), rt);
                }

                SizeF size = table.CalcDimensions(g);
                if (draw)
                {
                    table.Draw(g);
                }

                return(new Size((int)size.Width + 2, (int)size.Height + 2));
            }
        }
Пример #19
0
        protected void DrawFrame(SpriteBatch spriteBatch)
        {
            if (Selected)
            {
                Vector2 topLeft     = WorldPosition - CameraPosition;
                Vector2 bottomRight = topLeft + new Vector2(DimensionsInCells.X * Definitions.CellSizeInPixels, DimensionsInCells.Y * Definitions.CellSizeInPixels);

                RenderTools.Line(spriteBatch, TextureManager.Textures["pixel"], topLeft, new Vector2(bottomRight.X, topLeft.Y), 1.0f, Color.White, 0.01f);
                RenderTools.Line(spriteBatch, TextureManager.Textures["pixel"], new Vector2(bottomRight.X, topLeft.Y), bottomRight, 1.0f, Color.White, 0.01f);
                RenderTools.Line(spriteBatch, TextureManager.Textures["pixel"], bottomRight, new Vector2(topLeft.X, bottomRight.Y), 1.0f, Color.White, 0.01f);
                RenderTools.Line(spriteBatch, TextureManager.Textures["pixel"], new Vector2(topLeft.X, bottomRight.Y), topLeft, 1.0f, Color.White, 0.01f);
            }
        }
Пример #20
0
        public void Render(Shader shader, Camera c)
        {
            if (!Checked)
            {
                return;
            }

            // Bones use immediate mode for drawing.
            if (Runtime.renderBones)
            {
                shader.UseProgram();
            }

            if (bonesUbo == null)
            {
                bonesUbo = new BufferObject(BufferTarget.UniformBuffer);
            }

            GL.UniformBlockBinding(shader.Id, shader.GetUniformBlockIndex("Bones"), 0);
            bonesUbo.BindBase(BufferRangeTarget.UniformBuffer, 0);

            Matrix4[] matrices = RenderBones.GetShaderMatricesNoInverse();
            Matrix4[] binds    = RenderBones.GetShaderMatrices();

            int mat4Size = 16 * 4;

            bonesUbo.SetCapacity(400 * mat4Size, BufferUsageHint.DynamicDraw);
            bonesUbo.SetSubData(matrices, 0);
            bonesUbo.SetSubData(binds, 200 * mat4Size);

            var previousRenderSettings = new RenderSettings();

            foreach (MeleeDataObjectNode n in DataObjects.Nodes)
            {
                var newRenderSettings = n.GetRenderSettings();
                GLRenderSettings.SetRenderSettings(newRenderSettings, previousRenderSettings);
                previousRenderSettings = newRenderSettings;

                n.Render(c, shader);
            }

            if (Runtime.renderBones)
            {
                GL.UseProgram(0);
                GL.PushAttrib(AttribMask.DepthBufferBit);
                GL.Disable(EnableCap.DepthTest);

                RenderTools.DrawVBN(RenderBones);
                GL.PopAttrib();
            }
        }
Пример #21
0
        private void DrawSafeAreaBoundaries()
        {
            Vector2 topLeft     = new Vector2(Definitions.Back_Buffer_Width, Definitions.Back_Buffer_Height) * Data.Profile.Settings.DisplaySafeAreaFraction;
            Vector2 bottomRight = new Vector2(Definitions.Back_Buffer_Width, Definitions.Back_Buffer_Height) - topLeft;

            topLeft     += Data.Profile.Settings.DisplaySafeAreaTopLeft;
            bottomRight += Data.Profile.Settings.DisplaySafeAreaTopLeft;

            SpriteBatch.Begin();
            RenderTools.Line(SpriteBatch, TextureManager.Textures["pixel"], topLeft, new Vector2(bottomRight.X, topLeft.Y), 1.0f, Color.White, 0.5f);
            RenderTools.Line(SpriteBatch, TextureManager.Textures["pixel"], topLeft, new Vector2(topLeft.X, bottomRight.Y), 1.0f, Color.White, 0.5f);
            RenderTools.Line(SpriteBatch, TextureManager.Textures["pixel"], bottomRight, new Vector2(bottomRight.X, topLeft.Y), 1.0f, Color.White, 0.5f);
            RenderTools.Line(SpriteBatch, TextureManager.Textures["pixel"], bottomRight, new Vector2(topLeft.X, bottomRight.Y), 1.0f, Color.White, 0.5f);
            SpriteBatch.End();
        }
Пример #22
0
        private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }

            OnMdiWindowClosed();

            RenderTools.DisposeTextures();

            //Force garbage collection.
            GC.Collect();

            // Wait for all finalizers to complete before continuing.
            GC.WaitForPendingFinalizers();
        }
Пример #23
0
        public void Render(Camera c)
        {
            if (!Checked)
            {
                return;
            }
            Shader shader = OpenTKSharedResources.shaders["Dat"];

            if (Runtime.renderType != Runtime.RenderTypes.Shaded)
            {
                shader = OpenTKSharedResources.shaders["DatDebug"];
            }
            shader.UseProgram();

            SetSharedUniforms(c, shader);

            if (bonesUbo == null)
            {
                bonesUbo = new BufferObject(BufferTarget.UniformBuffer);
            }

            bonesUbo.BindBase(BufferRangeTarget.UniformBuffer, shader.GetUniformBlockIndex("Bones"));

            bonesUbo.SetData(RenderBones.GetShaderMatricesNoInverse(), BufferUsageHint.DynamicDraw);

            Matrix4[] binds = RenderBones.GetShaderMatrices();
            if (binds.Length > 0)
            {
                GL.UniformMatrix4(GL.GetUniformLocation(shader.Id, "binds"), binds.Length, false, ref binds[0].Row0.X);
            }

            foreach (MeleeDataObjectNode n in DataObjects.Nodes)
            {
                n.Render(c, shader);
            }

            GL.UseProgram(0);
            GL.PushAttrib(AttribMask.DepthBufferBit);
            GL.Disable(EnableCap.DepthTest);

            if (Runtime.renderBones)
            {
                RenderTools.DrawVBN(RenderBones);
            }
            GL.PopAttrib();
        }
Пример #24
0
        private void RenderCharacterLightColor(Vector3 topColor, Vector3 bottomColor)
        {
            charDifColorGLControl.MakeCurrent();
            GL.Viewport(charDifColorGLControl.ClientRectangle);
            GL.ClearColor(Color.White);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);

            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            RenderTools.DrawQuadGradient(topColor.X, topColor.Y, topColor.Z, bottomColor.X, bottomColor.Y, bottomColor.Z);

            charDifColorGLControl.SwapBuffers();
        }
Пример #25
0
        private void RenderAreaLightColor()
        {
            areaColorGLControl.MakeCurrent();
            GL.Viewport(areaColorGLControl.ClientRectangle);
            GL.ClearColor(Color.White);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);

            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            RenderTools.DrawQuadGradient(selectedAreaLight.skyR, selectedAreaLight.skyG, selectedAreaLight.skyB, selectedAreaLight.groundR, selectedAreaLight.groundG, selectedAreaLight.groundB);

            areaColorGLControl.SwapBuffers();
        }
Пример #26
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _controller = new ImGuiController(Width, Height);

            //Set the current theme instance
            ColorTheme.UpdateTheme(new DarkTheme());

            //Disable the docking buttons
            ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;

            //Enable docking support
            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            //Enable up/down key navigation
            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard;
            //Only move via the title bar instead of the whole window
            ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true;

            //Init rendering data
            TimelineWindow.OnLoad();
            Pipeline.InitBuffers();

            camera_speed = Pipeline._camera.KeyMoveSpeed;

            InitDock();
            LoadRecentList();

            RenderTools.Init();

            ReloadGlobalShaders();

            var Thread2 = new Thread((ThreadStart)(() =>
            {
                //Init plugins
                Toolbox.Core.FileManager.GetFileFormats();
            }));

            Thread2.Start();

            ForceFocused = true;
        }
Пример #27
0
        private void diffuseCubemapPathTBB_Click(object sender, EventArgs e)
        {
            OpenFileDialog sfd = new OpenFileDialog();

            sfd.Filter = "DDS |*.dds;";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                if (IsValidCubeMap(sfd.FileName))
                {
                    diffuseCubemapPathTB.Text      = System.IO.Path.GetFileName(sfd.FileName);
                    Runtime.PBR.DiffuseCubeMapPath = sfd.FileName;
                    RenderTools.ResetDiffuseCubeMap();
                    UpdateViewportSettings();
                }
                else
                {
                    MessageBox.Show("Invalid cube map file. Make sure it is a DDS with a cube map.");
                }
            }
        }
Пример #28
0
        public Size RenderTip(Graphics g, Size sizeMax, bool draw)
        {
            var table = new TableDesc();

            using (var rt = new RenderTools())
            {
                table.AddDetailRow(Resources.PeptideRegressionTipProvider_RenderTip_Peptide, DocNode.ModifiedSequence, rt);

                table.AddDetailRow(XLabel, Point.X.ToString(CultureInfo.CurrentCulture), rt);
                table.AddDetailRow(YLabel, Point.Y.ToString(CultureInfo.CurrentCulture), rt);

                var size = table.CalcDimensions(g);

                if (draw)
                {
                    table.Draw(g);
                }

                return(new Size((int)size.Width + 2, (int)size.Height + 2));
            }
        }
Пример #29
0
        private void DrawBoundingBoxes()
        {
            foreach (FMDL mdl in models)
            {
                foreach (FSHP m in mdl.shapes)
                {
                    if (m.IsSelected)
                    {
                        GL.Color4(Color.GhostWhite);
                    }
                    else
                    {
                        GL.Color4(Color.OrangeRed);
                    }

                    foreach (FSHP.BoundingBox box in m.boundingBoxes)
                    {
                        RenderTools.DrawRectangularPrism(box.Center, box.Extend.X, box.Extend.Y, box.Extend.Z, true);
                    }
                }
            }
        }
Пример #30
0
        /// <summary>
        /// Called when task calls <see cref="SceneRenderTask.CollectDrawCalls" /> event.
        /// </summary>
        /// <param name="renderContext">The rendering context.</param>
        public virtual void OnDraw(ref RenderContext renderContext)
        {
            if (_highlightMaterial == null ||
                (_highlights.Count == 0 && _highlightTriangles.Count == 0) ||
                renderContext.View.Pass == DrawPass.Depth
                )
            {
                return;
            }
            Profiler.BeginEvent("ViewportDebugDrawData.OnDraw");

            Matrix world;

            for (var i = 0; i < _highlights.Count; i++)
            {
                HighlightData highlight = _highlights[i];
                if (highlight.Target is StaticModel staticModel)
                {
                    var model = staticModel.Model;
                    if (model == null)
                    {
                        continue;
                    }
                    staticModel.Transform.GetWorld(out world);
                    var bounds = BoundingSphere.FromBox(staticModel.Box);

                    // Pick a proper LOD
                    int lodIndex = RenderTools.ComputeModelLOD(model, ref bounds.Center, bounds.Radius, ref renderContext);
                    var lods     = model.LODs;
                    if (lods == null || lods.Length < lodIndex || lodIndex < 0)
                    {
                        continue;
                    }
                    var lod = lods[lodIndex];

                    // Draw meshes
                    for (int meshIndex = 0; meshIndex < lod.Meshes.Length; meshIndex++)
                    {
                        if (lod.Meshes[meshIndex].MaterialSlotIndex == highlight.EntryIndex)
                        {
                            lod.Meshes[meshIndex].Draw(ref renderContext, _highlightMaterial, ref world);
                        }
                    }
                }
            }

            if (_highlightTriangles.Count > 0)
            {
                var mesh = _highlightTrianglesModel.LODs[0].Meshes[0];
                if (!Utils.ArraysEqual(_highlightTrianglesSet, _highlightTriangles))
                {
                    _highlightIndicesSet = new int[_highlightTriangles.Count];
                    for (int i = 0; i < _highlightIndicesSet.Length; i++)
                    {
                        _highlightIndicesSet[i] = i;
                    }
                    _highlightTrianglesSet = _highlightTriangles.ToArray();
                    mesh.UpdateMesh(_highlightTrianglesSet, _highlightIndicesSet);
                }

                world = Matrix.Identity;
                mesh.Draw(ref renderContext, _highlightMaterial, ref world);
            }

            Profiler.EndEvent();
        }
Пример #31
0
        public static Size RenderTip(PeptideDocNode nodePep,
            TransitionGroupDocNode nodeGroup,
            TransitionDocNode nodeTranSelected,
            SrmSettings settings,
            Graphics g,
            Size sizeMax,
            bool draw)
        {
            if (nodeGroup.TransitionGroup.IsCustomIon)
            {
                var customTable = new TableDesc();
                using (RenderTools rt = new RenderTools())
                {
                    customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodeGroup.CustomIon.Name, rt);
                    customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge,
                        nodeGroup.TransitionGroup.PrecursorCharge.ToString(LocalizationHelper.CurrentCulture), rt);
                    customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz,
                        string.Format("{0:F04}", nodeGroup.PrecursorMz), rt); // Not L10N
                    if (nodeGroup.CustomIon.Formula != null)
                    {
                        customTable.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula,
                            nodeGroup.CustomIon.Formula, rt);
                    }
                    SizeF size = customTable.CalcDimensions(g);
                    customTable.Draw(g);
                    return new Size((int) size.Width + 2, (int) size.Height + 2);
                }
            }
            ExplicitMods mods = (nodePep != null ? nodePep.ExplicitMods : null);
            IEnumerable<DocNode> choices = GetChoices(nodeGroup, settings, mods, true).ToArray();
            HashSet<DocNode> chosen = new HashSet<DocNode>(nodeGroup.Children);

            // Make sure all chosen peptides get listed
            HashSet<DocNode> setChoices = new HashSet<DocNode>(choices);
            setChoices.UnionWith(chosen);
            choices = setChoices.ToArray();

            Transition tranSelected = (nodeTranSelected != null ? nodeTranSelected.Transition : null);

            IFragmentMassCalc calc = settings.GetFragmentCalc(nodeGroup.TransitionGroup.LabelType, mods);
            string aa = nodeGroup.TransitionGroup.Peptide.Sequence;  // We handled custom ions above, and returned
            double[,] masses = calc.GetFragmentIonMasses(aa);

            var filter = settings.TransitionSettings.Filter;

            // Get charges and type pairs, making sure all chosen charges are included
            HashSet<int> setCharges = new HashSet<int>(filter.ProductCharges.Where(charge =>
                Math.Abs(charge) <= Math.Abs(nodeGroup.TransitionGroup.PrecursorCharge) &&
                Math.Sign(charge) == Math.Sign(nodeGroup.TransitionGroup.PrecursorCharge)));
            HashSet<IonType> setTypes = new HashSet<IonType>(filter.IonTypes);
            foreach (TransitionDocNode nodTran in chosen)
            {
                var type = nodTran.Transition.IonType;
                if (type == IonType.precursor)
                    continue;
                setCharges.Add(nodTran.Transition.Charge);
                setTypes.Add(type);
            }
            setTypes.Remove(IonType.precursor);
            int[] charges = setCharges.ToArray();
            Array.Sort(charges);
            IonType[] types = Transition.GetTypePairs(setTypes);

            var tableDetails = new TableDesc();
            var table = new TableDesc();

            using (RenderTools rt = new RenderTools())
            {
                string seqModified = GetModifiedSequence(nodePep, nodeGroup, settings);
                if (!Equals(seqModified, nodeGroup.TransitionGroup.Peptide.Sequence))
                    tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Modified, seqModified, rt);

                var precursorCharge = nodeGroup.TransitionGroup.PrecursorCharge;
                var precursorMz = nodeGroup.PrecursorMz;
                tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge,
                                          precursorCharge.ToString(LocalizationHelper.CurrentCulture), rt);
                tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz,
                                          string.Format("{0:F04}", precursorMz), rt); // Not L10N
                tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mh,
                                          string.Format("{0:F04}", nodeGroup.GetPrecursorIonMass()), // Not L10N
                                          rt);
                int? decoyMassShift = nodeGroup.TransitionGroup.DecoyMassShift;
                if (decoyMassShift.HasValue)
                {
                    tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Decoy_Mass_Shift,
                                              decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                }
                if (nodeGroup.HasLibInfo)
                {
                    foreach (KeyValuePair<PeptideRankId, string> pair in nodeGroup.LibInfo.RankValues)
                        tableDetails.AddDetailRow(pair.Key.Label, pair.Value, rt);
                }

                if (charges.Length > 0 && types.Length > 0)
                {
                    var headers = new RowDesc
                                  {
                                      CreateHead("#", rt), // Not L10N
                                      CreateHead("AA", rt), // Not L10N
                                      CreateHead("#", rt) // Not L10N
                                  };
                    foreach (int charge in charges)
                    {
                        string plusSub = Transition.GetChargeIndicator(charge);
                        foreach (IonType type in types)
                        {
                            CellDesc cell = CreateHead(type.ToString().ToLower() + plusSub, rt);
                            if (Transition.IsNTerminal(type))
                                headers.Insert(0, cell);
                            else
                                headers.Add(cell);
                        }
                    }
                    table.Add(headers);

                    int len = aa.Length;
                    for (int i = 0; i < len; i++)
                    {
                        CellDesc cellAA = CreateRowLabel(aa.Substring(i, 1), rt);
                        cellAA.Align = StringAlignment.Center;

                        var row = new RowDesc
                                  {
                                      CreateRowLabel(i == len - 1 ? string.Empty : (i + 1).ToString(CultureInfo.InvariantCulture), rt),
                                      cellAA,
                                      CreateRowLabel(i == 0 ? string.Empty : (len - i).ToString(CultureInfo.InvariantCulture), rt)
                                  };

                        foreach (int charge in charges)
                        {
                            foreach (IonType type in types)
                            {
                                CellDesc cell;
                                if (Transition.IsNTerminal(type))
                                {
                                    if (i == len - 1)
                                        cell = CreateData(string.Empty, rt);
                                    else
                                    {
                                        double massH = masses[(int)type, i];
                                        cell = CreateIon(type, i + 1, massH, charge, choices, chosen, tranSelected, rt);
                                    }
                                    row.Insert(0, cell);
                                }
                                else
                                {
                                    if (i == 0)
                                        cell = CreateData(string.Empty, rt);
                                    else
                                    {
                                        double massH = masses[(int)type, i - 1];
                                        cell = CreateIon(type, len - i, massH, charge, choices, chosen, tranSelected, rt);
                                    }
                                    row.Add(cell);
                                }
                            }
                        }
                        table.Add(row);
                    }
                }

                SizeF sizeDetails = tableDetails.CalcDimensions(g);
                sizeDetails.Height += TableDesc.TABLE_SPACING;    // Spacing between details and fragments
                SizeF size = table.CalcDimensions(g);
                if (draw)
                {
                    tableDetails.Draw(g);
                    g.TranslateTransform(0, sizeDetails.Height);
                    table.Draw(g);
                    g.TranslateTransform(0, -sizeDetails.Height);
                }

                int width = (int) Math.Round(Math.Max(sizeDetails.Width, size.Width));
                int height = (int) Math.Round(sizeDetails.Height + size.Height);
                return new Size(width + 2, height + 2);
            }
        }
Пример #32
0
        private static CellDesc CreateIon(IonType type, int ordinal, double massH, int charge,
            IEnumerable<DocNode> choices, ICollection<DocNode> chosen, Transition tranSelected,
            RenderTools rt)
        {
            double mz = SequenceMassCalc.GetMZ(massH, charge);
            CellDesc cell = CreateData(string.Format("{0:F02}", mz), rt); // Not L10N

            foreach (TransitionDocNode nodeTran in choices)
            {
                Transition tran = nodeTran.Transition;
                if (tran.IonType == type &&
                    tran.Ordinal == ordinal &&
                    tran.Charge == charge)
                {
                    cell.Font = rt.FontBold;
                    if (Equals(tran, tranSelected))
                    {
                        cell.Brush = rt.BrushSelected; // Stop after selected
                        break;
                    }
                    if (!chosen.Contains(nodeTran))
                        cell.Brush = rt.BrushChoice;  // Keep looking
                    else
                    {
                        cell.Brush = rt.BrushChosen;  // Stop after chosen
                        break;
                    }
                }
            }

            return cell;
        }
Пример #33
0
 private static CellDesc CreateHead(string text, RenderTools rt)
 {
     return new CellDesc(text, rt) { Font = rt.FontBold };
 }
Пример #34
0
 private static CellDesc CreateRowLabel(string text, RenderTools rt)
 {
     return new CellDesc(text, rt) { Align = StringAlignment.Far };
 }
Пример #35
0
        public override Size RenderTip(Graphics g, Size sizeMax, bool draw)
        {
            var sizeInitial = base.RenderTip(g, sizeMax, draw);
            if (ShowAnnotationTipOnly)
                return sizeInitial;
            g.TranslateTransform(0, sizeInitial.Height);
            FastaSequence fastaSeq = DocNode.Id as FastaSequence;

            var tableDetails = new TableDesc();
            using (RenderTools rt = new RenderTools())
            {
                SizeF sizeX80 = g.MeasureString(X80, rt.FontNormal);
                float widthLine = sizeX80.Width;
                float heightLine = sizeX80.Height;
                float heightMax = sizeMax.Height;
                tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Name, DocNode.Name, rt);
                // If current name isn't the original, show that.
                if (DocNode.PeptideGroup.Name != null && !Equals(DocNode.Name, DocNode.PeptideGroup.Name))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Name, DocNode.OriginalName, rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Accession))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Accession, DocNode.ProteinMetadata.Accession, rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.PreferredName))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Preferred_Name, DocNode.ProteinMetadata.PreferredName, rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Gene))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Gene, DocNode.ProteinMetadata.Gene, rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Species))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Species, DocNode.ProteinMetadata.Species, rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.DisplaySearchHistory()))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Searched, DocNode.ProteinMetadata.DisplaySearchHistory(), rt);
                if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Description))
                    tableDetails.AddDetailRowLineWrap(g,Resources.PeptideGroupTreeNode_RenderTip_Description, DocNode.ProteinMetadata.Description, rt);
                if (DocNode.PeptideGroup.Description != null && !Equals(DocNode.Description, DocNode.PeptideGroup.Description))
                    tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Description, DocNode.OriginalDescription, rt);
                SizeF sizeDetails = tableDetails.CalcDimensions(g);
                sizeDetails.Height += TableDesc.TABLE_SPACING;    // Spacing between details and fragments
                float heightTotal = sizeDetails.Height;
                widthLine = Math.Max(widthLine, sizeDetails.Width);

                if (draw)
                {
                    tableDetails.Draw(g);
                }

                if (fastaSeq != null)
                {
                    IList<DocNode> peptidesChoices = GetChoices(true).ToArray();
                    HashSet<DocNode> peptidesChosen = new HashSet<DocNode>(Chosen);

                    // Make sure all chosen peptides get listed
                    HashSet<DocNode> setChoices = new HashSet<DocNode>(peptidesChoices);
                    setChoices.UnionWith(peptidesChosen);
                    var arrayChoices = setChoices.ToArray();
                    Array.Sort(arrayChoices, (choice1, choice2) =>
                        PeptideFromChoice(choice1).Order - PeptideFromChoice(choice2).Order);
                    peptidesChoices = arrayChoices;

                    // Get the selected peptide, if there is one
                    PeptideTreeNode nodePepTree = SequenceTree.GetNodeOfType<PeptideTreeNode>();
                    Peptide peptideSelected = (nodePepTree != null ? nodePepTree.DocNode.Peptide : null);

                    int i = 0;
                    string aa = fastaSeq.Sequence;
                    const bool peptideList = false;
                    while (i < aa.Length)
                    {
                        // If this is not the last possible line, just render it.
                        if (heightTotal + heightLine * 2 <= heightMax)
                        {
                            i = RenderAALine(aa, peptideList, i, false, draw,
                                peptidesChoices, peptidesChosen, peptideSelected,
                                g, rt, heightTotal, widthLine);
                            heightTotal += heightLine;
                        }
                            // If not drawing, then this is the last possible line, and
                            // it will have content.
                        else if (!draw)
                        {
                            heightTotal += heightLine;
                            break;
                        }
                            // Otherwise, measure first, and then re-render, with an elipsis
                            // if the full sequence cannot be shown.
                        else
                        {
                            RenderAALine(aa, peptideList, i, false, false,
                                peptidesChoices, peptidesChosen, peptideSelected,
                                g, rt, heightTotal, widthLine);
                            RenderAALine(aa, peptideList, i, i < aa.Length, true,
                                peptidesChoices, peptidesChosen, peptideSelected,
                                g, rt, heightTotal, widthLine);
                            heightTotal += heightLine;
                            break;
                        }
                    }
                }
                return TipSize(Math.Max(widthLine, sizeInitial.Width), heightTotal + sizeInitial.Height);
            }
        }
Пример #36
0
        private static int RenderAALine(string aa, bool peptideList, int start, bool elipsis, bool draw,
            IEnumerable<DocNode> peptidesChoices, ICollection<DocNode> peptidesChosen, Peptide peptideSelected,
            Graphics g, RenderTools rt, float height, float width)
        {
            IEnumerator<DocNode> peptides = peptidesChoices.GetEnumerator();
            DocNode choice = peptides.MoveNext() ? peptides.Current : null;
            bool chosen = peptidesChosen.Contains(choice);
            Peptide peptide = PeptideFromChoice(choice);

            if (elipsis)
            {
                SizeF sizeElipsis = g.MeasureString(" ...", rt.FontNormal); // Not L10N
                width -= sizeElipsis.Width;
            }

            float widthTotal = 0;
            PointF ptDraw = new PointF(widthTotal, height);
            if (peptideList && aa[start] == 'X') // Not L10N: For amino acid comparison
                start++;
            for (int i = start; i < aa.Length; i++)
            {
                Font font = rt.FontNormal;
                Brush brush = rt.BrushNormal;
                if (peptide != null)
                {
                    while (peptide != null && i >= peptide.End)
                    {
                        choice = peptides.MoveNext() ? peptides.Current : null;
                        chosen = peptidesChosen.Contains(choice);
                        peptide = PeptideFromChoice(choice);
                    }
                    if (peptide != null && i >= peptide.Begin)
                    {
                        font = rt.FontBold;
                        if (Equals(peptide, peptideSelected))
                            brush = rt.BrushSelected;
                        else
                            brush = (chosen ? rt.BrushChosen : rt.BrushChoice);
                    }
                }
                if (peptideList && aa[i] == 'X') // Not L10N: For amino acid comparison
                    return i + 1;
                string s = aa.Substring(i, 1);
                SizeF sizeAa = g.MeasureString(s, font);
                widthTotal += sizeAa.Width;
                if (widthTotal > width)
                {
                    if (elipsis && draw)
                        g.DrawString(" ...", rt.FontNormal, rt.BrushNormal, ptDraw); // Not L10N
                    return i;
                }
                widthTotal -= 4;    // Remove MeasureString padding.
                if (draw)
                {
                    g.DrawString(s, font, brush, ptDraw);
                    ptDraw.X = widthTotal;
                }
            }

            return aa.Length;
        }
Пример #37
0
        public static Size RenderTip(TransitionDocNode nodeTran, Graphics g, Size sizeMax, bool draw)
        {
            var table = new TableDesc();
            using (RenderTools rt = new RenderTools())
            {
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Ion, nodeTran.Transition.FragmentIonName, rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Charge, nodeTran.Transition.Charge.ToString(LocalizationHelper.CurrentCulture), rt);
                table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Product_m_z, string.Format("{0:F04}", nodeTran.Mz), rt); // Not L10N
                int? decoyMassShift = nodeTran.Transition.DecoyMassShift;
                if (decoyMassShift.HasValue)
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt);

                if (nodeTran.HasLoss)
                {
                    // If there is only one loss, show its full description
                    var losses = nodeTran.Losses;
                    if (losses.Losses.Count == 1)
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, losses.ToStrings()[0], rt);
                    // Otherwise, just show the total mass for multiple losses
                    // followed by individual losses
                    else
                    {
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, string.Format("{0:F04}", losses.Mass), rt); // Not L10N
                        table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Losses, TextUtil.LineSeparate(losses.ToStrings()), rt);
                    }
                }
                if (nodeTran.HasLibInfo)
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_rank, nodeTran.LibInfo.Rank.ToString(LocalizationHelper.CurrentCulture), rt);
                    float intensity = nodeTran.LibInfo.Intensity;
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_intensity, MathEx.RoundAboveZero(intensity,
                        (intensity < 10 ? 1 : 0), 4).ToString(LocalizationHelper.CurrentCulture), rt);
                }
                if (nodeTran.Transition.IsCustom() && !string.IsNullOrEmpty(nodeTran.Transition.CustomIon.Formula))
                {
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeTran.Transition.CustomIon.Formula, rt);
                }

                SizeF size = table.CalcDimensions(g);
                if (draw)
                    table.Draw(g);

                return new Size((int)size.Width + 2, (int)size.Height + 2);
            }
        }
Пример #38
0
        public static Size RenderTip(PeptideDocNode nodePep,
            TransitionDocNode nodeTranSelected,
            SrmSettings settings,
            Graphics g,
            Size sizeMax,
            bool draw)
        {
            var table = new TableDesc();
            using (RenderTools rt = new RenderTools())
            {
                Peptide peptide = nodePep.Peptide;
                SizeF size;
                if (peptide.IsCustomIon)
                {
                    table.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodePep.CustomIon.Name, rt);
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodePep.CustomIon.Formula, rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Neutral_Mass,
                        nodePep.CustomIon.GetMass(settings.TransitionSettings.Prediction.PrecursorMassType).ToString(LocalizationHelper.CurrentCulture), rt);
                    size = table.CalcDimensions(g);
                    table.Draw(g);
                    return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
                }

                if (nodePep.Children.Count > 1)
                {
                    foreach (var typedModSequence in GetTypedModifiedSequences(nodePep, settings))
                        table.AddDetailRow(typedModSequence.Key.Title, typedModSequence.Value, rt);
                }

                if (peptide.Begin.HasValue)
                {
                    // Add a spacing row, if anything was added
                    if (table.Count > 0)
                        table.AddDetailRow(" ", " ", rt); // Not L10N
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Previous, peptide.PrevAA.ToString(CultureInfo.InvariantCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_First, peptide.Begin.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Last, ((peptide.End ?? 1) - 1).ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Next, peptide.NextAA.ToString(CultureInfo.InvariantCulture), rt);
                }
                if (nodePep.Rank.HasValue)
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Rank, nodePep.Rank.Value.ToString(LocalizationHelper.CurrentCulture), rt);

                size = table.CalcDimensions(g);
                if (draw)
                    table.Draw(g);

                // Render group tip, if there is only one, and this node is collapsed
                if (nodePep.Children.Count == 1)
                {
                    var nodeGroup = (TransitionGroupDocNode)nodePep.Children[0];
                    if (size.Height > 0)
                        size.Height += TableDesc.TABLE_SPACING;
                    if (draw)
                        g.TranslateTransform(0, size.Height);
                    Size sizeMaxGroup = new Size(sizeMax.Width, sizeMax.Height - (int)size.Height);
                    SizeF sizeGroup = TransitionGroupTreeNode.RenderTip(nodePep, nodeGroup,
                        nodeTranSelected, settings, g, sizeMaxGroup, draw);
                    if (draw)
                        g.TranslateTransform(0, -size.Height);

                    size.Width = Math.Max(size.Width, sizeGroup.Width);
                    size.Height += sizeGroup.Height;
                }

                return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
            }
        }