LTM Show Events Checkbox

Adds a checkbox to the LTM plot to enable and
disable the plot markers for season and events.
This commit is contained in:
Mark Liversedge
2013-02-04 12:51:30 +00:00
parent bb5126030d
commit 570c9af752
6 changed files with 44 additions and 25 deletions

View File

@@ -1405,7 +1405,7 @@ class LTMPlotZoneLabel: public QwtPlotItem
void
LTMPlot::refreshMarkers(QDate from, QDate to, int groupby)
{
// clear old markers
// clear old markers - if there are any
foreach(QwtPlotMarker *m, markers) {
m->detach();
delete m;
@@ -1415,29 +1415,11 @@ LTMPlot::refreshMarkers(QDate from, QDate to, int groupby)
double baseday = groupForDate(from, groupby);
// seasons and season events
foreach (Season s, main->seasons->seasons) {
if (settings->events) {
foreach (Season s, main->seasons->seasons) {
if (s.type != Season::temporary && s.name != settings->title && s.getStart() >= from && s.getStart() < to) {
if (s.type != Season::temporary && s.name != settings->title && s.getStart() >= from && s.getStart() < to) {
QwtPlotMarker *mrk = new QwtPlotMarker;
markers.append(mrk);
mrk->attach(this);
mrk->setLineStyle(QwtPlotMarker::VLine);
mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine));
QwtText text(s.getName());
text.setFont(QFont("Helvetica", 10, QFont::Bold));
text.setColor(GColor(CPLOTMARKER));
mrk->setValue(double(groupForDate(s.getStart(), groupby)) - baseday, 0.0);
mrk->setLabel(text);
}
foreach (SeasonEvent event, s.events) {
if (event.date > from && event.date < to) {
// and the events...
QwtPlotMarker *mrk = new QwtPlotMarker;
markers.append(mrk);
mrk->attach(this);
@@ -1445,14 +1427,33 @@ LTMPlot::refreshMarkers(QDate from, QDate to, int groupby)
mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine));
QwtText text(event.name);
QwtText text(s.getName());
text.setFont(QFont("Helvetica", 10, QFont::Bold));
text.setColor(GColor(CPLOTMARKER));
mrk->setValue(double(groupForDate(event.date, groupby)) - baseday, 10.0);
mrk->setValue(double(groupForDate(s.getStart(), groupby)) - baseday, 0.0);
mrk->setLabel(text);
}
}
foreach (SeasonEvent event, s.events) {
if (event.date > from && event.date < to) {
// and the events...
QwtPlotMarker *mrk = new QwtPlotMarker;
markers.append(mrk);
mrk->attach(this);
mrk->setLineStyle(QwtPlotMarker::VLine);
mrk->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
mrk->setLinePen(QPen(GColor(CPLOTMARKER), 0, Qt::DashDotLine));
QwtText text(event.name);
text.setFont(QFont("Helvetica", 10, QFont::Bold));
text.setColor(GColor(CPLOTMARKER));
mrk->setValue(double(groupForDate(event.date, groupby)) - baseday, 10.0);
mrk->setLabel(text);
}
}
}
}
return;
}

View File

@@ -123,6 +123,7 @@ class LTMSettings {
int groupBy;
bool shadeZones;
bool legend;
bool events;
QList<MetricDetail> metrics;
QList<SummaryMetrics> *data;
QList<SummaryMetrics> *measures;

View File

@@ -102,6 +102,9 @@ LTMTool::LTMTool(MainWindow *parent, const QDir &home, bool multi) : QWidget(par
showLegend = new QCheckBox("Show Legend");
basicsettingsLayout->addRow(new QLabel(""), showLegend);
showEvents = new QCheckBox("Show Events");
basicsettingsLayout->addRow(new QLabel(""), showEvents);
// controls
saveButton = new QPushButton(tr("Add"));
manageButton = new QPushButton(tr("Manage"));

View File

@@ -91,6 +91,7 @@ class LTMTool : public QWidget
QComboBox *groupBy;
QCheckBox *shadeZones;
QCheckBox *showLegend;
QCheckBox *showEvents;
QPushButton *saveButton;
QPushButton *manageButton;

View File

@@ -99,6 +99,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home)
settings.data = NULL;
settings.groupBy = LTM_DAY;
settings.legend = ltmTool->showLegend->isChecked();
settings.events = ltmTool->showEvents->isChecked();
settings.shadeZones = ltmTool->shadeZones->isChecked();
cl->addWidget(ltmTool);
@@ -111,6 +112,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home)
connect(ltmTool->presetPicker, SIGNAL(currentIndexChanged(int)), this, SLOT(chartSelected(int)));
connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int)));
connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int)));
connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int)));
connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange)));
connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday()));
connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange()));
@@ -327,6 +329,13 @@ LTMWindow::showLegendClicked(int state)
refreshPlot();
}
void
LTMWindow::showEventsClicked(int state)
{
settings.events = state;
refreshPlot();
}
void
LTMWindow::chartSelected(int selected)
{

View File

@@ -93,6 +93,7 @@ class LTMWindow : public LTMPlotContainer
Q_PROPERTY(int bin READ bin WRITE setBin USER true)
Q_PROPERTY(bool shade READ shade WRITE setShade USER true)
Q_PROPERTY(bool legend READ legend WRITE setLegend USER true)
Q_PROPERTY(bool events READ events WRITE setEvents USER true)
#ifdef GC_HAVE_LUCENE
Q_PROPERTY(QString filter READ filter WRITE setFilter USER true)
#endif
@@ -120,6 +121,8 @@ class LTMWindow : public LTMPlotContainer
void setShade(bool x) { ltmTool->shadeZones->setChecked(x); }
bool legend() const { return ltmTool->showLegend->isChecked(); }
void setLegend(bool x) { ltmTool->showLegend->setChecked(x); }
bool events() const { return ltmTool->showEvents->isChecked(); }
void setEvents(bool x) { ltmTool->showEvents->setChecked(x); }
int useSelected() { return ltmTool->dateSetting->mode(); }
void setUseSelected(int x) { ltmTool->dateSetting->setMode(x); }
@@ -155,6 +158,7 @@ class LTMWindow : public LTMPlotContainer
void metricSelected();
void groupBySelected(int);
void shadeZonesClicked(int);
void showEventsClicked(int);
void showLegendClicked(int);
void chartSelected(int);
void saveClicked();