view_asn.cpp

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

CPP
276
字号
/* * =========================================================================== * PRODUCTION $Log: view_asn.cpp,v $ * PRODUCTION Revision 1000.5  2004/06/01 21:02:27  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//*  $Id: view_asn.cpp,v 1000.5 2004/06/01 21:02:27 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 basic text viewer */#include <ncbi_pch.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 <objects/seq/Bioseq.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objmgr/util/sequence.hpp>#include <serial/serial.hpp>#include <serial/objostrasn.hpp>#include <connect/ncbi_conn_stream.hpp>#include "view_asn.hpp"BEGIN_NCBI_SCOPEUSING_SCOPE(objects);#include "view_asn_.cpp"void CViewAsn::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CViewAsn", "Text/ASN.1 Text Format",                 "ASN.1 Text Viewer", "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    args = cmds.AddViewCommand(eViewCommand_new_view);    args.AddArgument("id", "Seq-id of the record we wish to display",                     CSeq_id::GetTypeInfo());}CViewAsn::CViewAsn(const CPluginMessage& msg, const string& pool_name)    : CView()    , m_CurrentFont(FL_COURIER)    , m_CurrentFontSize(12){    m_Window.reset(x_CreateWindow());    m_Buffer.reset(new Fl_Text_Buffer());    m_Text->buffer(m_Buffer.get());    m_Text->textfont(m_CurrentFont);    m_Text->textsize(m_CurrentFontSize);    m_TextSize->value(1);    m_TextFont->value(2);    // create our view menu manager    m_ViewMenuMgr.reset(new CViewMenuMgr(m_Menu, "View", this, pool_name));    // decode the argument    const CPluginCommand& args = msg.GetRequest().GetCommand();    const CPluginArg& arg = args["id"];    const IDocument* doc = arg.GetDocument();    const CSeq_id* id =        dynamic_cast<const CSeq_id*> (arg.GetObject());    // assign to our core components    if (doc  &&  id) {        x_SetDocument(*doc);        m_SeqId.Reset(id);    }}CViewAsn::~CViewAsn(){    m_Window.reset();    m_Buffer.reset();}void CViewAsn::OnDocumentChanged(){    CBioseq_Handle handle =        m_Document->GetScope().GetBioseqHandle(*m_SeqId);    string str;    if (handle) {        CConn_MemoryStream ostr;        {{            auto_ptr<CObjectOStream> os                (CObjectOStream::Open(eSerial_AsnText, ostr));            *os << handle.GetTopLevelSeqEntry();        }}        str.resize(ostr.tellp() - CT_POS_TYPE(0));        ostr.read(const_cast<char*>(str.data()), str.size());    }    m_Buffer->text(str.c_str());    // retrieve a nice title    SetTitle(x_GetTitle(handle));    m_Window->redraw();    if ( !GetSelBuffer() ) {        SetSelBuffer().AddSelection(m_Document, *m_SeqId);    }    m_ViewMenuMgr->AddActiveViews(m_Document);    m_ViewMenuMgr->AddNewViews();//   (m_Document);}const string& CViewAsn::GetTitle(void) const{    static string s_str("ASN.1 Text View");    return s_str;}//// view submenu//void CViewAsn::x_OnFontHelvetica(){    m_CurrentFont = FL_HELVETICA;    m_Text->textfont(FL_HELVETICA);    m_Text->redraw();    m_TextFont->value(0);    m_TextFont->redraw();}void CViewAsn::x_OnFontTimes(){    m_CurrentFont = FL_TIMES;    m_Text->textfont(FL_TIMES);    m_Text->redraw();    m_TextFont->value(1);    m_TextFont->redraw();}void CViewAsn::x_OnFontCourier(){    m_CurrentFont = FL_COURIER;    m_Text->textfont(FL_COURIER);    m_Text->redraw();    m_TextFont->value(2);    m_TextFont->redraw();}void CViewAsn::x_OnFontSmall(){    m_CurrentFontSize = 10;    m_Text->textsize(10);    m_Text->redraw();    m_TextSize->value(0);    m_TextSize->redraw();}void CViewAsn::x_OnFontNormal(){    m_CurrentFontSize = 12;    m_Text->textsize(12);    m_Text->redraw();    m_TextSize->value(1);    m_TextSize->redraw();}void CViewAsn::x_OnFontLarge(){    m_CurrentFontSize = 14;    m_Text->textsize(14);    m_Text->redraw();    m_TextSize->value(2);    m_TextSize->redraw();}//// help submenu//void CViewAsn::x_OnHelpTextViewHelp(){}END_NCBI_SCOPE/* * =========================================================================== * $Log: view_asn.cpp,v $ * Revision 1000.5  2004/06/01 21:02:27  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9  2004/05/21 22:27:50  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8  2004/04/16 14:47:57  dicuccio * Use appropriate ISelection interface for dynamic menus * * Revision 1.7  2004/04/07 13:05:11  dicuccio * Changed view API - require CPluginMessage instead of CPluginArgSet * * Revision 1.6  2004/02/20 20:03:27  ucko * Fix to compile with stricter implementations of CT_POS_TYPE * * Revision 1.5  2004/01/22 17:44:47  dicuccio * Use CConn_MemoryStream instead of CNcbiOstrstream for in-code streaming * * Revision 1.4  2003/12/22 19:35:39  dicuccio * Updated to match new APIs in IView.  Added taxonomy tree / common tree browser * * Revision 1.3  2003/11/24 15:45:46  dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.2  2003/11/20 13:19:17  dicuccio * Fixed calling parameters for views to match new requirements - pass view's message pool name as second param * * Revision 1.1  2003/11/04 17:27:21  dicuccio * Split text views into three components * * =========================================================================== */

⌨️ 快捷键说明

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