-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from alicevision/dev/stats
Visual interface for node statistics
- Loading branch information
Showing
8 changed files
with
820 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.