view_default.cpp
来自「ncbi源码」· C++ 代码 · 共 172 行
CPP
172 行
/* * =========================================================================== * PRODUCTION $Log: view_default.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:55:48 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== *//* $Id: view_default.cpp,v 1000.1 2004/06/01 20:55:48 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: Josh Cherry * * File Description: Launch default viewer(s) for documents * */#include <ncbi_pch.hpp>#include "view_default.hpp"#include <corelib/ncbiapp.hpp>#include <corelib/ncbireg.hpp>#include <gui/core/idocument.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginValue.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginReply.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginValueConstraint.hpp>#include <gui/core/version.hpp>#include <gui/core/doc_manager.hpp>#include <gui/objutils/utils.hpp>#include <gui/utils/message_box.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);// standard info boilerplatevoid CAlgoPlugin_ViewDefault::GetInfo(CPluginInfo& info){ info.Reset(); // version info macro info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0, string(__DATE__) + " " + string(__TIME__), "CAlgoPlugin_ViewDefault", "", "View with Default Viewer(s)", ""); // command info CPluginCommandSet& cmds = info.SetCommands(); CPluginCommand& args = cmds.AddAlgoCommand(eAlgoCommand_run); args.AddArgument("document", "Document to view", CPluginArg::eDocument);}static void s_GetDefaultViewers(const CSerialObject& obj, vector<string>& viewers){ string name = obj.GetThisTypeInfo()->GetName(); // check registry for relevant entry CNcbiApplication* app = CNcbiApplication::Instance(); _ASSERT(app); CNcbiRegistry& registry = app->GetConfig(); string regentry = registry.GetString("VIEWERS", name, ""); if (!regentry.empty()) { // treat as a comma-separated list of viewers vector<string> fields; NStr::Tokenize(regentry, ",", fields); ITERATE (vector<string>, field, fields) { string viewer = NStr::TruncateSpaces(*field); viewers.push_back(viewer); } } else { // use predefined default defaults if (name == "Seq-entry" || name == "Bioseq" || name == "Bioseq-set" || name == "Seq-id") { viewers.push_back("CViewGraphic"); } else if (name == "Seq-align" || name == "Seq-align-set" || name == "Seq-annot") { viewers.push_back("CAlnMultiView"); } else if (name == "CPhyTreeSerial") { viewers.push_back("CPhyloTreeView"); } }}void CAlgoPlugin_ViewDefault::RunCommand(CPluginMessage& msg){ const CPluginCommand& args = msg.GetRequest().GetCommand(); CPluginReply& reply = msg.SetReply(); _TRACE("CAlgoPlugin_ViewDefault::Run()"); IDocument* doc = const_cast<IDocument*> (&args["document"].AsDocument()); if (!doc) { reply.SetStatus(eMessageStatus_failed); return; } const CSerialObject& obj = dynamic_cast<const CSerialObject&>(*doc->GetObject()); CRef<CSelectionBuffer> buf(new CSelectionBuffer()); buf->AddSelection(doc, obj); vector<string> viewers; s_GetDefaultViewers(obj, viewers); ITERATE (vector<string>, viewer, viewers) { CPluginUtils::CallPlugin(*viewer, eViewCommand_new_view, *buf); } reply.SetStatus(eMessageStatus_success);}END_NCBI_SCOPE/* * =========================================================================== * $Log: view_default.cpp,v $ * Revision 1000.1 2004/06/01 20:55:48 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * * Revision 1.4 2004/05/21 22:27:47 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.3 2004/05/03 13:05:42 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.2 2004/04/19 14:07:25 jcherry * Handle Seq-id * * Revision 1.1 2004/03/15 16:04:14 jcherry * Initial version * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?