# # # patch "guitone/src/model/Graph.cpp" # from [de74697beaa838c0e632572a499b514b6907cb0e] # to [1e0066fd921fb5216a8f20020a6763a097ce3864] # # patch "guitone/src/model/Graph.h" # from [68dbec1f0fe3ec2ce51504028eb7926d4e82c232] # to [36377094872b364668e0315d50f47c3fccb042da] # # patch "guitone/src/view/dialogs/AncestryGraph.cpp" # from [1c5ace2a61f538d3af94f52248b8fec2567b43d5] # to [2e827dec6bee68480a37c9250fcd0737fff92a91] # # patch "guitone/src/view/dialogs/AncestryGraph.h" # from [6470bec34a4fbeb900fca6daefc0e8fdaaba5a88] # to [39c887e1f21c75679b0f867a96ddcb52d174106b] # ============================================================ --- guitone/src/model/Graph.cpp de74697beaa838c0e632572a499b514b6907cb0e +++ guitone/src/model/Graph.cpp 1e0066fd921fb5216a8f20020a6763a097ce3864 @@ -21,10 +21,15 @@ #include "Graph.h" #include "../monotone/Monotone.h" -Graph::Graph(QObject *parent, qan::la::Graph* g ) -: AutomateCommand(parent) { graph = g; } +Graph::Graph(QObject *parent) : AutomateCommand(parent) +{ + graph = new qan::la::Graph(); +} -Graph::~Graph() {} +Graph::~Graph() +{ + if (graph) delete graph; +} bool Graph::readGraph() { ============================================================ --- guitone/src/model/Graph.h 68dbec1f0fe3ec2ce51504028eb7926d4e82c232 +++ guitone/src/model/Graph.h 36377094872b364668e0315d50f47c3fccb042da @@ -28,7 +28,7 @@ public: { Q_OBJECT public: - Graph(QObject*, qan::la::Graph* graph ); + Graph(QObject*); virtual ~Graph(); // needed Qt Model methods ============================================================ --- guitone/src/view/dialogs/AncestryGraph.cpp 1c5ace2a61f538d3af94f52248b8fec2567b43d5 +++ guitone/src/view/dialogs/AncestryGraph.cpp 2e827dec6bee68480a37c9250fcd0737fff92a91 @@ -19,9 +19,6 @@ ***************************************************************************/ #include "AncestryGraph.h" -#include "../../model/Graph.h" -#include "../../util/Settings.h" -#include "../../monotone/Monotone.h" #include "can/canGrid.h" AncestryGraph::AncestryGraph(QWidget* parent) @@ -29,47 +26,55 @@ AncestryGraph::AncestryGraph(QWidget* pa { setupUi(this); - // some weird macros make demoting a QGraphView as GraphItemView - // impossible, so we use the "hack" of placing the actual view into - // a normal QFrame - QHBoxLayout *hbox = new QHBoxLayout(graphFrame); + graph = new Graph(this); + graph->readGraph(); + + QHBoxLayout *hbox = new QHBoxLayout( graphFrame ); hbox->setMargin(0); - hbox->setSpacing(2); + hbox->setSpacing(2); - // create the Graph object, read the graph and - // wrap the item model class around - // we need to define this object on the heap, otherwise the connection - // with the monotone class does not work - Graph *graph = new Graph(this, new qan::la::Graph( ) ); - graph->readGraph(); - - graphItemModel = new qan::can::GraphItemModel(graph->getGraph()); - graphItemView = new qan::can::GraphItemView(graphFrame); + labelWait = new QLabel(tr("Please wait while the graph is being created...")); + labelWait->setAlignment(Qt::AlignCenter); - hbox->addWidget(graphItemView); - - qan::can::Grid* grid = new qan::can::GridCheckBoard( - graphItemView->getGraphicsView(), - QColor(255, 255, 255), - QColor(240, 240, 240) - ); - - // layout the graph if all nodes have been created + hbox->addWidget(labelWait); + + // create and layout the graphview if all nodes have been created connect(graph, SIGNAL(graphCreated()), - this, SLOT(layoutGraph())); + this, SLOT(createGraphView())); } -AncestryGraph::~AncestryGraph() {} +AncestryGraph::~AncestryGraph() +{ + if (graph) delete graph; + if (graphItemModel) delete graphItemModel; + if (graphItemView) delete graphItemView; + if (labelWait) delete labelWait; +} -void AncestryGraph::layoutGraph( ) +void AncestryGraph::createGraphView( ) { - qDebug("layouting Graph"); + graphItemModel = new qan::can::GraphItemModel(graph->getGraph()); + graphItemView = new qan::can::GraphItemView(graphFrame); - qan::la::VectorF origin( 2 ); origin( 0 ) = 10.f; origin( 1 ) = 10.f; - qan::la::VectorF spacing( 2 ); spacing( 0 ) = 120.f; spacing( 1 ) = 55.f; - qan::la::Layout* layout = new qan::la::DirectedTree( origin, spacing, qan::la::DirectedTree::HORIZONTAL ); + // hide the wait label and add the graph view + labelWait->hide(); + // FIXME: this crashes the application: + hbox->addWidget(graphItemView); + + qan::la::VectorF origin(2); + origin(0) = 10.f; + origin(1) = 10.f; + + qan::la::VectorF spacing(2); + spacing(0) = 120.f; + spacing(1) = 55.f; + + qan::la::Layout* layout = new qan::la::DirectedTree( + origin, + spacing, + qan::la::DirectedTree::HORIZONTAL + ); qan::utl::ProgressVoid progress; - graphItemView->layoutGraph(progress); - qDebug("layouting finished"); + graphItemView->layoutGraph(progress, layout); } ============================================================ --- guitone/src/view/dialogs/AncestryGraph.h 6470bec34a4fbeb900fca6daefc0e8fdaaba5a88 +++ guitone/src/view/dialogs/AncestryGraph.h 39c887e1f21c75679b0f867a96ddcb52d174106b @@ -21,10 +21,12 @@ #ifndef ANCESTRY_GRAPH_H #define ANCESTRY_GRAPH_H +#include #include "ui_ancestry_graph.h" #include "can/canGraphItemView.h" #include "can/canGraphItemModel.h" #include "la/laLayout.h" +#include "../../model/Graph.h" class AncestryGraph : public QDialog, private Ui::AncestryGraph { @@ -35,13 +37,15 @@ private: ~AncestryGraph(); private: + QHBoxLayout *hbox; + QLabel *labelWait; + Graph *graph; qan::can::GraphItemView *graphItemView; qan::can::GraphItemModel *graphItemModel; - qan::la::Layout* layout; protected slots: - void layoutGraph( ); + void createGraphView( ); }; #endif