-
Notifications
You must be signed in to change notification settings - Fork 21
Support data range selection in livreGUI #382
Conversation
tribal-tec
commented
Mar 2, 2017
- Publish new lexix/materialLUT event which contains data range
- Still publishes 'old' lexis/lookupTable1D
- Overhaul of the transfer function widgets; now uses QML to draw everything
#include <QQuickItem> | ||
#include <QVector4D> | ||
|
||
const QUrl QML_ROOT_COMPONENT( "qrc:/qml/AlphaWidget.qml" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
// convert the gradient stops to something that QML understands | ||
QList< QVariant > positions; | ||
QList< QVariant > colors; | ||
for( auto& stop: stops ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
property var positions: [] | ||
property alias controlpoints: controlpoints.controlpoints | ||
|
||
// interestingly enough there is no proper way to dynamically update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seriously, changing the stops of the gradient does not update it? That's terrible :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a programmatic way of updating/adding gradient stops...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the stops property is read-only, no other option.
anchors.fill: parent | ||
start: Qt.point(0, 0) | ||
end: Qt.point(parent.width, 0) | ||
gradient: root.gradient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does gradient have to be a property of root? Can't it be defined here directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly for easier access from C++ side, unless you meant something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's what I meant, I would have expected a property alias at the root instead of the other way around. Don't know if that works from C++ though. As it is now, it looks like an artifact linked to the onColorsChanged() magic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done
import QtQuick 2.0 | ||
import "qrc:/qml/style.js" as Style | ||
|
||
Item { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this top-level Item needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not
{ | ||
case Channel::red: color = Qt::red; break; | ||
case Channel::green: color = Qt::green; break; | ||
case Channel::blue: default: color = Qt::blue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the switch is a copy-paste from above, could be a helper function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
import QtQuick 2.0 | ||
import "qrc:/qml/style.js" as Style | ||
|
||
Item { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top-level item needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not
_ui->background->installEventFilter( this ); | ||
_ui->background->rootContext()->setContextProperty( "model", this ); | ||
|
||
connect( _ui->fitToDataButton, &QPushButton::clicked, [&] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although the result is the same, it would be enough for all the lambdas in this function to capture [this] instead of [&]
|
||
void RangeWidget::setRangeX(qreal rangeX) | ||
{ | ||
if( std::abs( _rangeX - rangeX ) <= 0.0001 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use qFuzzyCompare( _rangeX, rangeX )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's also good to know that it's used internally by the QRectF / QsizeF == operators
return false; | ||
} | ||
|
||
void RangeWidget::setRangeX(qreal rangeX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
* Publish new lexix/materialLUT event which contains data range * Still publishes 'old' lexis/lookupTable1D * Overhaul of the transfer function widgets; now uses QML to draw everything
All done (?) |