view_hit_matrix.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:8k
- /*
- * ===========================================================================
- * PRODUCTION $Log: view_hit_matrix.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 20:59:19 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: view_hit_matrix.cpp,v 1000.2 2004/06/01 20:59:19 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: Andrey Yazhuk
- *
- * File Description:
- * User-modifiable implementation file for extension of Dot Matrix
- * viewer for GBENCH
- */
- #include <ncbi_pch.hpp>
- #include "view_hit_matrix.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 <gui/objutils/utils.hpp>
- #include <serial/iterator.hpp>
- BEGIN_NCBI_SCOPE
- // We include the generated _.cpp file here. This avoids a nasty bug in some
- // versions of gcc in which inline functions are not intantiated.
- #include "view_hit_matrix_.cpp"
- //
- // standard plugin announcement boilerplate
- //
- void CHitMatrixView::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CHitMatrixView",
- "Dot Matrix Viewer",
- "Dot Matrix Viewer", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& args = cmds.AddViewCommand(eViewCommand_new_view);
- /*args.AddArgument("alignments", "Alignments to render",
- CSeq_align_set::GetTypeInfo(),
- CPluginArg::TData::e_Single);*/
- args.AddArgument("alignments", "Alignments to render",
- CSeq_annot::GetTypeInfo(),
- CPluginArg::TData::e_Single);
- args.SetConstraint("alignments",
- *CPluginValueConstraint::CreateAnnotType
- (CSeq_annot::TData::e_Align));
- /*args.SetConstraint("alignments",
- *CPluginValueConstraint::CreateAnnotType
- (CSeq_annot::TData::e_Align));*/
- }
- static
- DEFINE_MENU(Menu)
- SUBMENU("Zoom")
- MENU_ITEM(eCmdZoomIn, "Zoom In")
- MENU_ITEM(eCmdZoomOut, "Zoom Out")
- MENU_ITEM(eCmdZoomAll, "Zoom All")
- MENU_ITEM(eCmdZoomObjects, "Zoom to Hits")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomSel, "Zoom to Selection")
- MENU_ITEM(eCmdZoomSelObjects, "Zoom to Selected Hits")
- MENU_ITEM(eCmdSetEqualScale, "Make Proportional")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomInX, "Zoom In Subject")
- MENU_ITEM(eCmdZoomOutX, "Zoom Out Subject")
- MENU_ITEM(eCmdZoomAllX, "Zoom All Subject")
- MENU_SEPARATOR()
- MENU_ITEM(eCmdZoomInY, "Zoom In Query")
- MENU_ITEM(eCmdZoomOutY, "Zoom Out Query")
- MENU_ITEM(eCmdZoomAllY, "Zoom All Query")
- END_SUBMENU()
- SUBMENU("View")
- MENU_ITEM(eCmdChooseSeq, "Choose Sequences to Display...")
- MENU_ITEM(eCmdColorByScore, "Color by Score...")
- MENU_SEPARATOR()
- END_SUBMENU()
- END_MENU()
- CHitMatrixView::CHitMatrixView(const CPluginMessage& msg,
- const string& pool_name)
- : CAlnView()
- {
- m_Window.reset(x_CreateWindow());
-
- m_MenuBar->SetItems(Menu);
- m_MenuBar->SetCmdTarget(m_AlnView);
- // set our core components
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- const CPluginArg& arg = args["alignments"];
- // extract the alignments from the argument
- const CSeq_annot* annot =
- dynamic_cast<const CSeq_annot*>(arg.GetObject());
- const IDocument* doc = arg.GetDocument();
- if (annot && doc) {
- x_SetDocument(*doc);
- m_AnnotData.Reset(annot);
- }
- // create the view menu manager
- m_ViewMenuMgr.reset(new CViewMenuMgr(m_MenuBar, "View", this, pool_name));
- }
- void CHitMatrixView::OnDocumentChanged()
- {
- if (!m_Document) {
- return;
- }
- SetTitle(m_Document->GetShortTitle() + ": " + GetTitle());
- // create our alignment manager
- m_DataSource.Reset(
- new CHitMatrixDataSource(*m_AnnotData, m_Document->GetScope()));
- CHitMatrixDataSource::TIdRefCont all_ids = m_DataSource->GetSeqIDs();
- // choosing sequences to display
- if(all_ids.size() >1 ) {
- CHitMatrixDataSource::TIdRefCont::const_iterator it = all_ids.begin();
- CConstRef<CSeq_id> s_id(*it);
- CConstRef<CSeq_id> q_id(*(++it));
- m_DataSource->SelectIds(s_id, q_id);
- m_AlnView->SetDataSource(m_DataSource.GetPointer());
- }
-
- SetSelBuffer().Clear();
- SetSelBuffer().AddSelection(m_Document, *m_AnnotData);
- m_ViewMenuMgr->AddActiveViews(m_Document);
- m_ViewMenuMgr->AddNewViews();// (m_Document);
- }
- void CHitMatrixView::OnSelectionChanged(const CSelectionBuffer& buf)
- {
- if (!m_Document) {
- return;
- }
-
- SetSelBuffer().Clear();
- SetSelBuffer().AddSelection(m_Document, *m_AnnotData);
- m_ViewMenuMgr->AddActiveViews(m_Document);
- m_ViewMenuMgr->AddNewViews();// (m_Document);
- }
- const string& CHitMatrixView::GetTitle(void) const
- {
- static string s_str("Dot Matrix View");
- return s_str;
- }
- void CHitMatrixView::x_OnFileClose()
- {
- Hide();
- }
- void CHitMatrixView::x_OnZoomIn()
- {
- m_AlnView->OnZoomIn();
- }
- void CHitMatrixView::x_OnZoomOut()
- {
- m_AlnView->OnZoomOut();
- }
- void CHitMatrixView::x_OnZoomAll()
- {
- m_AlnView->OnZoomAll();
- }
- void CHitMatrixView::x_OnHelp()
- {
- }
- /*
- void CHitMatrixView::x_OnZoomSelection()
- {
- if (m_AlnView) {
- m_AlnView->OnZoomSelection();
- }
- }
- void CHitMatrixView::x_OnZoomSequence()
- {
- if (m_AlnView) {
- m_AlnView->OnZoomSequence();
- }
- }
- void CHitMatrixView::x_OnClearSelections()
- {
- if (m_AlnView) {
- m_AlnView->OnResetSelection();
- }
- }
- */
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: view_hit_matrix.cpp,v $
- * Revision 1000.2 2004/06/01 20:59:19 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8
- *
- * Revision 1.8 2004/05/21 22:27:49 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.7 2004/05/03 17:53:55 dicuccio
- * Tweaked makefiles to support new gui_objutils library
- *
- * Revision 1.6 2004/04/16 14:44:17 dicuccio
- * Pass appropriate ISelection interface to dynamic menus
- *
- * Revision 1.5 2004/04/07 13:02:00 dicuccio
- * Changed view API - require CPluginMessage instead of CPluginArgSet in ctor.
- * Changed published name of view from Hit Matrix to Dot Matrix
- *
- * Revision 1.4 2004/02/12 21:08:31 yazhuk
- * Reorganized menu and added new commands
- *
- * Revision 1.3 2004/01/15 20:53:16 yazhuk
- * Renamed m_Menu to m_MenuBar, added menu definition and menu setup code
- *
- * Revision 1.2 2003/12/22 19:33:15 dicuccio
- * Lots of changes. Changed to match new APIs in IView. Added better handling of messages received from other views
- *
- * Revision 1.1 2003/12/05 20:06:05 yazhuk
- * Initial revision
- *
- * ===========================================================================
- */