2014-11-18 18:32:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-11-18 18:32:43 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-11-18 18:32:43 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-11-18 18:32:43 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "timelineitemsrenderpass.h"
|
|
|
|
|
#include "timelinerenderstate.h"
|
|
|
|
|
#include <QSGSimpleRectNode>
|
|
|
|
|
#include <QSGVertexColorMaterial>
|
|
|
|
|
#include <QtAlgorithms>
|
|
|
|
|
|
2014-12-09 11:01:23 +01:00
|
|
|
namespace Timeline {
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2015-04-14 13:23:37 +02:00
|
|
|
class TimelineItemsRenderPassState : public TimelineRenderPass::State {
|
|
|
|
|
public:
|
|
|
|
|
TimelineItemsRenderPassState(const TimelineModel *model);
|
|
|
|
|
~TimelineItemsRenderPassState();
|
|
|
|
|
|
|
|
|
|
QSGNode *expandedRow(int row) const { return m_expandedRows[row]; }
|
|
|
|
|
QSGNode *collapsedRow(int row) const { return m_collapsedRows[row]; }
|
2014-12-09 12:44:23 +01:00
|
|
|
|
|
|
|
|
const QVector<QSGNode *> &expandedRows() const { return m_expandedRows; }
|
|
|
|
|
const QVector<QSGNode *> &collapsedRows() const { return m_collapsedRows; }
|
2015-04-14 13:23:37 +02:00
|
|
|
TimelineItemsMaterial *collapsedRowMaterial() { return &m_collapsedRowMaterial; }
|
|
|
|
|
|
|
|
|
|
int indexFrom() const { return m_indexFrom; }
|
|
|
|
|
int indexTo() const { return m_indexTo; }
|
|
|
|
|
void updateIndexes(int from, int to);
|
|
|
|
|
void updateCollapsedRowMaterial(float xScale, int selectedItem, QColor selectionColor);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_indexFrom;
|
|
|
|
|
int m_indexTo;
|
|
|
|
|
TimelineItemsMaterial m_collapsedRowMaterial;
|
|
|
|
|
|
|
|
|
|
QVector<QSGNode *> m_expandedRows;
|
|
|
|
|
QVector<QSGNode *> m_collapsedRows;
|
2014-11-18 18:32:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TimelineItemsGeometry {
|
2016-05-06 16:58:22 +02:00
|
|
|
// Vertex indices are 16bit
|
|
|
|
|
static const int maxVerticesPerNode = 0xffff;
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
enum VerticesPerEvent {
|
|
|
|
|
NoVertices = 0,
|
|
|
|
|
VerticesForSameHeight = 4,
|
|
|
|
|
VerticesForDifferentHeight = 6
|
|
|
|
|
};
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
TimelineItemsGeometry();
|
2014-11-18 18:32:43 +01:00
|
|
|
uint usedVertices;
|
2016-05-06 16:58:22 +02:00
|
|
|
|
2014-12-16 15:32:53 +01:00
|
|
|
OpaqueColoredPoint2DWithSize prevNode;
|
2016-05-06 16:58:22 +02:00
|
|
|
OpaqueColoredPoint2DWithSize currentNode;
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
QSGGeometryNode *node;
|
2015-09-01 17:09:36 +02:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
void initNodes();
|
|
|
|
|
|
|
|
|
|
bool isEmpty() const;
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
void allocate(QSGMaterial *material);
|
2016-05-06 16:58:22 +02:00
|
|
|
VerticesPerEvent addVertices();
|
|
|
|
|
void addEvent();
|
|
|
|
|
|
|
|
|
|
void nextNode(float itemLeft, float itemTop, float itemWidth = 0, float selectionId = 0,
|
|
|
|
|
uchar red = 0, uchar green = 0, uchar blue = 0);
|
|
|
|
|
void updateCurrentNode(float itemRight, float itemTop);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NodeUpdater {
|
|
|
|
|
public:
|
|
|
|
|
NodeUpdater(const TimelineModel *model, const TimelineRenderState *parentState,
|
|
|
|
|
TimelineItemsRenderPassState *state, int indexFrom, int indexTo);
|
|
|
|
|
void run();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static const int s_maxNumItems = 1 << 20;
|
|
|
|
|
static const qint64 s_invalidTimestamp = 0xffffffffffffffffLL;
|
|
|
|
|
|
|
|
|
|
struct ItemDescription
|
|
|
|
|
{
|
|
|
|
|
uchar red;
|
|
|
|
|
uchar green;
|
|
|
|
|
uchar blue;
|
|
|
|
|
|
|
|
|
|
float width;
|
|
|
|
|
float left;
|
|
|
|
|
float right;
|
|
|
|
|
|
|
|
|
|
float top;
|
|
|
|
|
float selectionId;
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-10 19:01:13 +02:00
|
|
|
void calculateDistances();
|
2016-05-06 16:58:22 +02:00
|
|
|
int updateVertices(TimelineItemsGeometry &geometry, const QVarLengthArray<qint64> &distances,
|
|
|
|
|
qint64 minDistance, float itemTop, int i) const;
|
|
|
|
|
void addEvent(TimelineItemsGeometry &geometry, const QVarLengthArray<qint64> &distances,
|
|
|
|
|
qint64 minDistance, const ItemDescription &item, int i) const;
|
|
|
|
|
int updateNodes(const int from, const int to) const;
|
|
|
|
|
|
|
|
|
|
const TimelineModel *m_model;
|
|
|
|
|
const TimelineRenderState *m_parentState;
|
|
|
|
|
const int m_indexFrom;
|
|
|
|
|
const int m_indexTo;
|
|
|
|
|
|
|
|
|
|
TimelineItemsRenderPassState *m_state;
|
|
|
|
|
QVarLengthArray<qint64> m_collapsedDistances;
|
|
|
|
|
QVarLengthArray<qint64> m_expandedDistances;
|
|
|
|
|
qint64 m_minCollapsedDistance;
|
|
|
|
|
qint64 m_minExpandedDistance;
|
2014-11-18 18:32:43 +01:00
|
|
|
};
|
|
|
|
|
|
2015-09-01 17:09:36 +02:00
|
|
|
void OpaqueColoredPoint2DWithSize::set(float nx, float ny, float nw, float nh, float nid,
|
2016-05-06 16:58:22 +02:00
|
|
|
uchar nr, uchar ng, uchar nb, uchar d) {
|
2015-09-01 17:09:36 +02:00
|
|
|
x = nx; y = ny; w = nw; h = nh; id = nid;
|
2016-05-06 16:58:22 +02:00
|
|
|
r = nr; g = ng, b = nb; a = d;
|
2015-09-01 17:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float OpaqueColoredPoint2DWithSize::top() const
|
|
|
|
|
{
|
2016-05-06 16:58:22 +02:00
|
|
|
return id < 0 ? (y / -id) : y;
|
2015-09-01 17:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
void OpaqueColoredPoint2DWithSize::update(float nr, float ny)
|
2015-09-01 17:09:36 +02:00
|
|
|
{
|
2016-08-22 19:52:20 +02:00
|
|
|
if (a <= MaximumDirection) {
|
2016-05-25 19:00:43 +02:00
|
|
|
a += MaximumDirection;
|
2016-08-22 19:52:20 +02:00
|
|
|
id = -2;
|
|
|
|
|
} else {
|
|
|
|
|
--id;
|
|
|
|
|
}
|
2016-05-06 16:58:22 +02:00
|
|
|
|
|
|
|
|
y += ny;
|
|
|
|
|
w = nr - x;
|
2015-09-01 17:09:36 +02:00
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
OpaqueColoredPoint2DWithSize::Direction OpaqueColoredPoint2DWithSize::direction() const
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
2016-05-25 19:00:43 +02:00
|
|
|
return static_cast<Direction>(a > MaximumDirection ? a - MaximumDirection : a);
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setCommon(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
a = 255;
|
2016-05-25 19:00:43 +02:00
|
|
|
if (master->a > MaximumDirection) {
|
2016-05-06 16:58:22 +02:00
|
|
|
id = std::numeric_limits<float>::lowest();
|
|
|
|
|
r = g = b = 128;
|
2014-11-18 18:32:43 +01:00
|
|
|
} else {
|
2016-05-06 16:58:22 +02:00
|
|
|
id = master->id;
|
|
|
|
|
r = master->r;
|
|
|
|
|
g = master->g;
|
|
|
|
|
b = master->b;
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setLeft(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
w = -master->w;
|
|
|
|
|
x = master->x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setRight(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
w = master->w;
|
|
|
|
|
x = master->x + master->w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setTop(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
y = master->id < 0 ? master->y / -master->id : master->y;
|
2016-05-25 16:09:43 +02:00
|
|
|
h = TimelineModel::defaultRowHeight() - y;
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setBottom(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
y = TimelineModel::defaultRowHeight();
|
2016-05-25 16:09:43 +02:00
|
|
|
h = (master->id < 0 ? master->y / -master->id : master->y) - TimelineModel::defaultRowHeight();
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
void OpaqueColoredPoint2DWithSize::setBottomLeft(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
setCommon(master);
|
|
|
|
|
setLeft(master);
|
|
|
|
|
setBottom(master);
|
|
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
void OpaqueColoredPoint2DWithSize::setBottomRight(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
setCommon(master);
|
|
|
|
|
setRight(master);
|
|
|
|
|
setBottom(master);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setTopLeft(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
setCommon(master);
|
|
|
|
|
setLeft(master);
|
|
|
|
|
setTop(master);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpaqueColoredPoint2DWithSize::setTopRight(const OpaqueColoredPoint2DWithSize *master)
|
|
|
|
|
{
|
|
|
|
|
setCommon(master);
|
|
|
|
|
setRight(master);
|
|
|
|
|
setTop(master);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsGeometry::addEvent()
|
|
|
|
|
{
|
|
|
|
|
OpaqueColoredPoint2DWithSize *v =
|
|
|
|
|
OpaqueColoredPoint2DWithSize::fromVertexData(node->geometry());
|
|
|
|
|
switch (currentNode.direction()) {
|
|
|
|
|
case OpaqueColoredPoint2DWithSize::BottomToTop:
|
|
|
|
|
v[usedVertices++].setBottomLeft(¤tNode);
|
|
|
|
|
v[usedVertices++].setBottomRight(¤tNode);
|
|
|
|
|
v[usedVertices++].setTopLeft(¤tNode);
|
|
|
|
|
v[usedVertices++].setTopRight(¤tNode);
|
|
|
|
|
break;
|
|
|
|
|
case OpaqueColoredPoint2DWithSize::TopToBottom:
|
|
|
|
|
if (prevNode.top() != currentNode.top()) {
|
|
|
|
|
v[usedVertices++].setTopRight(&prevNode);
|
|
|
|
|
v[usedVertices++].setTopLeft(¤tNode);
|
|
|
|
|
}
|
|
|
|
|
v[usedVertices++].setTopLeft((¤tNode));
|
|
|
|
|
v[usedVertices++].setTopRight((¤tNode));
|
|
|
|
|
v[usedVertices++].setBottomLeft((¤tNode));
|
|
|
|
|
v[usedVertices++].setBottomRight((¤tNode));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-01 17:09:36 +02:00
|
|
|
OpaqueColoredPoint2DWithSize *OpaqueColoredPoint2DWithSize::fromVertexData(QSGGeometry *geometry)
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(geometry->attributeCount() == 4);
|
|
|
|
|
Q_ASSERT(geometry->sizeOfVertex() == sizeof(OpaqueColoredPoint2DWithSize));
|
|
|
|
|
const QSGGeometry::Attribute *attributes = geometry->attributes();
|
|
|
|
|
Q_ASSERT(attributes[0].position == 0);
|
|
|
|
|
Q_ASSERT(attributes[0].tupleSize == 2);
|
|
|
|
|
Q_ASSERT(attributes[0].type == GL_FLOAT);
|
|
|
|
|
Q_ASSERT(attributes[1].position == 1);
|
|
|
|
|
Q_ASSERT(attributes[1].tupleSize == 2);
|
|
|
|
|
Q_ASSERT(attributes[1].type == GL_FLOAT);
|
|
|
|
|
Q_ASSERT(attributes[2].position == 2);
|
|
|
|
|
Q_ASSERT(attributes[2].tupleSize == 1);
|
|
|
|
|
Q_ASSERT(attributes[2].type == GL_FLOAT);
|
|
|
|
|
Q_ASSERT(attributes[3].position == 3);
|
|
|
|
|
Q_ASSERT(attributes[3].tupleSize == 4);
|
|
|
|
|
Q_ASSERT(attributes[3].type == GL_UNSIGNED_BYTE);
|
2015-01-12 11:08:33 +02:00
|
|
|
Q_UNUSED(attributes);
|
2015-09-01 17:09:36 +02:00
|
|
|
return static_cast<OpaqueColoredPoint2DWithSize *>(geometry->vertexData());
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
TimelineItemsGeometry::TimelineItemsGeometry() : usedVertices(0), node(0)
|
|
|
|
|
{
|
|
|
|
|
initNodes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsGeometry::initNodes()
|
|
|
|
|
{
|
|
|
|
|
currentNode.set(0, TimelineModel::defaultRowHeight(), 0, 0, 0, 0, 0, 0,
|
|
|
|
|
OpaqueColoredPoint2DWithSize::InvalidDirection);
|
|
|
|
|
prevNode.set(0, TimelineModel::defaultRowHeight(), 0, 0, 0, 0, 0, 0,
|
|
|
|
|
OpaqueColoredPoint2DWithSize::InvalidDirection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TimelineItemsGeometry::isEmpty() const
|
|
|
|
|
{
|
|
|
|
|
return usedVertices == 0 &&
|
|
|
|
|
currentNode.direction() == OpaqueColoredPoint2DWithSize::InvalidDirection;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
void TimelineItemsGeometry::allocate(QSGMaterial *material)
|
|
|
|
|
{
|
2015-09-01 17:09:36 +02:00
|
|
|
QSGGeometry *geometry = new QSGGeometry(OpaqueColoredPoint2DWithSize::attributes(),
|
|
|
|
|
usedVertices);
|
2016-12-12 13:00:35 +01:00
|
|
|
Q_ASSERT(geometry->vertexData());
|
2014-11-18 18:32:43 +01:00
|
|
|
geometry->setIndexDataPattern(QSGGeometry::StaticPattern);
|
|
|
|
|
geometry->setVertexDataPattern(QSGGeometry::StaticPattern);
|
|
|
|
|
node = new QSGGeometryNode;
|
|
|
|
|
node->setGeometry(geometry);
|
|
|
|
|
node->setFlag(QSGNode::OwnsGeometry, true);
|
|
|
|
|
node->setMaterial(material);
|
|
|
|
|
usedVertices = 0;
|
2016-05-06 16:58:22 +02:00
|
|
|
initNodes();
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
TimelineItemsGeometry::VerticesPerEvent TimelineItemsGeometry::addVertices()
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
2016-05-06 16:58:22 +02:00
|
|
|
switch (currentNode.direction()) {
|
|
|
|
|
case OpaqueColoredPoint2DWithSize::BottomToTop:
|
|
|
|
|
usedVertices += VerticesForSameHeight;
|
|
|
|
|
return VerticesForSameHeight;
|
|
|
|
|
case OpaqueColoredPoint2DWithSize::TopToBottom: {
|
|
|
|
|
VerticesPerEvent vertices = (prevNode.top() != currentNode.top() ?
|
|
|
|
|
VerticesForDifferentHeight : VerticesForSameHeight);
|
|
|
|
|
usedVertices += vertices;
|
|
|
|
|
return vertices;
|
|
|
|
|
} default:
|
|
|
|
|
return NoVertices;
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
void TimelineItemsGeometry::nextNode(float itemLeft, float itemTop, float itemWidth,
|
|
|
|
|
float selectionId, uchar red, uchar green, uchar blue)
|
|
|
|
|
{
|
|
|
|
|
prevNode = currentNode;
|
|
|
|
|
currentNode.set(itemLeft, itemTop, itemWidth, TimelineModel::defaultRowHeight() - itemTop,
|
|
|
|
|
selectionId, red, green, blue,
|
2016-05-25 13:09:13 +02:00
|
|
|
currentNode.direction() == OpaqueColoredPoint2DWithSize::BottomToTop ?
|
|
|
|
|
OpaqueColoredPoint2DWithSize::TopToBottom :
|
|
|
|
|
OpaqueColoredPoint2DWithSize::BottomToTop);
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsGeometry::updateCurrentNode(float itemRight, float itemTop)
|
|
|
|
|
{
|
|
|
|
|
currentNode.update(itemRight, itemTop);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
class TimelineExpandedRowNode : public QSGNode {
|
|
|
|
|
public:
|
|
|
|
|
TimelineItemsMaterial material;
|
|
|
|
|
virtual ~TimelineExpandedRowNode() {}
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
static qint64 startTime(const TimelineModel *model, const TimelineRenderState *parentState, int i)
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
2016-05-06 16:58:22 +02:00
|
|
|
return qMax(parentState->start(), model->startTime(i));
|
|
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
static qint64 endTime(const TimelineModel *model, const TimelineRenderState *parentState, int i)
|
|
|
|
|
{
|
|
|
|
|
return qMin(parentState->end(), model->startTime(i) + model->duration(i));
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-01 17:09:36 +02:00
|
|
|
const QSGGeometry::AttributeSet &OpaqueColoredPoint2DWithSize::attributes()
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
|
|
|
|
static QSGGeometry::Attribute data[] = {
|
|
|
|
|
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
|
|
|
|
|
QSGGeometry::Attribute::create(1, 2, GL_FLOAT),
|
|
|
|
|
QSGGeometry::Attribute::create(2, 1, GL_FLOAT),
|
|
|
|
|
QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE)
|
|
|
|
|
};
|
|
|
|
|
static QSGGeometry::AttributeSet attrs = {
|
|
|
|
|
4,
|
|
|
|
|
sizeof(OpaqueColoredPoint2DWithSize),
|
|
|
|
|
data
|
|
|
|
|
};
|
|
|
|
|
return attrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TimelineItemsRenderPass *TimelineItemsRenderPass::instance()
|
|
|
|
|
{
|
|
|
|
|
static const TimelineItemsRenderPass pass;
|
|
|
|
|
return &pass;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-09 14:18:05 +01:00
|
|
|
TimelineRenderPass::State *TimelineItemsRenderPass::update(const TimelineAbstractRenderer *renderer,
|
2014-11-18 18:32:43 +01:00
|
|
|
const TimelineRenderState *parentState,
|
|
|
|
|
State *oldState, int indexFrom,
|
|
|
|
|
int indexTo, bool stateChanged,
|
2018-01-11 13:31:58 +01:00
|
|
|
float spacing) const
|
2014-11-18 18:32:43 +01:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(stateChanged);
|
2014-12-10 14:11:09 +01:00
|
|
|
const TimelineModel *model = renderer->model();
|
2014-12-16 15:32:53 +01:00
|
|
|
if (!model || indexFrom < 0 || indexTo > model->count() || indexFrom >= indexTo)
|
2014-12-10 14:11:09 +01:00
|
|
|
return oldState;
|
|
|
|
|
|
2014-11-18 18:32:43 +01:00
|
|
|
QColor selectionColor = (renderer->selectionLocked() ? QColor(96,0,255) :
|
|
|
|
|
QColor(Qt::blue)).lighter(130);
|
|
|
|
|
|
|
|
|
|
TimelineItemsRenderPassState *state;
|
|
|
|
|
if (oldState == 0)
|
2015-04-14 13:23:37 +02:00
|
|
|
state = new TimelineItemsRenderPassState(model);
|
2014-11-18 18:32:43 +01:00
|
|
|
else
|
|
|
|
|
state = static_cast<TimelineItemsRenderPassState *>(oldState);
|
|
|
|
|
|
2014-12-10 14:11:09 +01:00
|
|
|
|
2015-04-14 13:23:37 +02:00
|
|
|
int selectedItem = renderer->selectedItem() == -1 ? -1 :
|
2014-11-18 18:32:43 +01:00
|
|
|
model->selectionId(renderer->selectedItem());
|
|
|
|
|
|
2015-04-14 13:23:37 +02:00
|
|
|
state->updateCollapsedRowMaterial(spacing / parentState->scale(), selectedItem, selectionColor);
|
2014-11-18 18:32:43 +01:00
|
|
|
|
2016-08-10 19:01:13 +02:00
|
|
|
if (state->indexFrom() < state->indexTo()) {
|
|
|
|
|
if (indexFrom < state->indexFrom() || indexTo > state->indexTo())
|
|
|
|
|
NodeUpdater(model, parentState, state, indexFrom, indexTo).run();
|
|
|
|
|
} else if (indexFrom < indexTo) {
|
|
|
|
|
NodeUpdater(model, parentState, state, indexFrom, indexTo).run();
|
|
|
|
|
}
|
2014-11-18 18:32:43 +01:00
|
|
|
|
|
|
|
|
if (model->expanded()) {
|
|
|
|
|
for (int row = 0; row < model->expandedRowCount(); ++row) {
|
|
|
|
|
TimelineExpandedRowNode *rowNode = static_cast<TimelineExpandedRowNode *>(
|
2015-04-14 13:23:37 +02:00
|
|
|
state->expandedRow(row));
|
2014-11-18 18:32:43 +01:00
|
|
|
rowNode->material.setScale(
|
|
|
|
|
QVector2D(spacing / parentState->scale(),
|
2018-01-11 13:31:58 +01:00
|
|
|
static_cast<float>(model->expandedRowHeight(row))) /
|
|
|
|
|
static_cast<float>(TimelineModel::defaultRowHeight()));
|
2014-11-18 18:32:43 +01:00
|
|
|
rowNode->material.setSelectedItem(selectedItem);
|
|
|
|
|
rowNode->material.setSelectionColor(selectionColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 13:23:37 +02:00
|
|
|
state->updateIndexes(indexFrom, indexTo);
|
2014-11-18 18:32:43 +01:00
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimelineItemsRenderPass::TimelineItemsRenderPass()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TimelineItemsMaterialShader : public QSGMaterialShader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TimelineItemsMaterialShader();
|
|
|
|
|
|
|
|
|
|
virtual void updateState(const RenderState &state, QSGMaterial *newEffect,
|
|
|
|
|
QSGMaterial *oldEffect);
|
|
|
|
|
virtual char const *const *attributeNames() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
virtual void initialize();
|
|
|
|
|
|
|
|
|
|
int m_matrix_id;
|
|
|
|
|
int m_scale_id;
|
|
|
|
|
int m_selection_color_id;
|
|
|
|
|
int m_selected_item_id;
|
|
|
|
|
int m_z_range_id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TimelineItemsMaterialShader::TimelineItemsMaterialShader()
|
|
|
|
|
: QSGMaterialShader()
|
|
|
|
|
{
|
2014-12-10 12:53:49 +01:00
|
|
|
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/timeline/timelineitems.vert"));
|
|
|
|
|
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/timeline/timelineitems.frag"));
|
2014-11-18 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial,
|
|
|
|
|
QSGMaterial *)
|
|
|
|
|
{
|
|
|
|
|
if (state.isMatrixDirty()) {
|
|
|
|
|
TimelineItemsMaterial *material = static_cast<TimelineItemsMaterial *>(newMaterial);
|
|
|
|
|
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
|
|
|
|
|
program()->setUniformValue(m_scale_id, material->scale());
|
|
|
|
|
program()->setUniformValue(m_selection_color_id, material->selectionColor());
|
|
|
|
|
program()->setUniformValue(m_selected_item_id, material->selectedItem());
|
|
|
|
|
program()->setUniformValue(m_z_range_id, GLfloat(1.0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char const *const *TimelineItemsMaterialShader::attributeNames() const
|
|
|
|
|
{
|
|
|
|
|
static const char *const attr[] = {"vertexCoord", "rectSize", "selectionId", "vertexColor", 0};
|
|
|
|
|
return attr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsMaterialShader::initialize()
|
|
|
|
|
{
|
|
|
|
|
m_matrix_id = program()->uniformLocation("matrix");
|
|
|
|
|
m_scale_id = program()->uniformLocation("scale");
|
|
|
|
|
m_selection_color_id = program()->uniformLocation("selectionColor");
|
|
|
|
|
m_selected_item_id = program()->uniformLocation("selectedItem");
|
|
|
|
|
m_z_range_id = program()->uniformLocation("_qt_zRange");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimelineItemsMaterial::TimelineItemsMaterial() : m_selectedItem(-1)
|
|
|
|
|
{
|
|
|
|
|
setFlag(QSGMaterial::Blending, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector2D TimelineItemsMaterial::scale() const
|
|
|
|
|
{
|
|
|
|
|
return m_scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsMaterial::setScale(QVector2D scale)
|
|
|
|
|
{
|
|
|
|
|
m_scale = scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimelineItemsMaterial::selectedItem() const
|
|
|
|
|
{
|
|
|
|
|
return m_selectedItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsMaterial::setSelectedItem(float selectedItem)
|
|
|
|
|
{
|
|
|
|
|
m_selectedItem = selectedItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor TimelineItemsMaterial::selectionColor() const
|
|
|
|
|
{
|
|
|
|
|
return m_selectionColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsMaterial::setSelectionColor(QColor selectionColor)
|
|
|
|
|
{
|
|
|
|
|
m_selectionColor = selectionColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSGMaterialType *TimelineItemsMaterial::type() const
|
|
|
|
|
{
|
|
|
|
|
static QSGMaterialType type;
|
|
|
|
|
return &type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSGMaterialShader *TimelineItemsMaterial::createShader() const
|
|
|
|
|
{
|
|
|
|
|
return new TimelineItemsMaterialShader;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 13:23:37 +02:00
|
|
|
TimelineItemsRenderPassState::TimelineItemsRenderPassState(const TimelineModel *model) :
|
|
|
|
|
m_indexFrom(std::numeric_limits<int>::max()), m_indexTo(-1)
|
|
|
|
|
{
|
|
|
|
|
m_expandedRows.reserve(model->expandedRowCount());
|
|
|
|
|
m_collapsedRows.reserve(model->collapsedRowCount());
|
|
|
|
|
for (int i = 0; i < model->expandedRowCount(); ++i) {
|
|
|
|
|
TimelineExpandedRowNode *node = new TimelineExpandedRowNode;
|
|
|
|
|
node->setFlag(QSGNode::OwnedByParent, false);
|
|
|
|
|
m_expandedRows << node;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < model->collapsedRowCount(); ++i) {
|
|
|
|
|
QSGNode *node = new QSGNode;
|
|
|
|
|
node->setFlag(QSGNode::OwnedByParent, false);
|
|
|
|
|
m_collapsedRows << node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimelineItemsRenderPassState::~TimelineItemsRenderPassState()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_collapsedRows);
|
|
|
|
|
qDeleteAll(m_expandedRows);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsRenderPassState::updateIndexes(int from, int to)
|
|
|
|
|
{
|
|
|
|
|
if (from < m_indexFrom)
|
|
|
|
|
m_indexFrom = from;
|
|
|
|
|
if (to > m_indexTo)
|
|
|
|
|
m_indexTo = to;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimelineItemsRenderPassState::updateCollapsedRowMaterial(float xScale, int selectedItem,
|
|
|
|
|
QColor selectionColor)
|
|
|
|
|
{
|
|
|
|
|
m_collapsedRowMaterial.setScale(QVector2D(xScale, 1));
|
|
|
|
|
m_collapsedRowMaterial.setSelectedItem(selectedItem);
|
|
|
|
|
m_collapsedRowMaterial.setSelectionColor(selectionColor);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
NodeUpdater::NodeUpdater(const TimelineModel *model, const TimelineRenderState *parentState,
|
|
|
|
|
TimelineItemsRenderPassState *state, int indexFrom, int indexTo) :
|
|
|
|
|
m_model(model), m_parentState(parentState), m_indexFrom(indexFrom), m_indexTo(indexTo),
|
2016-08-10 19:01:13 +02:00
|
|
|
m_state(state), m_minCollapsedDistance(0), m_minExpandedDistance(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NodeUpdater::calculateDistances()
|
2016-05-06 16:58:22 +02:00
|
|
|
{
|
|
|
|
|
int numItems = m_indexTo - m_indexFrom;
|
2016-08-10 19:01:13 +02:00
|
|
|
|
|
|
|
|
m_collapsedDistances.resize(numItems);
|
|
|
|
|
m_expandedDistances.resize(numItems);
|
|
|
|
|
QVarLengthArray<qint64> startsPerExpandedRow(m_model->expandedRowCount());
|
|
|
|
|
QVarLengthArray<qint64> startsPerCollapsedRow(m_model->collapsedRowCount());
|
|
|
|
|
memset(startsPerCollapsedRow.data(), 0xff, startsPerCollapsedRow.size());
|
|
|
|
|
memset(startsPerExpandedRow.data(), 0xff, startsPerExpandedRow.size());
|
|
|
|
|
for (int i = m_indexFrom; i < m_indexTo; ++i) {
|
|
|
|
|
// Add some "random" factor. Distances below 256ns cannot be properly displayed
|
|
|
|
|
// anyway and if all events have the same distance from one another, then we'd merge
|
|
|
|
|
// them all together otherwise.
|
|
|
|
|
qint64 start = startTime(m_model, m_parentState, i) + (i % 256);
|
|
|
|
|
qint64 end = endTime(m_model, m_parentState, i) + (i % 256);
|
|
|
|
|
if (start > end) {
|
|
|
|
|
m_collapsedDistances[i - m_indexFrom] = m_expandedDistances[i - m_indexFrom] = 0;
|
|
|
|
|
continue;
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
2016-08-10 19:01:13 +02:00
|
|
|
qint64 &collapsedStart = startsPerCollapsedRow[m_model->collapsedRow(i)];
|
|
|
|
|
m_collapsedDistances[i - m_indexFrom] = (collapsedStart != s_invalidTimestamp) ?
|
|
|
|
|
end - collapsedStart : std::numeric_limits<qint64>::max();
|
|
|
|
|
collapsedStart = start;
|
|
|
|
|
|
|
|
|
|
qint64 &expandedStart = startsPerExpandedRow[m_model->expandedRow(i)];
|
|
|
|
|
m_expandedDistances[i - m_indexFrom] = (expandedStart != s_invalidTimestamp) ?
|
|
|
|
|
end - expandedStart : std::numeric_limits<qint64>::max();
|
|
|
|
|
expandedStart = start;
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
2016-08-10 19:01:13 +02:00
|
|
|
|
|
|
|
|
QVarLengthArray<qint64> sorted = m_collapsedDistances;
|
|
|
|
|
std::sort(sorted.begin(), sorted.end());
|
|
|
|
|
m_minCollapsedDistance = sorted[numItems - s_maxNumItems];
|
|
|
|
|
sorted = m_expandedDistances;
|
|
|
|
|
std::sort(sorted.begin(), sorted.end());
|
|
|
|
|
m_minExpandedDistance = sorted[numItems - s_maxNumItems];
|
2016-05-06 16:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NodeUpdater::updateVertices(TimelineItemsGeometry &geometry,
|
|
|
|
|
const QVarLengthArray<qint64> &distances, qint64 minDistance,
|
|
|
|
|
float itemTop, int i) const
|
|
|
|
|
{
|
|
|
|
|
int vertices = 0;
|
|
|
|
|
if (geometry.isEmpty()) {
|
|
|
|
|
// We'll run another addVertices() on each row with content after the loop.
|
|
|
|
|
// Reserve some space for that.
|
|
|
|
|
vertices = TimelineItemsGeometry::VerticesForDifferentHeight;
|
|
|
|
|
geometry.nextNode(0, itemTop);
|
|
|
|
|
} else if (distances.isEmpty() || distances[i - m_indexFrom] > minDistance) {
|
|
|
|
|
vertices = geometry.addVertices();
|
|
|
|
|
geometry.nextNode(0, itemTop);
|
|
|
|
|
} else {
|
|
|
|
|
geometry.updateCurrentNode(0, itemTop);
|
|
|
|
|
}
|
|
|
|
|
return vertices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NodeUpdater::addEvent(TimelineItemsGeometry &geometry,
|
|
|
|
|
const QVarLengthArray<qint64> &distances, qint64 minDistance,
|
|
|
|
|
const NodeUpdater::ItemDescription &item, int i) const
|
|
|
|
|
{
|
|
|
|
|
if (geometry.isEmpty()) {
|
|
|
|
|
geometry.nextNode(item.left, item.top, item.width, item.selectionId, item.red,
|
|
|
|
|
item.green, item.blue);
|
|
|
|
|
} else if (distances.isEmpty() || distances[i - m_indexFrom] > minDistance) {
|
|
|
|
|
geometry.addEvent();
|
|
|
|
|
geometry.nextNode(item.left, item.top, item.width, item.selectionId, item.red,
|
|
|
|
|
item.green, item.blue);
|
|
|
|
|
} else {
|
|
|
|
|
geometry.updateCurrentNode(item.right, item.top);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int NodeUpdater::updateNodes(const int from, const int to) const
|
|
|
|
|
{
|
|
|
|
|
float defaultRowHeight = TimelineModel::defaultRowHeight();
|
|
|
|
|
|
|
|
|
|
QVector<TimelineItemsGeometry> expandedPerRow(m_model->expandedRowCount());
|
|
|
|
|
QVector<TimelineItemsGeometry> collapsedPerRow(m_model->collapsedRowCount());
|
|
|
|
|
|
|
|
|
|
int collapsedVertices = 0;
|
|
|
|
|
int expandedVertices = 0;
|
|
|
|
|
int lastEvent = from;
|
|
|
|
|
for (;lastEvent < to
|
|
|
|
|
&& collapsedVertices < TimelineItemsGeometry::maxVerticesPerNode
|
|
|
|
|
&& expandedVertices < TimelineItemsGeometry::maxVerticesPerNode;
|
|
|
|
|
++lastEvent) {
|
|
|
|
|
qint64 start = startTime(m_model, m_parentState, lastEvent);
|
|
|
|
|
qint64 end = endTime(m_model, m_parentState, lastEvent);
|
|
|
|
|
if (start > end)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
float itemTop = (1.0 - m_model->relativeHeight(lastEvent)) * defaultRowHeight;
|
|
|
|
|
|
|
|
|
|
expandedVertices += updateVertices(expandedPerRow[m_model->expandedRow(lastEvent)],
|
|
|
|
|
m_expandedDistances, m_minExpandedDistance, itemTop, lastEvent);
|
|
|
|
|
collapsedVertices += updateVertices(collapsedPerRow[m_model->collapsedRow(lastEvent)],
|
|
|
|
|
m_collapsedDistances, m_minCollapsedDistance, itemTop, lastEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0, end = m_model->expandedRowCount(); i < end; ++i) {
|
|
|
|
|
TimelineItemsGeometry &row = expandedPerRow[i];
|
|
|
|
|
if (row.currentNode.direction() != OpaqueColoredPoint2DWithSize::InvalidDirection)
|
|
|
|
|
row.addVertices();
|
|
|
|
|
if (row.usedVertices > 0) {
|
|
|
|
|
row.allocate(&static_cast<TimelineExpandedRowNode *>(
|
|
|
|
|
m_state->expandedRow(i))->material);
|
|
|
|
|
m_state->expandedRow(i)->appendChildNode(row.node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_model->collapsedRowCount(); ++i) {
|
|
|
|
|
TimelineItemsGeometry &row = collapsedPerRow[i];
|
|
|
|
|
if (row.currentNode.direction() != OpaqueColoredPoint2DWithSize::InvalidDirection)
|
|
|
|
|
row.addVertices();
|
|
|
|
|
if (row.usedVertices > 0) {
|
|
|
|
|
row.allocate(m_state->collapsedRowMaterial());
|
|
|
|
|
m_state->collapsedRow(i)->appendChildNode(row.node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ItemDescription item;
|
|
|
|
|
for (int i = from; i < lastEvent; ++i) {
|
|
|
|
|
qint64 start = startTime(m_model, m_parentState, i);
|
|
|
|
|
qint64 end = endTime(m_model, m_parentState, i);
|
|
|
|
|
if (start > end)
|
|
|
|
|
continue;
|
|
|
|
|
|
2016-11-08 18:11:36 +01:00
|
|
|
QRgb color = m_model->color(i);
|
|
|
|
|
item.red = qRed(color);
|
|
|
|
|
item.green = qGreen(color);
|
|
|
|
|
item.blue = qBlue(color);
|
2016-05-06 16:58:22 +02:00
|
|
|
|
|
|
|
|
item.width = end > start ? (end - start) * m_parentState->scale() :
|
|
|
|
|
std::numeric_limits<float>::min();
|
|
|
|
|
item.left = (start - m_parentState->start()) * m_parentState->scale();
|
|
|
|
|
item.right = (end - m_parentState->start()) * m_parentState->scale();
|
|
|
|
|
|
|
|
|
|
// This has to be the exact same expression as above, to guarantee determinism.
|
|
|
|
|
item.top = (1.0 - m_model->relativeHeight(i)) * defaultRowHeight;
|
|
|
|
|
item.selectionId = m_model->selectionId(i);
|
|
|
|
|
|
|
|
|
|
addEvent(expandedPerRow[m_model->expandedRow(i)], m_expandedDistances,
|
|
|
|
|
m_minExpandedDistance, item, i);
|
|
|
|
|
addEvent(collapsedPerRow[m_model->collapsedRow(i)], m_collapsedDistances,
|
|
|
|
|
m_minCollapsedDistance, item, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0, end = m_model->expandedRowCount(); i < end; ++i) {
|
|
|
|
|
TimelineItemsGeometry &row = expandedPerRow[i];
|
|
|
|
|
if (row.currentNode.direction() != OpaqueColoredPoint2DWithSize::InvalidDirection)
|
|
|
|
|
row.addEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0, end = m_model->collapsedRowCount(); i < end; ++i) {
|
|
|
|
|
TimelineItemsGeometry &row = collapsedPerRow[i];
|
|
|
|
|
if (row.currentNode.direction() != OpaqueColoredPoint2DWithSize::InvalidDirection)
|
|
|
|
|
row.addEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lastEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NodeUpdater::run()
|
|
|
|
|
{
|
2016-08-10 19:01:13 +02:00
|
|
|
if (m_indexTo - m_indexFrom > s_maxNumItems)
|
|
|
|
|
calculateDistances();
|
|
|
|
|
|
2016-05-06 16:58:22 +02:00
|
|
|
if (m_state->indexFrom() < m_state->indexTo()) {
|
|
|
|
|
if (m_indexFrom < m_state->indexFrom()) {
|
|
|
|
|
for (int i = m_indexFrom; i < m_state->indexFrom();)
|
|
|
|
|
i = updateNodes(i, m_state->indexFrom());
|
|
|
|
|
}
|
|
|
|
|
if (m_indexTo > m_state->indexTo()) {
|
|
|
|
|
for (int i = m_state->indexTo(); i < m_indexTo;)
|
|
|
|
|
i = updateNodes(i, m_indexTo);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = m_indexFrom; i < m_indexTo;)
|
|
|
|
|
i = updateNodes(i, m_indexTo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-09 11:01:23 +01:00
|
|
|
} // namespace Timeline
|