Create the grid with a single geometry

The gridgeometry is drawn with line primitives. Using one geometry for
the whole grid makes it easier to handle the grid as we don't need to
change properties for each individual line nodes. In addition, the grid
line repeaters got removed as they are not needed anymore.

Fixes: QTBUG-116661
Pick-to: 6.7
Change-Id: If657d1cda35ae78c9ef016235d99fecf75d716c9
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
Sami Varanka 2024-01-12 11:09:31 +02:00
parent fb2688a496
commit dd310faa9a
4 changed files with 442 additions and 479 deletions

View File

@ -891,8 +891,6 @@ void QQuickGraphsBars::handleRowCountChanged()
QCategory3DAxis *categoryAxisZ = static_cast<QCategory3DAxis *>(axisZ());
if (repeaterZ()) {
updateParameters();
segmentLineRepeaterZ()->model().clear();
segmentLineRepeaterZ()->setModel(m_cachedRowCount);
repeaterZ()->model().clear();
repeaterZ()->setModel(categoryAxisZ->labels().size());
}
@ -903,8 +901,6 @@ void QQuickGraphsBars::handleColCountChanged()
QCategory3DAxis *categoryAxisX = static_cast<QCategory3DAxis *>(axisX());
if (repeaterX()) {
updateParameters();
segmentLineRepeaterX()->model().clear();
segmentLineRepeaterX()->setModel(m_cachedColumnCount);
repeaterX()->model().clear();
repeaterX()->setModel(categoryAxisX->labels().size());
}

File diff suppressed because it is too large Load Diff

View File

@ -371,14 +371,6 @@ public:
QQuick3DNode *titleLabelY() const { return m_titleLabelY; }
QQuick3DNode *titleLabelZ() const { return m_titleLabelZ; }
QQuick3DRepeater *segmentLineRepeaterX() const { return m_segmentLineRepeaterX; }
QQuick3DRepeater *segmentLineRepeaterY() const { return m_segmentLineRepeaterY; }
QQuick3DRepeater *segmentLineRepeaterZ() const { return m_segmentLineRepeaterZ; }
QQuick3DRepeater *subsegmentLineRepeaterX() const { return m_subsegmentLineRepeaterX; }
QQuick3DRepeater *subsegmentLineRepeaterY() const { return m_subsegmentLineRepeaterY; }
QQuick3DRepeater *subsegmentLineRepeaterZ() const { return m_subsegmentLineRepeaterZ; }
bool isXFlipped() const { return m_xFlipped; }
void setXFlipped(bool xFlipped) { m_xFlipped = xFlipped; }
bool isYFlipped() const { return m_yFlipped; }
@ -475,6 +467,9 @@ public:
void minimizeMainGraph();
int horizontalFlipFactor() const;
void setHorizontalFlipFactor(int newHorizontalFlipFactor);
public Q_SLOTS:
virtual void handleAxisXChanged(QAbstract3DAxis *axis) = 0;
virtual void handleAxisYChanged(QAbstract3DAxis *axis) = 0;
@ -713,6 +708,9 @@ private:
// This is the same as the minimum bound of GridLine model.
const float angularLineOffset = -49.98f;
const float rotationOffset = 90.0f;
QQuick3DModel *m_gridGeometryModel = nullptr;
QQuick3DModel *m_sliceGridGeometryModel = nullptr;
Abstract3DChangeBitField m_changeTracker;
ThemeManager *m_themeManager = nullptr;
QAbstract3DGraph::SelectionFlags m_selectionMode = QAbstract3DGraph::SelectionItem;
@ -743,16 +741,8 @@ private:
QQuickItem *m_itemLabel = nullptr;
QQuick3DNode *m_sliceItemLabel = nullptr;
QQuick3DRepeater *m_segmentLineRepeaterX = nullptr;
QQuick3DRepeater *m_subsegmentLineRepeaterX = nullptr;
QQuick3DRepeater *m_segmentLineRepeaterY = nullptr;
QQuick3DRepeater *m_subsegmentLineRepeaterY = nullptr;
QQuick3DRepeater *m_segmentLineRepeaterZ = nullptr;
QQuick3DRepeater *m_subsegmentLineRepeaterZ = nullptr;
QQuick3DViewport *m_sliceView = nullptr;
QQuick3DRepeater *m_sliceHorizontalGridRepeater = nullptr;
QQuick3DRepeater *m_sliceVerticalGridRepeater = nullptr;
QQuick3DRepeater *m_sliceHorizontalLabelRepeater = nullptr;
QQuick3DRepeater *m_sliceVerticalLabelRepeater = nullptr;
@ -777,6 +767,7 @@ private:
bool m_zFlipped = false;
bool m_flipScales;
int m_horizontalFlipFactor = 1;
bool m_isFloorGridInRange = false;
bool m_hasVerticalSegmentLine = true;
@ -813,13 +804,12 @@ private:
void setUpLight();
void updateCamera();
void updateRadialLabelOffset();
void handleSegmentLineCountChanged(QAbstract3DAxis *axis, QQuick3DRepeater *repeater);
void handleSubSegmentLineCountChanged(QAbstract3DAxis *axis, QQuick3DRepeater *repeater);
QVector3D calculateLabelRotation(float labelAutoAngle);
void updateCustomData();
void updateCustomLabelsRotation();
float fontScaleFactor(float pointSize);
float labelAdjustment(float width);
void gridLineCountHelper(QAbstract3DAxis *axis, int &lineCount, int &sublineCount);
void createVolumeMaterial(QCustom3DVolume *volume, Volume &volumeItem);
QQuick3DModel *createSliceFrame(Volume &volumeItem);
@ -848,6 +838,8 @@ private:
float m_minZoomLevel = 10.0f;
float m_maxZoomLevel = 500.0f;
bool m_gridUpdate = false;
QVector3D m_requestedTarget = QVector3D();
QGraphsInputHandler *m_inputHandler = nullptr;

