#
#
# add_dir "libs"
#
# add_dir "libs/qanava"
#
# add_dir "libs/qanava/build"
#
# add_dir "libs/qanava/build/qan"
#
# add_dir "libs/qanava/src"
#
# add_dir "libs/qanava/src/ui"
#
# add_file "guitone/res/forms/ancestry_graph.ui"
# content [7e7f4aa6d5b1dc185e0b0ac8f5a05b5ed4c3bcf3]
#
# add_file "guitone/src/model/Graph.cpp"
# content [35fe7a0ea20b3254f120f8c39b60e925af131097]
#
# add_file "guitone/src/model/Graph.h"
# content [a2007e2c3765bc07a103e2172fc4340ad1eb997e]
#
# add_file "guitone/src/view/dialogs/AncestryGraph.cpp"
# content [4d168d008bd0e6043f946d4c5728a84370b3eea0]
#
# add_file "guitone/src/view/dialogs/AncestryGraph.h"
# content [8b3764f98c90d5c7fab0d8c529e97b92b92e4fc6]
#
# add_file "libs/libs.pro"
# content [ca5044adbf8828221942c937a63e7b40638b4aea]
#
# add_file "libs/qanava/build/build.pro"
# content [fea130f425d6c83a83f2843af84ced77e6e31b79]
#
# add_file "libs/qanava/build/qan/qan.pro"
# content [d5ef733dbb9849633e57e042ad112df5df9185c9]
#
# add_file "libs/qanava/qanava.pro"
# content [4b9d41233daf1c2fa2e1ed293eefed0b4d0b7252]
#
# add_file "libs/qanava/src/qanConfig.h"
# content [3888e646fb6334e4e5fe0c89bf6ebeeea47e2736]
#
# add_file "libs/qanava/src/qanController.cpp"
# content [2d05912d39496d3127db41a8099af62ba291288f]
#
# add_file "libs/qanava/src/qanController.h"
# content [2f743c33036f4d4c664e491b786f1797cb2bd1f2]
#
# add_file "libs/qanava/src/qanEdge.cpp"
# content [a6915d18182ee672105121cfeae13d2049a9805b]
#
# add_file "libs/qanava/src/qanEdge.h"
# content [a5585d277d33f6bc9d1169e42a5b40224855efbd]
#
# add_file "libs/qanava/src/qanGraph.h"
# content [f8253ed3de7c8c86c81686a8d558f1ded5d69f36]
#
# add_file "libs/qanava/src/qanGraph.hpp"
# content [71f74c300686f7de87b05f7ef7a9974cb1e8d3d2]
#
# add_file "libs/qanava/src/qanGraphItemModel.cpp"
# content [5589991ed19351c18ffe7c9b456a8bffcd5ce8a4]
#
# add_file "libs/qanava/src/qanGraphItemModel.h"
# content [ad90da3f02f4b547d29c7cb8b378c7fb613781f6]
#
# add_file "libs/qanava/src/qanGraphItemView.cpp"
# content [2650092cb13e790fe4e6e81a7476978b0fa8a2b6]
#
# add_file "libs/qanava/src/qanGraphItemView.h"
# content [4ff6a1e3a993c364ed5dfb4eaee72c8919814ad0]
#
# add_file "libs/qanava/src/qanGraphicsView.cpp"
# content [97aaefe368fdc15c63d293e9d40ef1630414fbea]
#
# add_file "libs/qanava/src/qanGraphicsView.h"
# content [6f582f9c7e90a38cb818d892cd999b9b1d86969f]
#
# add_file "libs/qanava/src/qanGrid.h"
# content [f98f7f90a1bf147fca5ccf385d06e3aaaf57b339]
#
# add_file "libs/qanava/src/qanGridItem.cpp"
# content [a521aaca80231c4a3cc1cad98105e155687d6ec2]
#
# add_file "libs/qanava/src/qanGridItem.h"
# content [14da4617240de3277b84e376e7652288b1e6ab07]
#
# add_file "libs/qanava/src/qanItemGeom.cpp"
# content [4a53eff9f53c160ca690661510384b6266bcfa42]
#
# add_file "libs/qanava/src/qanItemGeom.h"
# content [4a6d84dc2dd56022f8e1ef64327adc2e6f21bd6b]
#
# add_file "libs/qanava/src/qanLayout.cpp"
# content [511aa22d12419f13286818772fc60ed1968f49a9]
#
# add_file "libs/qanava/src/qanLayout.h"
# content [2f96b5189a86b669e54c072e9c621074ef76654f]
#
# add_file "libs/qanava/src/qanNode.cpp"
# content [c8b9d52caf4a8465cc270b911eaeb020c91fb888]
#
# add_file "libs/qanava/src/qanNode.h"
# content [5db78823a601423d53024a55532763ee5babcecd]
#
# add_file "libs/qanava/src/qanRepository.cpp"
# content [aa82d566624ec78117cf1e9c488c056d492d383b]
#
# add_file "libs/qanava/src/qanRepository.h"
# content [6ff55c5f0778c3d9c5befa905c9499497c70f738]
#
# add_file "libs/qanava/src/qanStyle.cpp"
# content [e37b580f9069abc280b206b7c8ac6b548c4495b1]
#
# add_file "libs/qanava/src/qanStyle.h"
# content [2a4c2efef1897cac58bad371e7d27bddab3f78a8]
#
# add_file "libs/qanava/src/qanTimeTree.cpp"
# content [00ddcd23a8433e6b4cc8491051fb48ccc1b7ed13]
#
# add_file "libs/qanava/src/qanTimeTree.h"
# content [0d123a00ba535d82f6e5707aa5b7fe1a33496d39]
#
# add_file "libs/qanava/src/qanVectorf.h"
# content [9e02d50a23ddb577123d14ebb92fcb70220a04ea]
#
# add_file "libs/qanava/src/ui/uiNodesItemModel.cpp"
# content [ce8ceeda6ffddcb4cc72a0ec843daec6550b337d]
#
# add_file "libs/qanava/src/ui/uiNodesItemModel.h"
# content [c40b4d3800f8d2b99be3c2072ee15d9a8fff7945]
#
# add_file "libs/qanava/src/ui/uiStyleModel.cpp"
# content [d93ce3111a03fcf80b343e6360915ea7d2b7d49b]
#
# add_file "libs/qanava/src/ui/uiStyleModel.h"
# content [8f0c369542dfceb2099554d7d064a1169a72a668]
#
# add_file "libs/qanava/src/ui/uiStyleView.cpp"
# content [ce449871831206f5bf55d96e801dae928444c284]
#
# add_file "libs/qanava/src/ui/uiStyleView.h"
# content [1a99cd669c8250ec1a2e607bfdb7f811c3d2bdb2]
#
# add_file "libs/qanava/src/ui/uiUtil.h"
# content [13f19d1cf4651914501e855d898f0ec26b5d54ab]
#
# patch "guitone/guitone.pro"
# from [89ffc63cab6945f7c72dd91d072bfa7425ae9d33]
# to [067355a047c27064dc3c1455a34579bf6554f0af]
#
# patch "guitone/res/forms/main_window.ui"
# from [afaa9b341aa26361f28b3c8d857fa07473987959]
# to [cfd66fbddffb6167fcf8240eb95c7a3e93042c87]
#
# patch "guitone/res/forms/preferences.ui"
# from [50dcda14fc2c4f5147800b73b015bf988efd52f4]
# to [5c8f89400f2da1fc0833738eb97b81ef5210caa2]
#
# patch "guitone/res/i18n/guitone_de.ts"
# from [8a9f18c91d4da422143541bbe523025eb7a280d3]
# to [afd926dcc7d88b42891b983cdeeff9f3d0f7bc8c]
#
# patch "guitone/src/view/MainWindow.cpp"
# from [7c815e194238287d2253ae81d76627724e6fa733]
# to [f0a536dfb4a7be366b0b1896dae37dacdad378eb]
#
# patch "guitone/src/view/MainWindow.h"
# from [bf1f12efde46c96a0194070d00a9677c8f29e0cd]
# to [777cac1855851bd2b95dfbc1ecab9c13e4ce6a82]
#
# patch "guitone.pro"
# from [fa381aa2095c52bb3876fb5ffff635ce8c30ab32]
# to [2297c37664f54796350e838adac98828c250f58a]
#
============================================================
--- guitone/res/forms/ancestry_graph.ui 7e7f4aa6d5b1dc185e0b0ac8f5a05b5ed4c3bcf3
+++ guitone/res/forms/ancestry_graph.ui 7e7f4aa6d5b1dc185e0b0ac8f5a05b5ed4c3bcf3
@@ -0,0 +1,92 @@
+
+ AncestryGraph
+
+
+ Qt::NonModal
+
+
+
+ 0
+ 0
+ 550
+ 373
+
+
+
+ Ancestry Graph
+
+
+
+ 9
+
+
+ 6
+
+ -
+
+
+ 0
+
+
+ 6
+
+
-
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ AncestryGraph
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ AncestryGraph
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
============================================================
--- guitone/src/model/Graph.cpp 35fe7a0ea20b3254f120f8c39b60e925af131097
+++ guitone/src/model/Graph.cpp 35fe7a0ea20b3254f120f8c39b60e925af131097
@@ -0,0 +1,108 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Thomas Keller *
+ * address@hidden *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "Graph.h"
+
+Graph::Graph(QObject *parent) : QObject(parent)
+{
+ graph = new qan::Graph();
+ mtnDelegate = new MonotoneDelegate(this);
+}
+
+Graph::~Graph()
+{
+ delete graph;
+ delete mtnDelegate;
+}
+
+bool Graph::readGraph()
+{
+ QStringList cmd;
+ cmd.append("graph");
+
+ return mtnDelegate->triggerCommand(cmd);
+}
+
+void Graph::parseOutput()
+{
+ QStringList revisionList = AutomateCommand::data.split("\n");
+
+ QMap nodeMap;
+ QMap parentMap;
+
+ qan::Node *curNode, *parentNode;
+
+ // 1st pass: create node objects for every rev and add it to the graph
+ for (int i=0, j=revisionList.size(); i 0);
+ QString rev = revs.takeFirst();
+ // for whatever reason inserting every node as root node creates a
+ // big memory hole
+ curNode = graph->insertNode(rev, -1, NULL);
+
+ // remember those for the 2nd pass
+ nodeMap[rev] = curNode;
+ parentMap[rev] = revs;
+
+ if (i % 100 == 0)
+ {
+ qDebug("added %d nodes", i);
+ }
+ }
+
+ qDebug("Graph: created nodes");
+
+ revisionList.clear();
+ QStringList singleRevs = nodeMap.keys();
+
+ // 2nd pass: now that we have all nodes create the edges
+ for (int i=0, j=singleRevs.size(); iinsertEdge(*parentNode, *curNode);
+ }
+ }
+ if (i % 100 == 0)
+ {
+ qDebug("added edges for %d nodes", i);
+ }
+ }
+
+ qDebug("Graph: created edges");
+
+ graph->generateRootNodes();
+
+ qDebug("Graph: generated root nodes");
+
+ emit graphCreated();
+}
+
============================================================
--- guitone/src/model/Graph.h a2007e2c3765bc07a103e2172fc4340ad1eb997e
+++ guitone/src/model/Graph.h a2007e2c3765bc07a103e2172fc4340ad1eb997e
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Thomas Keller *
+ * address@hidden *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef GRAPH_H
+#define GRAPH_H
+
+#include "AutomateCommand.h"
+#include "MonotoneDelegate.h"
+#include "qanGraph.h"
+
+#include
+
+class Graph : public QObject, public AutomateCommand
+{
+ Q_OBJECT
+public:
+ Graph(QObject *);
+ virtual ~Graph();
+
+ qan::Graph * getGraph() { return graph; }
+
+public slots:
+ bool readGraph();
+
+
+signals:
+ void graphCreated();
+
+private:
+ void parseOutput();
+ MonotoneDelegate * mtnDelegate;
+ qan::Graph * graph;
+};
+
+#endif
============================================================
--- guitone/src/view/dialogs/AncestryGraph.cpp 4d168d008bd0e6043f946d4c5728a84370b3eea0
+++ guitone/src/view/dialogs/AncestryGraph.cpp 4d168d008bd0e6043f946d4c5728a84370b3eea0
@@ -0,0 +1,82 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Thomas Keller *
+ * address@hidden *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "AncestryGraph.h"
+#include "qanGrid.h"
+
+AncestryGraph::AncestryGraph(QWidget* parent)
+ : Dialog(parent)
+{
+ setupUi(this);
+
+ graph = new Graph(this);
+ graph->readGraph();
+
+ QHBoxLayout *hbox = new QHBoxLayout( graphFrame );
+ hbox->setMargin(0);
+ hbox->setSpacing(2);
+
+ labelWait = new QLabel(tr("Please wait while the graph is being created..."));
+ labelWait->setAlignment(Qt::AlignCenter);
+
+ graphItemView = new qan::GraphItemView(graphFrame);
+ graphItemView->setModel(graph->getGraph());
+ graphItemView->hide();
+
+ hbox->addWidget(labelWait);
+ hbox->addWidget(graphItemView);
+
+ // create and layout the graphview if all nodes have been created
+ connect(graph, SIGNAL(graphCreated()),
+ this, SLOT(createGraphView()));
+}
+
+AncestryGraph::~AncestryGraph()
+{
+ if (graph) delete graph;
+ if (graphItemView) delete graphItemView;
+ if (labelWait) delete labelWait;
+}
+
+void AncestryGraph::createGraphView( )
+{
+ qan::VectorF origin(2);
+ origin(0) = 10.f;
+ origin(1) = 10.f;
+
+ qan::VectorF spacing(2);
+ spacing(0) = 120.f;
+ spacing(1) = 55.f;
+
+ qan::Layout* layout = new qan::DirectedTree(
+ origin,
+ spacing,
+ qan::DirectedTree::HORIZONTAL
+ );
+
+ graphItemView->setGraphLayout(layout);
+ graphItemView->layoutGraph();
+
+ // hide the wait label and show the graph view
+ labelWait->hide();
+ graphItemView->show();
+
+}
+
============================================================
--- guitone/src/view/dialogs/AncestryGraph.h 8b3764f98c90d5c7fab0d8c529e97b92b92e4fc6
+++ guitone/src/view/dialogs/AncestryGraph.h 8b3764f98c90d5c7fab0d8c529e97b92b92e4fc6
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Thomas Keller *
+ * address@hidden *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef ANCESTRY_GRAPH_H
+#define ANCESTRY_GRAPH_H
+
+#include
+
+#include "ui_ancestry_graph.h"
+
+#include "Dialog.h"
+#include "Graph.h"
+
+#include "qanGraphItemView.h"
+#include "qanLayout.h"
+
+class AncestryGraph : public Dialog, private Ui::AncestryGraph
+{
+ Q_OBJECT
+
+public:
+ AncestryGraph(QWidget*);
+ ~AncestryGraph();
+
+private:
+ QHBoxLayout *hbox;
+ QLabel *labelWait;
+ Graph *graph;
+ qan::GraphItemView *graphItemView;
+
+protected slots:
+
+ void createGraphView();
+};
+
+#endif
+
============================================================
--- libs/libs.pro ca5044adbf8828221942c937a63e7b40638b4aea
+++ libs/libs.pro ca5044adbf8828221942c937a63e7b40638b4aea
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = qanava
+
============================================================
--- libs/qanava/build/build.pro fea130f425d6c83a83f2843af84ced77e6e31b79
+++ libs/qanava/build/build.pro fea130f425d6c83a83f2843af84ced77e6e31b79
@@ -0,0 +1,2 @@
+TEMPLATE=subdirs
+SUBDIRS=qan
============================================================
--- libs/qanava/build/qan/qan.pro d5ef733dbb9849633e57e042ad112df5df9185c9
+++ libs/qanava/build/qan/qan.pro d5ef733dbb9849633e57e042ad112df5df9185c9
@@ -0,0 +1,61 @@
+
+LANGUAGE = C++
+DEFINES += QANAVA
+TARGET = qanava
+DESTDIR = ../
+CONFIG += debug \
+ warn_on \
+ qt \
+ thread staticlib
+QT += xml
+TEMPLATE = lib
+HEADERS += ../../src/qanConfig.h \
+ ../../src/qanEdge.h \
+ ../../src/qanGraph.h \
+ ../../src/qanGraph.hpp \
+ ../../src/qanGrid.h \
+ ../../src/qanLayout.h \
+ ../../src/qanNode.h \
+ ../../src/qanVectorf.h \
+ ../../src/qanRepository.h \
+ ../../src/qanTimeTree.h \
+ ../../src/qanController.h \
+ ../../src/qanItemGeom.h \
+ ../../src/qanStyle.h \
+ ../../src/qanGraphicsView.h \
+ ../../src/qanGraphItemView.h \
+ ../../src/qanGraphItemModel.h \
+ ../../src/qanGridItem.h \
+ ../../src/ui/uiStyleView.h \
+ ../../src/ui/uiStyleModel.h \
+ ../../src/ui/uiNodesItemModel.h \
+ ../../src/ui/uiUtil.h
+
+SOURCES += ../../src/qanEdge.cpp \
+ ../../src/qanLayout.cpp \
+ ../../src/qanNode.cpp \
+ ../../src/qanRepository.cpp \
+ ../../src/qanTimeTree.cpp \
+ ../../src/qanController.cpp \
+ ../../src/qanItemGeom.cpp \
+ ../../src/qanStyle.cpp \
+ ../../src/qanGraphicsView.cpp \
+ ../../src/qanGraphItemView.cpp \
+ ../../src/qanGraphItemModel.cpp \
+ ../../src/qanGridItem.cpp \
+ ../../src/ui/uiStyleView.cpp \
+ ../../src/ui/uiStyleModel.cpp \
+ ../../src/ui/uiNodesItemModel.cpp
+
+macx | unix {
+ QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter
+ UI_DIR = .ui
+ MOC_DIR = .moc
+ OBJECTS_DIR = .obj
+ DEFINES += QANAVA_UNIX
+ CONFIG += ppc x86
+}
+win32{
+ OBJECTS_DIR = ./Debug
+}
+
============================================================
--- libs/qanava/qanava.pro 4b9d41233daf1c2fa2e1ed293eefed0b4d0b7252
+++ libs/qanava/qanava.pro 4b9d41233daf1c2fa2e1ed293eefed0b4d0b7252
@@ -0,0 +1,2 @@
+TEMPLATE=subdirs
+SUBDIRS=build
============================================================
--- libs/qanava/src/qanConfig.h 3888e646fb6334e4e5fe0c89bf6ebeeea47e2736
+++ libs/qanava/src/qanConfig.h 3888e646fb6334e4e5fe0c89bf6ebeeea47e2736
@@ -0,0 +1,57 @@
+/*
+Qanava - Graph drawing library for QT
+Copyright (C) 2006 Benoit AUTHEMAN
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+//-----------------------------------------------------------------------------
+// This file is a part of the Qanava and LTM software.
+//
+// \file utlConfig.h
+// \author Benoit Autheman (address@hidden)
+// \date 2004 September 21
+//-----------------------------------------------------------------------------
+
+
+#ifndef qan_utlConfig_h
+#define qan_utlConfig_h
+
+
+// Configure this file either for LTM or Qanava
+#undef QAN_UTL_ROOT_NAMESPACE
+#define QAN_UTL_ROOT_NAMESPACE qan // Uncomment for Qanava
+//#define QAN_UTL_ROOT_NAMESPACE ltm // Uncomment for LTM
+
+#include
+
+#ifndef QANAVA_UNIX
+
+#pragma warning( disable:4786 ) // VC6: Too long template name in debug informations
+
+#pragma warning( disable:4251 ) // VC7.1: BOOST dll interface warning
+
+#pragma warning( disable:4275 ) // VC7.1: BOOST dll interface warning
+
+#pragma warning( disable:4290 ) // VC7.1: Explicit C++ exception specification
+
+#pragma warning( disable:4100 ) // VC7.1: Unreferenced formal parameter
+
+#pragma warning( disable:4244 ) // VC7.1: BOOST date and time warning
+
+#endif
+
+#endif // utlConfig_h
+
============================================================
--- libs/qanava/src/qanController.cpp 2d05912d39496d3127db41a8099af62ba291288f
+++ libs/qanava/src/qanController.cpp 2d05912d39496d3127db41a8099af62ba291288f
@@ -0,0 +1,529 @@
+/*
+Qanava - Graph drawing library for QT
+Copyright (C) 2006 Benoit AUTHEMAN
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+//-----------------------------------------------------------------------------
+// This file is a part of the Qanava software.
+//
+// \file canController.cpp
+// \author Benoit Autheman (address@hidden)
+// \date 2003 August 13
+//-----------------------------------------------------------------------------
+
+
+// Qanava headers
+#include "./qanController.h"
+#include "./qanGraphicsView.h"
+
+
+// QT headers
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+namespace qan { // ::qan
+
+
+bool Controller::Manager::keyPressEvent( QKeyEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->keyPressEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+bool Controller::Manager::mousePressEvent( QMouseEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->mousePressEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+bool Controller::Manager::mouseReleaseEvent( QMouseEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->mouseReleaseEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+bool Controller::Manager::mouseMoveEvent( QMouseEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->mouseMoveEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+bool Controller::Manager::mouseDoubleClickEvent( QMouseEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->mouseDoubleClickEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+bool Controller::Manager::wheelEvent( QWheelEvent* e )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->wheelEvent( e ) )
+ return true;
+ }
+ return false;
+}
+
+Controller* Controller::Manager::getController( QString name )
+{
+ for ( Controller::Manager::iterator controllerIter = begin( ); controllerIter != end( ); controllerIter++ )
+ {
+ if ( ( *controllerIter )->getName( ) == name )
+ return ( *controllerIter );
+ }
+ return 0;
+}
+
+void Controller::Manager::registerController( Controller* controller )
+{
+ if ( controller == 0 )
+ return;
+
+ push_back( controller );
+ QAction* controllerAction = controller->getAction( );
+ if ( controllerAction->isCheckable( ) )
+ _actionGroup->addAction( controllerAction ); // Only one checkable action active at a time
+}
+
+Controller::Controller( QString name, GraphicsView& graphicsView ) :
+ _graphicsView( graphicsView ),
+ _action( 0 ),
+ _name( name )
+{
+
+}
+
+
+/* PanController Constructor/Destructor *///-----------------------------------
+PanController::PanController( GraphicsView& graphicsView ) :
+ Controller( "pan_controller", graphicsView ),
+ _keyboardNavigation( true ),
+ _keyboardNavigationIntensity( 10.0 ),
+ _start( 0., 0. )
+{
+ QAction* action = new QAction( this );
+ action->setCheckable( true );
+ action->setText( "Pan" );
+ action->setVisible( true );
+ action->setIcon( QIcon( "images/qanava_pan.png" ) );
+ connect( action, SIGNAL( toggled( bool ) ), this, SLOT( toggled( bool ) ) );
+ setAction( action );
+
+ setKeyboardNavigation( true );
+}
+
+void PanController::toggled( bool state )
+{
+ setMode( state ? PAN : NONE );
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* PanController Keyboard Management *///--------------------------------------
+bool PanController::keyPressEvent( QKeyEvent* e )
+{
+ getGraphicsView( ).setFocusPolicy( Qt::ClickFocus );
+ if ( getKeyboardNavigation( ) )
+ {
+ switch ( e->key( ) )
+ {
+ case Qt::Key_Left:
+ getGraphicsView( ).translate( ( int )-_keyboardNavigationIntensity, 0 );
+ break;
+
+ case Qt::Key_Up:
+ getGraphicsView( ).translate( 0, ( int )-_keyboardNavigationIntensity );
+ break;
+
+ case Qt::Key_Right:
+ getGraphicsView( ).translate( ( int )_keyboardNavigationIntensity, 0 );
+ break;
+
+ case Qt::Key_Down:
+ getGraphicsView( ).translate( 0, ( int )_keyboardNavigationIntensity );
+ break;
+
+ default:
+ e->ignore( );
+ break;
+ }
+ }
+ return false;
+}
+
+/*! To use keyboard navigation, ensure that this widget parent widget has at least a 'Click'
+ focus policy (in Designer or with the QWidget::setFocusPolicy() method).
+*/
+void PanController::setKeyboardNavigation( bool state )
+{
+ _keyboardNavigation = state;
+ if ( state )
+ {
+ getGraphicsView( ).viewport( )->setFocusPolicy( Qt::StrongFocus );
+ getGraphicsView( ).setFocusPolicy( Qt::StrongFocus );
+ }
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* PanController Mouse Management *///-----------------------------------------
+bool PanController::mousePressEvent( QMouseEvent* e )
+{
+ // Navigation must not occurs if a node is under the mouse
+ QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+ QList< QGraphicsItem* > items = getGraphicsView( ).scene( )->items( p );
+ if ( items.size( ) == 0 )
+ { // TODO: prendre les elements de grille en compte (et tous ceux qui ne sont pas manipulables)
+ if ( getMode( ) == PAN )
+ {
+ _start = e->pos( );
+ getGraphicsView( ).viewport( )->setCursor( QCursor( Qt::SizeAllCursor ) );
+ setState( PANNING );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool PanController::mouseReleaseEvent( QMouseEvent* e )
+{
+ getGraphicsView( ).viewport( )->setCursor( QCursor( Qt::ArrowCursor ) );
+
+ if ( getMode( ) == PAN && getState( ) == PANNING )
+ setState( NONE ); // Stop panning until next click
+
+ return false;
+}
+
+bool PanController::mouseMoveEvent( QMouseEvent* e )
+{
+ if ( getMode( ) == PAN && getState( ) == PANNING )
+ {
+ QPointF p = e->pos( ); // No mapping, we move scrollbars in their coordinate system
+ //QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+
+ double accel = 1.0;
+ double dx = ( _start.x( ) - p.x( ) ) * accel;
+ double dy = ( _start.y( ) - p.y( ) ) * accel;
+
+ int valueY = ( int )( getGraphicsView( ).verticalScrollBar( )->value( ) + dy );
+ getGraphicsView( ).verticalScrollBar( )->setValue( valueY );
+ int valueX = ( int )( getGraphicsView( ).horizontalScrollBar( )->value( ) + dx );
+ getGraphicsView( ).horizontalScrollBar( )->setValue( valueX );
+
+ _start = p;
+ return true;
+ }
+ return false;
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* ZoomWindowController Constructor/Destructor *///-------------------------------
+ZoomWindowController::ZoomWindowController( GraphicsView& graphicsView ) :
+ Controller( "zoom_window_controller", graphicsView ),
+ _start( 0., 0. ),
+ _zoomRectItem( 0 )
+{
+ QAction* action = new QAction( this );
+ action->setCheckable( true );
+ action->setText( "Zoom Window" );
+ action->setVisible( true );
+ action->setIcon( QIcon( "images/qanava_zoomwindow.png" ) );
+ connect( action, SIGNAL( toggled( bool ) ), this, SLOT( toggled( bool ) ) );
+ setAction( action );
+
+ _zoomRectItem = new QGraphicsRectItem( QRectF( 0., 0., 50., 50. ), 0, getGraphicsView( ).scene( ) );
+ _zoomRectItem->setZValue( 100. );
+ QPen p;
+ p.setStyle( Qt::DotLine );
+ p.setWidth( 1 );
+ p.setColor( QColor( 55, 55, 55 ) );
+ _zoomRectItem->setPen( p );
+ _zoomRectItem->hide( );
+}
+
+void ZoomWindowController::toggled( bool state )
+{
+ setMode( state ? ZOOM : NONE );
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* ZoomWindowController Zooming Management *///--------------------------------
+bool ZoomWindowController::mousePressEvent( QMouseEvent* e )
+{
+ // Navigation must not occurs if a node is under the mouse
+ QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+ QList< QGraphicsItem* > items = getGraphicsView( ).scene( )->items( p );
+ if ( items.size( ) == 0 )
+ { // TODO: prendre les elements de grille en compte (et tous ceux qui ne sont pas manipulables)
+ if ( getMode( ) == ZOOM )
+ {
+ _start = getGraphicsView( ).mapToScene( e->pos( ) );
+ setState( ZOOMING );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool ZoomWindowController::mouseReleaseEvent( QMouseEvent* e )
+{
+ if ( getMode( ) == ZOOM && getState( ) == ZOOMING )
+ {
+ getGraphicsView( ).fitInView( _zoomRectItem->rect( ), Qt::KeepAspectRatioByExpanding );
+ _zoomRectItem->hide( );
+ setState( NONE ); // Stop zooming until next click
+ return true;
+ }
+
+ return false;
+}
+
+bool ZoomWindowController::mouseMoveEvent( QMouseEvent* e )
+{
+ if ( getMode( ) == ZOOM && getState( ) == ZOOMING && _zoomRectItem != 0 )
+ {
+ QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+
+ QRectF r( _start.x( ), _start.y( ),
+ p.x( ) - _start.x( ), p.y( ) - _start.y( ) );
+ _zoomRectItem->setRect( r );
+ _zoomRectItem->show( );
+ return true;
+ }
+ return false;
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* ZoomController Constructor/Destructor *///----------------------------------
+ZoomController::ZoomController( GraphicsView& graphicsView ) :
+ Controller( "zoom_controller", graphicsView ),
+ _actionZoomIn( new QAction( this ) ),
+ _actionZoomOut( new QAction( this ) )
+{
+ QAction* action = new QAction( this );
+ action->setCheckable( true );
+ action->setText( "Zoom" );
+ action->setVisible( true );
+ action->setIcon( QIcon( "images/qanava_zoom.png" ) );
+ setAction( action );
+
+ _actionZoomIn->setText( "Zoom In" );
+ _actionZoomIn->setVisible( true );
+ _actionZoomIn->setIcon( QIcon( "images/qanava_zoomin.png" ) );
+ connect( _actionZoomIn, SIGNAL( triggered( bool ) ), this, SLOT( zoomIn( bool ) ) );
+
+ _actionZoomOut->setText( "Zoom Out" );
+ _actionZoomOut->setVisible( true );
+ _actionZoomOut->setIcon( QIcon( "images/qanava_zoomout.png" ) );
+ connect( _actionZoomOut, SIGNAL( triggered( bool ) ), this, SLOT( zoomOut( bool ) ) );
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* ZoomController Zooming Management *///--------------------------------------
+void ZoomController::zoomIn( bool state )
+{
+ getGraphicsView( ).setZoom( getGraphicsView( ).getZoom( ) + 0.2 );
+}
+
+void ZoomController::zoomOut( bool state )
+{
+ getGraphicsView( ).setZoom( getGraphicsView( ).getZoom( ) - 0.2 );
+}
+
+bool ZoomController::wheelEvent( QWheelEvent* e )
+{
+ return false;
+}
+
+QAction* ZoomController::getAction( QString name )
+{
+ if ( name == "zoom_in" )
+ return _actionZoomIn;
+ else if ( name == "zoom_out" )
+ return _actionZoomOut;
+
+ return 0;
+}
+//-----------------------------------------------------------------------------
+
+
+
+/* Selection Controller Management *///------------------------------------------
+/*SelectionController::SelectionController( GraphicsView& graphicsView ) :
+ Controller( graphicsView )
+{
+}
+
+bool SelectionController::mouseDoubleClickEvent( QMouseEvent* e )
+{*/
+ // FIXME
+/* QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+ Item::List collisions;
+ getGraphicsView( ).getCanvas( )->getCollisions( p, collisions );
+ for ( Item::List::iterator itemIter = collisions.begin( ); itemIter != collisions.end( ); itemIter++ )
+ {
+ Item* item = *itemIter;
+ if ( getGraphicsView( ).getCanvas( )->isFreed( item ) )
+ break;
+
+ Node* node = getGraphicsView( ).getGraphicItemNode( item );
+ if ( node != 0 )
+ emit nodeSelected( node, p );
+ }*/
+
+/* return false;
+}*/
+//-----------------------------------------------------------------------------
+
+
+
+/* Tooltip Controller Management *///--------------------------------------------
+/*TooltipController::TooltipController( GraphicsView& graphicsView ) :
+ Controller( graphicsView ),
+ //_tipItem( 0 ),
+ _tipPos( 0, 0 ),
+ _timer( 0 )
+{
+ _timer = new QTimer( this );
+ connect( _timer, SIGNAL( timeout( ) ), SLOT( tipTimeout( ) ) );
+}*/
+
+/*void TooltipController::tipTimeout( )
+{*/
+ // FIXME
+ // Don't show tooltips in case of error or if another controller is already active
+/* if ( _tipItem == 0 || getGraphicsView( ).getControllerManager( ).isControllerActive( ) )
+ {
+ _timer->stop( );
+ return;
+ }
+
+ // Test if the mouse is still on the item that has started the tooltip demand (tooltip delay) milliseconds ago
+ Item::List collisions;
+ getGraphicsView( ).getCanvas( )->getCollisions( _tipPos, collisions );
+ for ( Item::List::iterator itemIter = collisions.begin( ); itemIter != collisions.end( ); itemIter++ )
+ {
+ Item* item = *itemIter;
+
+ if ( item == _tipItem )
+ {
+ Node* node = getGraphicsView( ).getGraphicItemNode( _tipItem );
+ if ( node != 0 )
+ {
+ // Compute the real screen viewport coordinates
+ QPoint viewportTipPosContent = getGraphicsView( ).mapFromCanvas( _tipPos );
+ emit nodeTipped( node, getGraphicsView( ).viewport( )->mapToGlobal( viewportTipPosContent ) );
+ }
+ }
+ }
+ _timer->stop( );
+ _tipItem = 0;*/
+//}
+
+//bool TooltipController::mouseMoveEvent( QMouseEvent* e )
+//{
+ // FIXME
+/* QPointF p = getGraphicsView( ).mapToScene( e->pos( ) );
+ _tipPos = p;
+
+ // If no button is pressed, there is no manipulation or navigation operation going on, so tooltip can be displayed
+ if ( e->button() != Qt::LeftButton )
+ {
+ Item::List collisions;
+ getGraphicsView( ).getCanvas( )->getCollisions( _tipPos, collisions );
+ for ( Item::List::iterator itemIter = collisions.begin( ); itemIter != collisions.end( ); itemIter++ )
+ {
+ Item* item = *itemIter;
+ if ( item == _tipItem && _timer->isActive( ) ) // Avoid the timer to be restarted when moving in the same item
+ break;
+
+ _tipPos = p;
+ if ( getGraphicsView( ).getCanvas( )->isFreed( item ) )
+ break;
+
+ Node* node = getGraphicsView( ).getGraphicItemNode( item );
+ if ( node != 0 )
+ {
+ _timer->start( 800 );
+ _tipItem = item;
+ return true;
+ }
+ break; // Take just the first intersecting item to avoid deep z selection
+ }
+ }
+ else
+ {
+ // There is a complex navigation or manipulation operation going on, don't display tooltips
+ _timer->stop( );
+ _tipItem = 0;
+ }
+ */
+// return false;
+//}
+
+//bool TooltipController::mouseDoubleClickEvent( QMouseEvent* e )
+//{
+ // Avoid interference with other controllers (such as simultaneous tip and double click node selection)
+ // FIXME
+ /*_timer->stop( );
+ _tipItem = 0;*/
+// return false;
+//}
+//-----------------------------------------------------------------------------
+
+
+} // ::qan
+
============================================================
--- libs/qanava/src/qanController.h 2f743c33036f4d4c664e491b786f1797cb2bd1f2
+++ libs/qanava/src/qanController.h 2f743c33036f4d4c664e491b786f1797cb2bd1f2
@@ -0,0 +1,352 @@
+/*
+Qanava - Graph drawing library for QT
+Copyright (C) 2006 Benoit AUTHEMAN
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+//-----------------------------------------------------------------------------
+// This file is a part of the Qanava software.
+//
+// \file canController.h
+// \author Benoit Autheman (address@hidden)
+// \date 2003 August 13
+//-----------------------------------------------------------------------------
+
+
+#ifndef canController_h
+#define canController_h
+
+
+// Qanava headers
+#include "./qanNode.h"
+
+
+// STD headers
+#include