alnvec_multi_model.cpp

来自「ncbi源码」· C++ 代码 · 共 205 行

CPP
205
字号
/* * =========================================================================== * PRODUCTION $Log: alnvec_multi_model.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:07:20  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== *//*  $Id: alnvec_multi_model.cpp,v 1000.1 2004/06/01 21:07:20 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 <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <gui/widgets/aln_multiple/alnvec_multi_model.hpp>#include <gui/widgets/aln_multiple/align_row.hpp>BEGIN_NCBI_SCOPEstatic const int kColorGradNumber = 32; /// number of gradient colors in alignment///////////////////////////////////////////////////////////////////////////////////CAlnVecMultiModel::CAlnVecMultiModel()    : m_bEnableScoring(true){    m_ScoreCache.SetGradNumber(kColorGradNumber);        CSimpleScoringMethod* p_method = new CSimpleScoringMethod();    //CSNPScoringMethod* p_method = new CSNPScoringMethod();    p_method->CreateColorTable(kColorGradNumber);        AddScoringMethod(p_method);    SetCurrentMethod(p_method->GetName());}CAlnVecMultiModel::~CAlnVecMultiModel(){    ITERATE(TMethods, it, m_Methods)   {        delete *it;    }    m_Methods.clear();}void CAlnVecMultiModel::SetDataSource(IAlnMultiDataSource* p_ds){    CAlnVecMultiDataSource* p_alnvec_ds = dynamic_cast<CAlnVecMultiDataSource*>(p_ds);        // check whether p_ds is compatible with this widget    _ASSERT(p_ds == NULL  ||  p_alnvec_ds);            m_pDataSource = p_ds;        if(p_alnvec_ds)        p_alnvec_ds->SetGapChar('-');        m_ScoreCache.SetAlnVec(p_alnvec_ds ? &p_alnvec_ds->GetAlnMgr() : NULL);        x_UpdateOnDataChanged();}void    CAlnVecMultiModel::EnableScoring(bool b_en){    m_bEnableScoring = b_en;}    bool    CAlnVecMultiModel::AddScoringMethod(IScoringMethod* method){    TMethods::const_iterator it = std::find(m_Methods.begin(), m_Methods.end(), method);    if(it == m_Methods.end())   {        m_Methods.push_back(method);        return true;    }    return false;}const   CAlnVecMultiModel::TMethods&        CAlnVecMultiModel::GetMethods(){    return  m_Methods;}bool    CAlnVecMultiModel::SetCurrentMethod(const string& name){    ITERATE(TMethods, it, m_Methods)   {        if((*it)->GetName() == name)   { // found it            m_ScoreCache.SetScoringMethod(*it);            return true;        }    }    return false;}const IScoringMethod*    CAlnVecMultiModel::GetCurrentMethod() const{    return m_ScoreCache.GetScoringMethod();}/// factory method for creation rowsIAlignRow*  CAlnVecMultiModel::x_CreateRow(TNumrow row){    _ASSERT(m_pDataSource  &&  m_pStyleCatalog);    const IAlignRowHandle* p_abs_handle = m_pDataSource->GetRowHandle(row);    const CAlnVecRowHandle* p_handle = dynamic_cast<const CAlnVecRowHandle*>(p_abs_handle);    _ASSERT(p_handle);    CAlnVecRow* p_row = new CAlnVecRow(*p_handle);            const CRowDisplayStyle* style = m_pStyleCatalog->GetStyleForRow(row);    p_row->SetDisplayStyle(style);        p_row->SetScoreCache(m_bEnableScoring ? &m_ScoreCache : NULL);    return static_cast<IAlignRow*>(p_row);}void CAlnVecMultiModel::x_UpdateOnDataChanged(){        CAlnMultiModel::x_UpdateOnDataChanged();    if(m_pDataSource) {                 m_ScoreCache.SetAlnVec(& x_GetAlnVecDS()->GetAlnMgr());        if(m_bEnableScoring)    {            m_ScoreCache.CalculateScores();        }    } else {        m_ScoreCache.SetAlnVec(NULL);    }}void    CAlnVecMultiModel::SetMasterRow(TNumrow new_row){    CAlnMultiModel::SetMasterRow(new_row);    x_UpdateOnCoordsChanged();}void    CAlnVecMultiModel::x_UpdateOnCoordsChanged(){    // this can be eliminated if scores are saved in seq coords    if(m_bEnableScoring)    {        m_ScoreCache.CalculateScores();     }}END_NCBI_SCOPE/* * =========================================================================== * $Log: alnvec_multi_model.cpp,v $ * Revision 1000.1  2004/06/01 21:07:20  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6  2004/05/21 22:27:52  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.5  2004/04/07 13:07:43  dicuccio * Minor formatting change * * Revision 1.4  2004/04/02 16:27:00  yazhuk * Replaced UpdateOnCoordsChanged() with x_UpdateOnCoordsChanged(); added * SetMasterRow(TNumrow) * * Revision 1.3  2004/03/24 19:18:24  yazhuk * Implemented scoring enabling/disabling * * Revision 1.2  2004/03/18 17:06:20  yazhuk * Redesigned Scoring Methods API * * Revision 1.1  2004/03/17 17:21:09  yazhuk * Initial revision; factored out from CAlnVecMultiWidget * * =========================================================================== */

⌨️ 快捷键说明

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