view_taxplot.cpp

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

CPP
256
字号
/* * =========================================================================== * PRODUCTION $Log: view_taxplot.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:01:53  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//*  $Id: view_taxplot.cpp,v 1000.1 2004/06/01 21:01:53 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 Taxplot Viewer *     */#include <ncbi_pch.hpp>#include "view_taxplot.hpp"#include "view_taxplot_ds.hpp"#include <gui/types.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 <serial/typeinfo.hpp>#include <objmgr/util/sequence.hpp>#include <gui/core/doc_manager.hpp>#include <gui/utils/message_box.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_taxplot_.cpp"// temporary...int    xTax,   yTax,   zTax;string labelx, labely, labelz;// defines : should be obtained automaticallyFl_Menu_Item taxonomy[] = {    {"A. gambiae str. PEST",	0,0, (void*)"180454"},    {"A. thaliana (thale cress)",0,0,(void*)"3702"},    {"C. elegans",	0,0,(void*)"6239"},    {"C. parvum",	0,0,(void*)"5807"},    {"Candida albicans",	0,0,(void*)"5476"},    {"D. melanogaster (fruit fly)",	0,0,(void*)"7227"},    {"E. cuniculi",	0,0,(void*)"6035"},    {"E. histolytica",0,0,(void*)"5759"},    {"G. lamblia ATCC 50803",	0,0,(void*)"184922"},    {"Homo sapiens (human)",	0,0,(void*)"9606"},    {"Leishmania major",	0,0,(void*)"5664"},    {"M. grisea 70-15",	0,0,(void*)"242507"},    {"Mus musculus (house mouse)",0,0,(void*)"10090"},    {"Neurospora crassa",	0,0,(void*)"5141"},    {"P. falciparum 3D7",	0,0,(void*)"36329"},    {"P. yoelii yoelii",	0,0,(void*)"73239"},    {"Rattus norvegicus",	0,0,(void*)"10116"},    {"S. cerevisiae",	0,0,(void*)"4932"},      {"S. pombe (fission yeast)",	0,0,(void*)"4896"},    {"Trypanosoma brucei",	0,0,(void*)"5691"},    {"Trypanosoma cruzi",	0,0,(void*)"5693"},    {0}};void cb_Tax1(Fl_Widget * widget, void * data){    Fl_Menu_* mw = (Fl_Menu_*)widget;    const   Fl_Menu_Item* m = mw->mvalue();    xTax      = NStr::StringToInt(string((char*)m->user_data()));        labelx    = m->label();    if(data) ((CTaxplotView*)data)->OnDocumentChanged();;}void cb_Tax2(Fl_Widget * widget, void * data){    Fl_Menu_* mw = (Fl_Menu_*)widget;    const   Fl_Menu_Item* m = mw->mvalue();      yTax      = NStr::StringToInt(string((char*)m->user_data()));    labely = m->label();        if(data) ((CTaxplotView*)data)->OnDocumentChanged();;}void cb_Tax3(Fl_Widget * widget, void * data){    Fl_Menu_* mw = (Fl_Menu_*)widget;    const   Fl_Menu_Item* m = mw->mvalue();      zTax      = NStr::StringToInt(string((char*)m->user_data()));    labelz = m->label();    if(data) ((CTaxplotView*)data)->OnDocumentChanged();;}//// standard plugin announcement boilerplate//void CTaxplotView::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CTaxplotView",                 "Taxplot Viewer",                 "Taxplot Viewer", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);        // only document                //args.AddArgument("document", "Document", CPluginArg::eDocument);            args.AddArgument("taxplot", "Taxplot", CShiReaderCache::GetTypeInfo());}CTaxplotView::CTaxplotView(const CPluginMessage& msg, const string& pool_name)    : CView(){    // main window    m_Window.reset(x_CreateWindow());        // getting document    const CPluginCommand& args = msg.GetRequest().GetCommand();    const CPluginArg& arg = args["taxplot"];    const IDocument* doc = arg.GetDocument();    //IDocument* doc = const_cast<IDocument*> (&args["document"].AsDocument());    const CShiReaderCache * cache   = dynamic_cast<const CShiReaderCache*>(&args["taxplot"].AsObject());        // setting view document    if (doc)  x_SetDocument(*doc);           // comboboxes    m_xCombo->menu(taxonomy); m_xCombo->value(5);    m_yCombo->menu(taxonomy); m_yCombo->value(2);    m_zCombo->menu(taxonomy); m_zCombo->value(17);    // events        m_xCombo->callback(cb_Tax1,(void*)this);      m_yCombo->callback(cb_Tax2,(void*)this);      m_zCombo->callback(cb_Tax3,(void*)this);    // setting initial values    cb_Tax1(m_xCombo, NULL);      cb_Tax2(m_yCombo, NULL);      cb_Tax3(m_zCombo, NULL);         }void CTaxplotView::OnViewCreated(IView& view){       }void CTaxplotView::OnDocumentChanged(){    if (m_Document){            SetTitle(m_Document->GetShortTitle() + ": " + GetTitle());                CShiReaderCache * cache   = dynamic_cast<CShiReaderCache*>(m_Document->GetObject());        if (cache) {            CTaxplotDataSource * ds = new CTaxplotDataSource(cache,  xTax, yTax, zTax);            ds->xLabel() = labelx; ds->yLabel() = labely; ds->zLabel() = labelz;                            m_DataSource.Reset(ds);              m_AlnInfo->SetDataSource(m_DataSource);        }        else {            throw runtime_error("No valid Taxplot data found in this document");                    }    }}void CTaxplotView::x_OnHelp(){}const string& CTaxplotView::GetTitle(void) const{    static string s_str("Taxplot View");    return s_str;}void CTaxplotView::x_OnFileClose(){    Hide();}END_NCBI_SCOPE/* * =========================================================================== * $Log: view_taxplot.cpp,v $ * Revision 1000.1  2004/06/01 21:01:53  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * * Revision 1.7  2004/05/21 22:27:49  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.6  2004/05/20 21:40:46  tereshko * Argument retrieval changed to uniform way with identifier taxplot * * Revision 1.5  2004/04/07 13:05:11  dicuccio * Changed view API - require CPluginMessage instead of CPluginArgSet * * Revision 1.4  2004/01/15 21:36:57  tereshko * Updates to UI, event hooks * * Revision 1.3  2004/01/15 17:01:09  tereshko * Fix for 64 bit compiler * * Revision 1.2  2004/01/14 23:22:42  tereshko * Removed unused pointer * * Revision 1.1  2004/01/14 16:37:05  tereshko * Taxplot viewer, initial revision * * =========================================================================== */

⌨️ 快捷键说明

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