From 1a88107e19ea887e69f085d6c11eb0e132e4129b Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 3 Oct 2006 01:14:56 +0000 Subject: [PATCH] Allow MussaAlignedWindows to create subanalyses I passed a shared_ptr reference for the subanalysis window from MussaWindow to MussaAlignedWindow so either window can be used to customize the same subanalysis. --- qui/MussaAlignedWindow.cpp | 33 +++++++++++++++++++++++++++++++++ qui/MussaAlignedWindow.hpp | 13 ++++++++++++- qui/MussaWindow.cpp | 4 ++-- qui/MussaWindow.hpp | 2 +- qui/SubanalysisWindow.hpp | 3 +++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/qui/MussaAlignedWindow.cpp b/qui/MussaAlignedWindow.cpp index 65e3d7b..4c917c4 100644 --- a/qui/MussaAlignedWindow.cpp +++ b/qui/MussaAlignedWindow.cpp @@ -14,9 +14,11 @@ using namespace std; MussaAlignedWindow::MussaAlignedWindow(MussaRef m, const set& sel_paths, + SubanalysisWindowRef window, QWidget *parent) : QMainWindow(parent), analysis(m), + subanalysis_window(window), pick_align_menu(tr("Choose Alignment")), view_align_menu(tr("View Alignment")), zoom(0), @@ -50,6 +52,11 @@ MussaAlignedWindow::MussaAlignedWindow(MussaRef m, void MussaAlignedWindow::setupActions() { + // more cut-n-paste from MussaWindow + createSubAnalysisAction = new QAction(tr("Add to Subanalysis"), this); + connect(createSubAnalysisAction, SIGNAL(triggered()), + this, SLOT(createSubAnalysis())); + //Save pixel map action saveBrowserPixmapAction = new QAction(tr("Save to image..."), this); connect(saveBrowserPixmapAction, (SIGNAL(triggered())), @@ -64,6 +71,13 @@ void MussaAlignedWindow::setupMenus() newMenu = menuBar()->addMenu(tr("&Edit")); newMenu->addAction(browser.getCopySelectedSequenceAsFastaAction()); + newMenu->addAction(createSubAnalysisAction); + + // add some extra features to the context menu + QMenu *popupMenu = browser.getPopupMenu(); + if (popupMenu) { + popupMenu->addAction(createSubAnalysisAction); + } } void MussaAlignedWindow::setupAlignmentMenus() @@ -137,6 +151,25 @@ void MussaAlignedWindow::setSelectedPaths(MussaRef m, const set& sel_paths) } } +// FIXME: this is a cut-n-paste from MussaWindow, perhaps they should be refactored to +// some shared place +void MussaAlignedWindow::createSubAnalysis() +{ + list result; + SequenceLocationModel& model = subanalysis_window->getModel(); + browser.copySelectedTracksAsSeqLocation(result); + for(list::iterator result_itor = result.begin(); + result_itor != result.end(); + ++result_itor) + { + model.push_back(*result_itor); + } + + if (not subanalysis_window->isVisible()) { + subanalysis_window->show(); + } +} + void MussaAlignedWindow::setAlignment(int alignment_index) { if (selected_paths.size() > 0) { diff --git a/qui/MussaAlignedWindow.hpp b/qui/MussaAlignedWindow.hpp index c4715f9..452ac0e 100644 --- a/qui/MussaAlignedWindow.hpp +++ b/qui/MussaAlignedWindow.hpp @@ -12,6 +12,7 @@ #include "qui/IntAction.hpp" #include "qui/ZoomWidget.hpp" #include "qui/seqbrowser/SequenceBrowserWidget.hpp" +#include "qui/SubanalysisWindow.hpp" //! Show sequence alignments class MussaAlignedWindow : public QMainWindow @@ -22,11 +23,16 @@ public: //! construct an aligned window for an analysis and selected paths /*! \param analysis is a shared_ptr to a mussa analysis * \param paths is a set of "paths" AKA integer offsets into the sequences stored in mussa + * \param window points to a SubanalysisWindowRef, so we can pick interesting + * sequence portions from both the mussa window and the sequence view window * \param parent is the typical Qt pointer to a parent widget */ - MussaAlignedWindow(MussaRef analysis, const std::set& paths, QWidget *parent=0); + MussaAlignedWindow(MussaRef analysis, const std::set& paths, + SubanalysisWindowRef window, QWidget *parent=0); public slots: + //! launch a sub analysis + void createSubAnalysis(); //! use selected_paths[pathid] to set the starting position of our sequence void setAlignment(int pathid); //! toggle whether or not to show the aligned basepairs of a window @@ -51,10 +57,12 @@ protected: //const std::set& selected_paths; std::vector selected_paths; std::vector view_paths; + SubanalysisWindowRef subanalysis_window; SequenceBrowserWidget browser; QMenu pick_align_menu; QMenu view_align_menu; + QAction *createSubAnalysisAction; QAction *saveBrowserPixmapAction; std::vector pick_actions; @@ -62,4 +70,7 @@ protected: ZoomWidget *zoom; QToolBar *alignTB; }; + +//! reference to a MussaAlignedWindow +typedef boost::shared_ptr MussaAlignedWindowRef; #endif diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index cb3c2ce..0170230 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -608,8 +608,8 @@ void MussaWindow::viewMussaAlignment() QObject::tr("you should probably select some paths " "first")); } else { - boost::shared_ptr ma_win( - new MussaAlignedWindow(analysis, selected_paths) + MussaAlignedWindowRef ma_win( + new MussaAlignedWindow(analysis, selected_paths, subanalysis_window) ); aligned_windows.push_back(ma_win); diff --git a/qui/MussaWindow.hpp b/qui/MussaWindow.hpp index ed34adb..8371c66 100644 --- a/qui/MussaWindow.hpp +++ b/qui/MussaWindow.hpp @@ -102,7 +102,7 @@ protected: std::list > aligned_windows; MotifEditor *motif_editor; MussaSetupDialog *setup_analysis_dialog; - boost::shared_ptr subanalysis_window; + SubanalysisWindowRef subanalysis_window; // display our wonderful mussa output SequenceBrowserWidget *browser; diff --git a/qui/SubanalysisWindow.hpp b/qui/SubanalysisWindow.hpp index ce141e8..0bf3294 100644 --- a/qui/SubanalysisWindow.hpp +++ b/qui/SubanalysisWindow.hpp @@ -36,4 +36,7 @@ private: SequenceLocationModel model; }; + +//! reference to a subanalysis window +typedef boost::shared_ptr SubanalysisWindowRef; #endif -- 2.30.2