diff options
-rw-r--r-- | barchart.cpp | 2 | ||||
-rw-r--r-- | continuouscolorscale.cpp | 8 | ||||
-rw-r--r-- | continuouscolorscale.h | 6 | ||||
-rw-r--r-- | main.h | 12 | ||||
-rw-r--r-- | main_view.qml | 12 | ||||
-rw-r--r-- | projectionobserver.cpp | 10 | ||||
-rw-r--r-- | projectionobserver.h | 8 | ||||
-rw-r--r-- | scatterplot.cpp | 60 | ||||
-rw-r--r-- | scatterplot.h | 10 | ||||
-rw-r--r-- | voronoisplat.h | 14 |
10 files changed, 73 insertions, 69 deletions
diff --git a/barchart.cpp b/barchart.cpp index fb98219..cfa82aa 100644 --- a/barchart.cpp +++ b/barchart.cpp @@ -35,7 +35,7 @@ BarChart::BarChart(QQuickItem *parent) , m_dragLastPos(-1.0f) , m_shouldUpdateSelection(false) , m_brushedItem(-1) - , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS)) + , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HeatedObjects)) , m_scale(0.0f, 1.0f, 0.0f, 1.0f) { setClip(true); diff --git a/continuouscolorscale.cpp b/continuouscolorscale.cpp index b6f6fae..392dd47 100644 --- a/continuouscolorscale.cpp +++ b/continuouscolorscale.cpp @@ -32,7 +32,7 @@ QColor ContinuousColorScale::color(qreal t) const ContinuousColorScale ContinuousColorScale::builtin(BuiltinContinuousColorScale scale) { switch (scale) { - case HEATED_OBJECTS: + case HeatedObjects: return ContinuousColorScale{ QColor( 0, 0, 0), QColor( 35, 0, 0), @@ -291,7 +291,7 @@ ContinuousColorScale ContinuousColorScale::builtin(BuiltinContinuousColorScale s QColor(255, 255, 247), QColor(255, 255, 255) }; - case RED_GRAY_BLUE: + case RedGrayBlue: return ContinuousColorScale{ QColor(221, 68, 68), QColor(220, 69, 68), @@ -550,7 +550,7 @@ ContinuousColorScale ContinuousColorScale::builtin(BuiltinContinuousColorScale s QColor( 69, 68, 220), QColor( 68, 68, 221) }; - case RAINBOW: + case Rainbow: return ContinuousColorScale{ QColor( 0, 0, 0), QColor( 45, 0, 36), @@ -810,6 +810,6 @@ ContinuousColorScale ContinuousColorScale::builtin(BuiltinContinuousColorScale s QColor(255, 255, 255) }; default: - return ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS); + return ContinuousColorScale::builtin(ContinuousColorScale::HeatedObjects); } } diff --git a/continuouscolorscale.h b/continuouscolorscale.h index 860decf..fee17ed 100644 --- a/continuouscolorscale.h +++ b/continuouscolorscale.h @@ -10,9 +10,9 @@ public: ContinuousColorScale(std::initializer_list<QColor> colors); enum BuiltinContinuousColorScale { - HEATED_OBJECTS, - RED_GRAY_BLUE, - RAINBOW, + HeatedObjects, + RedGrayBlue, + Rainbow, }; QColor color(qreal t) const; @@ -77,9 +77,9 @@ public: } enum ObserverType { - ObserverCurrent = ProjectionObserver::OBSERVER_CURRENT, - ObserverDiffPrevious = ProjectionObserver::OBSERVER_DIFF_PREVIOUS, - ObserverDiffOriginal = ProjectionObserver::OBSERVER_DIFF_ORIGINAL + ObserverCurrent = ProjectionObserver::ObserverCurrent, + ObserverDiffPrevious = ProjectionObserver::ObserverDiffPrevious, + ObserverDiffFirst = ProjectionObserver::ObserverDiffFirst }; Q_INVOKABLE bool setObserverType(ObserverType observerType) { @@ -172,9 +172,9 @@ private: QColor("#d62728"), QColor("#9467bd"), QColor("#8c564b"), QColor("#e377c2"), QColor("#17becf"), QColor("#7f7f7f"), }} - , COLOR_SCALE_CONTINUOUS{ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS)} - , COLOR_SCALE_DIVERGENT{ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE)} - , COLOR_SCALE_RAINBOW{ContinuousColorScale::builtin(ContinuousColorScale::RAINBOW)} + , COLOR_SCALE_CONTINUOUS{ContinuousColorScale::builtin(ContinuousColorScale::HeatedObjects)} + , COLOR_SCALE_DIVERGENT{ContinuousColorScale::builtin(ContinuousColorScale::RedGrayBlue)} + , COLOR_SCALE_RAINBOW{ContinuousColorScale::builtin(ContinuousColorScale::Rainbow)} , cpBarChart(0) , rpBarChart(0) , cpPlot(0) diff --git a/main_view.qml b/main_view.qml index b0cee3c..65e1095 100644 --- a/main_view.qml +++ b/main_view.qml @@ -336,10 +336,10 @@ ApplicationWindow { id: alphaSpinBox maximumValue: 100 minimumValue: 1 - value: splat.alpha() + value: splat.alpha decimals: 2 stepSize: 1 - onValueChanged: splat.setAlpha(this.value) + onValueChanged: splat.alpha = this.value } Label { text: "Radius (β):" } @@ -347,10 +347,10 @@ ApplicationWindow { id: betaSpinBox maximumValue: 100 minimumValue: 1 - value: splat.beta() + value: splat.beta decimals: 2 stepSize: 1 - onValueChanged: splat.setBeta(this.value) + onValueChanged: splat.beta = this.value } Label { text: "Opacity:" } @@ -417,10 +417,10 @@ ApplicationWindow { } RadioButton { id: diffOriginalMetricRadioButton - text: "Diff. to original" + text: "Diff. to first" exclusiveGroup: wrtMetricsGroup onClicked: { - if (!Main.setObserverType(Main.ObserverDiffOriginal)) { + if (!Main.setObserverType(Main.ObserverDiffFirst)) { this.checked = false; currentMetricRadioButton.checked = true; } diff --git a/projectionobserver.cpp b/projectionobserver.cpp index 2e6773d..a6b280f 100644 --- a/projectionobserver.cpp +++ b/projectionobserver.cpp @@ -8,7 +8,7 @@ ProjectionObserver::ProjectionObserver(const arma::mat &X, const arma::uvec &cpIndices, ProjectionHistory *history) - : m_type(OBSERVER_CURRENT) + : m_type(ObserverCurrent) , m_X(X) , m_cpIndices(cpIndices) , m_rpIndices(X.n_rows - cpIndices.n_elem) @@ -79,7 +79,7 @@ bool ProjectionObserver::setType(int type) return true; } - if (type == OBSERVER_DIFF_PREVIOUS && !m_history->hasPrev()) { + if (type == ObserverDiffPrevious && !m_history->hasPrev()) { return false; } @@ -146,11 +146,11 @@ void ProjectionObserver::setRPSelection(const std::vector<bool> &rpSelection) bool ProjectionObserver::emitValuesChanged() const { switch (m_type) { - case OBSERVER_CURRENT: + case ObserverCurrent: emit rpValuesChanged(m_values(m_rpIndices)); emit valuesChanged(m_values); return true; - case OBSERVER_DIFF_PREVIOUS: + case ObserverDiffPrevious: if (m_history->hasPrev()) { arma::vec diff = m_values - m_prevValues; emit rpValuesChanged(diff(m_rpIndices)); @@ -158,7 +158,7 @@ bool ProjectionObserver::emitValuesChanged() const return true; } return false; - case OBSERVER_DIFF_ORIGINAL: + case ObserverDiffFirst: if (m_history->hasFirst()) { arma::vec diff = m_values - m_firstValues; emit rpValuesChanged(diff(m_rpIndices)); diff --git a/projectionobserver.h b/projectionobserver.h index 11338f5..7e9239d 100644 --- a/projectionobserver.h +++ b/projectionobserver.h @@ -11,9 +11,11 @@ class ProjectionObserver { Q_OBJECT public: - static const int OBSERVER_CURRENT = 0; - static const int OBSERVER_DIFF_PREVIOUS = 1; - static const int OBSERVER_DIFF_ORIGINAL = 2; + enum ObserverType { + ObserverCurrent, + ObserverDiffPrevious, + ObserverDiffFirst + }; ProjectionObserver(const arma::mat &X, const arma::uvec &cpIndices, diff --git a/scatterplot.cpp b/scatterplot.cpp index 4c8e169..0b3ef45 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -204,12 +204,12 @@ void QuadTree::query(const QRectF &rect, std::vector<int> &result) const Scatterplot::Scatterplot(QQuickItem *parent) : QQuickItem(parent) , m_glyphSize(DEFAULT_GLYPH_SIZE) - , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS)) + , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HeatedObjects)) , m_autoScale(true) , m_sx(0, 1, 0, 1) , m_sy(0, 1, 0, 1) , m_brushedItem(-1) - , m_interactionState(STATE_NONE) + , m_interactionState(StateNone) , m_dragEnabled(false) , m_shouldUpdateGeometry(false) , m_shouldUpdateMaterials(false) @@ -449,7 +449,7 @@ QSGNode *Scatterplot::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) // Selection QSGSimpleRectNode *selectionNode = static_cast<QSGSimpleRectNode *>(node); - if (m_interactionState == STATE_SELECTING) { + if (m_interactionState == StateSelecting) { selectionNode->setRect(QRectF(m_dragOriginPos, m_dragCurrentPos)); selectionNode->markDirty(QSGNode::DirtyGeometry); } else { @@ -473,7 +473,7 @@ void Scatterplot::updateGlyphs(QSGNode *glyphsNode) return; } - if (m_interactionState == STATE_MOVING) { + if (m_interactionState == StateMoving) { tx = m_dragCurrentPos.x() - m_dragOriginPos.x(); ty = m_dragCurrentPos.y() - m_dragOriginPos.y(); } else { @@ -528,8 +528,8 @@ void Scatterplot::updateBrush(QSGNode *node) { QMatrix4x4 transform; if (m_brushedItem < 0 - || (m_interactionState != STATE_NONE - && m_interactionState != STATE_SELECTED)) { + || (m_interactionState != StateNone + && m_interactionState != StateSelected)) { transform.translate(-width(), -height()); } else { const arma::rowvec &row = m_xy.row(m_brushedItem); @@ -543,28 +543,28 @@ void Scatterplot::updateBrush(QSGNode *node) void Scatterplot::mousePressEvent(QMouseEvent *event) { switch (m_interactionState) { - case STATE_NONE: - case STATE_SELECTED: + case StateNone: + case StateSelected: switch (event->button()) { case Qt::LeftButton: if (event->modifiers() == Qt::ShiftModifier && m_dragEnabled) { - m_interactionState = STATE_MOVING; + m_interactionState = StateMoving; m_dragOriginPos = event->localPos(); m_dragCurrentPos = m_dragOriginPos; } else { - m_interactionState = STATE_BRUSHING; + m_interactionState = StateBrushing; } break; case Qt::RightButton: - m_interactionState = STATE_NONE; + m_interactionState = StateNone; m_selection.assign(m_selection.size(), false); emit selectionInteractivelyChanged(m_selection); break; } break; - case STATE_BRUSHING: - case STATE_SELECTING: - case STATE_MOVING: + case StateBrushing: + case StateSelecting: + case StateMoving: // Probably shouldn't reach these break; } @@ -573,22 +573,22 @@ void Scatterplot::mousePressEvent(QMouseEvent *event) void Scatterplot::mouseMoveEvent(QMouseEvent *event) { switch (m_interactionState) { - case STATE_BRUSHING: - m_interactionState = STATE_SELECTING; + case StateBrushing: + m_interactionState = StateSelecting; m_dragOriginPos = event->localPos(); m_dragCurrentPos = m_dragOriginPos; // fall through - case STATE_SELECTING: + case StateSelecting: m_dragCurrentPos = event->localPos(); update(); break; - case STATE_MOVING: + case StateMoving: m_dragCurrentPos = event->localPos(); m_shouldUpdateGeometry = true; update(); break; - case STATE_NONE: - case STATE_SELECTED: + case StateNone: + case StateSelected: break; } } @@ -598,16 +598,16 @@ void Scatterplot::mouseReleaseEvent(QMouseEvent *event) bool mergeSelection = (event->modifiers() == Qt::ControlModifier); switch (m_interactionState) { - case STATE_BRUSHING: + case StateBrushing: // Mouse clicked with brush target; set new selection or append to // current if (!mergeSelection) { m_selection.assign(m_selection.size(), false); } if (m_brushedItem == -1) { - m_interactionState = STATE_NONE; + m_interactionState = StateNone; } else { - m_interactionState = STATE_SELECTED; + m_interactionState = StateSelected; m_selection[m_brushedItem] = !m_selection[m_brushedItem]; } @@ -615,13 +615,13 @@ void Scatterplot::mouseReleaseEvent(QMouseEvent *event) m_shouldUpdateMaterials = true; update(); break; - case STATE_SELECTING: + case StateSelecting: { // Selecting points and mouse is now released; update selection and // brush bool anySelected = interactiveSelection(mergeSelection); - m_interactionState = anySelected ? STATE_SELECTED - : STATE_NONE; + m_interactionState = anySelected ? StateSelected + : StateNone; QPoint pos = event->pos(); m_brushedItem = m_quadtree->nearestTo(pos.x(), pos.y()); @@ -631,17 +631,17 @@ void Scatterplot::mouseReleaseEvent(QMouseEvent *event) update(); } break; - case STATE_MOVING: + case StateMoving: // Moving points and now stopped; apply manipulation - m_interactionState = STATE_SELECTED; + m_interactionState = StateSelected; applyManipulation(); m_shouldUpdateGeometry = true; update(); m_dragOriginPos = m_dragCurrentPos; break; - case STATE_NONE: - case STATE_SELECTED: + case StateNone: + case StateSelected: break; } } diff --git a/scatterplot.h b/scatterplot.h index f12c658..33c1ba9 100644 --- a/scatterplot.h +++ b/scatterplot.h @@ -88,11 +88,11 @@ private: int m_brushedItem; enum State { - STATE_NONE, - STATE_BRUSHING, - STATE_SELECTING, - STATE_SELECTED, - STATE_MOVING + StateNone, + StateBrushing, + StateSelecting, + StateSelected, + StateMoving } m_interactionState; bool m_dragEnabled; diff --git a/voronoisplat.h b/voronoisplat.h index 097b1ed..021e88b 100644 --- a/voronoisplat.h +++ b/voronoisplat.h @@ -12,6 +12,8 @@ class VoronoiSplat : public QQuickFramebufferObject { Q_OBJECT + Q_PROPERTY(float alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) + Q_PROPERTY(float beta READ beta WRITE setBeta NOTIFY betaChanged) public: VoronoiSplat(QQuickItem *parent = 0); @@ -20,10 +22,10 @@ public: const std::vector<float> &sites() const { return m_sites; } const std::vector<float> &values() const { return m_values; } const std::vector<float> &colorScale() const { return m_cmap; } - LinearScale<float> scaleX() const { return m_sx; } - LinearScale<float> scaleY() const { return m_sy; } - Q_INVOKABLE float alpha() const { return m_alpha; } - Q_INVOKABLE float beta() const { return m_beta; } + LinearScale<float> scaleX() const { return m_sx; } + LinearScale<float> scaleY() const { return m_sy; } + float alpha() const { return m_alpha; } + float beta() const { return m_beta; } bool sitesChanged() const { return m_sitesChanged; } bool valuesChanged() const { return m_valuesChanged; } @@ -60,10 +62,10 @@ public slots: void setScale(const LinearScale<float> &sx, const LinearScale<float> &sy); // Shepard blur radius - Q_INVOKABLE void setAlpha(float alpha); + void setAlpha(float alpha); // Maximum blur radius - Q_INVOKABLE void setBeta(float beta); + void setBeta(float beta); private: std::vector<float> m_sites, m_values, m_cmap; |