diff options
-rw-r--r-- | main.cpp | 7 | ||||
-rw-r--r-- | main.h | 16 | ||||
-rw-r--r-- | main_view.qml | 30 | ||||
-rw-r--r-- | scatterplot.cpp | 3 | ||||
-rw-r--r-- | scatterplot.h | 6 |
5 files changed, 55 insertions, 7 deletions
@@ -246,14 +246,11 @@ int main(int argc, char **argv) &projectionObserver, SLOT(setRPSelection(const std::vector<bool> &))); // General component set up + m->cpPlot->setDragEnabled(true); m->cpPlot->setAutoScale(false); - m->cpPlot->setAcceptHoverEvents(true); - m->cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); - m->rpPlot->setGlyphSize(3.0f); m->rpPlot->setAutoScale(false); - m->rpPlot->setAcceptHoverEvents(true); - m->rpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); + m->setSelectCPs(); m->cpBarChart->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); m->rpBarChart->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); @@ -58,6 +58,22 @@ public: arma::mat X() const { return m_dataset.cols(0, m_dataset.n_cols - 2); } arma::vec labels() const { return m_dataset.col(m_dataset.n_cols - 1); } + Q_INVOKABLE void setSelectRPs() { + cpPlot->setAcceptedMouseButtons(Qt::NoButton); + cpPlot->setAcceptHoverEvents(false); + + rpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); + rpPlot->setAcceptHoverEvents(true); + } + + Q_INVOKABLE void setSelectCPs() { + rpPlot->setAcceptedMouseButtons(Qt::NoButton); + rpPlot->setAcceptHoverEvents(false); + + cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); + cpPlot->setAcceptHoverEvents(true); + } + enum ObserverType { ObserverCurrent = ProjectionObserver::OBSERVER_CURRENT, ObserverDiffPrevious = ProjectionObserver::OBSERVER_DIFF_PREVIOUS, diff --git a/main_view.qml b/main_view.qml index 241f440..bcf64a5 100644 --- a/main_view.qml +++ b/main_view.qml @@ -26,6 +26,12 @@ ApplicationWindow { MenuItem { action: screenshotAction } MenuItem { action: quitAction } } + + Menu { + title: "Select" + MenuItem { action: selectRPsAction } + MenuItem { action: selectCPsAction } + } } statusBar: StatusBar { @@ -62,6 +68,7 @@ ApplicationWindow { objectName: "splat" x: parent.x y: parent.y + z: 0 anchors.fill: parent } @@ -70,6 +77,7 @@ ApplicationWindow { objectName: "rpPlot" x: parent.x y: parent.y + z: 1 anchors.fill: parent } @@ -78,6 +86,7 @@ ApplicationWindow { objectName: "cpPlot" x: parent.x y: parent.y + z: 2 anchors.fill: parent } @@ -441,6 +450,26 @@ ApplicationWindow { onTriggered: Qt.quit() } + Action { + id: selectRPsAction + text: "&Regular points" + shortcut: "R" + onTriggered: { + Main.setSelectRPs(); + statusLabel.text = "Selecting regular points"; + } + } + + Action { + id: selectCPsAction + text: "&Control points" + shortcut: "C" + onTriggered: { + Main.setSelectCPs(); + statusLabel.text = "Selecting control points"; + } + } + ListModel { id: metricsModel @@ -453,6 +482,7 @@ ApplicationWindow { id: colormapModel Component.onCompleted: { + // Data has to be fed this way; otherwise "value" is not correct this.append({ "value": Main.ColorScaleRainbow, "text": "Rainbow" diff --git a/scatterplot.cpp b/scatterplot.cpp index 69ed1b1..f501267 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -210,6 +210,7 @@ Scatterplot::Scatterplot(QQuickItem *parent) , m_sy(0, 1, 0, 1) , m_brushedItem(-1) , m_interactionState(STATE_NONE) + , m_dragEnabled(false) , m_shouldUpdateGeometry(false) , m_shouldUpdateMaterials(false) , m_quadtree(0) @@ -584,7 +585,7 @@ void Scatterplot::mousePressEvent(QMouseEvent *event) switch (m_interactionState) { case STATE_NONE: case STATE_SELECTED: - if (event->modifiers() == Qt::ShiftModifier) { + if (event->modifiers() == Qt::ShiftModifier && m_dragEnabled) { m_interactionState = STATE_BEGIN_MOVING; } m_dragOriginPos = event->localPos(); diff --git a/scatterplot.h b/scatterplot.h index 2f83719..9450568 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -17,6 +17,8 @@ class Scatterplot { Q_OBJECT public: + static const int PADDING = 20; + Scatterplot(QQuickItem *parent = 0); arma::mat XY() const; @@ -31,7 +33,8 @@ public: Q_INVOKABLE float glyphSize() const { return m_glyphSize; } - static const int PADDING = 20; + void setDragEnabled(bool enabled) { m_dragEnabled = enabled; } + bool isDragEnabled() const { return m_dragEnabled; } signals: void xyChanged(const arma::mat &XY) const; @@ -97,6 +100,7 @@ private: STATE_BEGIN_MOVING, STATE_MOVING } m_interactionState; + bool m_dragEnabled; QPointF m_dragOriginPos, m_dragCurrentPos; |