Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit 537ad177 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

change dtkComposerGraph API: remove dependancy on the scene

parent cf6cd360
......@@ -169,6 +169,7 @@ find_package(Qt5 REQUIRED COMPONENTS
Network
Gui
Test
Svg
Widgets
Xml
)
......
......@@ -108,21 +108,14 @@ int main(int argc, char **argv)
application->unspawn();
} else {
dtkComposerScene *scene = new dtkComposerScene;
dtkComposerStack *stack = new dtkComposerStack;
dtkComposerGraph *graph = new dtkComposerGraph;
dtkComposerEvaluator *evaluator = new dtkComposerEvaluator;;
scene->setFactory(factory);
scene->setStack(stack);
scene->setGraph(graph);
evaluator->setGraph(graph);
dtkComposerReader *reader;
reader = new dtkComposerReader;
dtkComposerReaderNoScene *reader;
reader = new dtkComposerReaderNoScene;
reader->setFactory(factory);
reader->setScene(scene);
reader->setGraph(graph);
if (parser->isSet(pgOption)) {
......
......@@ -153,11 +153,10 @@ dtkCreatorMainWindow::dtkCreatorMainWindow(QWidget *parent) : QMainWindow(parent
d->nodes = new dtkComposerNodeFactoryView(this);
d->nodes->setFactory(d->composer->factory());
d->graph = new dtkComposerGraphView(this);
d->graph->setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
d->graph->setScene(d->composer->graph());
d->graph->setVisible(false);
d->graph->setBackgroundBrush(QBrush(QPixmap(":dtkCreator/pixmaps/dtkComposerGraphView-bg.png")));
// d->graph = new dtkComposerGraphView(this);
// d->graph->setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
// d->graph->setVisible(false);
// d->graph->setBackgroundBrush(QBrush(QPixmap(":dtkCreator/pixmaps/dtkComposerGraphView-bg.png")));
// d->log_view = new dtkLogView(this);
// d->log_view->setVisible(false);
......
......@@ -39,7 +39,6 @@ set(${PROJECT_NAME}_HEADERS
dtkComposerFactory.h
dtkComposerGraph.h
dtkComposerGraphEdge.h
dtkComposerGraphLayouter.h
dtkComposerGraphNode.h
dtkComposerGraphNodeBegin.h
dtkComposerGraphNodeEnd.h
......@@ -127,6 +126,7 @@ set(${PROJECT_NAME}_HEADERS
dtkComposerTransmitterReceiver.tpp
dtkComposerView.h
dtkComposerReader.h
dtkComposerReaderNoScene.h
dtkComposerWidget.h
dtkComposerWriter.h
dtkComposerViewController
......@@ -162,7 +162,6 @@ set(${PROJECT_NAME}_SOURCES
dtkComposerFactory.cpp
dtkComposerGraph.cpp
dtkComposerGraphEdge.cpp
dtkComposerGraphLayouter.cpp
dtkComposerGraphNodeBegin.cpp
dtkComposerGraphNode.cpp
dtkComposerGraphNodeEnd.cpp
......@@ -234,6 +233,7 @@ set(${PROJECT_NAME}_SOURCES
dtkComposerTransmitterProxyVariant.cpp
dtkComposerView.cpp
dtkComposerReader.cpp
dtkComposerReaderNoScene.cpp
dtkComposerWidget.cpp
dtkComposerWriter.cpp
dtkComposerViewController.cpp
......@@ -269,6 +269,7 @@ target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Concurrent)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Network)
target_link_libraries(${PROJECT_NAME} Qt5::Svg)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::Xml)
......
......@@ -8,7 +8,6 @@
#include "dtkComposerFactory.h"
#include "dtkComposerGraph.h"
#include "dtkComposerGraphEdge.h"
#include "dtkComposerGraphLayouter.h"
#include "dtkComposerGraphNode.h"
#include "dtkComposerGraphNodeBegin.h"
#include "dtkComposerGraphNodeEnd.h"
......@@ -70,4 +69,5 @@
#include "dtkComposerTransmitterReceiver.h"
#include "dtkComposerView.h"
#include "dtkComposerReader.h"
#include "dtkComposerReaderNoScene.h"
#include "dtkComposerWriter.h"
......@@ -26,7 +26,6 @@
#include "dtkComposerGraphNodeEnd.h"
#include <dtkLog/dtkLogger.h>
#include <dtkMathSupport/dtkGraph.h>
#include <dtkWidgets/dtkNotification.h>
#include <QtCore>
......@@ -240,7 +239,6 @@ void dtkComposerEvaluator::setGraph(dtkComposerGraph *graph)
{
d->graph = graph;
connect(graph, SIGNAL(cleared()), this, SLOT(reset()));
}
void dtkComposerEvaluator::setStartNode(dtkComposerGraphNode *node)
......@@ -252,6 +250,8 @@ void dtkComposerEvaluator::run(bool run_concurrent)
{
QTime time; time.start();
// dtkTrace() << d->graph->toString();
if (d->stack.isEmpty())
d->stack.setCapacity(1024);
......@@ -280,6 +280,7 @@ void dtkComposerEvaluator::run(bool run_concurrent)
}
d->should_stop = false;
d->start_node = NULL;
emit evaluationStopped();
}
......@@ -362,7 +363,7 @@ bool dtkComposerEvaluator::step(bool run_concurrent)
return false;
d->current = d->stack.takeFirst();
// dtkTrace() << "handle " << d->current->title() << d->start_node->title() ;
dtkTrace() << "handle " << d->current->title() << d->start_node->title() ;
bool runnable = true;
dtkComposerGraphNodeList::const_iterator it;
......@@ -391,11 +392,11 @@ bool dtkComposerEvaluator::step(bool run_concurrent)
}
if (!node->endloop()) {
runnable = false;
// dtkTrace() << d->current->title() << " depends on " << node->title();
dtkTrace() << d->current->title() << " depends on " << node->title();
break;
} else {
// predecessor is an end loop, we can continue, but we must unset the endloop flag.
// dtkTrace() << "predecessor of "<< d->current->title() << " is an end loop, continue" << node->title();
dtkTrace() << "predecessor of "<< d->current->title() << " is an end loop, continue" << node->title();
node->setEndLoop(false);
}
}
......@@ -424,7 +425,7 @@ bool dtkComposerEvaluator::step(bool run_concurrent)
d->current->setStatus(dtkComposerGraphNode::Done);
}
} else {
// dtkTrace() << "evaluating leaf node"<< d->current->title();
dtkTrace() << "evaluating leaf node"<< d->current->title();
d->current->eval();
}
......
This diff is collapsed.
......@@ -24,11 +24,12 @@ class dtkComposerGraphEdgeList;
class dtkComposerGraphNode;
class dtkComposerGraphNodeList;
class dtkComposerGraphPrivate;
class dtkComposerSceneEdge;
class dtkComposerSceneNode;
class dtkComposerEdge;
class dtkComposerNode;
class dtkComposerNodeComposite;
class dtkGraph;
class DTKCOMPOSER_EXPORT dtkComposerGraph : public QGraphicsScene
class DTKCOMPOSER_EXPORT dtkComposerGraph : public QObject
{
Q_OBJECT
......@@ -37,20 +38,21 @@ public:
~dtkComposerGraph(void);
public:
void addNode(dtkComposerSceneNode *node);
void removeNode(dtkComposerSceneNode *node);
void addNode(dtkComposerNode *node, dtkComposerNode *parent);
void removeNode(dtkComposerNode *node, dtkComposerNode *parent);
void addBlock(dtkComposerSceneNode *node);
void removeBlock(dtkComposerSceneNode *node);
void addBlock(dtkComposerNode *node);
void removeBlock(dtkComposerNode *node, dtkComposerNode *parent);
void addEdge(dtkComposerSceneEdge *edge);
void removeEdge(dtkComposerSceneEdge *edge);
void addEdge(dtkComposerNode *source, dtkComposerNode *destination, QString src_type, QString dst_type);
void removeEdge(dtkComposerNode *source, dtkComposerNode *destination, QString src_type, QString dst_type, dtkComposerNode *parent);
/* void removeEdge(dtkComposerNode *source, dtkComposerNode *destination, dtkComposerNode *source_parent, dtkComposerNode *dest_parent, dtkComposerNode *source_owner_parent, dtkComposerNode *dest_owner_parent); */
void reparentNode(dtkComposerSceneNode *node, dtkComposerSceneNode *newparent);
void reparentNode(dtkComposerNode *node, dtkComposerNode *oldparent, dtkComposerNode *newparent);
void createGroup(dtkComposerSceneNode *node);
void destroyGroup(dtkComposerSceneNode *node);
void removeGroup(dtkComposerSceneNode *node);
void createGroup(dtkComposerNode *node, dtkComposerNode *parent);
void destroyGroup(dtkComposerNode *node, dtkComposerNode *parent);
void removeGroup(dtkComposerNode *node, dtkComposerNode *parent);
public:
dtkComposerGraphNode *root(void);
......@@ -70,7 +72,6 @@ public:
public:
void clear(void);
void layout(void);
public:
QString toString(void);
......@@ -78,9 +79,6 @@ public:
signals:
void cleared(void);
protected slots:
void onSelectionChanged(void);
private:
dtkComposerGraphPrivate *d;
};
......@@ -27,11 +27,9 @@ public:
int id;
};
dtkComposerGraphEdge::dtkComposerGraphEdge(void) : QGraphicsItem(), dtkGraphEdge(), d(new dtkComposerGraphEdgePrivate)
dtkComposerGraphEdge::dtkComposerGraphEdge(void) : dtkGraphEdge(), d(new dtkComposerGraphEdgePrivate)
{
d->id = 0;
this->setZValue(0);
}
dtkComposerGraphEdge::~dtkComposerGraphEdge(void)
......@@ -61,74 +59,6 @@ void dtkComposerGraphEdge::setId(int id)
d->id = id;
}
QRectF dtkComposerGraphEdge::boundingRect(void) const
{
if(!source() || !destination())
return QRectF();
QPointF s = source()->sceneBoundingRect().center();
QPointF e = destination()->sceneBoundingRect().center();
qreal xmin = qMin(s.x(), e.x());
qreal xmax = qMax(s.x(), e.x());
qreal ymin = qMin(s.y(), e.y());
qreal ymax = qMax(s.y(), e.y());
qreal x = xmin;
qreal y = ymin;
qreal w = xmax-xmin;
qreal h = ymax-ymin;
return QRectF(x, y, w, h);
}
void dtkComposerGraphEdge::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPointF s = source()->sceneBoundingRect().center();
QPointF e = destination()->sceneBoundingRect().center();
if (d->id == 0)
painter->setPen(Qt::black);
else if (d->id == 1)
painter->setPen(Qt::blue);
else if (d->id > 1) { // for switch case
int c = (180 + 10 * d->id) % 255;
// different levels of blue depending on id value.
painter->setPen(QColor (50, 50, c));
}
this->drawArrow(painter, s, e);
}
void dtkComposerGraphEdge::drawArrow(QPainter *p, QPointF from, QPointF to, qreal size, qreal end_margin)
{
QPointF points[3];
float a = atan2(from.y()-to.y(), from.x()-to.x());
to.setX(to.x()+4*end_margin*cos(a));
to.setY(to.y()+end_margin*sin(a));
end_margin += size;
a = atan2(from.y()-to.y(), from.x()-to.x());
QPointF k(to.x()+size*cos(a), to.y()+size*sin(a));
a += M_PI/2;
size /= 2;
QPointF i(k.x()+size*cos(a), k.y()+size*sin(a));
QPointF j(k.x()-size*cos(a), k.y()-size*sin(a));
p->save();
p->setRenderHint(QPainter::Antialiasing, true);
p->drawLine(from, k);
points[0] = to;
points[1] = i;
points[2] = j;
p->setPen(Qt::black);
p->setBrush(Qt::black);
p->drawConvexPolygon(points, 3);
p->restore();
}
// /////////////////////////////////////////////////////////////////
// dtkComposerGraphEdgeList
......
......@@ -20,7 +20,6 @@
#pragma once
#include <QtCore>
#include <QtWidgets>
#include <dtkMathSupport/dtkGraphEdge.h>
#include "dtkComposerGraphNode.h"
......@@ -32,7 +31,7 @@ class dtkGraphEdge;
// dtkComposerGraphEdge
// /////////////////////////////////////////////////////////////////
class dtkComposerGraphEdge : public QGraphicsItem, public dtkGraphEdge
class dtkComposerGraphEdge : public dtkGraphEdge
{
public:
dtkComposerGraphEdge(void);
......@@ -48,13 +47,6 @@ public:
public:
void setId(int id);
public:
QRectF boundingRect(void) const;
public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void drawArrow(QPainter *p, QPointF from, QPointF to, qreal size = 10, qreal end_margin = 18);
private:
dtkComposerGraphEdgePrivate *d;
};
......
#include "dtkComposerGraphLayouter.h"
\ No newline at end of file
/* dtkComposerGraphLayouter.cpp ---
*
* Author: Julien Wintz
* Copyright (C) 2008-2011 - Julien Wintz, Inria.
* Created: Fri Feb 10 10:17:18 2012 (+0100)
* Version: $Id$
* Last-Updated: Fri Feb 24 14:47:01 2012 (+0100)
* By: Julien Wintz
* Update #: 493
*/
/* Commentary:
*
* - removeCycle: greedy cycle removal algorithm
*/
/* Change log:
*
*/
#include "dtkComposerGraph.h"
#include "dtkComposerGraphEdge.h"
#include "dtkComposerGraphLayouter.h"
#include "dtkComposerGraphNode.h"
// /////////////////////////////////////////////////////////////////
// Helper functions
// /////////////////////////////////////////////////////////////////
dtkComposerGraphNodeList sort(dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
dtkComposerGraphNode *isolated(dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
dtkComposerGraphNode *source(dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
dtkComposerGraphNode *sink(dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
int i_degree(dtkComposerGraphNode *node, dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
int o_degree(dtkComposerGraphNode *node, dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
void reverse(dtkComposerGraphEdge *edge);
dtkComposerGraphEdgeList inset(dtkComposerGraphNode *node, dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
dtkComposerGraphEdgeList outset(dtkComposerGraphNode *node, dtkComposerGraphNodeList& nodes, dtkComposerGraphEdgeList& edges);
// /////////////////////////////////////////////////////////////////
// dtkComposerGraphLayouterPrivate
// /////////////////////////////////////////////////////////////////
class dtkComposerGraphLayouterPrivate
{
public:
dtkComposerGraphNodeList node_list;
dtkComposerGraphEdgeList edge_list;
public:
dtkComposerGraphEdgeList feedback;
dtkComposerGraphEdgeList reversed;
public:
QHash<dtkComposerGraphNode *, int> layers;
public:
void layout(void);
public:
void removeCycles(void);
void assignLayers(void);
void createDummys(void);
void assignPostns(void);
void createCycles(void);
};
void dtkComposerGraphLayouterPrivate::layout(void)
{
this->removeCycles();
this->assignLayers();
this->createDummys();
this->assignPostns();
this->createCycles();
}
void dtkComposerGraphLayouterPrivate::removeCycles(void)
{
dtkComposerGraphNodeList nodes = this->node_list;
dtkComposerGraphEdgeList edges = this->edge_list;
this->reversed = edges;
while(nodes.count()) {
// Handle sink nodes
while(dtkComposerGraphNode *s = sink(nodes, edges)) {
foreach(dtkComposerGraphEdge *edge, inset(s, nodes, edges)) {
this->feedback << edge;
this->reversed.removeAll(edge);
edges.removeAll(edge);
}
}
// Handle isolated nodes
while(dtkComposerGraphNode *i = isolated(nodes, edges)) {
nodes.removeAll(i);
}
// Handle source nodes
while(dtkComposerGraphNode *s = source(nodes, edges)) {
foreach(dtkComposerGraphEdge *edge, outset(s, nodes, edges)) {
this->feedback << edge;
this->reversed.removeAll(edge);
edges.removeAll(edge);
}
}
// Handle connected nodes
if(nodes.count()) {
dtkComposerGraphNode *m = nodes.first();
foreach(dtkComposerGraphNode *n, nodes)
if(o_degree(n, nodes, edges) - i_degree(n, nodes, edges) > o_degree(m, nodes, edges) - i_degree(m, nodes, edges))
m = n;
foreach(dtkComposerGraphEdge *e, outset(m, nodes, edges)) {
this->feedback << e;
this->reversed.removeAll(e);
edges.removeAll(e);
}
foreach(dtkComposerGraphEdge *e, inset(m, nodes, edges)) {
edges.removeAll(e);
}
nodes.removeAll(m);
}
}
foreach(dtkComposerGraphEdge *edge, this->reversed)
reverse(edge);
// qDebug() << __func__ << this->reversed.count() << "edges reversed";
}
void dtkComposerGraphLayouterPrivate::assignLayers(void)
{
dtkComposerGraphNodeList nodes = this->node_list;
dtkComposerGraphEdgeList edges = this->edge_list;
QList<dtkComposerGraphNode *> sortd = sort(nodes, edges);
foreach(dtkComposerGraphNode *node, sortd)
this->layers.insert(node, 1);
int height = 1;
foreach(dtkComposerGraphNode *u, sortd) {
foreach(dtkComposerGraphEdge *edge, outset(u, nodes, edges)) {
dtkComposerGraphNode *v = edge->destination();
this->layers[v] = qMax(this->layers[v], this->layers[u]+1);
height = qMax(height, this->layers[v]);
}
}
// qDebug() << __func__ << "Layout height is" << height;
}
void dtkComposerGraphLayouterPrivate::createDummys(void)
{
}
void dtkComposerGraphLayouterPrivate::assignPostns(void)
{
dtkComposerGraphNodeList nodes = this->node_list;
dtkComposerGraphEdgeList edges = this->edge_list;
// y-coordinate assignment
foreach(dtkComposerGraphNode *n, layers.keys())
n->setPos(QPointF(n->pos().x(), layers[n] * 2 * n->boundingRect().height()));
// x-coordinate assignment (left aligned)
QHash<int, int> layer_count;
QHash<int, qreal> layer_width;
int max_layer = 0;
qreal max_width = 0.0;
foreach(dtkComposerGraphNode *n, nodes) {
int layer = this->layers[n];
if(!layer_count.contains(layer))
layer_count.insert(layer, 0);
else
layer_count[layer] = layer_count[layer]+1;
n->setPos(QPointF(2*n->boundingRect().width()*layer_count[layer], n->pos().y()));
layer_width[layer] = n->sceneBoundingRect().right();
if(layer_width[layer] > max_width) {
max_width = layer_width[layer];
max_layer = layer;
}
}
// x-coordinate assignment (center aligned)
foreach(dtkComposerGraphNode *n, nodes)
if(this->layers[n] != max_layer)
n->setPos(n->pos() + QPointF((max_width-layer_width[this->layers[n]])/2.0, 0));
}
void dtkComposerGraphLayouterPrivate::createCycles(void)
{
foreach(dtkComposerGraphEdge *edge, this->reversed)
reverse(edge);
}
// /////////////////////////////////////////////////////////////////
// dtkComposerGraphLayouter
// /////////////////////////////////////////////////////////////////
dtkComposerGraphLayouter::dtkComposerGraphLayouter(void) : d(new dtkComposerGraphLayouterPrivate)
{
}
dtkComposerGraphLayouter::~dtkComposerGraphLayouter(void)
{
delete d;
d = NULL;
}
void dtkComposerGraphLayouter::setGraph(dtkComposerGraph *graph)
{
d->node_list = graph->nodes();
d->edge_list = graph->edges();
}
void dtkComposerGraphLayouter::layout(void)
{
d->layout();