mirror of https://github.com/qt/qtgraphs.git
Clip surface graph at y-axis limits
Fixes: QTBUG-125259 Change-Id: I259bed82d2e279d3a44f1543f6ba24897e4ce1ae Reviewed-by: Dilek Akcay <dilek.akcay@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
3865dcca31
commit
edf2f4c229
|
|
@ -7,7 +7,7 @@ in layout(location = 9) flat vec3 nF;
|
|||
|
||||
void MAIN()
|
||||
{
|
||||
if (any(greaterThan(UV, vec2(1.01))))
|
||||
if (any(greaterThan(UV, vec2(1.01))) || abs(VAR_WORLD_POSITION.y) > graphHeight)
|
||||
discard;
|
||||
vec3 color;
|
||||
vec2 gradientUV;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
void MAIN()
|
||||
{
|
||||
if (abs(VAR_WORLD_POSITION.y) > graphHeight)
|
||||
discard;
|
||||
BASE_COLOR = gridColor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1158,6 +1158,7 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model)
|
|||
material->setProperty("rangeMin", QVector2D(columnStart, rowStart));
|
||||
material->setProperty("range", QVector2D(sampleSpace.width(), sampleSpace.height()));
|
||||
material->setProperty("vertices", QVector2D(columnCount, rowCount));
|
||||
material->setProperty("graphHeight", scaleWithBackground().y());
|
||||
|
||||
model->vertices.clear();
|
||||
model->vertices.reserve(totalSize);
|
||||
|
|
@ -1242,6 +1243,7 @@ void QQuickGraphsSurface::updateModel(SurfaceModel *model)
|
|||
gridMaterial->setProperty("gridColor", gridColor);
|
||||
gridMaterial->setProperty("range", QVector2D(sampleSpace.width(), sampleSpace.height()));
|
||||
gridMaterial->setProperty("vertices", QVector2D(columnCount, rowCount));
|
||||
gridMaterial->setProperty("graphHeight", scaleWithBackground().y());
|
||||
|
||||
m_proxyDirty = true;
|
||||
}
|
||||
|
|
@ -1832,7 +1834,8 @@ bool QQuickGraphsSurface::doPicking(const QPointF &position)
|
|||
|
||||
if (!pickResult.isEmpty()) {
|
||||
for (auto picked : pickResult) {
|
||||
if (picked.objectHit()
|
||||
bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y();
|
||||
if (inBounds && picked.objectHit()
|
||||
&& picked.objectHit()->objectName().contains(QStringLiteral("ProxyModel"))) {
|
||||
pickedPos = picked.position();
|
||||
pickedModel = qobject_cast<QQuick3DModel *>(picked.objectHit()->parentItem());
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ CustomMaterial {
|
|||
|
||||
property vector2d vertices
|
||||
property vector2d range
|
||||
property real graphHeight
|
||||
|
||||
vertexShader: "qrc:/shaders/surfaceGridvert"
|
||||
fragmentShader: "qrc:/shaders/surfaceGridfrag"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ CustomMaterial {
|
|||
property vector2d rangeMin
|
||||
property vector2d range
|
||||
property vector2d vertices
|
||||
property real graphHeight
|
||||
|
||||
property real gradientMin
|
||||
property real gradientHeight
|
||||
|
|
|
|||
Loading…
Reference in New Issue