mirror of https://github.com/qt/qtgraphs.git
Scale rootNode by 100
Also adds support for rootNode scaling
Fixes: QTBUG-132925
Change-Id: If9be83def9532779762da2aab89d411705bfba7d
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
(cherry picked from commit f318db38b7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9d6edfb25b
commit
9e93bf6e81
|
|
@ -20,7 +20,7 @@ void MAIN()
|
|||
if (valueColoring)
|
||||
gradientUV = vec2(heightValue, 0);
|
||||
else
|
||||
gradientUV = vec2((VAR_WORLD_POSITION.y + 1.0) / 2.0, 0.0);
|
||||
gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
|
||||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void MAIN()
|
|||
if (valueColoring)
|
||||
gradientUV = vec2(heightValue, 0);
|
||||
else
|
||||
gradientUV = vec2((VAR_WORLD_POSITION.y + 1.0) / 2.0, 0.0);
|
||||
gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
|
||||
color = texture(custex, gradientUV).xyz;
|
||||
alpha = texture(custex, gradientUV).w;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ void MAIN()
|
|||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
case 2: // Range gradient
|
||||
vec2 gradientUV = vec2((VAR_WORLD_POSITION.y + 1.0) / 2.0, 0.0);
|
||||
vec2 gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
|
||||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ void MAIN()
|
|||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
case 2: // Range gradient
|
||||
vec2 gradientUV = vec2((VAR_WORLD_POSITION.y + 1.0) / 2.0, 0.0);
|
||||
vec2 gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
|
||||
color = texture(custex, gradientUV);
|
||||
if (!usePoint)
|
||||
color = vColor;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ VARYING vec2 UV;
|
|||
|
||||
void MAIN()
|
||||
{
|
||||
if (any(greaterThan(UV, vec2(1.01))) || abs(VAR_WORLD_POSITION.y) > graphHeight)
|
||||
if (any(greaterThan(UV, vec2(1.01))) || abs(pos.y) > graphHeight)
|
||||
discard;
|
||||
vec4 color;
|
||||
vec2 gradientUV;
|
||||
|
|
@ -16,7 +16,7 @@ void MAIN()
|
|||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
case 1: //Range gradient
|
||||
gradientUV = vec2((VAR_WORLD_POSITION.y + 1.0) / 2.0, 0.0);
|
||||
gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
|
||||
color = texture(custex, gradientUV);
|
||||
break;
|
||||
case 2: // Uniform color
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
vec4 color;
|
||||
VARYING vec3 pos;
|
||||
void MAIN()
|
||||
{
|
||||
if (abs(VAR_WORLD_POSITION.y) > graphHeight)
|
||||
if (abs(pos.y) > graphHeight)
|
||||
discard;
|
||||
color = gridColor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
VARYING vec3 pos;
|
||||
void MAIN()
|
||||
{
|
||||
vec2 UV = UV0 * (vertices / range);
|
||||
VERTEX = texture(height, UV).rgb;
|
||||
pos = VERTEX;
|
||||
POSITION = MODELVIEWPROJECTION_MATRIX * vec4(VERTEX, 1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1796,6 +1796,7 @@ void QQuickGraphsBars::updateBarVisuals(QBar3DSeries *series)
|
|||
QQmlListReference materialsRef(barList.at(i)->model, "materials");
|
||||
auto customMaterial = qobject_cast<QQuick3DCustomMaterial *>(materialsRef.at(0));
|
||||
customMaterial->setProperty("valueColoring", series->isValueColoringEnabled());
|
||||
customMaterial->setProperty("rootScale", rootNode()->scale().y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1861,6 +1862,7 @@ void QQuickGraphsBars::updateMaterialProperties(QQuick3DModel *item,
|
|||
customMaterial->setProperty("isHighlight", isHighlight || isMultiHighlight);
|
||||
}
|
||||
customMaterial->setProperty("specularBrightness", lightStrength() * 0.05);
|
||||
customMaterial->setProperty("rootScale", rootNode()->scale().y());
|
||||
}
|
||||
|
||||
void QQuickGraphsBars::removeBarModels()
|
||||
|
|
|
|||
|
|
@ -1796,6 +1796,8 @@ void QQuickGraphsItem::componentComplete()
|
|||
{
|
||||
QQuick3DViewport::componentComplete();
|
||||
|
||||
rootNode()->setScale(QVector3D(100,100,100));
|
||||
|
||||
auto url = QUrl(QStringLiteral("defaultMeshes/backgroundMesh"));
|
||||
m_background = new QQuick3DModel();
|
||||
m_backgroundScale = new QQuick3DNode();
|
||||
|
|
@ -4234,9 +4236,10 @@ void QQuickGraphsItem::updateItemLabel(QVector3D position)
|
|||
{
|
||||
if (m_labelPosition != position)
|
||||
m_labelPosition = position;
|
||||
QVector3D pos2d = mapFrom3DScene(m_labelPosition);
|
||||
|
||||
QVector3D pos2d = mapFrom3DScene(m_labelPosition * rootNode()->scale().z());
|
||||
int pointSize = theme()->labelFont().pointSize();
|
||||
float scale = m_labelScale.x() * ((-10.0f * pointSize) + 650.0f) / pos2d.z();
|
||||
float scale = m_labelScale.x() * ((-10.0f * pointSize) + 650.0f) / (pos2d.z() / rootNode()->scale().z());
|
||||
scale = scale < 0 ? -scale : scale;
|
||||
if (m_sliceView && m_sliceView->isVisible())
|
||||
m_itemLabel->setScale(scale * .2f);
|
||||
|
|
@ -4986,7 +4989,7 @@ void QQuickGraphsItem::updateCamera()
|
|||
|
||||
const float scale = qMin(width(), height() * 1.6f);
|
||||
const float magnificationScaleFactor = 1.0f / 640.0f;
|
||||
const float magnification = scale * magnificationScaleFactor;
|
||||
const float magnification = scale * magnificationScaleFactor / rootNode()->scale().x();
|
||||
|
||||
auto useOrtho = isOrthoProjection();
|
||||
if (useOrtho) {
|
||||
|
|
@ -6746,10 +6749,10 @@ void QQuickGraphsItem::setUpCamera()
|
|||
// By default we could get away with a value of 10 or 15, but as camera zoom is implemented
|
||||
// by moving it, we have to take into account the maximum zoom out level. The other
|
||||
// option would be to adjust far clip whenever zoom level changes.
|
||||
const float farclip = 700.f;
|
||||
const float farclip = 7000.f;
|
||||
|
||||
m_pCamera = new QQuick3DPerspectiveCamera(rootNode());
|
||||
m_pCamera->setClipNear(0.001f);
|
||||
m_pCamera->setClipNear(0.1f);
|
||||
m_pCamera->setClipFar(farclip);
|
||||
m_pCamera->setFieldOfView(45.0f);
|
||||
m_pCamera->setPosition(QVector3D(.0f, .0f, 5.f));
|
||||
|
|
@ -6790,7 +6793,6 @@ void QQuickGraphsItem::setUpLight()
|
|||
*QQuick3DObjectPrivate::get(rootNode())->sceneManager);
|
||||
light->setParent(camera());
|
||||
light->setParentItem(camera());
|
||||
light->setShadowBias(0.1f);
|
||||
light->setSoftShadowQuality(QQuick3DAbstractLight::QSSGSoftShadowQuality::Hard);
|
||||
m_light = light;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -616,6 +616,7 @@ void QQuickGraphsScatter::updateItemMaterial(QQuick3DModel *item,
|
|||
material->setProperty("colorStyle", 2);
|
||||
|
||||
material->setProperty("usePoint", usePoint);
|
||||
material->setProperty("rootScale", rootNode()->scale().y());
|
||||
}
|
||||
|
||||
void QQuickGraphsScatter::updateInstancedMaterialProperties(ScatterModel *graphModel,
|
||||
|
|
@ -659,6 +660,7 @@ void QQuickGraphsScatter::updateMaterialProperties(QQuick3DModel *item,
|
|||
QQmlListReference materialsRef(item, "materials");
|
||||
auto customMaterial = static_cast<QQuick3DCustomMaterial *>(materialsRef.at(0));
|
||||
customMaterial->setProperty("transparency", transparency);
|
||||
customMaterial->setProperty("rootScale", rootNode()->scale().y());
|
||||
|
||||
int style = customMaterial->property("colorStyle").value<int>();
|
||||
if (style == 0) {
|
||||
|
|
|
|||
|
|
@ -1776,6 +1776,7 @@ void QQuickGraphsSurface::updateMaterial(SurfaceModel *model)
|
|||
texInput->texture()->setSource(QUrl());
|
||||
}
|
||||
}
|
||||
material->setProperty("rootScale", rootNode()->scale().y());
|
||||
material->setProperty("hasTransparency", hasTransparency);
|
||||
material->update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ CustomMaterial {
|
|||
|
||||
property bool valueColoring
|
||||
property real heightValue
|
||||
property real rootScale
|
||||
|
||||
property real specularBrightness: 0.25
|
||||
readonly property real shininess: (1.0 - specularBrightness) * 100
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ CustomMaterial {
|
|||
property bool isHighlight
|
||||
property bool instancing
|
||||
property bool transparency: false
|
||||
property real rootScale
|
||||
|
||||
property bool valueColoring
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ CustomMaterial {
|
|||
property color uColor
|
||||
property bool usePoint
|
||||
property bool transparency: false
|
||||
property real rootScale
|
||||
|
||||
property real specularBrightness: 0.25
|
||||
readonly property real shininess: (1.0 - specularBrightness) * 100
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ CustomMaterial {
|
|||
property color uColor
|
||||
property bool usePoint
|
||||
property bool transparency: false
|
||||
property real rootScale
|
||||
|
||||
property real specularBrightness: 0.25
|
||||
readonly property real shininess: (1.0 - specularBrightness) * 100
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ CustomMaterial {
|
|||
property vector2d uvOffset
|
||||
property vector2d size
|
||||
property vector2d vertCount
|
||||
property real rootScale
|
||||
|
||||
property real gradientMin
|
||||
property real gradientHeight
|
||||
|
|
|
|||
Loading…
Reference in New Issue