mirror of https://github.com/qt/qtgraphs.git
Get rid of some clazy warnings in qquickgraphsurface.cpp
Fix "c++11 range-loop might detach Qt container" warnings. Change-Id: I2b264a140f8f3a8503e6f004d912a6c725627031 Reviewed-by: Niko Korkala <niko.korkala@qt.io> Reviewed-by: Kwanghyo Park <kwanghyo.park@qt.io> (cherry picked from commitfcd5ccf73a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commitb2acb80917) Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
974913f29a
commit
361d9806c5
|
|
@ -200,7 +200,7 @@ QValue3DAxis *QQuickGraphsSurface::axisZ() const
|
||||||
void QQuickGraphsSurface::handleShadingChanged()
|
void QQuickGraphsSurface::handleShadingChanged()
|
||||||
{
|
{
|
||||||
auto series = static_cast<QSurface3DSeries *>(sender());
|
auto series = static_cast<QSurface3DSeries *>(sender());
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->series == series) {
|
if (model->series == series) {
|
||||||
updateModel(model);
|
updateModel(model);
|
||||||
break;
|
break;
|
||||||
|
|
@ -210,7 +210,7 @@ void QQuickGraphsSurface::handleShadingChanged()
|
||||||
|
|
||||||
void QQuickGraphsSurface::handleWireframeColorChanged()
|
void QQuickGraphsSurface::handleWireframeColorChanged()
|
||||||
{
|
{
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
QQmlListReference gridMaterialRef(model->gridModel, "materials");
|
QQmlListReference gridMaterialRef(model->gridModel, "materials");
|
||||||
auto gridMaterial = gridMaterialRef.at(0);
|
auto gridMaterial = gridMaterialRef.at(0);
|
||||||
QColor gridColor = model->series->wireframeColor();
|
QColor gridColor = model->series->wireframeColor();
|
||||||
|
|
@ -537,7 +537,7 @@ void QQuickGraphsSurface::handleFlatShadingSupportedChange(bool supported)
|
||||||
if (m_flatShadingSupported != supported) {
|
if (m_flatShadingSupported != supported) {
|
||||||
m_flatShadingSupported = supported;
|
m_flatShadingSupported = supported;
|
||||||
// Emit the change for all added surfaces
|
// Emit the change for all added surfaces
|
||||||
for (QAbstract3DSeries *series : m_seriesList) {
|
for (QAbstract3DSeries *series : std::as_const(m_seriesList)) {
|
||||||
QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(series);
|
QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(series);
|
||||||
emit surfaceSeries->flatShadingSupportedChanged(m_flatShadingSupported);
|
emit surfaceSeries->flatShadingSupportedChanged(m_flatShadingSupported);
|
||||||
}
|
}
|
||||||
|
|
@ -586,7 +586,7 @@ void QQuickGraphsSurface::handleItemChanged(qsizetype rowIndex, qsizetype column
|
||||||
|
|
||||||
bool newItem = true;
|
bool newItem = true;
|
||||||
QPoint candidate((int(rowIndex)), (int(columnIndex)));
|
QPoint candidate((int(rowIndex)), (int(columnIndex)));
|
||||||
for (ChangeItem item : m_changedItems) {
|
for (ChangeItem item : std::as_const(m_changedItems)) {
|
||||||
if (item.point == candidate && item.series == series) {
|
if (item.point == candidate && item.series == series) {
|
||||||
newItem = false;
|
newItem = false;
|
||||||
break;
|
break;
|
||||||
|
|
@ -735,7 +735,7 @@ void QQuickGraphsSurface::setSelectedPoint(const QPoint position,
|
||||||
|
|
||||||
// Clear selection from other series and finally set new selection to the
|
// Clear selection from other series and finally set new selection to the
|
||||||
// specified series
|
// specified series
|
||||||
for (QAbstract3DSeries *otherSeries : m_seriesList) {
|
for (QAbstract3DSeries *otherSeries : std::as_const(m_seriesList)) {
|
||||||
QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(otherSeries);
|
QSurface3DSeries *surfaceSeries = static_cast<QSurface3DSeries *>(otherSeries);
|
||||||
if (surfaceSeries != m_selectedSeries)
|
if (surfaceSeries != m_selectedSeries)
|
||||||
surfaceSeries->d_func()->setSelectedPoint(invalidSelectionPosition());
|
surfaceSeries->d_func()->setSelectedPoint(invalidSelectionPosition());
|
||||||
|
|
@ -833,7 +833,7 @@ bool QQuickGraphsSurface::isFlatShadingSupported()
|
||||||
QList<QSurface3DSeries *> QQuickGraphsSurface::surfaceSeriesList()
|
QList<QSurface3DSeries *> QQuickGraphsSurface::surfaceSeriesList()
|
||||||
{
|
{
|
||||||
QList<QSurface3DSeries *> surfaceSeriesList;
|
QList<QSurface3DSeries *> surfaceSeriesList;
|
||||||
for (QAbstract3DSeries *abstractSeries : m_seriesList) {
|
for (QAbstract3DSeries *abstractSeries : std::as_const(m_seriesList)) {
|
||||||
QSurface3DSeries *surfaceSeries = qobject_cast<QSurface3DSeries *>(abstractSeries);
|
QSurface3DSeries *surfaceSeries = qobject_cast<QSurface3DSeries *>(abstractSeries);
|
||||||
if (surfaceSeries)
|
if (surfaceSeries)
|
||||||
surfaceSeriesList.append(surfaceSeries);
|
surfaceSeriesList.append(surfaceSeries);
|
||||||
|
|
@ -939,7 +939,7 @@ void QQuickGraphsSurface::removeSeries(QSurface3DSeries *series)
|
||||||
void QQuickGraphsSurface::clearSelection()
|
void QQuickGraphsSurface::clearSelection()
|
||||||
{
|
{
|
||||||
setSelectedPoint(invalidSelectionPosition(), 0, false);
|
setSelectedPoint(invalidSelectionPosition(), 0, false);
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -962,7 +962,8 @@ void QQuickGraphsSurface::componentComplete()
|
||||||
{
|
{
|
||||||
QQuickGraphsItem::componentComplete();
|
QQuickGraphsItem::componentComplete();
|
||||||
|
|
||||||
for (auto series : surfaceSeriesList()) {
|
auto serieslist = surfaceSeriesList();
|
||||||
|
for (auto series : std::as_const(serieslist)) {
|
||||||
addModel(series);
|
addModel(series);
|
||||||
changePointerMeshTypeForSeries(series->mesh(), series);
|
changePointerMeshTypeForSeries(series->mesh(), series);
|
||||||
}
|
}
|
||||||
|
|
@ -988,7 +989,7 @@ void QQuickGraphsSurface::synchData()
|
||||||
|
|
||||||
if (isSurfaceTextureChanged()) {
|
if (isSurfaceTextureChanged()) {
|
||||||
if (!isChangedTexturesEmpty()) {
|
if (!isChangedTexturesEmpty()) {
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (hasSeriesToChangeTexture(model->series))
|
if (hasSeriesToChangeTexture(model->series))
|
||||||
updateMaterial(model);
|
updateMaterial(model);
|
||||||
}
|
}
|
||||||
|
|
@ -1047,7 +1048,7 @@ void QQuickGraphsSurface::synchData()
|
||||||
|
|
||||||
void QQuickGraphsSurface::updateGraph()
|
void QQuickGraphsSurface::updateGraph()
|
||||||
{
|
{
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
bool seriesVisible = model->series->isVisible();
|
bool seriesVisible = model->series->isVisible();
|
||||||
if (isSeriesVisibilityDirty()) {
|
if (isSeriesVisibilityDirty()) {
|
||||||
if (!seriesVisible) {
|
if (!seriesVisible) {
|
||||||
|
|
@ -1093,7 +1094,7 @@ void QQuickGraphsSurface::updateGraph()
|
||||||
if (hasChangedSeriesList()) {
|
if (hasChangedSeriesList()) {
|
||||||
handleChangedSeries();
|
handleChangedSeries();
|
||||||
} else {
|
} else {
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
bool visible = model->series->isVisible();
|
bool visible = model->series->isVisible();
|
||||||
if (visible)
|
if (visible)
|
||||||
updateModel(model);
|
updateModel(model);
|
||||||
|
|
@ -1177,8 +1178,8 @@ void QQuickGraphsSurface::calculateSceneScalingFactors()
|
||||||
void QQuickGraphsSurface::handleChangedSeries()
|
void QQuickGraphsSurface::handleChangedSeries()
|
||||||
{
|
{
|
||||||
auto changedSeries = changedSeriesList();
|
auto changedSeries = changedSeriesList();
|
||||||
for (auto series : changedSeries) {
|
for (auto series : std::as_const(changedSeries)) {
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->series == series) {
|
if (model->series == series) {
|
||||||
updateModel(model);
|
updateModel(model);
|
||||||
}
|
}
|
||||||
|
|
@ -1824,14 +1825,14 @@ void QQuickGraphsSurface::toggleSliceGraph()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPointF worldCoord;
|
QPointF worldCoord;
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->picked) {
|
if (model->picked) {
|
||||||
QPoint coords = model->selectedVertex.coord;
|
QPoint coords = model->selectedVertex.coord;
|
||||||
worldCoord = mapCoordsToWorldSpace(model, coords);
|
worldCoord = mapCoordsToWorldSpace(model, coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
bool visible = model->series->isVisible();
|
bool visible = model->series->isVisible();
|
||||||
|
|
||||||
model->sliceModel->setVisible(visible);
|
model->sliceModel->setVisible(visible);
|
||||||
|
|
@ -2070,7 +2071,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
if (!m_pickThisFrame && m_proxyDirty) {
|
if (!m_pickThisFrame && m_proxyDirty) {
|
||||||
m_pickThisFrame = true;
|
m_pickThisFrame = true;
|
||||||
m_lastPick = position;
|
m_lastPick = position;
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
updateProxyModel(model);
|
updateProxyModel(model);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -2087,7 +2088,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
createSliceView();
|
createSliceView();
|
||||||
|
|
||||||
if (!pickResult.isEmpty()) {
|
if (!pickResult.isEmpty()) {
|
||||||
for (auto picked : pickResult) {
|
for (auto picked : std::as_const(pickResult)) {
|
||||||
bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y();
|
bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y();
|
||||||
if (inBounds && picked.objectHit()) {
|
if (inBounds && picked.objectHit()) {
|
||||||
pickedPos = picked.position();
|
pickedPos = picked.position();
|
||||||
|
|
@ -2102,7 +2103,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool visible = false;
|
bool visible = false;
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->model == pickedModel)
|
if (model->model == pickedModel)
|
||||||
visible = model->series->isVisible();
|
visible = model->series->isVisible();
|
||||||
}
|
}
|
||||||
|
|
@ -2119,7 +2120,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
if (!pickedPos.isNull() && inRange) {
|
if (!pickedPos.isNull() && inRange) {
|
||||||
float min = -1.0f;
|
float min = -1.0f;
|
||||||
|
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (!model->series->isVisible()) {
|
if (!model->series->isVisible()) {
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2128,7 +2129,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
model->picked = (model->model == pickedModel);
|
model->picked = (model->model == pickedModel);
|
||||||
|
|
||||||
SurfaceVertex selectedVertex;
|
SurfaceVertex selectedVertex;
|
||||||
for (auto vertex : model->vertices) {
|
for (auto vertex : std::as_const(model->vertices)) {
|
||||||
QVector3D pos = vertex.position;
|
QVector3D pos = vertex.position;
|
||||||
float dist = pickedPos.distanceToPoint(pos);
|
float dist = pickedPos.distanceToPoint(pos);
|
||||||
if (selectedVertex.position.isNull() || dist < min) {
|
if (selectedVertex.position.isNull() || dist < min) {
|
||||||
|
|
@ -2147,7 +2148,7 @@ bool QQuickGraphsSurface::doPicking(QPointF position)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2160,7 +2161,7 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
m_pickThisFrame = true;
|
m_pickThisFrame = true;
|
||||||
QVector3D toScene = mapFrom3DScene(origin);
|
QVector3D toScene = mapFrom3DScene(origin);
|
||||||
m_lastPick = QPointF(toScene.x(), toScene.y());
|
m_lastPick = QPointF(toScene.x(), toScene.y());
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
updateProxyModel(model);
|
updateProxyModel(model);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -2177,14 +2178,14 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
createSliceView();
|
createSliceView();
|
||||||
|
|
||||||
if (!pickResult.isEmpty()) {
|
if (!pickResult.isEmpty()) {
|
||||||
for (auto picked : pickResult) {
|
for (auto picked : std::as_const(pickResult)) {
|
||||||
bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y();
|
bool inBounds = qAbs(picked.position().y()) < scaleWithBackground().y();
|
||||||
if (inBounds && picked.objectHit()
|
if (inBounds && picked.objectHit()
|
||||||
&& picked.objectHit()->objectName().contains(QStringLiteral("ProxyModel"))) {
|
&& picked.objectHit()->objectName().contains(QStringLiteral("ProxyModel"))) {
|
||||||
pickedPos = picked.position();
|
pickedPos = picked.position();
|
||||||
pickedModel = qobject_cast<QQuick3DModel *>(picked.objectHit()->parentItem());
|
pickedModel = qobject_cast<QQuick3DModel *>(picked.objectHit()->parentItem());
|
||||||
bool visible = false;
|
bool visible = false;
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->model == pickedModel)
|
if (model->model == pickedModel)
|
||||||
visible = model->series->isVisible();
|
visible = model->series->isVisible();
|
||||||
}
|
}
|
||||||
|
|
@ -2192,7 +2193,7 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2203,7 +2204,7 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
if (!pickedPos.isNull() && inRange) {
|
if (!pickedPos.isNull() && inRange) {
|
||||||
float min = -1.0f;
|
float min = -1.0f;
|
||||||
|
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (!model->series->isVisible()) {
|
if (!model->series->isVisible()) {
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2212,7 +2213,7 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
model->picked = (model->model == pickedModel);
|
model->picked = (model->model == pickedModel);
|
||||||
|
|
||||||
SurfaceVertex selectedVertex;
|
SurfaceVertex selectedVertex;
|
||||||
for (auto vertex : model->vertices) {
|
for (auto vertex : std::as_const(model->vertices)) {
|
||||||
QVector3D pos = vertex.position;
|
QVector3D pos = vertex.position;
|
||||||
float dist = pickedPos.distanceToPoint(pos);
|
float dist = pickedPos.distanceToPoint(pos);
|
||||||
if (selectedVertex.position.isNull() || dist < min) {
|
if (selectedVertex.position.isNull() || dist < min) {
|
||||||
|
|
@ -2231,7 +2232,7 @@ bool QQuickGraphsSurface::doRayPicking(QVector3D origin, QVector3D direction)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
model->picked = false;
|
model->picked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2243,7 +2244,7 @@ void QQuickGraphsSurface::updateSelectedPoint()
|
||||||
bool labelVisible = false;
|
bool labelVisible = false;
|
||||||
|
|
||||||
auto list = surfaceSeriesList();
|
auto list = surfaceSeriesList();
|
||||||
for (auto series : list) {
|
for (auto series : std::as_const(list)) {
|
||||||
// If the pointer and its instancing do not exist yet (as will happen in widget case),
|
// If the pointer and its instancing do not exist yet (as will happen in widget case),
|
||||||
// we must create them
|
// we must create them
|
||||||
if (!m_selectionPointers.value(series))
|
if (!m_selectionPointers.value(series))
|
||||||
|
|
@ -2254,13 +2255,13 @@ void QQuickGraphsSurface::updateSelectedPoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF worldCoord;
|
QPointF worldCoord;
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if (model->picked) {
|
if (model->picked) {
|
||||||
QPoint coords = model->selectedVertex.coord;
|
QPoint coords = model->selectedVertex.coord;
|
||||||
worldCoord = mapCoordsToWorldSpace(model, coords);
|
worldCoord = mapCoordsToWorldSpace(model, coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
if ((!selectionMode().testFlag(QtGraphs3D::SelectionFlag::MultiSeries) && !model->picked)
|
if ((!selectionMode().testFlag(QtGraphs3D::SelectionFlag::MultiSeries) && !model->picked)
|
||||||
|| model->selectedVertex.position.isNull()) {
|
|| model->selectedVertex.position.isNull()) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2431,7 +2432,7 @@ void QQuickGraphsSurface::createSliceView()
|
||||||
setSliceOrthoProjection(true);
|
setSliceOrthoProjection(true);
|
||||||
QQuickGraphsItem::createSliceView();
|
QQuickGraphsItem::createSliceView();
|
||||||
|
|
||||||
for (auto surfaceModel : m_model) {
|
for (auto surfaceModel : std::as_const(m_model)) {
|
||||||
addSliceModel(surfaceModel);
|
addSliceModel(surfaceModel);
|
||||||
changeSlicePointerMeshTypeForSeries(surfaceModel->series->mesh(), surfaceModel->series);
|
changeSlicePointerMeshTypeForSeries(surfaceModel->series->mesh(), surfaceModel->series);
|
||||||
}
|
}
|
||||||
|
|
@ -2545,7 +2546,7 @@ void QQuickGraphsSurface::addSliceModel(SurfaceModel *model)
|
||||||
void QQuickGraphsSurface::updateSingleHighlightColor()
|
void QQuickGraphsSurface::updateSingleHighlightColor()
|
||||||
{
|
{
|
||||||
auto list = surfaceSeriesList();
|
auto list = surfaceSeriesList();
|
||||||
for (auto series : list) {
|
for (auto series : std::as_const(list)) {
|
||||||
QQmlListReference pMaterialRef(m_selectionPointers.value(series), "materials");
|
QQmlListReference pMaterialRef(m_selectionPointers.value(series), "materials");
|
||||||
auto pmat = qobject_cast<QQuick3DPrincipledMaterial *>(pMaterialRef.at(0));
|
auto pmat = qobject_cast<QQuick3DPrincipledMaterial *>(pMaterialRef.at(0));
|
||||||
if (pmat)
|
if (pmat)
|
||||||
|
|
@ -2560,7 +2561,7 @@ void QQuickGraphsSurface::updateSingleHighlightColor()
|
||||||
|
|
||||||
void QQuickGraphsSurface::updateLightStrength()
|
void QQuickGraphsSurface::updateLightStrength()
|
||||||
{
|
{
|
||||||
for (auto model : m_model) {
|
for (auto model : std::as_const(m_model)) {
|
||||||
QQmlListReference materialRef(model->model, "materials");
|
QQmlListReference materialRef(model->model, "materials");
|
||||||
QQuick3DCustomMaterial *material = qobject_cast<QQuick3DCustomMaterial *>(materialRef.at(0));
|
QQuick3DCustomMaterial *material = qobject_cast<QQuick3DCustomMaterial *>(materialRef.at(0));
|
||||||
material->setProperty("specularBrightness", lightStrength() * 0.05);
|
material->setProperty("specularBrightness", lightStrength() * 0.05);
|
||||||
|
|
@ -2569,7 +2570,7 @@ void QQuickGraphsSurface::updateLightStrength()
|
||||||
|
|
||||||
void QQuickGraphsSurface::handleThemeTypeChange()
|
void QQuickGraphsSurface::handleThemeTypeChange()
|
||||||
{
|
{
|
||||||
for (auto model : m_model)
|
for (auto model : std::as_const(m_model))
|
||||||
updateMaterial(model);
|
updateMaterial(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue