diff options
Diffstat (limited to 'retrace/daemon')
-rw-r--r-- | retrace/daemon/bargraph/glframe_qbargraph.cpp | 17 | ||||
-rw-r--r-- | retrace/daemon/bargraph/glframe_qbargraph.hpp | 17 | ||||
-rw-r--r-- | retrace/daemon/bargraph/ui/qml/mainwin.qml | 163 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/BarGraphControl.qml | 115 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/mainwin.qml | 18 |
5 files changed, 288 insertions, 42 deletions
diff --git a/retrace/daemon/bargraph/glframe_qbargraph.cpp b/retrace/daemon/bargraph/glframe_qbargraph.cpp index f44bc066..ea410126 100644 --- a/retrace/daemon/bargraph/glframe_qbargraph.cpp +++ b/retrace/daemon/bargraph/glframe_qbargraph.cpp @@ -225,6 +225,8 @@ BarGraphView::mouseWheel(int degrees, float zoom_point_x) { m_translate = new_translate; m_zoom = new_zoom; + emit zoomChanged(); + emit translateChanged(); update(); } @@ -233,3 +235,18 @@ BarGraphView::zoom(float *zoom, float *translate) const { *zoom = m_zoom; *translate = m_translate; } + +void +BarGraphView::setZoom(float z) { + m_zoom = z; + emit zoomChanged(); + update(); +} + +void +BarGraphView::setTranslate(float z) { + m_translate = z; + emit translateChanged(); + update(); +} + diff --git a/retrace/daemon/bargraph/glframe_qbargraph.hpp b/retrace/daemon/bargraph/glframe_qbargraph.hpp index a28d467f..7b3d7962 100644 --- a/retrace/daemon/bargraph/glframe_qbargraph.hpp +++ b/retrace/daemon/bargraph/glframe_qbargraph.hpp @@ -77,6 +77,15 @@ class BarGraphView : public QQuickFramebufferObject, READ randomBarCount WRITE setRandomBarCount NOTIFY onRandomBarCount) + Q_PROPERTY(float zoom + READ getZoom + WRITE setZoom + NOTIFY zoomChanged) + Q_PROPERTY(float translate + READ getTranslate + WRITE setTranslate + NOTIFY translateChanged) + public: BarGraphView(); QQuickFramebufferObject::Renderer *createRenderer() const; @@ -95,6 +104,12 @@ class BarGraphView : public QQuickFramebufferObject, int randomBarCount() const {return m_randomBars;} void setRandomBarCount(int count); + float getZoom() const { return m_zoom; } + void setZoom(float z); + + float getTranslate() const { return m_translate; } + void setTranslate(float z); + void zoom(float *zoom, float *translate) const; std::vector<float> mouse_area; @@ -102,6 +117,8 @@ class BarGraphView : public QQuickFramebufferObject, signals: void onModel(); void onRandomBarCount(); + void zoomChanged(); + void translateChanged(); private: mutable std::mutex m_protect; diff --git a/retrace/daemon/bargraph/ui/qml/mainwin.qml b/retrace/daemon/bargraph/ui/qml/mainwin.qml index a9348a83..1e5f1754 100644 --- a/retrace/daemon/bargraph/ui/qml/mainwin.qml +++ b/retrace/daemon/bargraph/ui/qml/mainwin.qml @@ -25,11 +25,10 @@ // * Mark Janes <mark.a.janes@intel.com> // **********************************************************************/ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Layouts 1.1 -import QtQuick.Dialogs 1.1 +import QtQuick 2.6 import ApiTrace 1.0 +import QtQuick.Controls 1.5 +import QtQuick.Layouts 1.3 ApplicationWindow { width: 600 @@ -41,35 +40,143 @@ ApplicationWindow { id: selection } - BarGraph { - id: barGraph - selection: selection - visible: true + ColumnLayout { anchors.fill: parent - randomBarCount: 1000 - MouseArea { - property var startx : -1.0; - property var starty : -1.0; - anchors.fill: parent - onPressed : { - startx = mouse.x / barGraph.width; - starty = (barGraph.height - mouse.y) / barGraph.height; - barGraph.mouseDrag(startx, starty, startx, starty); + + BarGraph { + id: barGraph + width: mainWindow.width + height: mainWindow.height - scrollBar.height + selection: selection + visible: true + randomBarCount: 1000 + MouseArea { + property var startx : -1.0; + property var starty : -1.0; + anchors.fill: parent + onPressed : { + startx = mouse.x / barGraph.width; + starty = (barGraph.height - mouse.y) / barGraph.height; + barGraph.mouseDrag(startx, starty, startx, starty); + } + onPositionChanged : { + if (mouse.buttons & Qt.LeftButton) { + var endx = mouse.x / barGraph.width; + var endy = (barGraph.height - mouse.y) / barGraph.height; + barGraph.mouseDrag(startx, starty, endx, endy) + } + } + onWheel : { + var wheelx = 1.0; + wheelx = wheel.x / barGraph.width; + barGraph.mouseWheel(wheel.angleDelta.y / 2, wheelx); + } + onReleased : { + barGraph.mouseRelease(); + } + } + onZoomChanged: { + scrollBar.positionHandle() + } + onTranslateChanged: { + scrollBar.positionHandle() } - onPositionChanged : { - if (mouse.buttons & Qt.LeftButton) { - var endx = mouse.x / barGraph.width; - var endy = (barGraph.height - mouse.y) / barGraph.height; - barGraph.mouseDrag(startx, starty, endx, endy) + } + Item { + id: scrollBar + height: 20 + width: mainWindow.width + anchors { + left: mainWindow.left; + margins: 1; + } + function zoomIn () { + barGraph.mouseWheel(45, 0.5); + } + function zoomOut () { + barGraph.mouseWheel(-45, 0.5); + } + function positionHandle() { + handle.width = (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom + var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width; + var fullTranslation = 1.0 - barGraph.zoom; + if (fullTranslation == 0) { + handle.x = backScrollbar.height; + } else { + handle.x = backScrollbar.height + barGraph.translate * maxXOffset / fullTranslation; } } - onWheel : { - var wheelx = 1.0; - wheelx = wheel.x / barGraph.width; - barGraph.mouseWheel(wheel.angleDelta.y / 5, wheelx); + Rectangle { + id: backScrollbar; + radius: 2; + color: Qt.rgba(0.5, 0.5, 0.5, 0.85); + anchors { fill: parent; } } - onReleased : { - barGraph.mouseRelease(); + MouseArea { + width: height; + anchors { + top: parent.top; + left: parent.left; + bottom: parent.bottom; + margins: (backScrollbar.border.width +1); + } + onClicked: { scrollBar.zoomOut(); } + + Text { + text: "-"; + anchors.centerIn: parent; + } + } + MouseArea { + width: height; + anchors { + top: parent.top; + right: parent.right; + bottom: parent.bottom; + margins: (backScrollbar.border.width +1); + } + onClicked: { scrollBar.zoomIn(); } + + Text { + text: "+"; + anchors.centerIn: parent; + } + } + + Item { + id: handle; + width: (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom + x: backScrollbar.height + onXChanged: { + if (barGraph.zoom == 1.0) { + barGraph.translate = 0.0; + } else { + var fullTranslation = 1.0 - barGraph.zoom; + var xOffset = handle.x - backScrollbar.height; + var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width; + barGraph.translate = fullTranslation * xOffset / maxXOffset; + } + } + + anchors { + top: parent.top; + bottom: parent.bottom; + } + Rectangle { + id: backHandle; + color: Qt.rgba(0.2, 0.2, 0.2, 1.0) + anchors { fill: parent; } + } + MouseArea { + id: clicker; + drag { + target: handle; + minimumX: backScrollbar.height; + maximumX: (backScrollbar.width - backScrollbar.height - handle.width); + axis: Drag.XAxis; + } + anchors { fill: parent; } + } } } } diff --git a/retrace/daemon/ui/qml/BarGraphControl.qml b/retrace/daemon/ui/qml/BarGraphControl.qml index c300aef7..01333969 100644 --- a/retrace/daemon/ui/qml/BarGraphControl.qml +++ b/retrace/daemon/ui/qml/BarGraphControl.qml @@ -121,21 +121,29 @@ Item { } Item { Layout.alignment: Qt.AlignTop - Layout.preferredHeight: 400 + Layout.preferredHeight: 500 Layout.fillWidth: true Layout.fillHeight: true anchors.top: comboBoxes.bottom anchors.topMargin: 10 + anchors.bottomMargin: 10 BarGraph { id: barGraph anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 + anchors.bottom: scrollBar.top anchors.left: parent.left anchors.right: scale.left model: metric_model selection: control.selection + + onZoomChanged : { + scrollBar.positionHandle(); + } + onTranslateChanged : { + scrollBar.positionHandle(); + } + MouseArea { property var startx : -1.0; property var starty : -1.0; @@ -165,8 +173,7 @@ Item { Rectangle { id: scale anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 + anchors.bottom: scrollBar.top anchors.right: parent.right width: axisText.width Text { @@ -180,6 +187,104 @@ Item { + formatFloat(metric_model.maxMetric * 0.2) } } + Item { + id: scrollBar + height: 20 + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + margins: 1; + } + function zoomIn () { + barGraph.mouseWheel(45, 0.5); + } + function zoomOut () { + barGraph.mouseWheel(-45, 0.5); + } + function positionHandle() { + handle.width = (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom + var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width; + var fullTranslation = 1.0 - barGraph.zoom; + if (fullTranslation == 0) { + handle.x = backScrollbar.height; + } else { + handle.x = backScrollbar.height + barGraph.translate * maxXOffset / fullTranslation; + } + } + Rectangle { + id: backScrollbar; + radius: 2; + color: Qt.rgba(0.5, 0.5, 0.5, 0.85); + anchors { fill: parent; } + } + MouseArea { + width: height; + anchors { + top: parent.top; + left: parent.left; + bottom: parent.bottom; + margins: (backScrollbar.border.width +1); + } + onClicked: { scrollBar.zoomOut(); } + + Text { + text: "-"; + anchors.centerIn: parent; + } + } + MouseArea { + width: height; + anchors { + top: parent.top; + right: parent.right; + bottom: parent.bottom; + margins: (backScrollbar.border.width +1); + } + onClicked: { scrollBar.zoomIn(); } + + Text { + text: "+"; + anchors.centerIn: parent; + } + } + + Item { + id: handle; + width: (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom + x: backScrollbar.height + onXChanged: { + if (barGraph.zoom == 1.0) { + barGraph.translate = 0.0; + } else { + var fullTranslation = 1.0 - barGraph.zoom; + var xOffset = handle.x - backScrollbar.height; + var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width; + barGraph.translate = fullTranslation * xOffset / maxXOffset; + } + } + + anchors { + top: parent.top; + bottom: parent.bottom; + } + Rectangle { + id: backHandle; + color: Qt.rgba(0.2, 0.2, 0.2, 1.0) + anchors { fill: parent; } + } + MouseArea { + id: clicker; + drag { + target: handle; + minimumX: backScrollbar.height; + maximumX: (backScrollbar.width - backScrollbar.height - handle.width); + axis: Drag.XAxis; + } + anchors { fill: parent; } + } + } + } } } } diff --git a/retrace/daemon/ui/qml/mainwin.qml b/retrace/daemon/ui/qml/mainwin.qml index 0eb32478..06418aae 100644 --- a/retrace/daemon/ui/qml/mainwin.qml +++ b/retrace/daemon/ui/qml/mainwin.qml @@ -6,8 +6,8 @@ import ApiTrace 1.0 import Qt.labs.settings 1.0 ApplicationWindow { - width: 600 - height: 500 + width: 1000 + height: 800 visible: true id: mainWindow @@ -36,15 +36,15 @@ ApplicationWindow { Rectangle { id: imageBox anchors.top: parent.top - anchors.topMargin: 30 + anchors.topMargin: 100 anchors.horizontalCenter: parent.horizontalCenter - width: 500 - height: 120 + width: 800 + height: 200 border.width: 1 visible: true Image { - height: 120 - width: 500 + height: 200 + width: 800 id: appIcon source: "qrc:///qml/images/retracer_icon.png" visible: true @@ -52,7 +52,7 @@ ApplicationWindow { } Text { id: enterText - width: 500 + width: 800 anchors.centerIn: parent text: "trace file:" } @@ -62,7 +62,7 @@ ApplicationWindow { text: "ForHeight" } Rectangle { - width: 500 + width: 800 id: textBox border.width: 1 height: textHeight.height * 1.5 |