View File

@ -99,42 +99,10 @@ void QQuickGraphsSurface::handleWireframeColorChanged()
void QQuickGraphsSurface::handleFlipHorizontalGridChanged(bool flip)
{
if (!segmentLineRepeaterX() || !segmentLineRepeaterZ())
return;
int gridLineCountX = segmentLineRepeaterX()->count();
int subGridLineCountX = subsegmentLineRepeaterX()->count();
int gridLineCountZ = segmentLineRepeaterZ()->count();
int subGridLineCountZ = subsegmentLineRepeaterZ()->count();
float factor = -1.0f;
if (isGridUpdated())
factor = flip ? -1.0f : 1.0f;
for (int i = 0; i < subGridLineCountZ; i++) {
QQuick3DNode *lineNode = static_cast<QQuick3DNode *>(subsegmentLineRepeaterZ()->objectAt(i));
QVector3D pos = lineNode->position();
pos.setY(pos.y() * factor);
lineNode->setPosition(pos);
}
for (int i = 0; i < gridLineCountZ; i++) {
QQuick3DNode *lineNode = static_cast<QQuick3DNode *>(segmentLineRepeaterZ()->objectAt(i));
QVector3D pos = lineNode->position();
pos.setY(pos.y() * factor);
lineNode->setPosition(pos);
}
for (int i = 0; i < subGridLineCountX; i++) {
QQuick3DNode *lineNode = static_cast<QQuick3DNode *>(subsegmentLineRepeaterX()->objectAt(i));
QVector3D pos = lineNode->position();
pos.setY(pos.y() * factor);
lineNode->setPosition(pos);
}
for (int i = 0; i < gridLineCountX; i++) {
QQuick3DNode *lineNode = static_cast<QQuick3DNode *>(segmentLineRepeaterX()->objectAt(i));
QVector3D pos = lineNode->position();
pos.setY(pos.y() * factor);
lineNode->setPosition(pos);
}
for (int i = 0; i < repeaterX()->count(); i++) {
QQuick3DNode *obj = static_cast<QQuick3DNode *>(repeaterX()->objectAt(i));
QVector3D pos = obj->position();
@ -753,6 +721,9 @@ void QQuickGraphsSurface::componentComplete()
void QQuickGraphsSurface::synchData()
{
if (isFlipHorizontalGridChanged())
setHorizontalFlipFactor(flipHorizontalGrid() ? -1 : 1);
QQuickGraphsItem::synchData();
if (isSelectedPointChanged()) {