Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatViewer fixex #574

Merged
merged 4 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions meshroom/ui/qml/Charts/ChartViewCheckBox.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import QtQuick 2.9
import QtQuick.Controls 2.3


/**
* A custom CheckBox designed to be used in ChartView's legend.
*/
CheckBox {
id: root

property color color

leftPadding: 0
font.pointSize: 8

indicator: Rectangle {
width: 11
height: width
border.width: 1
border.color: root.color
color: "transparent"
anchors.verticalCenter: parent.verticalCenter

Rectangle {
anchors.fill: parent
anchors.margins: parent.border.width + 1
visible: parent.parent.checkState != Qt.Unchecked
anchors.topMargin: parent.parent.checkState === Qt.PartiallyChecked ? 5 : 2
anchors.bottomMargin: anchors.topMargin
color: parent.border.color
anchors.centerIn: parent
}
}
}
105 changes: 105 additions & 0 deletions meshroom/ui/qml/Charts/ChartViewLegend.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import QtQuick 2.9
import QtQuick.Controls 2.9
import QtCharts 2.3


/**
* ChartViewLegend is an interactive legend component for ChartViews.
* It provides a CheckBox for each series that can control its visibility,
* and highlight on hovering.
*/
Flow {
id: root

// The ChartView to create the legend for
property ChartView chartView
// Currently hovered series
property var hoveredSeries: null

readonly property ButtonGroup buttonGroup: ButtonGroup {
id: legendGroup
exclusive: false
}

/// Shortcut function to clear legend
function clear() {
seriesModel.clear();
}

// Update internal ListModel when ChartView's series change
Connections {
target: chartView
onSeriesAdded: seriesModel.append({"series": series})
onSeriesRemoved: {
for(var i = 0; i < seriesModel.count; ++i)
{
if(seriesModel.get(i)["series"] === series)
{
seriesModel.remove(i);
return;
}
}
}
}

onChartViewChanged: {
clear();
for(var i = 0; i < chartView.count; ++i)
seriesModel.append({"series": chartView.series(i)});
}

Repeater {

// ChartView series can't be accessed directly as a model.
// Use an intermediate ListModel populated with those series.
model: ListModel {
id: seriesModel
}

ChartViewCheckBox {
ButtonGroup.group: legendGroup

checked: series.visible
text: series.name
color: series.color

onHoveredChanged: {
if(hovered && series.visible)
root.hoveredSeries = series;
else
root.hoveredSeries = null;
}

// hovered serie properties override
states: [
State {
when: series && root.hoveredSeries === series
PropertyChanges { target: series; width: 5.0 }
},
State {
when: series && root.hoveredSeries && root.hoveredSeries !== series
PropertyChanges { target: series; width: 0.2 }
}
]

MouseArea {
anchors.fill: parent
onClicked: {
if(mouse.modifiers & Qt.ControlModifier)
root.soloSeries(index);
else
series.visible = !series.visible;
}
}
}
}

/// Hide all series but the one at index 'idx'
function soloSeries(idx) {
for(var i = 0; i < seriesModel.count; i++) {
chartView.series(i).visible = false;
}
chartView.series(idx).visible = true;
}

}
4 changes: 4 additions & 0 deletions meshroom/ui/qml/Charts/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Charts

ChartViewLegend 1.0 ChartViewLegend.qml
ChartViewCheckBox 1.0 ChartViewCheckBox.qml
8 changes: 1 addition & 7 deletions meshroom/ui/qml/GraphEditor/NodeLog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ FocusScope {
if(!chunksLV.count || chunksLV.currentChunk)
logComponentLoader.source = Filepath.stringToUrl(currentFile);

if(currentItem.fileProperty === "statisticsFile") {
logComponentLoader.componentNb = 1
} else {
logComponentLoader.componentNb = 0
}
}

TabButton {
Expand All @@ -123,9 +118,8 @@ FocusScope {
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
property int componentNb: 0
property url source
sourceComponent: componentNb === 0 ? textFileViewerComponent : statViewerComponent
sourceComponent: fileSelector.currentItem.fileProperty === "statisticsFile" ? statViewerComponent : textFileViewerComponent
}

Component {
Expand Down
Loading