aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-02-08 14:26:48 -0200
committerSamuel Fadel <samuelfadel@gmail.com>2016-02-08 14:26:48 -0200
commit6ce50a77d7659e5e7fbcaceead0e17d37ce8856d (patch)
tree2d252f6895a8e562eb5ae4e4db65a8ca0bd820e3
parent0ca3153549230cfd60675aad3b4a900580ec01b4 (diff)
User can now select RPs & CPs, using the R & C keys.
-rw-r--r--main.cpp7
-rw-r--r--main.h16
-rw-r--r--main_view.qml30
-rw-r--r--scatterplot.cpp3
-rw-r--r--scatterplot.h6
5 files changed, 55 insertions, 7 deletions
diff --git a/main.cpp b/main.cpp
index f90a11a..47bea3d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
diff --git a/main.h b/main.h
index b9368ac..d3184da 100644
--- a/main.h
+++ b/main.h
@@ -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;