phylo_tree_demo_ui.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:6k
- /*
- * ===========================================================================
- * PRODUCTION $Log: phylo_tree_demo_ui.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:12:05 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: phylo_tree_demo_ui.cpp,v 1000.1 2004/06/01 21:12:05 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: Vlad Lebedev
- *
- * File Description:
- *
- */
- #include <ncbi_pch.hpp>
- #include "phylo_tree_demo_ui.hpp"
- #include <gui/utils/message_box.hpp>
- #include <gui/utils/fltk_utils.hpp>
- #include <objtools/data_loaders/genbank/gbloader.hpp>
- #include <serial/objistr.hpp>
- #include <objects/seq/Seq_annot.hpp>
- #include <serial/serial.hpp>
- #include <gui/widgets/phylo_tree/phylo_tree_reader.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- #include "phylo_tree_demo_ui_.cpp"
- Int4 currRenderer = 0;
- Fl_Menu_Item renderers[] = {
- {"Rectangle Cladogram", 0,0, (void*)"0"},
- {"Slated Cladogram", 0,0, (void*)"1"},
- {0}
- };
- void cb_Renderer(Fl_Widget * widget, void * data)
- {
- Fl_Menu_* mw = (Fl_Menu_*)widget;
- const Fl_Menu_Item* m = mw->mvalue();
- currRenderer = NStr::StringToInt(string((char*)m->user_data()));
- if(data) ((CPhyloTreeWidget*)data)->SetCurrRenderer(currRenderer);
- //((CPhyloTreeWidget*)data)->request_focus();
- }
- CPhyloTreeDemoUI::CPhyloTreeDemoUI()
- {
- m_Window = x_CreateWindow();
- CFltkEvent::SetOSDefaults();
-
- CPhyloPhylipReader * reader = new CPhyloPhylipReader("(A05242:3.0,A09942:4.0)");
- m_DataSource.Reset(new CPhyloTreeDataSource(reader));
-
- m_AlnWidget->SetDataSource(m_DataSource.GetPointer());
-
- }
- CPhyloTreeDemoUI::~CPhyloTreeDemoUI()
- {
- // these must be deleted in proper order
- m_DataSource.Reset();
- m_Scope.Reset();
- m_ObjMgr.Reset();
- }
- void CPhyloTreeDemoUI::Show(int argc, char** argv)
- {
- m_Renderer->menu(renderers);
- m_Renderer->value(0);
- m_Renderer->callback(cb_Renderer, (void*)m_AlnWidget);
- m_Window->show(argc, argv);
- Fl::run();
- }
- void CPhyloTreeDemoUI::x_OnLoadAccession()
- {
- /*
- CSeq_id id(m_Accession->value());
- if (id.Which() == CSeq_id::e_not_set) {
- string msg("Accession '");
- msg += m_Accession->value();
- msg += "' not recognized as a valid accession";
- NcbiMessageBox(msg, eDialog_Ok, eIcon_Exclamation,
- "Unhandled Accession");
- return;
- }
- if ( !m_ObjMgr ) {
- m_ObjMgr.Reset(new CObjectManager());
- m_ObjMgr->RegisterDataLoader(*new CGBDataLoader(),
- CObjectManager::eDefault);
- m_Scope.Reset(new CScope(*m_ObjMgr));
- m_Scope->AddDefaults();
- }
- // retrieve our sequence
- CBioseq_Handle handle = m_Scope->GetBioseqHandle(id);
- if ( !handle ) {
- string msg("Can't find sequence for accession '");
- msg += m_Accession->value();
- msg += "'";
- NcbiMessageBox(msg, eDialog_Ok, eIcon_Exclamation,
- "Sequence Not Found");
- return;
- }
- //m_DataSource.Reset(new CCrossAlnDataSource(aset.GetObject(), m_Scope.GetObject()));
- */
- }
- void CPhyloTreeDemoUI::x_OnLoadFile()
- {
- m_AlnWidget->SetDataSource(m_DataSource.GetPointer());
- /*
- string filename(m_InputFile->value());
- auto_ptr<CObjectIStream> is(CObjectIStream::Open(eSerial_AsnText, filename));
- //CRef<CSeq_align_set> aset(new CSeq_align_set());
- CRef<CSeq_annot> annot(new CSeq_annot());
- *is >> *annot;
- if ( !m_ObjMgr ) {
- m_ObjMgr.Reset(new CObjectManager());
- m_ObjMgr->RegisterDataLoader(*new CGBDataLoader(),
- CObjectManager::eDefault);
- m_Scope.Reset(new CScope(*m_ObjMgr));
- m_Scope->AddDefaults();
- }
- //m_DataSource.Reset(new CCrossAlnDataSource(aset.GetObject(), m_Scope.GetObject()));zzzzz
- m_DataSource.Reset(new CCrossAlnDataSource(annot.GetObject(), m_Scope.GetObject()));
- CCrossAlnDataSource::TIdRefCont all_ids = m_DataSource->GetSeqIDs();
- // choosing sequences to display
- if(all_ids.size() >1 ) {
- CCrossAlnDataSource::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_AlnWidget->SetDataSource(m_DataSource.GetPointer());
- x_FillLists();
- }
- */
- }
- void CPhyloTreeDemoUI::x_QuitApp()
- {
- delete m_MainWindow;
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: phylo_tree_demo_ui.cpp,v $
- * Revision 1000.1 2004/06/01 21:12:05 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2
- *
- * Revision 1.2 2004/05/21 22:27:54 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.1 2004/02/13 17:05:23 tereshko
- * Phylogenetic Tree Widget initial revision
- *
- * Revision 1.2 2004/01/05 18:50:29 vasilche
- * Fixed path to include files.
- *
- * Revision 1.1 2003/12/22 13:09:17 lebedev
- * Initial revision
- *
- * ===========================================================================
- */