Improve ctrl selection, plus show duration above flow graph

This commit is contained in:
Mark Watkins 2014-07-19 22:51:17 +10:00
parent b6491cac84
commit 5e672eb651
5 changed files with 32 additions and 10 deletions

View File

@ -137,6 +137,7 @@ gGraph::gGraph(QString name, gGraphView *graphview, QString title, QString units
rec_miny = rec_maxy = 0;
rphysmax_y = rphysmin_y = 0;
m_zoomY = 0;
m_selectedDuration = 0;
if (graphview) {
graphview->addGraph(this, group);
@ -697,6 +698,7 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
if (m_graphview->m_selected_graph == this) { // Left Mouse button dragging
if (event->buttons() & Qt::LeftButton) {
//qDebug() << m_title << "Moved" << x << y << left << right << top << bottom << m_width << h;
int a1 = MIN(x, x2);
int a2 = MAX(x, x2);
@ -716,22 +718,22 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
}
qint64 a = double(a2 - a1) * xmult;
m_selectedDuration = a;
float d = double(a) / 86400000.0;
int h = a / 3600000;
int m = (a / 60000) % 60;
int s = (a / 1000) % 60;
int ms(a % 1000);
QString str;
if (d > 1) {
str.sprintf("%1.0f days", d);
m_selDurString.sprintf("%1.0f days", d);
} else {
str.sprintf("%02i:%02i:%02i:%03i", h, m, s, ms);
m_selDurString.sprintf("%02i:%02i:%02i:%03i", h, m, s, ms);
}
if (qstatus2) {
qstatus2->setText(str);
qstatus2->setText(m_selDurString);
}
doredraw = true;

View File

@ -286,6 +286,9 @@ class gGraph : public QObject
static const short maxZoomY = 2;
inline qint64 selectedDuration() const { return m_selectedDuration; }
inline QString selDurString() const { return m_selDurString; }
protected:
//! \brief Mouse Wheel events
virtual void wheelEvent(QWheelEvent *event);
@ -340,6 +343,9 @@ class gGraph : public QObject
short m_zoomY;
QRect m_rect;
qint64 m_selectedDuration;
QString m_selDurString;
protected slots:
//! \brief Deselects any highlights, and schedules a main gGraphView redraw
void Timeout();

View File

@ -1220,6 +1220,7 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
m_lastypos = y;
// QPoint p(x,y);
// QMouseEvent e(event->type(),p,event->button(),event->buttons(),event->modifiers());
m_graphs[i]->mouseMoveEvent(event);
done = true;
@ -1558,6 +1559,8 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
// The graph that got the button press gets the release event
if (m_button_down) {
m_button_down = false;
m_metaselect = event->modifiers() & Qt::ControlModifier;
if (m_metaselect) {
m_point_released = event->pos();
} else {
@ -1568,12 +1571,12 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
void gGraphView::keyReleaseEvent(QKeyEvent *event)
{
if (m_metaselect) {
QMouseEvent event(QEvent::MouseButtonRelease, m_point_released, Qt::LeftButton, Qt::LeftButton, event.modifiers());
if (m_metaselect && !(event->modifiers() & Qt::ControlModifier)) {
QMouseEvent mevent(QEvent::MouseButtonRelease, m_point_released, Qt::LeftButton, Qt::LeftButton, event->modifiers());
if (m_graph_index>=0)
m_graphs[m_graph_index]->mouseReleaseEvent(&event);
m_graphs[m_graph_index]->mouseReleaseEvent(&mevent);
qDebug() << "Control released";
m_metaselect = false;
}
#ifdef BROKEN_OPENGL_BUILD
QWidget::keyReleaseEvent(event);
@ -1785,6 +1788,9 @@ void gGraphView::wheelEvent(QWheelEvent *event)
void gGraphView::keyPressEvent(QKeyEvent *event)
{
if (m_button_down) {
m_metaselect = event->modifiers() & Qt::ControlModifier;
}
if (event->key() == Qt::Key_Tab) {
event->ignore();
return;

View File

@ -348,6 +348,9 @@ class gGraphView
//! \brief Graph drawing routines, returns true if there weren't any graphs to draw
bool renderGraphs(QPainter &painter);
//! \brief Used internally by graph mousehandler to set modifier state
void setMetaSelect(bool b) { m_metaselect = b; }
// for profiling purposes, a count of lines drawn in a single frame
int lines_drawn_this_frame;
int quads_drawn_this_frame;

View File

@ -285,11 +285,16 @@ void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion &reg
if (time > 0) { val = cnt / time; }
QString a;
if (w.graphView()->selectionInProgress()) {
QString a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " +
a = QObject::tr("Duration")+": "+w.selDurString();
} else {
a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " +
QObject::tr("Duration") + " " + QString().sprintf("%02i:%02i:%02i", h, m, s) + ", " + m_text + ": " + QString::number(val, 'f', 2);
}
if (isSpan) {
float sph;