align_row.cpp

来自「ncbi源码」· C++ 代码 · 共 1,105 行 · 第 1/3 页

CPP
1,105
字号
    m_pStyle->GetTextFont().TextOut(x, rc_vp.Top() - m_BaseHeight + 1, w,                            m_BaseHeight, m_Text.c_str(), FL_ALIGN_LEFT);    // draw focus frame    if(b_wid_focused  &&  (state & fItemFocused) != 0) {        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);        glBegin(GL_LINE_LOOP);            glVertex2d(rc_vp.Left(), rc_vp.Bottom());            glVertex2d(rc_vp.Right(), rc_vp.Bottom());            glVertex2d(rc_vp.Right(), rc_vp.Top());            glVertex2d(rc_vp.Left(), rc_vp.Top());        glEnd();    }    pane.Close();}void    CAlnVecRow::x_RenderGraph(CGlPane& pane, CConstRef<CAlnVec::CAlnChunkVec> chunks){    if(m_bExpanded) {        if( m_pGraph  && m_pGraph->IsCreated())   {            TModelUnit offset_y = pane.GetOffsetY();            int y = (int) (pane.GetVisibleRect().Top() - offset_y) + m_BaseHeight;            int h = m_Height - m_BaseHeight;            m_pGraph->Render(pane, y, h, chunks);        } else _ASSERT(false);    }}const static int kButtonOffset = 2;const static int kButtonSize = 11;const static int kButtonSignSize = 7;/// Returns buttons bounds in screen coordinates, "pane" parameter specifies CGlPane/// corresponding to "Icons" columnTVPRect CAlnVecRow::x_GetButtonRect(CGlPane& pane, EButtons btn){    const TVPRect& rc_vp = pane.GetViewport();    int btn_space = kButtonSize + kButtonOffset;    int x = rc_vp.Left() + kButtonOffset + ((int) btn) * btn_space;    int y_top = rc_vp.Top() - (m_BaseHeight - kButtonSize) / 2;// kButtonOffset;    TVPRect rc(x, y_top - kButtonSize + 1, x + kButtonSize - 1, y_top);    return rc;}void    CAlnVecRow::x_RenderIcons(CGlPane& pane){    _ASSERT(m_pStyle);    pane.OpenPixels();        glColorC(m_pStyle->GetTextColor());    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);    // draw "Expand" button    TVPRect rc_btn = x_GetButtonRect(pane, eExpand);    glRectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());    if(IsExpandable())    {        int offset = (kButtonSize - kButtonSignSize) / 2;        TVPPoint pt_c = rc_btn.CenterPoint();        // render "+" or "-"        glBegin(GL_LINES);            glVertex2d(rc_btn.Left() + offset, pt_c.Y());            glVertex2d(rc_btn.Left() + offset + kButtonSignSize, pt_c.Y());            if(! m_bExpanded)   {                glVertex2d(pt_c.X(), rc_btn.Bottom() + offset);                glVertex2d(pt_c.X(), rc_btn.Bottom() + offset + kButtonSignSize);            }        glEnd();    }    if(m_pGraph  &&  m_pGraph->HasData())   {   // draw "Graph" button        rc_btn = x_GetButtonRect(pane, eSetupGraphs);        glRectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());        m_pStyle->GetTextFont().TextOut(rc_btn.Left() + 1, rc_btn.Bottom() + 1,                                        kButtonSize - 2, kButtonSize - 2, "...", FL_ALIGN_CENTER);    }    // draw strand marker    rc_btn = x_GetButtonRect(pane, eStrandMarker);    int y_c = rc_btn.CenterPoint().Y();    int half = rc_btn.Height() / 2;    int x1 = rc_btn.Left();    int x2 = rc_btn.Right();    if(m_Handle.IsNegativeStrand()) {        swap(x1, x2);    }    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);    glColor3d(0.0, 0.5, 0.0);    glBegin(GL_POLYGON);        glVertex2d(x1, y_c - half);        glVertex2d(x2, y_c);        glVertex2d(x1, y_c + half);    glEnd();    pane.Close();}void    CAlnVecRow::x_RenderStartPos(CGlPane& pane){    const TModelRect& rc_v = pane.GetVisibleRect();    int aln_pos = (int) floor(rc_v.Left());    x_RenderAlnPos(pane, aln_pos, CAlnVec::eRight);}void    CAlnVecRow::x_RenderEndPos(CGlPane& pane){    const TModelRect& rc_v = pane.GetVisibleRect();    int aln_pos = -1 + (int) ceil(rc_v.Right());    x_RenderAlnPos(pane, aln_pos, CAlnVec::eLeft);}void    CAlnVecRow::x_RenderSeqEnd(CGlPane& pane){    TSeqPos pos = m_Handle.GetBioseqHandle().GetBioseqLength() -1;    x_RenderPos(pane, pos, "");}// generates text label for given position in alignmentvoid    CAlnVecRow::x_RenderAlnPos(CGlPane& pane, TSeqPos aln_pos, CAlnVec::ESearchDirection dir){    char *s_marker = "";    int seq_pos = m_Handle.GetSeqPosFromAlnPos(aln_pos);    if(seq_pos == -1)   {        seq_pos = m_Handle.GetSeqPosFromAlnPos(aln_pos, dir);        switch(dir) {        case CAlnVec::eRight:  s_marker = ">>  "; break;        case CAlnVec::eLeft:  s_marker = "<<  "; break;        default: break;        }    }    x_RenderPos(pane, seq_pos, s_marker);}void    CAlnVecRow::x_RenderPos(CGlPane& pane, TSeqPos pos, const char* s_marker){    _ASSERT(m_pStyle);    pane.OpenPixels();    const TVPRect& rc_vp = pane.GetViewport();    // draw box    glColorC(m_pStyle->GetFrameColor());    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);    glRectd(rc_vp.Left(), rc_vp.Bottom(), rc_vp.Right(), rc_vp.Top() + 1);    string s_num = CTextUtils::FormatSeparatedNumber(pos + 1);    string s_label(s_marker);    s_label += s_num;    glColorC(m_pStyle->GetTextColor());    int x = rc_vp.Left() + kTextOffsetX;    int w = rc_vp.Width() - kTextOffsetX * 3;    m_pStyle->GetTextFont().TextOut(x, rc_vp.Top() - m_BaseHeight + 1, w, m_BaseHeight,                            s_label.c_str(), FL_ALIGN_RIGHT);    pane.Close();}void    CAlnVecRow::x_RenderEmptyBox(CGlPane& pane){    pane.OpenPixels();    glColorC(m_pStyle->GetFrameColor());    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);    TVPRect rc_vp = pane.GetViewport();    glRectd(rc_vp.Left(), rc_vp.Bottom(), rc_vp.Right(), rc_vp.Top());    pane.Close();}bool    CAlnVecRow::IsExpandable() const{    return m_pGraph->HasData();}bool    CAlnVecRow::IsExpanded() const{    return m_bExpanded;}void    CAlnVecRow::Expand(bool b_exp){    if(IsExpandable()  &&  IsExpanded() != b_exp)   {        m_bExpanded = b_exp;        m_Height = m_BaseHeight;        if(m_bExpanded) {            x_CreateGraph();            if(m_pGraph  &&  m_pGraph->IsCreated())  {                m_Height += m_pGraph->GetPreferredHeight();            }        } else x_DestroyGraph();        if (x_GetHost()) {            x_GetHost()->ARH_OnRowChanged(this);        }    }}const IAlnRowGraphProperties*     CAlnVecRow::GetProperties() const{    return m_pGraph ? m_pGraph->GetProperties() : NULL;}void    CAlnVecRow::SetProperties(IAlnRowGraphProperties* props){    if(m_pGraph)   {        m_pGraph->SetProperties(props);    }}END_NCBI_SCOPE/* * =========================================================================== * $Log: align_row.cpp,v $ * Revision 1000.5  2004/06/01 21:07:00  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.41 * * Revision 1.41  2004/05/21 22:27:52  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.40  2004/05/10 17:46:35  yazhuk * Addressed GCC warnings * * Revision 1.39  2004/04/06 19:07:35  yazhuk * Added "EColumnType col_type" argument to GetHTMLActiveAreas(), added generation * of CHTMLActiveAreas for graphics in alignment * * Revision 1.38  2004/04/06 16:06:32  yazhuk * Removed _ASSERT from RenderColumn() * * Revision 1.37  2004/04/06 13:34:04  dicuccio * Formatting changes - trimmed trailing white space off of lines * * Revision 1.36  2004/04/02 17:13:31  yazhuk * Removed dumplicate 'const' * * Revision 1.35  2004/04/02 16:41:07  yazhuk * Rendering of strand indicator, clean-up * * Revision 1.34  2004/03/29 19:09:18  yazhuk * Added API for Graph properties access, CHTMLActiveArea-s generation, * eliminated m_TraceProxy * * Revision 1.33  2004/03/26 15:01:59  yazhuk * CTraceDataProxy  class added * * Revision 1.32  2004/03/25 13:05:49  dicuccio * Use _TRACE() instead of cout * * Revision 1.31  2004/03/24 19:21:49  yazhuk * Lots of changes in data loading, tooltips. * * Revision 1.30  2004/03/18 17:10:19  yazhuk * Added API for expanding rows * * Revision 1.29  2004/03/16 15:37:22  vasilche * Added required include * * Revision 1.28  2004/03/11 17:50:41  dicuccio * Updated typedefs: dropped TDimension, TPosition, TIndex, TColor; use TSeqRange * instead of TRange * * Revision 1.27  2004/03/08 17:07:31  yazhuk * Replaced CTraceGraph with IAlnVecRowGraph interface; clean-up * * Revision 1.26  2004/03/08 15:44:23  yazhuk * Implemented creation of Trace Graphs from CSeq_graphs, refactored tooltips * generation and rendering * * Revision 1.25  2004/03/05 17:39:14  dicuccio * Use sequence::Getid() instead of CSeq_id::GetStringDescr() * * Revision 1.24  2004/03/02 15:12:21  yazhuk * Added support for Trace Graphs * * Revision 1.23  2004/02/17 15:19:10  yazhuk * Support for graphics caching * * Revision 1.22  2004/02/10 19:54:51  yazhuk * Redesigned alignment rendering, implemented scores averaging * * Revision 1.21  2004/01/08 19:44:04  yazhuk * Extended tooltips support * * Revision 1.20  2003/12/29 23:21:07  yazhuk * Added GetTooltip() * * Revision 1.19  2003/12/18 21:10:27  yazhuk * Redesigned CAlnVecRow - separated display style * * Revision 1.18  2003/12/08 15:15:45  yazhuk * Implemented workaround for OpenGL precision problems. * * Revision 1.17  2003/12/01 17:00:44  yazhuk * Migrated to using CGUIEvent * * Revision 1.16  2003/11/17 21:18:51  yazhuk * Refactored sequence rendering, replaced TextOut() with ArrayTextOut * * Revision 1.15  2003/11/03 16:50:41  yazhuk * Implemented event handling and support for expanding/collapsing alignment rows * * Revision 1.14  2003/10/29 23:33:23  yazhuk * Migrated to new classes, did a lot of refactoring * * Revision 1.13  2003/10/20 15:52:47  yazhuk * Changed colors. * * Revision 1.12  2003/10/15 21:27:07  yazhuk * Migrated from using CAlnVec to accessing data via "generic" interface in CAlignDataSource. * * Revision 1.11  2003/10/10 19:05:58  yazhuk * Implemented score coloring * * Revision 1.10  2003/10/08 14:17:25  dicuccio * use glColor3fv instead of glColorC * * Revision 1.9  2003/10/03 16:31:17  yazhuk * Fixed bug with closing CGlPane * * Revision 1.8  2003/09/29 13:44:46  yazhuk * Added "SeqEnd" column and functions for rendering "Start", "End" and "SeqEnd" columns * * Revision 1.7  2003/09/23 21:59:49  yazhuk * Changed color and adjusted text output position * * Revision 1.6  2003/09/14 14:03:44  ucko * #include <math.h> (needed with GCC) * * Revision 1.5  2003/09/10 20:39:04  yazhuk * Introduced notion of Columns * * Revision 1.4  2003/09/08 20:48:48  yazhuk * Suppressed "-" drawing for gaps * * Revision 1.3  2003/09/08 16:22:13  yazhuk * Drawing insertions, small improvements * * Revision 1.2  2003/09/02 16:53:57  yazhuk * GCC compilation fixes * * Revision 1.1  2003/08/28 18:25:28  yazhuk * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

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