view_featid.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: view_featid.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 21:01:18 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: view_featid.cpp,v 1000.2 2004/06/01 21:01:18 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:
- *
- */
- #include <ncbi_pch.hpp>
- #include "view_featid.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 <objmgr/util/feature.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- #include "view_featid_.cpp"
- void CViewFeatId::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CViewFeatId", "Feature IDs",
- "List of IDs in features", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& args = cmds.AddViewCommand(eViewCommand_new_view);
- args.AddArgument("feat", "Feature to display",
- CSeq_feat::GetTypeInfo());
- }
- CViewFeatId::CViewFeatId(const CPluginMessage& msg,
- const string& pool_name)
- : CView()
- {
- m_Window.reset(x_CreateWindow());
- // create our dynamic menu managers
- m_AlgoMenuMgr.reset(new CAlgoMenuMgr(m_Menu, "Tools", this));
- m_ViewMenuMgr.reset(new CViewMenuMgr(m_Menu, "View", this, pool_name));
- // decode the argument
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- const CPluginArg& arg = args["feat"];
- const IDocument* doc = arg.GetDocument();
- const CSeq_feat* feat =
- dynamic_cast<const CSeq_feat*> (arg.GetObject());
- // assign to our core components
- if (doc && feat) {
- x_SetDocument(*doc);
- m_Feature.Reset(feat);
- }
- }
- /**
- void CViewFeatId::OnSelectionChanged(const CSelectionBuffer& buf)
- {
- m_StatusBar->SetMessage("No features.");
- if ( !m_FeatIdTable || !GetDocument() || &buf == &GetSelBuffer()) {
- return;
- }
- // accept our selections
- SetSelBuffer().Clear();
- m_FeatIdTable->ClearSelections();
- CSelectionBuffer::TSelList sels = buf.DecomposeToPairs();
- ITERATE (CSelectionBuffer::TSelList, iter, sels) {
- const IDocument* doc = iter->m_Document;
- // only accept selections for the current document
- if ( doc != m_Document) {
- continue;
- }
- // only select seq-feat selections
- const CSeq_feat* feat =
- dynamic_cast<const CSeq_feat*>(iter->m_Object.GetPointer());
- if ( !feat ) {
- continue;
- }
- // select!
- SetSelBuffer().AddSelection(doc, *feat);
- m_FeatIdTable->SelectFeature(*feat);
- }
- m_FeatIdTable->redraw();
- // prepare our status bar message
- x_UpdateStatusMessage();
- // reset our menus
- x_UpdateDynMenus();
- }
- **/
- void CViewFeatId::OnDocumentChanged()
- {
- x_Update();
- }
- void CViewFeatId::x_Update()
- {
- SetTitle(GetTitle());
- m_StatusBar->SetMessage("No features.");
- if ( !m_FeatIdTable || !GetDocument() ) {
- return;
- }
- m_FeatIdTable->Update(*m_Feature);
- string str = m_Document->GetShortTitle() + ": ";
- feature::GetLabel(*m_Feature, &str, feature::eBoth,
- &m_Document->GetScope());
- SetTitle(str);
- // prepare our status bar message
- x_UpdateStatusMessage();
- // update our dynamic menus
- x_UpdateDynMenus();
- }
- void CViewFeatId::x_UpdateStatusMessage()
- {
- }
- void CViewFeatId::x_UpdateDynMenus()
- {
- m_ViewMenuMgr->Clear();
- m_AlgoMenuMgr->Clear();
- m_ViewMenuMgr->AddActiveViews(GetDocument());
- m_ViewMenuMgr->AddNewViews();
- m_AlgoMenuMgr->AddAlgoMenu();
- }
-
- const string& CViewFeatId::GetTitle() const
- {
- static string s_str("Feature ID View");
- return s_str;
- }
- void CViewFeatId::x_OnHelp()
- {
- }
- void CViewFeatId::x_OnSelChanged()
- {
- SetSelBuffer().Clear();
- // find our selected IDs
- for (size_t i = 0; i < m_FeatIdTable->GetRows(); ++i) {
- if ( !m_FeatIdTable->row_selected(i) ) {
- continue;
- }
- const CSeq_loc* loc = m_FeatIdTable->GetData(i);
- if (loc) {
- SetSelBuffer().AddSelection(GetDocument(), *loc);
- }
- }
- // update our dynamic menus
- x_UpdateDynMenus();
- //...and notify our connected views
- PostSelectionChanged(GetSelBuffer());
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: view_featid.cpp,v $
- * Revision 1000.2 2004/06/01 21:01:18 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5
- *
- * Revision 1.5 2004/05/21 22:27:49 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.4 2004/04/16 14:47:27 dicuccio
- * Enabled alignment table view. Use appropriate ISelection interface for dynamic menus
- *
- * Revision 1.3 2004/04/07 13:05:11 dicuccio
- * Changed view API - require CPluginMessage instead of CPluginArgSet
- *
- * Revision 1.2 2004/01/20 18:17:53 dicuccio
- * Changed to match new API in CTablePanel
- *
- * Revision 1.1 2004/01/13 20:38:47 dicuccio
- * Added new view: feature IDs
- *
- * ===========================================================================
- */