1 #include <QApplication>
15 #include "qui/seqbrowser/SequenceBrowser.hpp"
16 #include "mussa_exceptions.hpp"
20 SequenceBrowser::SequenceBrowser(QWidget *parent)
27 QSize SequenceBrowser::sizeHint() const
29 //return QSize((int)GlSeqBrowser::viewportHeight(), (int)GlSeqBrowser::viewportWidth());
30 return QSize(600, 400);
33 void SequenceBrowser::setViewportCenter(float x)
35 const float epsilon = 1e-10;
36 float center = GlSeqBrowser::viewportCenter();
37 float difference = fabsf(x - center);
38 float abs_x = fabsf(x);
39 center = fabsf(center);
41 // the difference < epsilon * val is one of the recommended tests
42 // for float equality.
43 // of course since we're looking for not equals, we need to toss a
44 // not at the beginning
45 if (not (difference < epsilon * abs_x or difference < epsilon * center))
47 GlSeqBrowser::setViewportCenter(x);
48 emit viewportChanged();
53 void SequenceBrowser::setZoom(double new_zoom)
55 if (new_zoom != GlSeqBrowser::zoom()) {
56 GlSeqBrowser::setZoom(new_zoom);
57 emit viewportChanged();
62 void SequenceBrowser::setClipPlane(int )
65 if (clipZ != (double) newZ){
66 clipZ = (double) newZ;
72 void SequenceBrowser::copySelectedSequenceAsFasta()
76 copySelectedTracksAsFasta(buffer);
78 // get reference to clipboard
79 QClipboard *clipboard = QApplication::clipboard();
80 clipboard->setText(buffer.c_str());
84 void SequenceBrowser::clear()
86 GlSeqBrowser::clear();
90 void SequenceBrowser::push_sequence(const Sequence &s)
92 GlSeqBrowser::push_sequence(s);
96 void SequenceBrowser::push_sequence(GlSequence &gs)
98 GlSeqBrowser::push_sequence(gs);
104 void SequenceBrowser::initializeGL()
106 GlSeqBrowser::initializeGL();
109 void SequenceBrowser::resizeGL(int width, int height)
111 GlSeqBrowser::resizeGL(width, height);
112 emit viewportChanged();
115 void SequenceBrowser::paintGL()
117 GlSeqBrowser::paintGL();
120 void SequenceBrowser::mousePressEvent( QMouseEvent *e)
124 selectedMode = false;
125 bandOrigin = e->pos();
127 rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
129 rubberBand->setGeometry(QRect(bandOrigin, QSize()));
133 void SequenceBrowser::mouseMoveEvent( QMouseEvent *e)
136 rubberBand->setGeometry(QRect(bandOrigin, e->pos()).normalized());
139 void SequenceBrowser::mouseReleaseEvent( QMouseEvent *e)
142 if (rubberBand != 0) {
144 QRect r = QRect(bandOrigin, e->pos()).normalized();
145 bandOrigin = r.topLeft();
147 selectRegion(r.top(), r.left(), r.bottom(), r.right());