alninfo_table.cpp
来自「ncbi源码」· C++ 代码 · 共 280 行
CPP
280 行
/* * =========================================================================== * PRODUCTION $Log: alninfo_table.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 20:58:51 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== *//* $Id: alninfo_table.cpp,v 1000.2 2004/06/01 20:58:51 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: Mike DiCuccio * * File Description: * CAlnInfoTable -- text (tabular) view of alignment, intended for internal * NCBI use */#include <ncbi_pch.hpp>#include "alninfo_table.hpp"#include <objects/seqloc/Seq_id.hpp>#include <objmgr/util/sequence.hpp>#include <FL/fl_draw.H>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);CAlnInfoTable::CAlnInfoTable(int x, int y, int w, int h, const char* label) : CTablePanelBase(x, y, w, h, label), m_Mode(eSegments){ row_header(true); col_header(true);}void CAlnInfoTable::Update(CAlnVec& aln_mgr){ m_AlnMgr.Reset(&aln_mgr); redraw(); // make sure the table is set correctly SetCols(m_AlnMgr->GetNumSegs()); SetRows(m_AlnMgr->GetNumRows()); x_SetColWidths();}void CAlnInfoTable::resize(int x, int y, int w, int h){ CTablePanelBase::resize(x, y, w, h); x_SetColWidths();}void CAlnInfoTable::x_SetColWidths(){ const int title_width = 90; int width = (int)(float(w() - title_width) / float (GetCols())); width = max(70, width); for (size_t i = 0; i < GetCols(); ++i) { col_width(i, width); } row_header_width(title_width); //col_width(title_width, -1); //col_width(title_width, -2);}int CAlnInfoTable::handle(int event){ switch (event) { case FL_PUSH: {{ /** FIXME int row = get_row(Fl::event_x(), Fl::event_y()); int col = get_col(Fl::event_x(), Fl::event_y()); if (col < 0 && row >= 0 && Fl::event_clicks()) { m_AlnMgr->SetAnchor(row); GetCols(m_AlnMgr->GetNumSegs()); x_SetColWidths(); redraw(); return 1; } **/ }} break; } return CTablePanelBase::handle(event);}void CAlnInfoTable::draw_cell(TableContext ctx, int row, int col, int x, int y, int w, int h){ if ( !m_AlnMgr ) { return; } switch (ctx) { case CONTEXT_STARTPAGE: fl_font(labelfont(), labelsize()); break; case CONTEXT_ROW_HEADER: fl_push_clip(x, y, w, h); {{ fl_draw_box(GetRowHeaderBox(), x, y, w, h, row_header_color()); if (row < GetRows()) { fl_color(labelcolor()); const CSeq_id& best_id = sequence::GetId(m_AlnMgr->GetBioseqHandle(row), sequence::eGetId_Best); string str; best_id.GetLabel(&str); fl_draw(str.c_str(), x, y, w, h, FL_ALIGN_CENTER); } }} fl_pop_clip(); break; case CONTEXT_COL_HEADER: fl_push_clip(x, y, w, h); {{ fl_draw_box(GetColHeaderBox(), x, y, w, h, col_header_color()); if (col < GetCols()) { fl_color(labelcolor()); string str = NStr::IntToString(m_AlnMgr->GetLen(col)); fl_draw(str.c_str(), x, y, w, h, FL_ALIGN_CENTER); } }} fl_pop_clip(); break; case CONTEXT_CELL: fl_push_clip(x, y, w, h); {{ // BG COLOR fl_color(row_selected(row) ? selection_color() : FL_BACKGROUND2_COLOR); fl_rectf(x, y, w, h); // TEXT if (row < GetRows() && col < GetCols()) { string str; // actual column data if (m_AlnMgr->GetStart(row, col) == -1) { str = "---"; } else { switch (m_Mode) { case eSegments: // here we show the sequence offset for this segment str = NStr::IntToString(m_AlnMgr->GetStart(row, col)); break; case eSequence: // here we show the actual sequence for this segment m_AlnMgr->GetSegSeqString(str, row, col); break; case eScores: // here we show the score for the alignment break; } } fl_color(labelcolor()); fl_draw(str.c_str(), x + Fl::box_dx(FL_BORDER_FRAME), y + Fl::box_dy(FL_BORDER_FRAME), w - Fl::box_dw(FL_BORDER_FRAME), h - Fl::box_dh(FL_BORDER_FRAME), FL_ALIGN_LEFT); } // BORDER fl_draw_box(FL_BORDER_FRAME, x, y, w, h, FL_LIGHT2); }} fl_pop_clip(); break; case CONTEXT_ENDPAGE: fl_push_clip(this->x(), this->y(), this->w(), this->h()); {{ fl_draw_box(box(), this->x(), this->y(), this->w(), this->h(), color()); }} fl_pop_clip(); break; default: break; }}void CAlnInfoTable::SetMode(EMode mode){ m_Mode = mode; redraw();}END_NCBI_SCOPE/* * =========================================================================== * $Log: alninfo_table.cpp,v $ * Revision 1000.2 2004/06/01 20:58:51 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * * Revision 1.10 2004/05/21 22:27:48 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.9 2004/05/03 17:52:14 dicuccio * Fix compiler warning about signed/unsigned comparison * * Revision 1.8 2004/03/05 17:37:11 dicuccio * Use sequence::GetId() instead of CSeq_id::GetStringDescr() * * Revision 1.7 2004/01/20 18:17:52 dicuccio * Changed to match new API in CTablePanel * * Revision 1.6 2003/09/24 18:25:36 dicuccio * Inherit from CTablePanelBase. Cleaned up rendering code. * * Revision 1.5 2003/09/04 14:52:47 dicuccio * Code clean-up. Table noew (mostly) works * * Revision 1.4 2003/07/25 13:44:48 dicuccio * Replaced Flv_Table with Fl_Table * * Revision 1.3 2003/03/25 19:43:01 dicuccio * Use a minimum widgt for each column. Indicate anchored row via color * * Revision 1.2 2003/03/04 14:31:20 dicuccio * Added USING_SCOPE(objects) to appease MSVC * * Revision 1.1 2003/03/03 18:29:55 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?