Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Support data range selection in livreGUI #382

Merged
merged 1 commit into from
Mar 6, 2017
Merged

Support data range selection in livreGUI #382

merged 1 commit into from
Mar 6, 2017

Conversation

tribal-tec
Copy link
Contributor

  • 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

@tribal-tec
Copy link
Contributor Author

livregui

#include <QQuickItem>
#include <QVector4D>

const QUrl QML_ROOT_COMPONENT( "qrc:/qml/AlphaWidget.qml" );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace{}

Copy link
Contributor Author

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 )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

Copy link
Contributor Author

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
Copy link

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 :-(

Copy link
Contributor Author

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...

Copy link

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
Copy link

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?

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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 {
Copy link

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?

Copy link
Contributor Author

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;
Copy link

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

Copy link
Contributor Author

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 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top-level item needed?

Copy link
Contributor Author

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, [&]
Copy link

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 )
Copy link

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 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one!

Copy link

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)
Copy link

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
@tribal-tec
Copy link
Contributor Author

All done (?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants