algo_menu.cpp

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

CPP
286
字号
/* * =========================================================================== * PRODUCTION $Log: algo_menu.cpp,v $ * PRODUCTION Revision 1000.4  2004/06/01 20:43:37  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.28 * PRODUCTION * =========================================================================== *//*  $Id: algo_menu.cpp,v 1000.4 2004/06/01 20:43:37 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: * *    CAlgoMenuDataInternal -- Class to hold callback information necessary to spawn an *                     algorithm plugin from an FLTK callback * *    CAlgoMenuMgr  -- Manager for dynamic FLTK algorithm plugin menu + *                     callback data */#include <ncbi_pch.hpp>#include <gui/core/idocument.hpp>#include <gui/core/doc_manager.hpp>#include <gui/core/algo.hpp>#include <gui/core/algo_menu.hpp>#include <gui/core/algo_factory.hpp>#include <gui/core/plugin_registry.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/objutils/iselection.hpp>#include <gui/utils/message_box.hpp>#include <algorithm>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);//// internal class to manage algorithm pop-up menus// this is done to remove a header file dependency on plugin_handle.hpp//class CAlgoMenuDataInternal : public IAlgoMenuData{public:    CAlgoMenuDataInternal(const string& plugin, ISelection* sel_source);    virtual void DoCallback();private:    ISelection* m_SelSource;    string      m_Plugin;};//// default ctor for our base menu data class//CAlgoMenuDataInternal::CAlgoMenuDataInternal(const string& plugin,                                             ISelection* sel_source)     : m_SelSource(sel_source),      m_Plugin(plugin){}//// DoCallback() merely launches the plugin//void CAlgoMenuDataInternal::DoCallback(){    if ( m_Plugin.empty() ) {        return;    }    // make sure we supply a valid (even if empty) selection buffer    TConstScopedObjects objs;    m_SelSource->GetSelections(objs);    CSelectionBuffer empty_buf;    NON_CONST_ITERATE (TConstScopedObjects, iter, objs) {        const IDocument* doc = CDocManager::GetDocumentFromScope(*iter->scope);        if (doc) {            empty_buf.AddSelection(doc, *iter->object);        }    }    // now, call our plugin    CPluginUtils::CallPlugin(m_Plugin, eAlgoCommand_run, empty_buf);}//// default ctor for the view menu manager class//CAlgoMenuMgr::CAlgoMenuMgr(Fl_Menu_* menu, const string& base,                           ISelection* sel_source)    : CFltkMenuMgrBase<IAlgoMenuData>(menu)    , m_SelSource(sel_source){    SetMenuBase(base);}//// Clear()// this clears the contents of our two submenus//void CAlgoMenuMgr::Clear(){    // Do our base class clear    x_ClearData();    if ( !m_Menu ) {        return;    }    // remove our managed sub-item rom the list    x_RemoveSubitems(m_Base);}//// AddAlgoMenu()// This adds a submenu for all possible plugins//void CAlgoMenuMgr::AddAlgoMenu(){    string menu_base = m_Base;    if ( !menu_base.empty() ) {        menu_base += "/";    }    CPluginRegistry::TPlugins plugins =        CPluginRegistry::GetPlugins(eAlgoCommand_run);    NON_CONST_ITERATE (CPluginRegistry::TPlugins, iter, plugins) {        CPluginHandle plugin = *iter;        string s = plugin.GetMenuItem();        if ( !menu_base.empty() ) {            s = menu_base + s;        }        x_AddItem(s, new CAlgoMenuDataInternal(plugin.GetClassName(),                                               m_SelSource));    }}END_NCBI_SCOPE/* * =========================================================================== * $Log: algo_menu.cpp,v $ * Revision 1000.4  2004/06/01 20:43:37  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.28 * * Revision 1.28  2004/05/21 22:27:40  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.27  2004/05/03 12:48:46  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.26  2004/04/16 14:36:49  dicuccio * Use ISelection as selection source instead of passing selections in explicitly * * Revision 1.25  2003/12/22 19:18:31  dicuccio * CSelectionBuffer::GetSelections() - dead API; use operator bool instead * * Revision 1.24  2003/11/06 20:06:29  dicuccio * Moved USING_SCOPE(objects) to implementation files * * Revision 1.23  2003/10/23 16:15:12  dicuccio * Removed dead code * * Revision 1.22  2003/09/30 13:39:42  dicuccio * Removed spurious sort() after retrieving plugins - not needed * * Revision 1.21  2003/09/16 13:58:43  dicuccio * Renamed interface base class for algo menu data * * Revision 1.20  2003/09/04 14:01:51  dicuccio * Introduce IDocument and IView as abstract base classes for CDocument and CView * * Revision 1.19  2003/08/05 17:01:37  dicuccio * General code clean-up.  REemoved unnecessary try/catch * * Revision 1.18  2003/07/21 19:26:48  dicuccio * Changed data class interface from Run() to DoCallback() -- more descriptive. * Modified all menu structures to accept a selection buffer; use selection * buffers internally for all operations.  Fixed screening of plugins based on * selection contents * * Revision 1.17  2003/07/14 11:00:12  shomrat * Plugin messageing system related changes * * Revision 1.16  2003/06/30 20:04:04  dicuccio * Fixed problem with odd crashing of plugins - changed menu data class to hold a * copy of a plugin handle rather than a reference. * * Revision 1.15  2003/06/25 17:02:54  dicuccio * Split CPluginHandle into a handle (pointer-to-implementation) and * implementation file.  Lots of #include file clean-ups. * * Revision 1.14  2003/05/30 14:15:41  dicuccio * Renamed MessageBox to NcbiMessageBox because brain-dead MSVC thinks this is * ::MessageBox and rewrites the symbol as MessageBoxA, which results in an * unresolved external and conflict with the Win32 API :(. * * Revision 1.13  2003/05/30 12:56:50  dicuccio * Converted code to use MessageBox() instead of * fl_ask()/fl_message()/fl_alert() * * Revision 1.12  2003/05/05 12:41:33  dicuccio * Moved tools out of an explicit 'plugins' submenu * * Revision 1.11  2003/04/29 14:35:53  dicuccio * Added interface function to retrieve algorithms based on contents of a * IDocument.  Fully implemented screening of algorithms based on selection * contents * * Revision 1.10  2003/04/19 01:52:57  ucko * iterate -> ITERATE * * Revision 1.9  2003/04/16 18:18:50  dicuccio * Modified algo menu to use generic plugin launch facility (CallPlugin()) * * Revision 1.8  2003/03/31 13:41:11  dicuccio * Added new ctor for CAlgoMenuDataInternal - initialize with just a plugin * handle * * Revision 1.7  2003/03/25 13:09:26  dicuccio * First implementation to add the plugin arguments dialog to query for user * input * * Revision 1.6  2003/03/10 21:56:45  kuznets * iterate -> ITERATE * * Revision 1.5  2003/02/24 13:03:14  dicuccio * Renamed classes in plugin spec: *     CArgSeg --> CPluginArgSet *     CArgument --> CPluginArg *     CPluginArgs --> CPluginCommand *     CPluginCommands --> CPluginCommandSet * * Revision 1.4  2003/02/20 19:49:52  dicuccio * Created new plugin architecture, based on ASN.1 spec.  Moved GBENCH frameowrk * over to use new plugin architecture. * * Revision 1.3  2003/01/13 13:10:05  dicuccio * Namespace clean-up.  Retired namespace gui -> converted all to namespace * ncbi.  Moved all FLUID-generated code into namespace ncbi. * * Revision 1.2  2003/01/10 17:33:07  dicuccio * Changed TPluginList --> TPlugins * * Revision 1.1  2002/12/20 19:12:58  dicuccio * Initial revision. * * =========================================================================== */

⌨️ 快捷键说明

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