view_feattable.cpp

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

CPP
537
字号
/* * =========================================================================== * PRODUCTION $Log: view_feattable.cpp,v $ * PRODUCTION Revision 1000.7  2004/06/01 21:01:26  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.37 * PRODUCTION * =========================================================================== *//*  $Id: view_feattable.cpp,v 1000.7 2004/06/01 21:01:26 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: * */#include <ncbi_pch.hpp>#include "view_feattable.hpp"#include "visible_range_dlg.hpp"#include "preference_dlg.hpp"#include <gui/types.hpp>#include <gui/core/doc_manager.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/PluginValue.hpp>#include <objmgr/scope.hpp>#include <objmgr/seq_vector.hpp>#include <serial/typeinfo.hpp>#include <objmgr/util/sequence.hpp>BEGIN_NCBI_SCOPE#include "view_feattable_.cpp"void CViewFeatTable::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CViewFeatTable", "Feature Table",                 "Tabular list of all features in a record", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);    args.AddArgument("loc", "Location to display",                     CSeq_loc::GetTypeInfo());}CViewFeatTable::CViewFeatTable(const CPluginMessage& msg,                                const string& pool_name)    : CView(){    m_Window.reset(x_CreateWindow());    // create our dynamic menu managers    m_AlgoMenuMgr.reset(new CAlgoMenuMgr(m_Menu, "Tools", this));    m_ViewMenuMgr.reset(new CViewMenuMgr(m_Menu, "View", this, pool_name));    m_SortMenuMgr.reset(new CSortMenuMgr(m_Menu, "View"));    m_SortMenuMgr->AddSortMenu(m_FeatTable);    // decode the argument    const CPluginCommand& args = msg.GetRequest().GetCommand();    const CPluginArg& arg = args["loc"];    const IDocument* doc = arg.GetDocument();    const CSeq_loc* loc =        dynamic_cast<const CSeq_loc*> (arg.GetObject());    // assign to our core components    if (doc  &&  loc) {        x_SetDocument(*doc);        m_SeqId.Reset(&sequence::GetId(*loc));		// set sequence range        x_SetVisibleRange(*loc);    }}void CViewFeatTable::OnSelectionChanged(const CSelectionBuffer& buf){    m_StatusBar->SetMessage("No features.");    if ( !m_FeatTable  ||  !GetDocument()  ||  &buf == &GetSelBuffer()) {        return;    }    // accept our selections    SetSelBuffer().Clear();    m_FeatTable->ClearSelections();    TConstScopedObjects sels = buf.DecomposeToPairs();    ITERATE (TConstScopedObjects, iter, sels) {        SConstScopedObject cso = *iter;        const IDocument* doc =            CDocManager::GetDocumentFromScope(*cso.scope);        // only accept selections for the current document        if ( doc != m_Document) {            continue;        }        // only select seq-feat selections        const CSeq_feat* feat =            dynamic_cast<const CSeq_feat*>(cso.object.GetPointer());        if ( !feat ) {            continue;        }        // select!        SetSelBuffer().AddSelection(doc, *feat);        m_FeatTable->SelectFeature(*feat);    }    m_FeatTable->redraw();    // prepare our status bar message    x_UpdateStatusMessage();    // reset our menus    x_UpdateDynMenus();}void CViewFeatTable::OnDocumentChanged(){    x_Update();}void CViewFeatTable::OnVisibleRangeChanged(const CSeq_loc& loc){    SetVisibleRange(loc);    m_FeatTable->SetVisibleRange(*m_VisibleRange);    m_FeatTable->Update(GetDocument()->GetScope().GetBioseqHandle(*m_SeqId));}void CViewFeatTable::x_Update(){    SetTitle(GetTitle());    m_StatusBar->SetMessage("No features.");    if ( !m_FeatTable  || !GetDocument() ) {        return;    }    CBioseq_Handle handle =        GetDocument()->GetScope().GetBioseqHandle(*m_SeqId);    m_FeatTable->Update(handle);    SetTitle(x_GetTitle(handle));    // prepare our status bar message    x_UpdateStatusMessage();    // update our dynamic menus    x_UpdateDynMenus();}void CViewFeatTable::x_UpdateStatusMessage(){    //    // prepare our status bar message    //    string status_msg;    int total_feats = m_FeatTable->GetTotalFeats();    status_msg = NStr::IntToString(total_feats) + " feature";    if (total_feats != 1) {        status_msg += "s";    }    if (m_FeatTable->GetFilters().GetFilters().size() != 0) {        int num_filts = m_FeatTable->GetFilters().GetFilters().size();        status_msg += ", " + NStr::IntToString(num_filts) + " filter";        if (num_filts != 1) {            status_msg += "s";        }        int filtered_feats = m_FeatTable->GetFilteredFeats();        status_msg +=            ", " + NStr::IntToString(filtered_feats) + " feature";        if (filtered_feats != 1) {            status_msg += "s match";        } else {            status_msg += " matches";        }    } else {        status_msg += ", no filters selected";    }    m_StatusBar->SetMessage(status_msg);}void CViewFeatTable::x_SetVisibleRange(const CSeq_loc& loc){    if (loc.IsWhole()) {        CRef<CSeq_loc> seq_loc(new CSeq_loc);        seq_loc->SetWhole().Assign(*m_SeqId);        SetVisibleRange(*seq_loc);    } else {        TSeqRange range = loc.GetTotalRange();        x_SetVisibleRange(range);    }}void CViewFeatTable::x_SetVisibleRange(const TSeqRange& range){    CRef<CSeq_loc> seq_loc(new CSeq_loc());    // Set  seq loc with the range     seq_loc->SetInt().SetFrom(range.GetFrom());    seq_loc->SetInt().SetTo  (range.GetTo());	seq_loc->SetId(*m_SeqId);    SetVisibleRange(*seq_loc);    m_FeatTable->SetVisibleRange(*m_VisibleRange);}void CViewFeatTable::x_UpdateDynMenus(){    m_ViewMenuMgr->Clear();    m_AlgoMenuMgr->Clear();    if ( !GetSelBuffer() ) {        SetSelBuffer().AddSelection(m_Document, *m_SeqId);    }    m_ViewMenuMgr->AddActiveViews(GetDocument());    m_ViewMenuMgr->AddNewViews();    m_AlgoMenuMgr->AddAlgoMenu();}    

⌨️ 快捷键说明

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