view_graphic.cpp

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

CPP
606
字号
/* * =========================================================================== * PRODUCTION $Log: view_graphic.cpp,v $ * PRODUCTION Revision 1000.7  2004/06/01 20:59:43  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.64 * PRODUCTION * =========================================================================== *//*  $Id: view_graphic.cpp,v 1000.7 2004/06/01 20:59:43 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 portion of main graphical sequence viewer class */#include <ncbi_pch.hpp>#include "view_graphic.hpp"#include <gui/core/doc_manager.hpp>#include <gui/core/idocument.hpp>#include <gui/core/selection_buffer.hpp>#include <gui/core/version.hpp>#include <gui/core/view_exception.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginCommand.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginValue.hpp>#include <util/range.hpp>#include <objmgr/util/sequence.hpp>#include <gui/widgets/seq_graphic/seqgraphic_conf.hpp>#include <gui/widgets/seq_graphic/seqgraphic_ds.hpp>#include <gui/dialogs/config/theme_config_panel.hpp>// #include <gui/dialogs/config/theme_config_panel2.hpp>#include <gui/dialogs/config/theme_mediator.hpp>#include <gui/dialogs/config/theme_dlg.hpp>// #include <gui/dialogs/config/config_dlg.hpp>#include <gui/config/settings.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_graphic_.cpp"void CViewGraphic::GetInfo(CPluginInfo& info){    info.Reset();    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CViewGraphic", "Graphical View",                 "Graphical view of sequence and features", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);    args.AddArgument("loc", "Location to display",                     CSeq_loc::GetTypeInfo());}DEFINE_MENU(ToolBarMenu)    MENU_ITEM(eCmdPrevExon, "Prev. Exon")    MENU_ITEM(eCmdNextExon, "Next. Exon")END_MENU()BEGIN_CMD_MAP(CViewGraphic, CCommandTarget)    //ON_COMMAND(eCmdPrevExon, &CViewGraphic::x_OnPrevExon)    //ON_COMMAND(eCmdNextExon, &CViewGraphic::x_OnNextExon)END_CMD_MAP()void CViewGraphic::x_OnPrevExon(){    m_SeqWidget->OnPrevExon();}void CViewGraphic::x_OnNextExon(){    m_SeqWidget->OnNextExon();}CViewGraphic::CViewGraphic(const CPluginMessage& msg, const string& pool_name)    : CView(){    m_Window.reset(x_CreateWindow());    m_ToolBar->SetItems(ToolBarMenu);    m_ToolBar->SetCmdTarget(this);    AddChildCmdTarget(m_SeqWidget);        // decode the argument    const CPluginCommand& args = msg.GetRequest().GetCommand();    const CPluginArg& arg = args["loc"];    const CSeq_loc& loc = dynamic_cast<const CSeq_loc&> (arg.AsObject());    const IDocument* doc = arg.GetDocument();    // assign to our core components    x_SetDocument(*doc);    m_SeqId.Reset(&sequence::GetId(loc));    // create the configuration object.    CRef<CPluginConfigCache> thePCC        (&CDocManager::GetSettings().SetPluginConfig());    CRef<CSeqGraphicConfig> configSettings(new CSeqGraphicConfig(thePCC));    x_SetConfig(configSettings);     // create our data source    m_DataSource.Reset        (new CSeqGraphicDataSource(m_Document->GetScope(), *m_SeqId));    m_SeqWidget->SetDataSource(m_DataSource);    // set our visible range    CRef<CSeq_loc> seq_loc(new CSeq_loc);    // get sequence range    TSeqRange range = loc.GetTotalRange();    m_SeqWidget->ZoomOnRange(range);    // 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);    // create the dynamic menu managers    m_ViewMenuMgr.reset        (new CViewMenuMgr(m_MenuBar, "View", m_SeqWidget, pool_name));    m_ToolMenuMgr.reset        (new CAlgoMenuMgr(m_MenuBar, "Tools", m_SeqWidget));}void CViewGraphic::OnDocumentChanged(){    // if our document has changed, we clear our selections because they    // may no longer be valid    SetSelBuffer().Clear();    // set our window title as well    SetTitle(x_GetTitle(m_DataSource->GetBioseqHandle()));    m_SeqWidget->redraw();    //    // fill our dynamic menus    //    x_UpdateDynMenus();}void CViewGraphic::OnSelectionChanged(const CSelectionBuffer& buf){    SetSelBuffer().Copy(buf);    m_SeqWidget->ClearSelection();    TConstScopedObjects sels = GetSelBuffer().DecomposeToPairs();    ITERATE (TConstScopedObjects, iter, sels) {        SConstScopedObject cso = *iter;        const IDocument* doc = CDocManager::GetDocumentFromScope(*cso.scope);        const CObject* obj   = cso.object;        // only accept selections for the current document        if ( doc != m_Document) {            continue;        }        // select ranges on sequence        const CSeq_loc* loc = dynamic_cast<const CSeq_loc*>(obj);        if (loc) {            m_SeqWidget->SelectSeqLoc(loc);        } else {            m_SeqWidget->SelectObject(obj);        }    }    //    // fill our dynamic menus    //    x_UpdateDynMenus();}void CViewGraphic::OnVisibleRangeChanged(const CSeq_loc& loc){    SetVisibleRange(loc);}void CViewGraphic::x_UpdateDynMenus(){    // view menu first    m_ToolMenuMgr->Clear();    m_ViewMenuMgr->Clear();    if ( !GetSelBuffer() ) {        SetSelBuffer().AddSelection(GetDocument(), *m_SeqId);    }    m_ViewMenuMgr->AddActiveViews(GetDocument());    m_ViewMenuMgr->AddNewViews();    m_ToolMenuMgr->AddAlgoMenu();    // m_PopupMenu was "eating" mouse move events. The tooltips never come up in the widget.    //m_PopupMenu->copy(m_MenuBar->menu());}const string& CViewGraphic::GetTitle(void) const{    static string s_str("Graphical View");    return s_str;}void CViewGraphic::SetVisibleRange(const CSeq_loc& loc){    // call the base class    CView::SetVisibleRange(loc);    // do our widget-specific things    TSeqRange range = loc.GetTotalRange();    m_SeqWidget->ZoomOnRange(range);    m_SeqWidget->redraw();    //x_UpdateDynMenus();}void CViewGraphic::SetFeatureFocus(const CSeq_feat& feat){}void CViewGraphic::x_Print(const CPrintOptions& opts){    m_SeqWidget->Print(opts);}void CViewGraphic::x_PanelCallback(){    vector< CRef<CSeq_loc> > locs = m_SeqWidget->GetSelectedSeqLocs();    TConstObjects objs = m_SeqWidget->GetSelectedObjects();    bool update_menus = false;    if (locs.size()  ||  objs.size()) {        // retrieve selections        // selections come in two forms: sets of layout objects and sets of        // seq-locs representing selected ranges        SetSelBuffer().Clear();        // seq-locs first        ITERATE(vector< CRef<CSeq_loc> >, loc_iter, locs) {            SetSelBuffer().AddSelection(GetDocument(), **loc_iter);        }        // now, selected layout objects        ITERATE(TConstObjects, obj_iter, objs) {            const CObject& obj = obj_iter->GetObject();            SetSelBuffer().AddSelection(GetDocument(), obj);        }        update_menus = true;    } else if (GetSelBuffer()) {        SetSelBuffer().Clear();        update_menus = true;    }

⌨️ 快捷键说明

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