aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2015-08-27 15:22:29 -0300
committerSamuel Fadel <samuelfadel@gmail.com>2015-08-27 15:22:29 -0300
commit04e48cd798a28ad8df3233fa46b185d02d2d3f96 (patch)
tree7f5152883619d781f79f93ae936183b0012ede7e
parent09ba6872c6cfac49142a5c4b6d494c5c9d40aa4e (diff)
Renamed member m_currentState and reordered to match declaration and initialization.
-rw-r--r--scatterplot.cpp18
-rw-r--r--scatterplot.h15
2 files changed, 17 insertions, 16 deletions
diff --git a/scatterplot.cpp b/scatterplot.cpp
index 964642c..a121304 100644
--- a/scatterplot.cpp
+++ b/scatterplot.cpp
@@ -11,9 +11,9 @@ static const float PI = 3.1415f;
Scatterplot::Scatterplot(QQuickItem *parent)
: QQuickItem(parent)
+ , m_currentInteractionState(INTERACTION_NONE)
, m_shouldUpdateGeometry(false)
, m_shouldUpdateMaterials(false)
- , m_currentState(INTERACTION_NONE)
, m_colorScale{
QColor("#1f77b4"),
QColor("#ff7f0e"),
@@ -157,7 +157,7 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
} else
root = oldNode;
- if (m_currentState == INTERACTION_MOVING) {
+ if (m_currentInteractionState == INTERACTION_MOVING) {
tx = m_dragCurrentPos.x() - m_dragOriginPos.x();
ty = m_dragCurrentPos.y() - m_dragOriginPos.y();
} else
@@ -196,7 +196,7 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
m_shouldUpdateMaterials = false;
// Draw selection
- if (m_currentState == INTERACTION_SELECTING) {
+ if (m_currentInteractionState == INTERACTION_SELECTING) {
QSGSimpleRectNode *selectionNode = 0;
if (!root->firstChild()->nextSibling()) {
selectionNode = new QSGSimpleRectNode;
@@ -220,10 +220,10 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
void Scatterplot::mousePressEvent(QMouseEvent *event)
{
- switch (m_currentState) {
+ switch (m_currentInteractionState) {
case INTERACTION_NONE:
case INTERACTION_SELECTED:
- m_currentState = (event->button() == Qt::MiddleButton) ? INTERACTION_MOVING
+ m_currentInteractionState = (event->button() == Qt::MiddleButton) ? INTERACTION_MOVING
: INTERACTION_SELECTING;
m_dragOriginPos = event->localPos();
m_dragCurrentPos = m_dragOriginPos;
@@ -237,7 +237,7 @@ void Scatterplot::mousePressEvent(QMouseEvent *event)
void Scatterplot::mouseMoveEvent(QMouseEvent *event)
{
- switch (m_currentState) {
+ switch (m_currentInteractionState) {
case INTERACTION_SELECTING:
m_dragCurrentPos = event->localPos();
update();
@@ -259,16 +259,16 @@ void Scatterplot::mouseReleaseEvent(QMouseEvent *event)
{
bool mergeSelection;
- switch (m_currentState) {
+ switch (m_currentInteractionState) {
case INTERACTION_SELECTING:
mergeSelection = (event->button() == Qt::RightButton);
- m_currentState = selectGlyphs(mergeSelection) ? INTERACTION_SELECTED
+ m_currentInteractionState = selectGlyphs(mergeSelection) ? INTERACTION_SELECTED
: INTERACTION_NONE;
update();
break;
case INTERACTION_MOVING:
- m_currentState = INTERACTION_SELECTED;
+ m_currentInteractionState = INTERACTION_SELECTED;
updateGeometry();
break;
case INTERACTION_NONE:
diff --git a/scatterplot.h b/scatterplot.h
index a942217..a115755 100644
--- a/scatterplot.h
+++ b/scatterplot.h
@@ -43,21 +43,22 @@ private:
arma::mat m_xy;
float m_xmin, m_xmax, m_ymin, m_ymax;
- bool m_shouldUpdateGeometry, m_shouldUpdateMaterials;
-
- arma::vec m_colorData;
-
- ColorScale m_colorScale;
-
enum InteractionState {
INTERACTION_NONE,
INTERACTION_SELECTING,
INTERACTION_SELECTED,
INTERACTION_MOVING
- } m_currentState;
+ } m_currentInteractionState;
+
QPointF m_dragOriginPos, m_dragCurrentPos;
QSet<int> m_selectedGlyphs;
+
+ bool m_shouldUpdateGeometry, m_shouldUpdateMaterials;
+
+ arma::vec m_colorData;
+
+ ColorScale m_colorScale;
};
#endif // SCATTERPLOT_H