view_phylo_tree.cpp

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

CPP
305
字号
/* * =========================================================================== * PRODUCTION $Log: view_phylo_tree.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 20:59:57  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.12 * PRODUCTION * =========================================================================== *//*  $Id: view_phylo_tree.cpp,v 1000.1 2004/06/01 20:59:57 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:  Vladimir Tereshkov * * File Description: *     *     */#include <ncbi_pch.hpp>#include "view_phylo_tree.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 <gui/core/idocument.hpp>#include <gui/core/iview.hpp>#include <gui/core/view.hpp>#include <gui/core/view_menu.hpp>#include <gui/core/algo_menu.hpp>#include <gui/types.hpp>#include <serial/serialimpl.hpp>#include <algo/phy_tree/phy_tree_serial.hpp>#include <gui/widgets/phylo_tree/phylo_tree_reader.hpp>#include <serial/iterator.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);// 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_phylo_tree_.cpp"#define TRY_TO_USE_NEW_MENU_SYSTEM#ifdef TRY_TO_USE_NEW_MENU_SYSTEM    #define m_MenuBar m_MenuBarNew #else     #define m_MenuBar m_MenuBarOld #endif// Events mapEVENT_MAP_RX_BEGIN(CPhyloTreeView)    EVENT_FORWARD(CViewEvent::eSelectionChanged,  m_PhyloTree)    EVENT_FORWARD(CViewEvent::eTreeSelectionChanged, m_PhyloTree)EVENT_MAP_RX_END//// standard plugin announcement boilerplate//void CPhyloTreeView::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CPhyloTreeView",                 "Phylogenetic Tree Viewer",                 "Phylogenetic Tree Viewer", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);    args.AddArgument("tree", "Tree", CPhyTreeSerial::GetTypeInfo());}// addon to menuitem#define MENU_ITEM_RADIO(cmd, label) \    { CMenuItem::eItem, label, cmd, "", CMenuItem::eRadioItem}, #define MENU_ITEM_RADIO_SET(cmd, label) \    { CMenuItem::eItem, label, cmd, "", CMenuItem::eRadioItem|CMenuItem::eSet}, #define MENU_ITEM_CHECK(cmd, label) \    { CMenuItem::eItem, label, cmd, "", CMenuItem::eCheckItem}, #define MENU_ITEM_CHECK_SET(cmd, label) \    { CMenuItem::eItem, label, cmd, "", CMenuItem::eCheckItem|CMenuItem::eSet}, staticDEFINE_MENU(Menu)    SUBMENU("Zoom")        MENU_ITEM(eCmdZoomIn, "Zoom In")        MENU_ITEM(eCmdZoomOut, "Zoom Out")        MENU_ITEM(eCmdZoomAll, "Zoom All")                    END_SUBMENU()    SUBMENU("Graph")               MENU_ITEM_RADIO_SET(eCmdSetGraphType1, "Rectangle Cladogram")        MENU_ITEM_RADIO(eCmdSetGraphType2, "Slated Cladogram")           MENU_ITEM_RADIO(eCmdSetGraphType3, "Radial Tree")        MENU_ITEM_RADIO(eCmdSetGraphType4, "Force Layout")        MENU_SEPARATOR()        MENU_ITEM_CHECK(eCmdUseDistances, "Distances Rendering")               END_SUBMENU()END_MENU()CPhyloTreeView::CPhyloTreeView(const CPluginMessage& msg,                               const string& pool_name)    : CView(){    m_Window.reset(x_CreateWindow());        m_MenuBar->SetItems(Menu);    m_MenuBar->SetCmdTarget(m_PhyloTree);       #ifdef TRY_TO_USE_NEW_MENU_SYSTEM        int width, height;    this->GetSize(width, height);    height = m_MenuBar->GetPreferredSize().Y();        m_MenuBar->size(width, height);        m_MenuBar->position(0,0);    #endif    // set our core components    const CPluginCommand& args = msg.GetRequest().GetCommand();    const CPluginArg& arg = args["tree"];    // extract tree from argument     const CPhyTreeSerial *tree =        dynamic_cast<const CPhyTreeSerial *>(&args["tree"].AsObject());    if (!tree) {        throw runtime_error("CPhyloTreeView::Save: not a tree");    }    const IDocument* doc = arg.GetDocument();    if (tree  &&  doc) {        x_SetDocument(*doc);        m_DataSource.Reset(new CPhyloTreeDataSource());          m_SeqIds    = tree->GetIds();        m_TreeData  = tree->GetTree();    }        // create the view menu manager#ifndef TRY_TO_USE_NEW_MENU_SYSTEM    m_ViewMenuMgr.reset(new CViewMenuMgr(m_MenuBar, "View", this, pool_name));#endif    // setting host for sending events    m_PhyloTree->SetHost(this);}void CPhyloTreeView::OnDocumentChanged(){    if (!m_Document) {        return;    }    SetTitle(m_Document->GetShortTitle() + ": " + GetTitle());        m_DataSource.Reset        (new CPhyloTreeDataSource(m_TreeData, m_SeqIds,                                  m_Document->GetScope()));    m_PhyloTree->SetDataSource(m_DataSource.GetPointer());             if ( !GetSelBuffer() ) {        ITERATE (vector< CConstRef<CSeq_id> >, iter, m_SeqIds) {            SetSelBuffer().AddSelection(GetDocument(), **iter);        }    }#ifndef TRY_TO_USE_NEW_MENU_SYSTEM    m_ViewMenuMgr->AddActiveViews(m_Document);    m_ViewMenuMgr->AddNewViews();//   (m_Document);    #endif}const string& CPhyloTreeView::GetTitle(void) const{    static string s_str("Phylogenetic Tree View");    return s_str;}void CPhyloTreeView::x_OnFileClose(){    Hide();}void CPhyloTreeView::x_OnZoomIn(){    m_PhyloTree->OnZoomIn();}void CPhyloTreeView::x_OnZoomOut(){    m_PhyloTree->OnZoomOut();}void CPhyloTreeView::x_OnZoomAll(){    m_PhyloTree->OnZoomAll();}void CPhyloTreeView::x_OnHelp(){}END_NCBI_SCOPE/* * =========================================================================== * $Log: view_phylo_tree.cpp,v $ * Revision 1000.1  2004/06/01 20:59:57  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.12 * * Revision 1.12  2004/05/21 22:27:49  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.11  2004/05/20 15:31:46  tereshko * Implemented support for new updates-driven menu * * Revision 1.10  2004/05/06 19:44:36  tereshko * Added force tree layout * * Revision 1.9  2004/05/03 17:52:53  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.8  2004/04/28 19:29:22  tereshko * Changed menu structure * * Revision 1.7  2004/04/16 14:45:29  dicuccio * Code clean-up.  Use appropriate ISelection interface for dynamic menus * * Revision 1.6  2004/04/07 13:03:14  dicuccio * Changed view API - require CPluginMessage instead of CPluginArgSet.  Changed name of phy tree variable to match its origin * * Revision 1.5  2004/04/02 16:46:12  yazhuk * Added CScope argument to the Data Source constructor * * Revision 1.4  2004/03/30 17:12:52  tereshko * Added support for events broadcasting * * Revision 1.3  2004/03/02 18:31:55  tereshko * Added radial tree layout * * Revision 1.2  2004/02/18 15:11:59  tereshko * Added renderer switching handle, corrected defines * * Revision 1.1  2004/02/17 23:45:52  tereshko * Phylogenetic tree viewer plugin. Initial revision. * * Revision 1.4  2004/02/12 21:08:31  yazhuk * Reorganized menu and added new commands * * Revision 1.3  2004/01/15 20:53:16  yazhuk * Renamed m_Menu to m_MenuBar, added menu definition and menu setup code * * Revision 1.2  2003/12/22 19:33:15  dicuccio * Lots of changes.  Changed to match new APIs in IView.  Added better handling of messages received from other views * * Revision 1.1  2003/12/05 20:06:05  yazhuk * Initial revision *  * =========================================================================== */

⌨️ 快捷键说明

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