view_alntable.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:10k
- /*
- * ===========================================================================
- * PRODUCTION $Log: view_alntable.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 21:01:08 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: view_alntable.cpp,v 1000.2 2004/06/01 21:01:08 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_alntable.hpp"
- #include "visible_range_dlg.hpp"
- #include "preference_dlg.hpp"
- #include <gui/types.hpp>
- #include <gui/core/doc_manager.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 <objmgr/seq_vector.hpp>
- #include <serial/typeinfo.hpp>
- #include <objmgr/util/sequence.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- #include "view_alntable_.cpp"
- void CViewAlnTable::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CViewAlnTable", "Alignment Table",
- "Tabular list of alignments", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& args = cmds.AddViewCommand(eViewCommand_new_view);
- args.AddArgument("aligns", "Alignments to display",
- CSeq_align::GetTypeInfo(),
- CPluginArg::TData::e_Array);
- }
- CViewAlnTable::CViewAlnTable(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", m_AlnTable));
- m_ViewMenuMgr.reset(new CViewMenuMgr(m_Menu, "View", m_AlnTable, pool_name));
- // decode the argument
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- plugin_args::TAlignList aligns;
- GetArgValue(args["aligns"], aligns);
- list< CConstRef<CSeq_align> > align_list;
- CConstRef<IDocument> doc_ref;
- ITERATE (plugin_args::TAlignList, iter, aligns) {
- doc_ref = iter->first;
- align_list.push_back(iter->second);
- }
- x_SetDocument(*doc_ref);
- m_DataSource.Reset(new CAlnTableDS(doc_ref->GetScope(), align_list));
- m_AlnTable->SetDataSource(*m_DataSource);
- }
- void CViewAlnTable::OnDocumentChanged()
- {
- x_Update();
- }
- void CViewAlnTable::x_Update()
- {
- SetTitle(GetTitle());
- m_StatusBar->SetMessage("No alignments.");
- if ( !m_AlnTable || !GetDocument() ) {
- return;
- }
- m_AlnTable->Update();
- // prepare our status bar message
- x_UpdateStatusMessage();
- // update our dynamic menus
- x_UpdateDynMenus();
- }
- void CViewAlnTable::x_UpdateStatusMessage()
- {
- //
- // prepare our status bar message
- //
- string status_msg;
- int total_aligns = m_AlnTable->GetRows();
- status_msg = NStr::IntToString(total_aligns) + " alignment";
- if (total_aligns != 1) {
- status_msg += "s";
- }
- m_StatusBar->SetMessage(status_msg);
- }
- void CViewAlnTable::x_UpdateDynMenus()
- {
- m_ViewMenuMgr->Clear();
- m_AlgoMenuMgr->Clear();
- m_ViewMenuMgr->AddActiveViews(GetDocument());
- m_ViewMenuMgr->AddNewViews();
- m_AlgoMenuMgr->AddAlgoMenu();
- }
-
- const string& CViewAlnTable::GetTitle() const
- {
- static string s_str("Alignment Table View");
- return s_str;
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: view_alntable.cpp,v $
- * Revision 1000.2 2004/06/01 21:01:08 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- *
- * Revision 1.3 2004/05/21 22:27:49 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.2 2004/04/16 14:47:27 dicuccio
- * Enabled alignment table view. Use appropriate ISelection interface for dynamic menus
- *
- * Revision 1.1 2004/04/07 12:01:35 dicuccio
- * Initial revision
- *
- * Revision 1.34 2004/03/11 17:47:22 dicuccio
- * Use TSeqRange instead of TRange
- *
- * Revision 1.33 2004/01/27 18:45:35 dicuccio
- * Added missing header files
- *
- * Revision 1.32 2004/01/20 18:17:53 dicuccio
- * Changed to match new API in CTablePanel
- *
- * Revision 1.31 2004/01/07 18:51:46 dicuccio
- * Guard against self-assignment in OnSelectionsChanged()
- *
- * Revision 1.30 2003/12/30 15:03:56 dicuccio
- * Added ability to pass selections into feature table
- *
- * Revision 1.29 2003/12/24 17:23:49 friedman
- * Changed x_UpdateDynMenus to pass in visible range seqloc instead of seqid.
- *
- * Revision 1.28 2003/12/24 16:33:18 friedman
- * Added posting visible range change message.
- *
- * Revision 1.27 2003/12/22 19:32:24 dicuccio
- * Lots of code clean-up. Changed to match new APIs in IView. Added first pass
- * at processing selections (not entirely working)
- *
- * Revision 1.26 2003/12/22 18:15:08 friedman
- * Added various visible range methods and the selection of a method
- * through the preference menu selection and dialog.
- *
- * Revision 1.25 2003/12/03 22:24:12 friedman
- * Added changing visible range of the table.
- *
- * Revision 1.24 2003/11/26 19:45:39 friedman
- * Changed CSeq_id plugn arg to CSeq_loc. Set visible range based on seq loc passed in.
- *
- * Revision 1.23 2003/11/24 15:45:45 dicuccio
- * Renamed CVersion to CPluginVersion
- *
- * Revision 1.22 2003/11/20 21:50:39 jcherry
- * Set status message *after* updating feature table (fixes reporting of
- * number of features)
- *
- * Revision 1.21 2003/11/20 16:54:33 ucko
- * OnVisibleRangeChanged: don't try to introduce const in static_cast<>.
- *
- * Revision 1.20 2003/11/19 20:45:28 friedman
- * Added handling a visible range change event
- *
- * Revision 1.19 2003/11/04 12:51:28 friedman
- * Added event message pool callbacks for the document all-view message pool.
- *
- * Revision 1.18 2003/10/27 20:03:42 dicuccio
- * Rearranged Update() to be consistent
- *
- * Revision 1.17 2003/10/07 13:47:07 dicuccio
- * Renamed CPluginURL* to CPluginValue*
- *
- * Revision 1.16 2003/09/04 14:54:23 dicuccio
- * Use IDocument instead of CDocument. Changed APIs to match changes in IView
- *
- * Revision 1.15 2003/07/31 17:04:34 dicuccio
- * Changed type stored by feature table view - use CMappedFeat instead of CFeature
- * (less memory consumption)
- *
- * Revision 1.14 2003/07/22 15:32:17 dicuccio
- * Changed to make use of new API in plugin_utils.hpp - GetArgValue()
- *
- * Revision 1.13 2003/06/26 15:33:41 dicuccio
- * Moved GetURLValue() from PluginURL.hpp to plugin_utils.hpp. Fixed compilation
- * errors relating to missing #includes
- *
- * Revision 1.12 2003/06/25 17:03:01 dicuccio
- * Split CPluginHandle into a handle (pointer-to-implementation) and
- * implementation file. Lots of #include file clean-ups.
- *
- * Revision 1.11 2003/06/20 14:53:53 dicuccio
- * Revised plugin registration - moved GetInfo() into the plugin handler
- *
- * Revision 1.10 2003/06/02 16:06:24 dicuccio
- * Rearranged src/objects/ subtree. This includes the following shifts:
- * - src/objects/asn2asn --> arc/app/asn2asn
- * - src/objects/testmedline --> src/objects/ncbimime/test
- * - src/objects/objmgr --> src/objmgr
- * - src/objects/util --> src/objmgr/util
- * - src/objects/alnmgr --> src/objtools/alnmgr
- * - src/objects/flat --> src/objtools/flat
- * - src/objects/validator --> src/objtools/validator
- * - src/objects/cddalignview --> src/objtools/cddalignview
- * In addition, libseq now includes six of the objects/seq... libs, and libmmdb
- * replaces the three libmmdb? libs.
- *
- * Revision 1.9 2003/05/19 13:46:51 dicuccio
- * Moved gui/core/plugin/ --> gui/plugin/. Merged core libraries into
- * libgui_core.so
- *
- * Revision 1.8 2003/04/29 14:56:16 dicuccio
- * Reworked FLUID-generated code: better memory management, more explicit control
- * over the constructor
- *
- * Revision 1.7 2003/04/24 16:42:52 dicuccio
- * Updated to reflect changes in IDocument, plugin API
- *
- * Revision 1.6 2003/03/17 14:54:15 dicuccio
- * Changed base class CView - added member variable for FLTK gui component for
- * child windows, which is now maintained via an auto_ptr<>. Eliminated
- * Show()/Hide() as a pure virtual requirement.
- *
- * Revision 1.5 2003/03/03 14:58:56 dicuccio
- * Changed to use visible range from the base class. Added an explicit setter for
- * the visible range
- *
- * Revision 1.4 2003/01/13 13:10:09 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted all to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.3 2003/01/08 14:58:47 dicuccio
- * Major overhaul. Added column selection dialog to base class - moved out of
- * this class. Added ability to sort columns based on menu selections. Added
- * ability to filter features based on a wide range of criteria.
- *
- * Revision 1.2 2002/12/31 16:16:27 dicuccio
- * Fixed odd compiler error in MSVC release builds - ambiguous '&&' operator
- *
- * Revision 1.1 2002/12/30 18:49:41 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */