⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hit_matrix_graph.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: hit_matrix_graph.hpp,v $ * PRODUCTION Revision 1000.2  2004/04/12 18:16:46  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4 * PRODUCTION * =========================================================================== */#ifndef __GUI_WIDGETS_HIT_MATRIX___HIT_MATRIX_GRAPH__HPP#define __GUI_WIDGETS_HIT_MATRIX___HIT_MATRIX_GRAPH__HPP/*  $Id: hit_matrix_graph.hpp,v 1000.2 2004/04/12 18:16:46 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Andrey Yazhuk * * File Description: * */#include <corelib/ncbistl.hpp>#include <gui/opengl/glcolor.hpp>#include <gui/opengl/glpane.hpp>#include <gui/widgets/gl/ievent_handler.hpp>#include <gui/widgets/hit_matrix/hit_data_adapter.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::objects);/// CHitElemGlyph is a simple graphical object representing a Hit Element.///class CHitElemGlyph{public:        enum    ERenderingPass    {        eHitElemLines,        eConnectionLines,        eProjLines,        eEndPoints,        eOther    };public:    CHitElemGlyph();    CHitElemGlyph(const CHitElemDataAdapter& hit_elem);    const CHitElemDataAdapter&  GetHitElem()  const {   return m_HitElem;    }    inline void     SetColorIndex(int index )       {   m_ColorIndex = index;   }    inline int      GetColorIndex()  const   {   return m_ColorIndex;    }        inline void     SetSelected(bool b_set)    {   m_bSelected = b_set;    }    inline bool     IsSelected()    const   {   return m_bSelected; }    void    GetModelRect(TModelRect& rc) const;    void    Render(CGlPane& pane, ERenderingPass what);    void    StartVertex();    void    EndVertex();        /// return shortest distance in pixels  from the given point in viewport    /// to the graphical representation of the hit on the screen    double  GetDistPixels(CGlPane& pane, const TVPPoint& pt) const;    /// returns true if hit is contained by given rectangle (in VP coordinates)    bool    InRect(CGlPane& pane, const TVPRect& rc) const;protected:   CHitElemDataAdapter  m_HitElem;   int  m_ColorIndex;   bool m_bSelected;};/// CHitGlyph is a simple graphical object representing a Hit as a set of/// corresponding Hit Elements.///class CHitGlyph{public:    typedef     vector<CHitElemGlyph>   TElemGlyphCont;    /// c'tor creates child CHitElemGlyph-s    CHitGlyph(const CHitDataAdapter* p_hit);    inline  const CHitDataAdapter&    GetHit()        {        return *m_pHit;    }    TElemGlyphCont& GetElems();    void     SetColorIndex(int index);    void    Render(CGlPane& pane, CHitElemGlyph::ERenderingPass what);protected:    const   CHitDataAdapter* m_pHit;    TElemGlyphCont  m_Elems;};class IHitMatrixGraphHost{public:    virtual ~IHitMatrixGraphHost()  {};    virtual void     HMGH_Redraw(void) = 0;    virtual TVPUnit  HMGH_GetVPPosByY(int y) const = 0;};///   CHitMatrixGraph///  class CHitMatrixGraph : public IEventHandler{public:    typedef vector<CHitGlyph*>      THitGlyphVector;    typedef set<CHitElemGlyph*>     TElemGlyphSet;        CHitMatrixGraph();    ~CHitMatrixGraph();    void    DeleteGlyphs();    void    CreateGlyph(const CHitDataAdapter* p_hit_elem);        const   THitGlyphVector&    GetClyphs() const   {   return m_vGlyphs;   }    const   TElemGlyphSet&      GetSelectedGlyphs() const   {   return m_SelGlyphs; }        void    Render(CGlPane& pane);        // Score    void    CreateColorTable(int size);    void    AssignColorsByScore(CConstRef<CObject_id> score_id);    void    SetHost(IHitMatrixGraphHost* pHost);    /// IEventHandler implementation    virtual int handle(CGUIEvent& event, CGlPane& pane);protected:    void    x_RenderHits(CGlPane& pane);    void    x_RenderSelection(CGlPane& pane);    void    x_RenderPath(CGlPane& pane);    void    x_RenderEventHandler(CGlPane& pane);    inline const CGlColor&    x_GetColorByIndex(int index)    {        _ASSERT(index < (int) m_vColors.size());        return index < 0 ? m_DefaultColor : m_vColors[index];    }    /// user event handlers - translate event to signals    int x_OnMousePush(CGUIEvent& event);    int x_OnMouseDrag(CGUIEvent& event);    int x_OnMouseRelease(CGUIEvent& event);    int x_OnMouseMove(void);    int x_OnKeyDown(void);    int x_OnKeyUp(void);    /// event handling state    enum    EState {        eIdle,        eSelPoint, /// selecting a single glyph by point        eSelRect   /// selecting multiple glyphs by rectangle    };        void    x_OnSelectCursor(void);    bool    x_SelectByPoint( bool b_inc);    void    x_SelectByRect( bool b_inc);   protected:    typedef list<CHitElemGlyph*>    TPath;    typedef list<TPath>             TPathCont;        THitGlyphVector     m_vGlyphs; /// primary storage for glyphs    TElemGlyphSet       m_SelGlyphs; /// set of selected Glyphs (hit elements)    TPathCont           m_Paths;        /// rendering state        int m_CurrColorIndex;    vector<CGlColor>    m_vColors;    CGlColor            m_DefaultColor;    CGlColor            m_SelColor;    CGlColor            m_HighLightColor;    CGlColor            m_PathColor;    CGlColor            m_ProjLinesColor;    CGlColor            m_ProjBackColor;    /// event handling    IHitMatrixGraphHost *m_pHost;    CGlPane     *m_pPane;    EState      m_State;    TVPPoint    m_StartPoint;    TVPPoint    m_DragPoint;    Fl_Cursor   m_Cursor;};END_NCBI_SCOPE/* * =========================================================================== * $Log: hit_matrix_graph.hpp,v $ * Revision 1000.2  2004/04/12 18:16:46  gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4 * * Revision 1.4  2003/12/05 17:43:54  yazhuk * Added function for retrieving selection, modified AssignColorByScore() * * Revision 1.3  2003/12/01 17:08:20  yazhuk * Redesigned classes in accordance with the new data model. * * Revision 1.2  2003/11/18 17:56:06  yazhuk * Fixed GCC warnings * * Revision 1.1  2003/11/17 21:00:14  yazhuk * Initial revision * * =========================================================================== */#endif  // __GUI_WIDGETS_HIT_MATRIX___HIT_MATRIX_GRAPH__HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -