From 3c8be168c0f958611de0b1c813bd099e5fd19fce Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Fri, 17 Mar 2006 07:16:57 +0000 Subject: [PATCH] refactored PathScene into SequenceBrowserWidget The thing that was really hurting my brain was trying to keep track of which of all the classes needed to actually implement the SequenceBrowserWidget was actually implementing some function. SequenceBrowserWidget is now the central control widget that manages how all of the sub-widgets connect. I could've tried to simplify how the SequenceBrowserWidget::updatePosition code worked but it was to hard and I didn't bother. --- Doxyfile | 2 +- alg/{gltracks.cpp => glseqbrowser.cpp} | 72 +++++----- alg/{gltracks.hpp => glseqbrowser.hpp} | 12 +- alg/module.mk | 2 +- alg/test/module.mk | 2 +- alg/test/test_annotation_color.cpp | 19 +++ ...est_gltracks.cpp => test_glseqbrowser.cpp} | 8 +- mussagl.cpp | 4 +- mussagl.pro | 28 ++-- qui/{PathWindow.cpp => MussaWindow.cpp} | 81 ++++------- qui/{PathWindow.hpp => MussaWindow.hpp} | 20 ++- qui/PathSidebar.hpp | 21 --- qui/PathWidget.cpp | 51 ------- qui/PathWidget.hpp | 28 ---- qui/ScrollableScene.hpp | 31 ----- .../ScrollableSequenceBrowser.cpp} | 23 ++-- qui/seqbrowser/ScrollableSequenceBrowser.hpp | 32 +++++ .../SequenceBrowser.cpp} | 53 ++++--- .../SequenceBrowser.hpp} | 6 +- .../SequenceBrowserSidebar.cpp} | 18 +-- qui/seqbrowser/SequenceBrowserSidebar.hpp | 39 ++++++ qui/seqbrowser/SequenceBrowserWidget.cpp | 130 ++++++++++++++++++ qui/seqbrowser/SequenceBrowserWidget.hpp | 59 ++++++++ qui/{ => seqbrowser}/SequenceDescription.cpp | 4 +- qui/{ => seqbrowser}/SequenceDescription.hpp | 0 25 files changed, 434 insertions(+), 311 deletions(-) rename alg/{gltracks.cpp => glseqbrowser.cpp} (86%) rename alg/{gltracks.hpp => glseqbrowser.hpp} (93%) rename alg/test/{test_gltracks.cpp => test_glseqbrowser.cpp} (86%) rename qui/{PathWindow.cpp => MussaWindow.cpp} (83%) rename qui/{PathWindow.hpp => MussaWindow.hpp} (84%) delete mode 100644 qui/PathSidebar.hpp delete mode 100644 qui/PathWidget.cpp delete mode 100644 qui/PathWidget.hpp delete mode 100644 qui/ScrollableScene.hpp rename qui/{ScrollableScene.cpp => seqbrowser/ScrollableSequenceBrowser.cpp} (54%) create mode 100644 qui/seqbrowser/ScrollableSequenceBrowser.hpp rename qui/{PathScene.cpp => seqbrowser/SequenceBrowser.cpp} (58%) rename qui/{PathScene.hpp => seqbrowser/SequenceBrowser.hpp} (88%) rename qui/{PathSidebar.cpp => seqbrowser/SequenceBrowserSidebar.cpp} (61%) create mode 100644 qui/seqbrowser/SequenceBrowserSidebar.hpp create mode 100644 qui/seqbrowser/SequenceBrowserWidget.cpp create mode 100644 qui/seqbrowser/SequenceBrowserWidget.hpp rename qui/{ => seqbrowser}/SequenceDescription.cpp (94%) rename qui/{ => seqbrowser}/SequenceDescription.hpp (100%) diff --git a/Doxyfile b/Doxyfile index 3f2a47d..ecd33c0 100644 --- a/Doxyfile +++ b/Doxyfile @@ -450,7 +450,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = alg qui . +INPUT = alg qui qui/seqbrowser . # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/alg/gltracks.cpp b/alg/glseqbrowser.cpp similarity index 86% rename from alg/gltracks.cpp rename to alg/glseqbrowser.cpp index 1d5e1e1..cb6b0e3 100644 --- a/alg/gltracks.cpp +++ b/alg/glseqbrowser.cpp @@ -1,4 +1,4 @@ -#include "alg/gltracks.hpp" +#include "alg/glseqbrowser.hpp" #include "mussa_exceptions.hpp" #include @@ -6,7 +6,7 @@ using namespace std; -GlTracks::GlTracks() +GlSeqBrowser::GlSeqBrowser() : border(25), max_ortho(400.0, 0.0, 600.0, 0.0), cur_ortho(max_ortho), @@ -18,7 +18,7 @@ GlTracks::GlTracks() { } -GlTracks::GlTracks(const GlTracks& gt) +GlSeqBrowser::GlSeqBrowser(const GlSeqBrowser& gt) : border(gt.border), max_ortho(gt.max_ortho), cur_ortho(gt.cur_ortho), @@ -30,7 +30,7 @@ GlTracks::GlTracks(const GlTracks& gt) { } -void GlTracks::initializeGL() +void GlSeqBrowser::initializeGL() { glEnable(GL_DEPTH_TEST); glClearColor(1.0, 1.0, 1.0, 0.0); @@ -38,7 +38,7 @@ void GlTracks::initializeGL() glShadeModel(GL_FLAT); } -void GlTracks::resizeGL(int width, int height) +void GlSeqBrowser::resizeGL(int width, int height) { viewport_size.x = width; viewport_size.y = height; @@ -46,7 +46,7 @@ void GlTracks::resizeGL(int width, int height) //update_layout(); } -void GlTracks::paintGL() const +void GlSeqBrowser::paintGL() const { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); @@ -63,7 +63,7 @@ void GlTracks::paintGL() const glFlush(); } -void GlTracks::processSelection(GLuint hits, GLuint buffer[], GLuint bufsize) +void GlSeqBrowser::processSelection(GLuint hits, GLuint buffer[], GLuint bufsize) { GLuint *ptr; GLuint names; @@ -130,7 +130,7 @@ void GlTracks::processSelection(GLuint hits, GLuint buffer[], GLuint bufsize) } } -void GlTracks::selectRegion(int top, int left, int bottom, int right) +void GlSeqBrowser::selectRegion(int top, int left, int bottom, int right) { GLfloat x_scale = cur_ortho.width()/((float)viewport_size.x); GLfloat y_scale = cur_ortho.height()/((float)viewport_size.y); @@ -151,7 +151,7 @@ void GlTracks::selectRegion(int top, int left, int bottom, int right) // hopefully this will make a buffer big enough to receive // everything being selected //const size_t pathz_count = mussaAnalysis->paths().refined_pathz.size(); - //const GLuint select_buf_size = 1 + 5 * (pathz_count + tracks.size()); + //const GLuint select_buf_size = 1 + 5 * (pathz_count + sequences.size()); const GLuint select_buf_size = 500000; GLuint selectBuf[select_buf_size]; glSelectBuffer(select_buf_size, selectBuf); @@ -173,82 +173,82 @@ void GlTracks::selectRegion(int top, int left, int bottom, int right) processSelection(hits, selectBuf, select_buf_size); } -float GlTracks::left() const +float GlSeqBrowser::left() const { return max_ortho.left; } -float GlTracks::right() const +float GlSeqBrowser::right() const { return max_ortho.right; } -void GlTracks::setViewportCenter(float x) +void GlSeqBrowser::setViewportCenter(float x) { update_viewport(x, zoom_level); viewport_center = x; } -float GlTracks::viewportLeft() const +float GlSeqBrowser::viewportLeft() const { return cur_ortho.left; } -float GlTracks::viewportCenter() const +float GlSeqBrowser::viewportCenter() const { return viewport_center; } -float GlTracks::viewportRight() const +float GlSeqBrowser::viewportRight() const { return cur_ortho.right; } -float GlTracks::viewportHeight() const +float GlSeqBrowser::viewportHeight() const { return cur_ortho.top - cur_ortho.bottom; } -float GlTracks::viewportWidth() const +float GlSeqBrowser::viewportWidth() const { return cur_ortho.right - cur_ortho.left; } -void GlTracks::setZoom(int new_zoom) +void GlSeqBrowser::setZoom(int new_zoom) { update_viewport(viewport_center, new_zoom); zoom_level = new_zoom; } -int GlTracks::zoom() const +int GlSeqBrowser::zoom() const { return zoom_level; } -void GlTracks::setColorMapper(AnnotationColors& cm) +void GlSeqBrowser::setColorMapper(AnnotationColors& cm) { color_mapper = cm; } -AnnotationColors& GlTracks::colorMapper() +AnnotationColors& GlSeqBrowser::colorMapper() { return color_mapper; } -void GlTracks::clear() +void GlSeqBrowser::clear() { clear_links(); path_segments.clear(); track_container.clear(); } -void GlTracks::push_sequence(const Sequence &s) +void GlSeqBrowser::push_sequence(const Sequence &s) { GlSequence gs(s, color_mapper); push_sequence(gs); } -void GlTracks::push_sequence(GlSequence &gs) +void GlSeqBrowser::push_sequence(GlSequence &gs) { clear_links(); pathid = 0; @@ -258,12 +258,12 @@ void GlTracks::push_sequence(GlSequence &gs) path_segments.push_back(pair_segment_map()); } -const std::vector& GlTracks::tracks() const +const std::vector& GlSeqBrowser::sequences() const { return track_container; } -void GlTracks::clear_links() +void GlSeqBrowser::clear_links() { path_segment_map_vector::iterator psmv_i; for(psmv_i = path_segments.begin(); @@ -275,7 +275,7 @@ void GlTracks::clear_links() } void -GlTracks::link(vector path, vector rc, int length) +GlSeqBrowser::link(const vector& path, const vector& rc, int length) { if (path.size() < 2) { // should i throw an error instead? @@ -284,8 +284,8 @@ GlTracks::link(vector path, vector rc, int length) if (path.size() != rc.size()) { throw runtime_error("path and reverse compliment must be the same length"); } - vector::iterator path_i = path.begin(); - vector::iterator rc_i = rc.begin(); + vector::const_iterator path_i = path.begin(); + vector::const_iterator rc_i = rc.begin(); int track_i = 0; int prev_x = *path_i; ++path_i; bool prev_rc = *rc_i; ++rc_i; @@ -317,7 +317,7 @@ GlTracks::link(vector path, vector rc, int length) ++pathid; } -void GlTracks::update_viewport(float center, int new_zoom) +void GlSeqBrowser::update_viewport(float center, int new_zoom) { float max_width = max_ortho.width(); // division by zero is a major bummer @@ -329,7 +329,7 @@ void GlTracks::update_viewport(float center, int new_zoom) cur_ortho.right = center+new_max_width; } -void GlTracks::update_layout() +void GlSeqBrowser::update_layout() { typedef std::vector::iterator glseq_itor_type; float available_height = (float)cur_ortho.top - 2 * (float)border; @@ -337,7 +337,7 @@ void GlTracks::update_layout() size_t track_count = track_container.size(); if (track_count > 1) { - // we have several tracks + // we have several sequences float track_spacing = available_height / (track_count-1); float y = available_height + (float)border; for(glseq_itor_type seq_i = track_container.begin(); @@ -367,7 +367,7 @@ void GlTracks::update_layout() viewport_center = (cur_ortho.width()/2) + cur_ortho.left; } -void GlTracks::draw() const +void GlSeqBrowser::draw() const { glMatrixMode(GL_MODELVIEW); glInitNames(); @@ -380,7 +380,7 @@ void GlTracks::draw() const draw_selection(); } -void GlTracks::draw_selection() const +void GlSeqBrowser::draw_selection() const { // draw selection box glEnable(GL_BLEND); @@ -394,7 +394,7 @@ void GlTracks::draw_selection() const glDisable(GL_BLEND); } -void GlTracks::draw_tracks() const +void GlSeqBrowser::draw_tracks() const { for(size_t track_i = 0; track_i != track_container.size(); ++track_i) { @@ -404,7 +404,7 @@ void GlTracks::draw_tracks() const } } -void GlTracks::draw_segments() const +void GlSeqBrowser::draw_segments() const { glLineWidth(0.1); // each vector contains path_segment_maps of all the connections diff --git a/alg/gltracks.hpp b/alg/glseqbrowser.hpp similarity index 93% rename from alg/gltracks.hpp rename to alg/glseqbrowser.hpp index 2a88aff..fa337a5 100644 --- a/alg/gltracks.hpp +++ b/alg/glseqbrowser.hpp @@ -10,11 +10,11 @@ #include "alg/glsequence.hpp" //! Manage rendering a collection of glSequences -class GlTracks +class GlSeqBrowser { public: - GlTracks(); - GlTracks(const GlTracks&); + GlSeqBrowser(); + GlSeqBrowser(const GlSeqBrowser&); //! setup the opengl canvas void initializeGL(); @@ -24,7 +24,7 @@ public: void paintGL() const; //! select a region (using canvas coordinates) - void GlTracks::selectRegion(int top, int left, int bottom, int right); + void GlSeqBrowser::selectRegion(int top, int left, int bottom, int right); //! max world left coordinate float left() const; @@ -52,12 +52,12 @@ public: //! add a glsequence to the back of our track container void push_sequence(GlSequence &s); //! return our track container - const std::vector& tracks() const; + const std::vector& sequences() const; //! clear all the line segments between all the sequences void clear_links(); //! define a path - void link(std::vector path, std::vector isRC, int length); + void link(const std::vector& path, const std::vector& isRC, int length); //! Provide a logical name for a type discriminator for our glName stack enum FeatureType { MussaTrack, MussaSegment }; diff --git a/alg/module.mk b/alg/module.mk index 4a215ed..105f202 100644 --- a/alg/module.mk +++ b/alg/module.mk @@ -16,7 +16,7 @@ MUSSA_ALG_SRC := $(addprefix $(CURDIR), $(SOURCES.cpp)) MUSSA_ALG_OBJ := $(MUSSA_ALG_SRC:.cpp=$(OBJEXT)) GLSOURCES.cpp := glsequence.cpp \ - gltracks.cpp + glseqbrowser.cpp MUSSA_ALG_GL_SRC := $(addprefix $(CURDIR), $(GLSOURCES.cpp)) MUSSA_ALG_GL_OBJ := $(MUSSA_ALG_GL_SRC:.cpp=$(OBJEXT)) diff --git a/alg/test/module.mk b/alg/test/module.mk index 63bf408..dae6b68 100644 --- a/alg/test/module.mk +++ b/alg/test/module.mk @@ -4,7 +4,7 @@ SOURCES.cpp := test_annotation_color.cpp \ test_conserved_path.cpp \ test_flp.cpp \ test_glsequence.cpp \ - test_gltracks.cpp \ + test_glseqbrowser.cpp \ test_color.cpp \ test_main.cpp \ test_mussa.cpp \ diff --git a/alg/test/test_annotation_color.cpp b/alg/test/test_annotation_color.cpp index 2e2a56e..4cde0dd 100644 --- a/alg/test/test_annotation_color.cpp +++ b/alg/test/test_annotation_color.cpp @@ -41,3 +41,22 @@ BOOST_AUTO_TEST_CASE( simple_annot_colors ) BOOST_CHECK_EQUAL( ac.lookup("bleem", "a"), black); } +// can we assign a color? +BOOST_AUTO_TEST_CASE( annotation_color_assignment ) +{ + Color black(0.0, 0.0, 0.0); + Color white(1.0, 1.0, 1.0); + Color red(1.0, 0.0, 0.0); + + AnnotationColors ac1; + ac1.setColor(white); + ac1.appendTypeColor("bleem", black); + ac1.appendInstanceColor("bleem", "a", red); + + AnnotationColors ac2; + BOOST_CHECK_EQUAL( ac2.color(), black ); + ac2 = ac1; + BOOST_CHECK_EQUAL( ac2.color(), white ); + BOOST_CHECK_EQUAL( ac2.typeColor("bleem"), ac1.typeColor("bleem") ); + BOOST_CHECK_EQUAL( ac2.lookup("bleem","a"), ac1.lookup("bleem","a") ); +} diff --git a/alg/test/test_gltracks.cpp b/alg/test/test_glseqbrowser.cpp similarity index 86% rename from alg/test/test_gltracks.cpp rename to alg/test/test_glseqbrowser.cpp index 58b91fc..ba4fcae 100644 --- a/alg/test/test_gltracks.cpp +++ b/alg/test/test_glseqbrowser.cpp @@ -7,7 +7,7 @@ using namespace boost::assign; #include #include "alg/annotation_colors.hpp" -#include "alg/gltracks.hpp" +#include "alg/glseqbrowser.hpp" #include "alg/sequence.hpp" using namespace std; @@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE ( gltracks_connect ) Sequence seq1(s1); Sequence seq2(s2); - GlTracks gt; + GlSeqBrowser gt; gt.push_sequence(seq0); gt.push_sequence(seq1); gt.push_sequence(seq2); @@ -36,8 +36,8 @@ BOOST_AUTO_TEST_CASE ( gltracks_connect ) path.clear(); path += 3,3,3; gt.link(path, rc, 1); BOOST_CHECK_EQUAL( gt.path_segments.size(), 2 ); - GlTracks::segment_key p(1, 1); - GlTracks::pair_segment_map::iterator psm_i = gt.path_segments[0].find(p); + GlSeqBrowser::segment_key p(1, 1); + GlSeqBrowser::pair_segment_map::iterator psm_i = gt.path_segments[0].find(p); BOOST_CHECK( psm_i != gt.path_segments[0].end() ); BOOST_CHECK_EQUAL( psm_i->second.path_ids.size(), 2 ); diff --git a/mussagl.cpp b/mussagl.cpp index 1447b7d..008b888 100644 --- a/mussagl.cpp +++ b/mussagl.cpp @@ -1,6 +1,6 @@ #include -#include "qui/PathWindow.hpp" +#include "qui/MussaWindow.hpp" #include "alg/parse_options.hpp" int main(int argc, char **argv) @@ -12,7 +12,7 @@ int main(int argc, char **argv) return 1; } - PathWindow win(analysis); + MussaWindow win(analysis); win.show(); app.exec(); return 0; diff --git a/mussagl.pro b/mussagl.pro index ae1cade..8c06335 100644 --- a/mussagl.pro +++ b/mussagl.pro @@ -12,42 +12,42 @@ INCLUDEPATH += . alg qui # Input HEADERS += mussa_exceptions.hpp \ - qui/PathWidget.hpp \ - qui/PathWindow.hpp \ - qui/PathScene.hpp \ - qui/PathSidebar.hpp \ - qui/ScrollableScene.hpp \ - qui/SequenceDescription.hpp \ + qui/MussaWindow.hpp \ qui/ThresholdWidget.hpp \ qui/ImageScaler.hpp \ qui/ImageSaveDialog.hpp \ + qui/seqbrowser/SequenceBrowserWidget.hpp \ + qui/seqbrowser/SequenceBrowser.hpp \ + qui/seqbrowser/SequenceBrowserSidebar.hpp \ + qui/seqbrowser/ScrollableSequenceBrowser.hpp \ + qui/seqbrowser/SequenceDescription.hpp \ alg/annotation_colors.hpp \ alg/color.hpp \ alg/conserved_path.hpp \ alg/flp.hpp \ alg/glsequence.hpp \ - alg/gltracks.hpp \ + alg/glseqbrowser.hpp \ alg/mussa.hpp \ alg/nway_paths.hpp \ alg/parse_options.hpp \ alg/sequence.hpp SOURCES += mussagl.cpp \ - qui/PathWidget.cpp \ - qui/PathWindow.cpp \ - qui/PathScene.cpp \ - qui/PathSidebar.cpp \ - qui/ScrollableScene.cpp \ - qui/SequenceDescription.cpp \ + qui/MussaWindow.cpp \ qui/ThresholdWidget.cpp \ qui/ImageScaler.cpp \ qui/ImageSaveDialog.cpp \ + qui/seqbrowser/SequenceBrowserWidget.cpp \ + qui/seqbrowser/SequenceBrowser.cpp \ + qui/seqbrowser/SequenceBrowserSidebar.cpp \ + qui/seqbrowser/ScrollableSequenceBrowser.cpp \ + qui/seqbrowser/SequenceDescription.cpp \ alg/annotation_colors.cpp \ alg/color.cpp \ alg/conserved_path.cpp \ alg/flp.cpp \ alg/flp_seqcomp.cpp \ alg/glsequence.cpp \ - alg/gltracks.cpp \ + alg/glseqbrowser.cpp \ alg/mussa.cpp \ alg/nway_entropy.cpp \ alg/nway_other.cpp \ diff --git a/qui/PathWindow.cpp b/qui/MussaWindow.cpp similarity index 83% rename from qui/PathWindow.cpp rename to qui/MussaWindow.cpp index 883563a..4822d31 100644 --- a/qui/PathWindow.cpp +++ b/qui/MussaWindow.cpp @@ -10,19 +10,17 @@ #include #include -#include "qui/PathScene.hpp" -#include "qui/PathWindow.hpp" -#include "qui/ImageSaveDialog.hpp" +#include "qui/MussaWindow.hpp" #include "mussa_exceptions.hpp" #include using namespace std; -PathWindow::PathWindow(Mussa *analysis_, QWidget *parent) : +MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) : QMainWindow(parent), analysis(analysis_), - path_view(this), + browser(this), mussaViewTB("Path Views"), zoomBox(), threshold(), @@ -35,7 +33,7 @@ PathWindow::PathWindow(Mussa *analysis_, QWidget *parent) : // a segfault when using WhatsThis feature with // opengl widget. //scene->setWhatsThis(tr("Mussa in OpenGL!")); - setCentralWidget(&path_view); + setCentralWidget(&browser); mussaViewTB.addAction(toggleMotifsAction); @@ -43,7 +41,7 @@ PathWindow::PathWindow(Mussa *analysis_, QWidget *parent) : zoomBox.setRange(2,1000); mussaViewTB.addWidget(&zoomBox); connect(&zoomBox, SIGNAL(valueChanged(int)), - &path_view.scene(), SLOT(setZoom(int))); + &browser, SLOT(setZoom(int))); threshold.setRange(19, 30); threshold.setThreshold(19); @@ -61,7 +59,7 @@ PathWindow::PathWindow(Mussa *analysis_, QWidget *parent) : updateAnalysis(); } -void PathWindow::setupActions() +void MussaWindow::setupActions() { // we really don't want to run this more than once. assert (closeAction == 0); @@ -123,13 +121,13 @@ void PathWindow::setupActions() whatsThisAction->setIcon(QIcon("icons/help.png")); //Save pixel map action - saveOpenGlPixmapAction = new QAction(tr("Save to image..."), this); - connect(saveOpenGlPixmapAction, (SIGNAL(triggered())), - this, SLOT(promptSaveOpenGlPixmap())); - saveOpenGlPixmapAction->setIcon(QIcon("icons/image2.png")); + saveBrowserPixmapAction = new QAction(tr("Save to image..."), this); + connect(saveBrowserPixmapAction, (SIGNAL(triggered())), + &browser, SLOT(promptSaveBrowserPixmap())); + saveBrowserPixmapAction->setIcon(QIcon("icons/image2.png")); } -void PathWindow::setupMainMenu() +void MussaWindow::setupMainMenu() { // we need to run setupActions first assert (closeAction != 0); @@ -144,7 +142,7 @@ void PathWindow::setupMainMenu() newMenu->addAction(loadMotifListAction); newMenu->addAction(saveMotifListAction); newMenu->addSeparator(); - newMenu->addAction(saveOpenGlPixmapAction); + newMenu->addAction(saveBrowserPixmapAction); newMenu->addSeparator(); newMenu->addAction(closeAction); @@ -157,7 +155,7 @@ void PathWindow::setupMainMenu() newMenu->addAction(aboutAction); } -void PathWindow::about() +void MussaWindow::about() { QMessageBox::about(this, tr("About mussa"), tr("Welcome to Multiple Species Sequence Analysis\n" @@ -165,18 +163,18 @@ void PathWindow::about() "Tristan De Buysscher, Diane Trout\n")); } -void PathWindow::createNewAnalysis() +void MussaWindow::createNewAnalysis() { NotImplementedBox(); } -void PathWindow::createSubAnalysis() +void MussaWindow::createSubAnalysis() { NotImplementedBox(); } -void PathWindow::loadMotifList() +void MussaWindow::loadMotifList() { QString caption("Load a motif list"); QString filter("Motif list(*.txt *.mtl)"); @@ -200,12 +198,12 @@ void PathWindow::loadMotifList() assert (analysis != 0); } -void PathWindow::saveMotifList() +void MussaWindow::saveMotifList() { NotImplementedBox(); } -void PathWindow::loadMupa() +void MussaWindow::loadMupa() { QString caption("Load a mussa parameter file"); QString filter("Mussa Parameters (*.mupa)"); @@ -235,7 +233,7 @@ void PathWindow::loadMupa() assert (analysis != 0); } -void PathWindow::loadSavedAnalysis() +void MussaWindow::loadSavedAnalysis() { QString caption("Load a previously run analysis"); QString muway_dir = QFileDialog::getExistingDirectory(this, @@ -262,7 +260,7 @@ void PathWindow::loadSavedAnalysis() assert (analysis != 0); } -void PathWindow::setSoftThreshold(int threshold) +void MussaWindow::setSoftThreshold(int threshold) { if (analysis->get_soft_thres() != threshold) { analysis->set_soft_thres(threshold); @@ -272,7 +270,7 @@ void PathWindow::setSoftThreshold(int threshold) } } -void PathWindow::showMussaToolbar() +void MussaWindow::showMussaToolbar() { if (mussaViewTB.isVisible()) mussaViewTB.hide(); @@ -280,47 +278,28 @@ void PathWindow::showMussaToolbar() mussaViewTB.show(); } -void PathWindow::toggleMotifs() +void MussaWindow::toggleMotifs() { NotImplementedBox(); } -void PathWindow::NotImplementedBox() +void MussaWindow::NotImplementedBox() { QMessageBox::warning(this, QObject::tr("mussa"), QObject::tr("Not implemented yet")); } -void PathWindow::promptSaveOpenGlPixmap() -{ - QSize size; - size = path_view.scene().size(); - //Image Save Dialog - ImageSaveDialog imageSaveDialog(&path_view.scene(), this); - imageSaveDialog.setSize(size.width(), size.height()); - int result = imageSaveDialog.exec(); - cout << "Result: " << result << "\n"; -} - -void PathWindow::updateAnalysis() +void MussaWindow::updateAnalysis() { cout << "analysis updated" << endl; - path_view.scene().clear(); - path_view.scene().setColorMapper(analysis->colorMapper()); + browser.clear(); const vector& seqs = analysis->sequences(); - for(vector::const_iterator seq_i = seqs.begin(); - seq_i != seqs.end(); - ++seq_i) - { - GlSequence *gs= new GlSequence(*seq_i, analysis->colorMapper()); - path_view.scene().push_sequence(*gs); - } + browser.setSequences(seqs, analysis->colorMapper()); updateLinks(); - path_view.updateTracks(); } -void PathWindow::updateLinks() +void MussaWindow::updateLinks() { - path_view.scene().clear_links(); + browser.clear_links(); bool reversed = false; const NwayPaths& nway = analysis->paths(); @@ -357,8 +336,8 @@ void PathWindow::updateLinks() normalized_path.push_back(x); rc_flags.push_back(reversed); } - path_view.scene().link(normalized_path, rc_flags, path_itor->window_size); + browser.link(normalized_path, rc_flags, path_itor->window_size); } - path_view.scene().update(); + browser.update(); } diff --git a/qui/PathWindow.hpp b/qui/MussaWindow.hpp similarity index 84% rename from qui/PathWindow.hpp rename to qui/MussaWindow.hpp index 65bafdf..0ba819c 100644 --- a/qui/PathWindow.hpp +++ b/qui/MussaWindow.hpp @@ -1,25 +1,23 @@ -#ifndef _PATHWINDOW_H_ -#define _PATHWINDOW_H_ - - +#ifndef _MUSSAWINDOW_H_ +#define _MUSSAWINDOW_H_ #include #include #include #include -#include "qui/PathWidget.hpp" +#include "qui/seqbrowser/SequenceBrowserWidget.hpp" #include "qui/ThresholdWidget.hpp" class QAction; class Mussa; -class PathWindow : public QMainWindow +class MussaWindow : public QMainWindow { Q_OBJECT public: - PathWindow(Mussa* analysis=0, QWidget *parent=0); + MussaWindow(Mussa* analysis=0, QWidget *parent=0); public slots: //! display an about box, contemplating the politics of the author list @@ -50,12 +48,10 @@ public slots: void showMussaToolbar(); - void promptSaveOpenGlPixmap(); - protected: Mussa *analysis; // display our wonderful mussa output - PathWidget path_view; + SequenceBrowserWidget browser; QToolBar mussaViewTB; QSpinBox zoomBox; ThresholdWidget threshold; @@ -71,7 +67,7 @@ protected: QAction *showMussaViewToolbarAction; QAction *toggleMotifsAction; QAction *whatsThisAction; - QAction *saveOpenGlPixmapAction; + QAction *saveBrowserPixmapAction; //! initialze the actions void setupActions(); @@ -79,7 +75,7 @@ protected: void setupMainMenu(); //! stub function to fill in QActions void NotImplementedBox(); - //! update the PathScene with our analysis + //! update the SequenceBrowser with our analysis void updateAnalysis(); //! update the view of conserved windows void updateLinks(); diff --git a/qui/PathSidebar.hpp b/qui/PathSidebar.hpp deleted file mode 100644 index 852f1c9..0000000 --- a/qui/PathSidebar.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _PATH_SIDEBAR_H -#define _PATH_SIDEBAR_H - -#include - -#include -#include -#include "qui/PathScene.hpp" -#include "qui/SequenceDescription.hpp" - -//! store a collection of sequence descriptions for the PathWidget -class PathSidebar : public QWidget -{ -public: - PathSidebar(QWidget *parent = 0); - - void updateSidebar(PathScene& scene); - QVBoxLayout layout; - std::vector descriptions; -}; -#endif diff --git a/qui/PathWidget.cpp b/qui/PathWidget.cpp deleted file mode 100644 index 1b4cd52..0000000 --- a/qui/PathWidget.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include - -#include "qui/PathScene.hpp" -#include "qui/PathWidget.hpp" -#include "qui/ScrollableScene.hpp" -#include "qui/SequenceDescription.hpp" -#include "alg/glsequence.hpp" - -#include -using namespace std; - -PathWidget::PathWidget(QWidget *parent) - : QSplitter(parent), - scrollable_scene(parent) -{ - setOrientation(Qt::Horizontal); - - addWidget(&left_sidebar); - addWidget(&scrollable_scene); - addWidget(&right_sidebar); - - connect(&scrollable_scene.scene(), SIGNAL(viewportChanged()), - this, SLOT(updatePosition())); -} - -void PathWidget::updateTracks() -{ - left_sidebar.updateSidebar(scrollable_scene.scene()); - right_sidebar.updateSidebar(scrollable_scene.scene()); - updatePosition(); -} - -void PathWidget::updatePosition() -{ - const PathScene& scene = scrollable_scene.scene(); - const vector &tracks = scene.tracks(); - vector left = left_sidebar.descriptions; - vector right = right_sidebar.descriptions; - for(size_t i = 0; i != tracks.size() and i != right.size(); ++i) - { - left[i]->setPosition(tracks[i].leftbase(scene.viewportLeft())); - right[i]->setPosition(tracks[i].rightbase(scene.viewportRight())); - } -} diff --git a/qui/PathWidget.hpp b/qui/PathWidget.hpp deleted file mode 100644 index 7c47f42..0000000 --- a/qui/PathWidget.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _PATH_WIDGET_H_ -#define _PATH_WIDGET_H_ - -#include - -#include "qui/ScrollableScene.hpp" -#include "qui/PathSidebar.hpp" - -class PathWidget : public QSplitter -{ - Q_OBJECT - -public: - PathWidget(QWidget *parent=0); - - PathScene& scene() { return scrollable_scene.scene(); } - -public slots: - //! when a scene changes its tracks lets update some of our meta info - void updateTracks(); - void updatePosition(); - -private: - ScrollableScene scrollable_scene; - PathSidebar left_sidebar; - PathSidebar right_sidebar; -}; -#endif diff --git a/qui/ScrollableScene.hpp b/qui/ScrollableScene.hpp deleted file mode 100644 index 4b90e53..0000000 --- a/qui/ScrollableScene.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _SCROLLABLE_SCENE_H_ -#define _SCROLLABLE_SCENE_H_ - -#include -#include -#include "qui/PathScene.hpp" - -class ScrollableScene : public QWidget -{ - Q_OBJECT - -public: - ScrollableScene(QWidget *parent=0); - PathScene path_scene; - - PathScene& scene() { return path_scene; } -public slots: - //! update the scrollbar with current viewport information - void updateScrollBar(); - //! update scene with the properly scalled scrollbar offset - void setViewportCenter(int x); - -private: - QScrollBar viewportBar; - int thumb; - - float range; - float scale; -}; - -#endif diff --git a/qui/ScrollableScene.cpp b/qui/seqbrowser/ScrollableSequenceBrowser.cpp similarity index 54% rename from qui/ScrollableScene.cpp rename to qui/seqbrowser/ScrollableSequenceBrowser.cpp index 0c3de45..0349c87 100644 --- a/qui/ScrollableScene.cpp +++ b/qui/seqbrowser/ScrollableSequenceBrowser.cpp @@ -1,21 +1,20 @@ - #include -#include "qui/ScrollableScene.hpp" +#include "qui/seqbrowser/ScrollableSequenceBrowser.hpp" -ScrollableScene::ScrollableScene(QWidget *parent) : +ScrollableSequenceBrowser::ScrollableSequenceBrowser(QWidget *parent) : QWidget(parent), viewportBar(Qt::Horizontal) { // construct central opengl widget QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(&path_scene); + layout->addWidget(&sequence_browser); layout->addWidget(&viewportBar); connect(&viewportBar, SIGNAL(valueChanged(int)), this, SLOT(setViewportCenter(int))); - connect(&path_scene, SIGNAL(viewportChanged()), + connect(&sequence_browser, SIGNAL(viewportChanged()), this, SLOT(updateScrollBar())); setLayout(layout); @@ -24,13 +23,13 @@ ScrollableScene::ScrollableScene(QWidget *parent) : updateScrollBar(); } -void ScrollableScene::updateScrollBar() +void ScrollableSequenceBrowser::updateScrollBar() { - float max_right = path_scene.right(); - float max_left = path_scene.left(); + float max_right = sequence_browser.right(); + float max_left = sequence_browser.left(); float max_range = max_right - max_left; - float cur_left = path_scene.viewportLeft(); - float cur_right = path_scene.viewportRight(); + float cur_left = sequence_browser.viewportLeft(); + float cur_right = sequence_browser.viewportRight(); float cur_center = ((cur_right-cur_left)/2)+cur_left; // set range to min thumb = (int)cur_center; @@ -38,11 +37,11 @@ void ScrollableScene::updateScrollBar() viewportBar.setValue(thumb); } -void ScrollableScene::setViewportCenter(int x) +void ScrollableSequenceBrowser::setViewportCenter(int x) { if (x != thumb) { thumb = x; - path_scene.setViewportCenter(thumb); + sequence_browser.setViewportCenter(thumb); } } diff --git a/qui/seqbrowser/ScrollableSequenceBrowser.hpp b/qui/seqbrowser/ScrollableSequenceBrowser.hpp new file mode 100644 index 0000000..b8a470e --- /dev/null +++ b/qui/seqbrowser/ScrollableSequenceBrowser.hpp @@ -0,0 +1,32 @@ +#ifndef _SCROLLABLE_SEQUENCE_BROWSER_H_ +#define _SCROLLABLE_SEQUENCE_BROWSER_H_ + +#include +#include +#include "qui/seqbrowser/SequenceBrowser.hpp" + +class ScrollableSequenceBrowser : public QWidget +{ + Q_OBJECT + +public: + ScrollableSequenceBrowser(QWidget *parent=0); + SequenceBrowser sequence_browser; + + SequenceBrowser& browser() { return sequence_browser; } + const SequenceBrowser& browser() const { return sequence_browser; } +public slots: + //! update the scrollbar with current viewport information + void updateScrollBar(); + //! update scene with the properly scalled scrollbar offset + void setViewportCenter(int x); + +private: + QScrollBar viewportBar; + int thumb; + + float range; + float scale; +}; + +#endif diff --git a/qui/PathScene.cpp b/qui/seqbrowser/SequenceBrowser.cpp similarity index 58% rename from qui/PathScene.cpp rename to qui/seqbrowser/SequenceBrowser.cpp index 4a48882..1ff2339 100644 --- a/qui/PathScene.cpp +++ b/qui/seqbrowser/SequenceBrowser.cpp @@ -11,29 +11,28 @@ #include #include -#include "qui/PathScene.hpp" -#include "alg/glsequence.hpp" +#include "qui/seqbrowser/SequenceBrowser.hpp" #include "mussa_exceptions.hpp" using namespace std; -PathScene::PathScene(QWidget *parent) +SequenceBrowser::SequenceBrowser(QWidget *parent) : QGLWidget(parent), rubberBand(0), drawingBand(false) { } -QSize PathScene::sizeHint() const +QSize SequenceBrowser::sizeHint() const { - //return QSize((int)GlTracks::viewportHeight(), (int)GlTracks::viewportWidth()); + //return QSize((int)GlSeqBrowser::viewportHeight(), (int)GlSeqBrowser::viewportWidth()); return QSize(600, 400); } -void PathScene::setViewportCenter(float x) +void SequenceBrowser::setViewportCenter(float x) { const float epsilon = 1e-10; - float center = GlTracks::viewportCenter(); + float center = GlSeqBrowser::viewportCenter(); float difference = fabsf(x - center); float abs_x = fabsf(x); center = fabsf(center); @@ -44,22 +43,22 @@ void PathScene::setViewportCenter(float x) // not at the beginning if (not (difference < epsilon * abs_x or difference < epsilon * center)) { - GlTracks::setViewportCenter(x); + GlSeqBrowser::setViewportCenter(x); emit viewportChanged(); update(); } } -void PathScene::setZoom(int new_zoom) +void SequenceBrowser::setZoom(int new_zoom) { - if (new_zoom != GlTracks::zoom()) { - GlTracks::setZoom(new_zoom); + if (new_zoom != GlSeqBrowser::zoom()) { + GlSeqBrowser::setZoom(new_zoom); emit viewportChanged(); update(); } } -void PathScene::setClipPlane(int ) +void SequenceBrowser::setClipPlane(int ) { /* if (clipZ != (double) newZ){ @@ -69,42 +68,42 @@ void PathScene::setClipPlane(int ) */ } -void PathScene::clear() +void SequenceBrowser::clear() { - GlTracks::clear(); + GlSeqBrowser::clear(); emit tracksChanged(); } -void PathScene::push_sequence(const Sequence &s) +void SequenceBrowser::push_sequence(const Sequence &s) { - GlTracks::push_sequence(s); + GlSeqBrowser::push_sequence(s); emit tracksChanged(); } -void PathScene::push_sequence(GlSequence &gs) +void SequenceBrowser::push_sequence(GlSequence &gs) { - GlTracks::push_sequence(gs); + GlSeqBrowser::push_sequence(gs); emit tracksChanged(); } //////////////////// // Rendering code -void PathScene::initializeGL() +void SequenceBrowser::initializeGL() { - GlTracks::initializeGL(); + GlSeqBrowser::initializeGL(); } -void PathScene::resizeGL(int width, int height) +void SequenceBrowser::resizeGL(int width, int height) { - GlTracks::resizeGL(width, height); + GlSeqBrowser::resizeGL(width, height); } -void PathScene::paintGL() +void SequenceBrowser::paintGL() { - GlTracks::paintGL(); + GlSeqBrowser::paintGL(); } -void PathScene::mousePressEvent( QMouseEvent *e) +void SequenceBrowser::mousePressEvent( QMouseEvent *e) { drawingBand = true; @@ -117,13 +116,13 @@ void PathScene::mousePressEvent( QMouseEvent *e) rubberBand->show(); } -void PathScene::mouseMoveEvent( QMouseEvent *e) +void SequenceBrowser::mouseMoveEvent( QMouseEvent *e) { if (drawingBand) rubberBand->setGeometry(QRect(bandOrigin, e->pos()).normalized()); } -void PathScene::mouseReleaseEvent( QMouseEvent *e) +void SequenceBrowser::mouseReleaseEvent( QMouseEvent *e) { drawingBand = false; rubberBand->hide(); diff --git a/qui/PathScene.hpp b/qui/seqbrowser/SequenceBrowser.hpp similarity index 88% rename from qui/PathScene.hpp rename to qui/seqbrowser/SequenceBrowser.hpp index ef4a357..ed3da99 100644 --- a/qui/PathScene.hpp +++ b/qui/seqbrowser/SequenceBrowser.hpp @@ -9,19 +9,19 @@ #include "alg/mussa.hpp" #include "alg/glsequence.hpp" -#include "alg/gltracks.hpp" +#include "alg/glseqbrowser.hpp" class QMouseEvent; class QRubberBand; /*! \brief Render mussa sequences and paths */ -class PathScene: public QGLWidget, public GlTracks +class SequenceBrowser: public QGLWidget, public GlSeqBrowser { Q_OBJECT public: - PathScene(QWidget *parent=0); + SequenceBrowser(QWidget *parent=0); QSize sizeHint() const; diff --git a/qui/PathSidebar.cpp b/qui/seqbrowser/SequenceBrowserSidebar.cpp similarity index 61% rename from qui/PathSidebar.cpp rename to qui/seqbrowser/SequenceBrowserSidebar.cpp index 50bf9cc..b09a858 100644 --- a/qui/PathSidebar.cpp +++ b/qui/seqbrowser/SequenceBrowserSidebar.cpp @@ -1,15 +1,14 @@ -#include "qui/PathSidebar.hpp" -#include "alg/glsequence.hpp" +#include "qui/seqbrowser/SequenceBrowserSidebar.hpp" using namespace std; -PathSidebar::PathSidebar(QWidget* parent) +SequenceBrowserSidebar::SequenceBrowserSidebar(QWidget* parent) : QWidget(parent) { setLayout(&layout); } -void PathSidebar::updateSidebar(PathScene& scene) +void SequenceBrowserSidebar::clear() { for (vector::iterator desc_i = descriptions.begin(); desc_i != descriptions.end(); @@ -18,12 +17,15 @@ void PathSidebar::updateSidebar(PathScene& scene) layout.removeWidget(*desc_i); } descriptions.clear(); - cout << "sidebar " << scene.tracks().size() << endl; - for (vector::const_iterator track_i = scene.tracks().begin(); - track_i != scene.tracks().end(); +} + +void SequenceBrowserSidebar::setSequences(vector& sequences) +{ + clear(); + for (vector::const_iterator track_i = sequences.begin(); + track_i != sequences.end(); ++track_i) { - cout << " " << track_i->sequence().length() << endl; SequenceDescription *desc = new SequenceDescription(this); //disc->setName(track_i->sequence().name()); desc->setLength(track_i->sequence().length()); diff --git a/qui/seqbrowser/SequenceBrowserSidebar.hpp b/qui/seqbrowser/SequenceBrowserSidebar.hpp new file mode 100644 index 0000000..48bc78e --- /dev/null +++ b/qui/seqbrowser/SequenceBrowserSidebar.hpp @@ -0,0 +1,39 @@ +#ifndef _SEQUENCE_BROWSER_SIDEBAR_H +#define _SEQUENCE_BROWSER_SIDEBAR_H + +#include + +#include +#include +#include "qui/seqbrowser/SequenceBrowser.hpp" +#include "qui/seqbrowser/SequenceDescription.hpp" +#include "alg/glsequence.hpp" + +//! store a collection of sequence descriptions for the SequenceBrowserWidget +class SequenceBrowserSidebar : public QWidget +{ + Q_OBJECT + +public: + enum SidebarSide { Left, Right }; + + SequenceBrowserSidebar(QWidget *parent = 0); + + //! clear our list of descriptions + void clear(); + void setSequences(std::vector& ); + + std::vector descriptions; +public slots: + //! update the reported sequence position for each of our sequences + /*! for example when the right side is at position 3000 call + * iterate over each sequence and get its rightbase pair value + */ + //void updatePositionValues(float left, float right); + +private: + QVBoxLayout layout; + //! for updating positions we need to know which side we're on + //SidebarSide sidebar_side; +}; +#endif diff --git a/qui/seqbrowser/SequenceBrowserWidget.cpp b/qui/seqbrowser/SequenceBrowserWidget.cpp new file mode 100644 index 0000000..215bcd3 --- /dev/null +++ b/qui/seqbrowser/SequenceBrowserWidget.cpp @@ -0,0 +1,130 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include "qui/seqbrowser/SequenceBrowserWidget.hpp" +#include "qui/seqbrowser/SequenceBrowser.hpp" +#include "qui/seqbrowser/ScrollableSequenceBrowser.hpp" +#include "qui/seqbrowser/SequenceDescription.hpp" +#include "qui/ImageSaveDialog.hpp" + +#include "alg/glsequence.hpp" + +#include +using namespace std; + +SequenceBrowserWidget::SequenceBrowserWidget(QWidget *parent) + : QSplitter(parent), + scrollable_browser(parent) +{ + setOrientation(Qt::Horizontal); + + addWidget(&left_sidebar); + addWidget(&scrollable_browser); + addWidget(&right_sidebar); + + connect(&scrollable_browser.browser(), SIGNAL(viewportChanged()), + this, SLOT(updatePosition())); +} + +void SequenceBrowserWidget::clear() +{ + converted_sequences.clear(); + scrollable_browser.browser().clear(); + left_sidebar.clear(); + right_sidebar.clear(); +} + +void SequenceBrowserWidget::setSequences(const std::vector& sequences, + AnnotationColors& cm) +{ + SequenceBrowser& browser = scrollable_browser.browser(); + clear(); + for(vector::const_iterator seq_i = sequences.begin(); + seq_i != sequences.end(); + ++seq_i) + { + GlSequence *gs= new GlSequence(*seq_i, cm); + converted_sequences.push_back(*gs); + browser.push_sequence(*gs); + } + left_sidebar.setSequences(converted_sequences); + right_sidebar.setSequences(converted_sequences); + updatePosition(); +} + +void SequenceBrowserWidget::setSequences(std::vector& sequences) +{ + SequenceBrowser& browser = scrollable_browser.browser(); + clear(); + for(vector::iterator seq_i = sequences.begin(); + seq_i != sequences.end(); + ++seq_i) + { + browser.push_sequence(*seq_i); + } + left_sidebar.setSequences(sequences); + right_sidebar.setSequences(sequences); + updatePosition(); +} + +const vector& SequenceBrowserWidget::sequences() const +{ + return scrollable_browser.browser().sequences(); +} + +void SequenceBrowserWidget::clear_links() +{ + scrollable_browser.browser().clear_links(); +} + +void SequenceBrowserWidget::link(const std::vector& path, + const std::vector& isRC, + int length) +{ + scrollable_browser.browser().link(path, isRC, length); +} + +/* This could theoretically be pushed down to some set + * of signals and slots connecting SequenceDescriptions and + * some signal emitted by the browser's viewportChanged code + * but evertime I tried to figure it out, I got confused about + * how the descriptions in one of the sidebars was supposed to know + * if it was mapping the rightbase or the leftbase. + * And so though this could be better the typical use cases + * can just talk to the SequenceBrowserWidget for rendering + * or mussa output + */ +void SequenceBrowserWidget::updatePosition() +{ + const SequenceBrowser& browser = scrollable_browser.browser(); + const vector &sequences = browser.sequences(); + vector left = left_sidebar.descriptions; + vector right = right_sidebar.descriptions; + for(size_t i = 0; i != sequences.size() and i != right.size(); ++i) + { + left[i]->setPosition(sequences[i].leftbase(browser.viewportLeft())); + right[i]->setPosition(sequences[i].rightbase(browser.viewportRight())); + } +} + +void SequenceBrowserWidget::promptSaveBrowserPixmap() +{ + QSize size; + size = scrollable_browser.browser().size(); + //Image Save Dialog + ImageSaveDialog imageSaveDialog(&scrollable_browser.browser(), this); + imageSaveDialog.setSize(size.width(), size.height()); + int result = imageSaveDialog.exec(); + cout << "Result: " << result << "\n"; +} + +void SequenceBrowserWidget::setZoom(int z) +{ + scrollable_browser.browser().setZoom(z); +} diff --git a/qui/seqbrowser/SequenceBrowserWidget.hpp b/qui/seqbrowser/SequenceBrowserWidget.hpp new file mode 100644 index 0000000..e51f445 --- /dev/null +++ b/qui/seqbrowser/SequenceBrowserWidget.hpp @@ -0,0 +1,59 @@ +#ifndef _PATH_WIDGET_H_ +#define _PATH_WIDGET_H_ + +#include + +#include + +#include "alg/sequence.hpp" +#include "alg/glsequence.hpp" +#include "qui/seqbrowser/ScrollableSequenceBrowser.hpp" +#include "qui/seqbrowser/SequenceBrowserSidebar.hpp" + +//! the master widget that makes a useful Sequence Browser +class SequenceBrowserWidget : public QSplitter +{ + Q_OBJECT + +public: + SequenceBrowserWidget(QWidget *parent=0); + + //SequenceBrowser& browser() { return scrollable_browser.browser(); } + + //! reset all of our stored data back to the empty state + void clear(); + + /* Attach sequences to our browser, its best to attach them all + * at once, as otherwise the Sidebar has some rendering trouble + * as it draw and redraws the SequenceDescriptions in the various + * positions. + */ + //void push_sequences(std::vector& sequences); + void setSequences(const std::vector& sequences, AnnotationColors& cm); + void setSequences(std::vector& sequences); + const std::vector& sequences() const; + + //! reset just the links we're displaying + void clear_links(); + //! set per species links + void link(const std::vector &path, const std::vector& isRC, int length); + +public slots: + //! set the zoom level of our browser + void setZoom(int); + + void updatePosition(); + //! ask the user where to save an image of the current browser view + void promptSaveBrowserPixmap(); + +private: + ScrollableSequenceBrowser scrollable_browser; + SequenceBrowserSidebar left_sidebar; + SequenceBrowserSidebar right_sidebar; + + //! sequences created by a setSequences(vector) call + /*! I need to save them so i can free them to avoid a memory leak + */ + std::vector converted_sequences; +}; +#endif diff --git a/qui/SequenceDescription.cpp b/qui/seqbrowser/SequenceDescription.cpp similarity index 94% rename from qui/SequenceDescription.cpp rename to qui/seqbrowser/SequenceDescription.cpp index 130483b..f62d52b 100644 --- a/qui/SequenceDescription.cpp +++ b/qui/seqbrowser/SequenceDescription.cpp @@ -1,7 +1,7 @@ -#include "qui/SequenceDescription.hpp" - #include +#include "qui/seqbrowser/SequenceDescription.hpp" + using namespace std; SequenceDescription::SequenceDescription(QWidget *parent) diff --git a/qui/SequenceDescription.hpp b/qui/seqbrowser/SequenceDescription.hpp similarity index 100% rename from qui/SequenceDescription.hpp rename to qui/seqbrowser/SequenceDescription.hpp -- 2.30.2