view_multialign.cpp

来自「ncbi源码」· C++ 代码 · 共 576 行 · 第 1/2 页

CPP
576
字号
/* * =========================================================================== * PRODUCTION $Log: view_multialign.cpp,v $ * PRODUCTION Revision 1000.6  2004/06/01 20:59:28  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.51 * PRODUCTION * =========================================================================== *//*  $Id: view_multialign.cpp,v 1000.6 2004/06/01 20:59:28 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: *    User-modifiable implementation file for extension of Multiple Alignment *    viewer for GBENCH */#include <ncbi_pch.hpp>#include "view_multialign.hpp"#include <gui/core/plugin_utils.hpp>#include <gui/core/version.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginCommand.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/objutils/utils.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objtools/alnmgr/alnmix.hpp>#include <objtools/alnmgr/alnvec.hpp>#include <gui/widgets/aln_multiple/align_row.hpp>#include <gui/widgets/aln_multiple/alnvec_multi_ds.hpp>#include <gui/widgets/aln_multiple/align_row.hpp>#include <serial/iterator.hpp>BEGIN_NCBI_SCOPE// We include the generated _.cpp file here.  This avoids a nasty bug in some// versions of gcc in which inline functions are not intantiated.#include "view_multialign_.cpp"DEFINE_MENU(Menu)    SUBMENU("Display")        MENU_ITEM(eCmdZoomIn, "Zoom In")        MENU_ITEM(eCmdZoomOut, "Zoom Out")        MENU_ITEM(eCmdZoomAll, "Zoom All")        MENU_ITEM(eCmdZoomSeq, "Zoom to Sequence")        MENU_ITEM(eCmdZoomSel, "Zoom Selection")        MENU_SEPARATOR()        MENU_ITEM(eCmdSetSelMaster , "Set Selected as Master")        MENU_ITEM(eCmdSetConsMaster, "Set Consensus as Master")        MENU_ITEM(eCmdUnsetMaster, "Unset Master")        MENU_SEPARATOR()        MENU_ITEM(eCmdHideSelected, "Hide Selected Rows")	    MENU_ITEM(eCmdShowAll, "Show All Rows")        MENU_SEPARATOR()        MENU_ITEM(eCmdMoveSelectedUp, "Move Selected Items Up")    END_SUBMENU()    SUBMENU("Selection")        MENU_ITEM(eCmdResetSelection, "Reset Selection")        MENU_SEPARATOR()        MENU_ITEM(eCmdMarkSelected, "Mark Selected")        MENU_ITEM(eCmdUnMarkSelected, "UnMark Selected")        MENU_ITEM(eCmdUnMarkAll, "UnMark All")        MENU_SEPARATOR()        MENU_ITEM(eCmdMoveSelectedUp, "Move Selected Items Up")    END_SUBMENU()    SUBMENU("View")    END_SUBMENU()    SUBMENU("Tools")    END_SUBMENU()        SUBMENU("&Help")    END_SUBMENU()END_MENU()// Events mapEVENT_MAP_RX_BEGIN(CAlnMultiView)    EVENT_ACCEPT(CViewEvent::eSelectionChanged,  OnSelChangedEvent)EVENT_MAP_RX_END//// standard plugin announcement boilerplate//void CAlnMultiView::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CAlnMultiView",                 "Multiple Alignment Viewer",                 "Multiple Alignment Viewer", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);    args.AddArgument("alignments", "Alignments to merge and render",                     CSeq_annot::GetTypeInfo(),                     CPluginArg::TData::e_Array);    args.SetConstraint("alignments",                       *CPluginValueConstraint::CreateAnnotType                       (CSeq_annot::TData::e_Align));}CAlnMultiView::CAlnMultiView(const CPluginMessage& msg, const string& pool_name)    : CAlnView(){    m_Window.reset(x_CreateWindow());    m_AlnWidget->Create();    m_AlnWidget->SetListener(this);    // Setup menu and command handling    m_Menu->SetItems(Menu);    m_Menu->SetCmdTarget(static_cast<CCommandTarget*>(this));    AddChildCmdTarget(static_cast<CCommandTarget*>(m_AlnWidget));    m_StyleCatalog.SetDefaultStyle(new CAlnVecRowDisplayStyle());    m_StyleCatalog.SetWidgetStyle(m_AlnWidget->GetDisplayStyle());    m_AlnWidget->SetStyleCatalog(&m_StyleCatalog);    // set our core components    const CPluginCommand& args = msg.GetRequest().GetCommand();    plugin_args::TAnnotList aligns;    GetArgValue(args["alignments"], aligns);    CRef<CSeq_annot> annot(new CSeq_annot());    const IDocument* doc = NULL;    ITERATE (plugin_args::TAnnotList, iter, aligns) {        doc = iter->first;        annot->SetData().SetAlign()            .insert(annot->SetData().SetAlign().end(),                    iter->second->GetData().GetAlign().begin(),                    iter->second->GetData().GetAlign().end());    }    // extract the alignments from the argument    if (annot.GetPointer()  &&  doc) {        x_SetDocument(*doc);        m_AnnotData.Reset(annot);    }    // create the view menu manager    m_ViewMenuMgr.reset(new CViewMenuMgr(m_Menu, "View", this, pool_name));    m_AlgoMenuMgr.reset(new CAlgoMenuMgr(m_Menu, "Tools", this));}BEGIN_CMD_MAP(CAlnMultiView, CAlnView)    ON_COMMAND(eCmdResetSelection,  &CAlnMultiView::OnResetSelection)    ON_COMMAND(eCmdSetConsMaster,   &CAlnMultiView::OnMakeConsensusRowMaster)        ON_COMMAND(eCmdMarkSelected,    &CAlnMultiView::OnMarkSelected)    ON_COMMAND(eCmdUnMarkAll,       &CAlnMultiView::OnUnMarkAll)END_CMD_MAP()void CAlnMultiView::OnDocumentChanged(){    if (m_Document) {        SetTitle(m_Document->GetShortTitle() + ": " + GetTitle());        // create our alignment manager        m_DataSource.Reset(new CAlnVecMultiDataSource());        m_DataSource->Init(*m_AnnotData, m_Document->GetScope());        m_AlnWidget->SetDataSource(m_DataSource);        SetSelBuffer().Clear();        SetSelBuffer().AddSelection(GetDocument(), *m_AnnotData);        m_ViewMenuMgr->AddActiveViews(m_Document);        m_ViewMenuMgr->AddNewViews();//   (GetSelBuffer());        m_AlgoMenuMgr->AddAlgoMenu();//   (GetSelBuffer());    }}void CAlnMultiView::OnSelectionChanged(const CSelectionBuffer& buf){    if (m_Document) {        if ( !GetSelBuffer() ) {            SetSelBuffer().AddSelection(GetDocument(), *m_AnnotData);        }        m_ViewMenuMgr->AddActiveViews(m_Document);        m_ViewMenuMgr->AddNewViews();//   (GetSelBuffer());        m_AlgoMenuMgr->AddAlgoMenu();//   (GetSelBuffer());    }}void CAlnMultiView::OnVisibleRangeChanged(const CSeq_loc& loc){}const string& CAlnMultiView::GetTitle(void) const{    static string s_str("Multiple Alignment View");    return s_str;}void CAlnMultiView::x_OnFileClose(){    Hide();}void CAlnMultiView::x_OnHelp(){}void CAlnMultiView::OnResetSelection(){    if (m_AlnWidget) {        m_AlnWidget->OnResetSelection();    }    SetSelBuffer().Clear();    SetSelBuffer().AddSelection(GetDocument(), *m_AnnotData);    m_ViewMenuMgr->AddActiveViews(m_Document);    m_ViewMenuMgr->AddNewViews();//   (GetSelBuffer());    m_AlgoMenuMgr->AddAlgoMenu();//   (GetSelBuffer());}void CAlnMultiView::OnMakeConsensusRowMaster(){    if (m_DataSource.GetPointer()  &&  m_AlnWidget) {        IAlnMultiDataSource::TNumrow row = m_DataSource->GetConsensusRow();                if(row == -1)   { // create it            m_DataSource->CreateConsensus();            row = m_DataSource->GetConsensusRow();        }        m_DataSource->SetAnchor(row); //last row - consensus        m_AlnWidget->SetDataSource(m_DataSource);        //m_AlnWidget->MakeConsensusRowMaster();        //m_AlnWidget->redraw();    }}void CAlnMultiView::OnMarkSelected(void){    if (m_AlnWidget) {        m_AlnWidget->OnMarkSelected();        // fill our selection buffer        SetSelBuffer().Clear();        // GetMarks() returns marked locations        CAlnMultiWidget::TPSeqLocList locs;        m_AlnWidget->GetMarks(locs);        ITERATE (CAlnMultiWidget::TPSeqLocList, iter, locs) {            SetSelBuffer().AddSelection(GetDocument(), **iter);        }        /**        // GetSelection() returns selections in alignment coordinates        const CAlnMultiWidget::TRangeColl& range_coll = m_AlnWidget->GetSelection();

⌨️ 快捷键说明

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