case MouseMode::CROSSHAIR:
this->eraseCrosshair(true);
break;
- case MouseMode::INTEGRATE:
+ case MouseMode::INTEGRATION_BASELINE:
this->eraseIntegrationBaseline(true);
break;
- case MouseMode::ZOOM:
+ case MouseMode::ZOOM_RECTANGLE:
this->eraseZoomRect(true);
break;
}
case GraphView::MouseMode::CROSSHAIR:
drawCrosshair(xPix, yPix);
break;
- case GraphView::MouseMode::ZOOM:
+ case GraphView::MouseMode::ZOOM_RECTANGLE:
drawZoomRect(xPix, yPix);
break;
- case GraphView::MouseMode::INTEGRATE:
+ case GraphView::MouseMode::INTEGRATION_BASELINE:
drawIntegrationBaseline(xPix, yPix);
break;
}
switch (ev->button()) {
case Qt::LeftButton:
switch (m_mouseMode) {
- case GraphView::MouseMode::CROSSHAIR:
- switch (m_graphCtrlMode) {
- case GraphControlModes::ZOOM:
- m_zoomRectStartXPix = ev->x();
- m_zoomRectStartYPix = ev->y();
- m_zoomRectLastXPix = ev->x();
- m_zoomRectLastYPix = ev->y();
- eraseCrosshair(true);
- m_mouseMode = GraphView::MouseMode::ZOOM;
- break;
- case GraphControlModes::INTEGRATE_BASELINE:
- m_integrateStartBLYPix = relToYPix(m_controller->valueToRel(m_controller->getXYValues(xPixToRel(ev->x())).second));
- m_integrateStopBLYPix = m_integrateStartBLYPix;
- case GraphControlModes::INTEGRATE_INTERSECT:
- m_integrateStartXPix = ev->x();
- m_integrateStartYPix = ev->y();
- m_integrateStopXPix = ev->x();
- m_integrateStopYPix = ev->y();
- eraseCrosshair(true);
- m_graphCrosshairXPix = -1;
- m_mouseMode = GraphView::MouseMode::INTEGRATE;
- }
+ case GraphView::MouseMode::CROSSHAIR:
+ switch (m_graphCtrlMode) {
+ case GraphControlModes::ZOOM:
+ startZoom(ev->pos());
break;
- case GraphView::MouseMode::ZOOM:
- zoom(m_zoomRectStartXPix, m_zoomRectStartYPix, m_zoomRectLastXPix, m_zoomRectLastYPix);
- m_mouseMode = GraphView::MouseMode::CROSSHAIR;
+ case GraphControlModes::INTEGRATE:
+ startIntegration(ev->pos());
break;
- case GraphView::MouseMode::INTEGRATE:
- PeakDrawData pdData = m_controller->integratePeak(xPixToRel(m_integrateStartXPix), yPixToRel(m_integrateStartYPix),
- xPixToRel(m_integrateStopXPix), yPixToRel(m_integrateStopYPix), m_integrationType);
- eraseIntegrationBaseline(true);
- QRegion reg = renderPeak(pdData, m_background);
- copyPixmapRegion(reg, m_background, m_pixmap);
- update(reg);
- m_integrateStartXPix = -1;
- m_mouseMode = GraphView::MouseMode::CROSSHAIR;
- break;
- }
+ }
+ break;
+
+ case GraphView::MouseMode::ZOOM_RECTANGLE:
+ doZoom();
+ break;
+ case GraphView::MouseMode::INTEGRATION_BASELINE:
+ doIntegration();
+ break;
+ }
break;
case Qt::RightButton:
switch (m_mouseMode) {
- case GraphView::MouseMode::CROSSHAIR:
- eraseCrosshair(true);
- showContextMenu(ev->pos(), ev->globalPos());
- break;
- case GraphView::MouseMode::ZOOM:
- eraseZoomRect(true);
- m_mouseMode = GraphView::MouseMode::CROSSHAIR;
- break;
- case GraphView::MouseMode::INTEGRATE:
- eraseIntegrationBaseline(true);
- m_integrateStartXPix = -1;
- m_mouseMode = GraphView::MouseMode::CROSSHAIR;
- break;
- default:
- break;
+ case GraphView::MouseMode::CROSSHAIR:
+ doShowContextMenu(ev->pos(), ev->globalPos());
+ break;
+ case GraphView::MouseMode::ZOOM_RECTANGLE:
+ cancelZoom();
+ break;
+ case GraphView::MouseMode::INTEGRATION_BASELINE:
+ cancelIntegration();
+ break;
+ default:
+ break;
}
break;
default:
/** Private methods **/
+void GraphView::cancelIntegration()
+{
+ eraseIntegrationBaseline(true);
+ m_integrateStartXPix = -1;
+ m_mouseMode = GraphView::MouseMode::CROSSHAIR;
+}
+
+void GraphView::cancelZoom()
+{
+ eraseZoomRect(true);
+ m_mouseMode = GraphView::MouseMode::CROSSHAIR;
+}
+
+void GraphView::doIntegration()
+{
+ IntegrationType itype;
+ switch (m_integrationMode) {
+ case GraphView::IntegrationMode::BASELINE:
+ itype = IntegrationType::BASELINE;
+ break;
+ case GraphView::IntegrationMode::INTERSECTION:
+ itype = IntegrationType::INTERSECTION;
+ break;
+ default:
+ itype = IntegrationType::NONE;
+ break;
+ }
+
+ PeakDrawData pdData = m_controller->integratePeak(xPixToRel(m_integrateStartXPix), yPixToRel(m_integrateStartYPix),
+ xPixToRel(m_integrateStopXPix), yPixToRel(m_integrateStopYPix), itype);
+ eraseIntegrationBaseline(true);
+
+ QRegion reg = renderPeak(pdData, m_background);
+ copyPixmapRegion(reg, m_background, m_pixmap);
+ update(reg);
+ m_integrateStartXPix = -1;
+ m_mouseMode = GraphView::MouseMode::CROSSHAIR;
+}
+
+void GraphView::doShowContextMenu(const QPoint& pos, const QPoint& globalPos)
+{
+ eraseCrosshair(true);
+ showContextMenu(pos, globalPos);
+}
+
+void GraphView::doZoom()
+{
+ zoom(m_zoomRectStartXPix, m_zoomRectStartYPix, m_zoomRectLastXPix, m_zoomRectLastYPix);
+ m_mouseMode = GraphView::MouseMode::CROSSHAIR;
+}
+
void GraphView::drawCrosshair(const int xPix, const int yPix)
{
QPainter p;
reg = eraseIntegrationBaseline();
- if (m_integrationType == IntegrationType::BASELINE) {
+ if (m_integrationMode == GraphView::IntegrationMode::BASELINE) {
m_integrateStopBLYPix = relToYPix(m_controller->valueToRel(m_controller->getXYValues(xPixToRel(x)).second));
double vstarty = std::min(m_integrateStartBLYPix, m_integrateStartYPix);
double vstopy = std::min(m_integrateStopBLYPix, y);
if (m_integrateStartXPix < 0)
return QRegion();
- if (m_integrationType == IntegrationType::BASELINE) {
+ if (m_integrationMode == GraphView::IntegrationMode::BASELINE) {
int top, bottom, left, right;
top = Helpers::minof(m_integrateStartYPix, m_integrateStopYPix, m_integrateStartBLYPix, m_integrateStopBLYPix);
bottom = Helpers::maxof(m_integrateStartYPix, m_integrateStopYPix, m_integrateStartBLYPix, m_integrateStopBLYPix);
m_ctxMenu.exec(globalPos);
}
+void GraphView::startIntegration(const QPoint& pos)
+{
+ switch (m_integrationMode) {
+ case GraphView::IntegrationMode::BASELINE:
+ Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, "Starting integration by baseline");
+ m_integrateStartBLYPix = relToYPix(m_controller->valueToRel(m_controller->getXYValues(xPixToRel(pos.x())).second));
+ m_integrateStopBLYPix = m_integrateStartBLYPix;
+ break;
+ case GraphView::IntegrationMode::INTERSECTION:
+ Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, "Starting inregration by intersection");
+ break;
+ }
+ m_integrateStartXPix = pos.x();
+ m_integrateStartYPix = pos.y();
+ m_integrateStopXPix = pos.x();
+ m_integrateStopYPix = pos.y();
+
+ eraseCrosshair(true);
+ m_graphCrosshairXPix = -1;
+ m_mouseMode = GraphView::MouseMode::INTEGRATION_BASELINE;
+}
+
+void GraphView::startZoom(const QPoint& pos)
+{
+ m_zoomRectStartXPix = pos.x();
+ m_zoomRectStartYPix = pos.y();
+ m_zoomRectLastXPix = pos.x();
+ m_zoomRectLastYPix = pos.y();
+
+ eraseCrosshair(true);
+ m_mouseMode = GraphView::MouseMode::ZOOM_RECTANGLE;
+}
+
void GraphView::updateValuesUnderCrosshair(const int xPix)
{
double x = xPixToRel(xPix);
{
Q_OBJECT
public:
- enum class MouseMode {
- CROSSHAIR,
- ZOOM,
- INTEGRATE
- };
-
explicit GraphView(std::shared_ptr<SignalController> controller, QWidget* parent = nullptr);
void leaveEvent(QEvent* );
void mouseDoubleClickEvent(QMouseEvent* );
bool refresh(QRegion reg = QRegion());
private:
+ enum class GraphControlModes {
+ ZOOM,
+ INTEGRATE
+ };
+ enum class MouseMode {
+ CROSSHAIR,
+ ZOOM_RECTANGLE,
+ INTEGRATION_BASELINE
+ };
+ enum class IntegrationMode {
+ BASELINE,
+ INTERSECTION
+ };
+
+ void cancelIntegration();
+ void cancelZoom();
+ void doIntegration();
+ void doShowContextMenu(const QPoint& pos, const QPoint& globalPos);
+ void doZoom();
void drawCrosshair(const int xPix, const int yPix);
void drawIntegrationBaseline(const int x, const int y);
void drawZoomRect(const int x, const int y);
void updateValuesUnderCrosshair(const int xPix);
void setDefaultZoom();
void showContextMenu(const QPoint& pos, const QPoint& globalPos);
+ void startIntegration(const QPoint& pos);
+ void startZoom(const QPoint& pos);
void zoom(const int fromXPix, const int fromYPix, const int toXPix, const int toYPix);
static inline double RELATIVE_Y_MAX_WITH_MARGIN()
GraphViewContextMenu m_ctxMenu;
- MouseMode m_mouseMode;
GraphControlModes m_graphCtrlMode;
+ MouseMode m_mouseMode;
+ IntegrationMode m_integrationMode;
/* Crosshair */
int m_graphCrosshairXPix;
int m_graphCrosshairYPix;
/* Integration baseline */
- IntegrationType m_integrationType;
int m_integrateStartBLYPix;
int m_integrateStopBLYPix;
int m_integrateStartXPix;
void onCtxMenuZoomOut();
public slots:
- void onControlModeChanged(GraphControlModes mode)
- { m_graphCtrlMode = mode;
- if (mode == GraphControlModes::INTEGRATE_BASELINE) m_integrationType = IntegrationType::BASELINE;
- else if (mode == GraphControlModes::INTEGRATE_INTERSECT) m_integrationType = IntegrationType::INTERSECTION;
+ void onSetZoomMode() {
+ m_graphCtrlMode = GraphView::GraphControlModes::ZOOM;
+ }
+ void onSetIntegrateBaseline() {
+ m_graphCtrlMode = GraphView::GraphControlModes::INTEGRATE;
+ m_integrationMode = GraphView::IntegrationMode::BASELINE;
+ }
+ void onSetIntegrateIntersection() {
+ m_graphCtrlMode = GraphView::GraphControlModes::INTEGRATE;
+ m_integrationMode = GraphView::IntegrationMode::INTERSECTION;
}
signals:
{
/* Controls panel */
connect(ui->qpb_integrateBaseline, SIGNAL(pressed()), this, SLOT(onIntegrateBaselineSelected()));
- connect(ui->qpb_integrateIntersect, SIGNAL(pressed()), this, SLOT(onIntegrateIntersectSelected()));
+ connect(ui->qpb_integrateIntersect, SIGNAL(pressed()), this, SLOT(onIntegrateIntersectionSelected()));
connect(ui->qpb_zoom, SIGNAL(pressed()), this, SLOT(onZoomSelected()));
/* DATA menu */
void MainWindow::onAddToDashboard(SignalView* sw)
{
if (ui->qpb_integrateBaseline->isChecked())
- sw->m_graphView->onControlModeChanged(GraphControlModes::INTEGRATE_BASELINE);
+ sw->m_graphView->onSetIntegrateBaseline();
else if(ui->qpb_integrateIntersect->isChecked())
- sw->m_graphView->onControlModeChanged(GraphControlModes::INTEGRATE_INTERSECT);
+ sw->m_graphView->onSetIntegrateIntersection();
else if(ui->qpb_zoom->isChecked())
- sw->m_graphView->onControlModeChanged(GraphControlModes::ZOOM);
+ sw->m_graphView->onSetZoomMode();
- connect(this, SIGNAL(controlModeChanged(GraphControlModes)), sw->m_graphView, SLOT(onControlModeChanged(GraphControlModes)));
+ connect(this, SIGNAL(integrateBaselineMode()), sw->m_graphView, SLOT(onSetIntegrateBaseline()));
+ connect(this, SIGNAL(integrateIntersectionMode()), sw->m_graphView, SLOT(onSetIntegrateIntersection()));
+ connect(this, SIGNAL(zoomMode()), sw->m_graphView, SLOT(onSetZoomMode()));
connect(sw, SIGNAL(fullSizeToggle()), this, SLOT(onSWFullSizeToggle()));
m_dashboard->addWidget(sw);
void MainWindow::onIntegrateBaselineSelected()
{
- emit controlModeChanged(GraphControlModes::INTEGRATE_BASELINE);
+ emit integrateBaselineMode();
}
-void MainWindow::onIntegrateIntersectSelected()
+void MainWindow::onIntegrateIntersectionSelected()
{
- emit controlModeChanged(GraphControlModes::INTEGRATE_INTERSECT);
+ emit integrateIntersectionMode();
}
void MainWindow::onLoadSequence()
void MainWindow::onZoomSelected()
{
- emit controlModeChanged(GraphControlModes::ZOOM);
+ emit zoomMode();
}
MainWindow::~MainWindow()