Showing
17 changed files
with
72 additions
and
79 deletions
| 1 | +#include "stdafx.h" | ||
| 1 | #include "GraphItem.h" | 2 | #include "GraphItem.h" |
| 2 | 3 | ||
| 3 | -#include <boost/graph/fruchterman_reingold.hpp> | ||
| 4 | -#include <boost/graph/random_layout.hpp> | ||
| 5 | -#include <boost/graph/circle_layout.hpp> | ||
| 6 | -#include <boost/graph/dijkstra_shortest_paths.hpp> | ||
| 7 | -#include <boost/algorithm/string.hpp> //boost::split | ||
| 8 | -#include <boost/bimap.hpp> | ||
| 9 | -#include <boost/regex.hpp> | ||
| 10 | - | ||
| 11 | -#include <exception> | ||
| 12 | -#include <iterator> | ||
| 13 | -#include <string> | ||
| 14 | -#include <map> | ||
| 15 | -#include <vector> | ||
| 16 | - | ||
| 17 | -#include <QDebug> | ||
| 18 | -#include <QtWidgets> | ||
| 19 | - | ||
| 20 | - | ||
| 21 | GraphItem::GraphItem(ifstream& fin) | 4 | GraphItem::GraphItem(ifstream& fin) |
| 22 | { | 5 | { |
| 23 | if (!fin) | 6 | if (!fin) |
| ... | @@ -270,6 +253,13 @@ void GraphItem::path_highlighting(std::string start, std::string end) | ... | @@ -270,6 +253,13 @@ void GraphItem::path_highlighting(std::string start, std::string end) |
| 270 | 253 | ||
| 271 | } | 254 | } |
| 272 | 255 | ||
| 256 | +void GraphItem::reset_color() | ||
| 257 | +{ | ||
| 258 | + for (auto& n: nodeList) { | ||
| 259 | + n->setColor(QColor()); | ||
| 260 | + } | ||
| 261 | +} | ||
| 262 | + | ||
| 273 | //event handler | 263 | //event handler |
| 274 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | 264 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
| 275 | { | 265 | { | ... | ... |
| 1 | #ifndef GRAPHITEM_H | 1 | #ifndef GRAPHITEM_H |
| 2 | #define GRAPHITEM_H | 2 | #define GRAPHITEM_H |
| 3 | 3 | ||
| 4 | -#include <QGraphicsItem> | 4 | +#include "stdafx.h" |
| 5 | -#include <QList> | ||
| 6 | -#include <QColor> | ||
| 7 | - | ||
| 8 | -#include <boost/graph/adjacency_list.hpp> | ||
| 9 | -#include <boost/graph/topology.hpp> | ||
| 10 | -#include <boost/graph/graph_traits.hpp> | ||
| 11 | - | ||
| 12 | -#include <fstream> | ||
| 13 | - | ||
| 14 | #include "NodeItem.h" | 5 | #include "NodeItem.h" |
| 15 | #include "EdgeItem.h" | 6 | #include "EdgeItem.h" |
| 16 | 7 | ||
| ... | @@ -68,6 +59,7 @@ public: | ... | @@ -68,6 +59,7 @@ public: |
| 68 | 59 | ||
| 69 | //methods | 60 | //methods |
| 70 | void path_highlighting(std::string start, std::string end); | 61 | void path_highlighting(std::string start, std::string end); |
| 62 | + void reset_color(); | ||
| 71 | // | 63 | // |
| 72 | 64 | ||
| 73 | protected: | 65 | protected: | ... | ... |
| 1 | #ifndef GRAPHICSVIEW_H | 1 | #ifndef GRAPHICSVIEW_H |
| 2 | #define GRAPHICSVIEW_H | 2 | #define GRAPHICSVIEW_H |
| 3 | 3 | ||
| 4 | -#include <QFrame> | 4 | +#include "stdafx.h" |
| 5 | -#include <QGraphicsView> | ||
| 6 | -#include <QGridLayout> | ||
| 7 | 5 | ||
| 8 | //pre-declare | 6 | //pre-declare |
| 9 | class View; | 7 | class View; |
| 10 | 8 | ||
| 11 | - | ||
| 12 | class GraphicsView | 9 | class GraphicsView |
| 13 | : public QGraphicsView | 10 | : public QGraphicsView |
| 14 | { | 11 | { | ... | ... |
| 1 | #ifndef MAINWINDOW_H | 1 | #ifndef MAINWINDOW_H |
| 2 | #define MAINWINDOW_H | 2 | #define MAINWINDOW_H |
| 3 | 3 | ||
| 4 | -#include <QMainWindow> | 4 | +#include "stdafx.h" |
| 5 | -#include <QtWidgets> | ||
| 6 | -#include <QGridLayout> | ||
| 7 | -#include <QtGui> | ||
| 8 | - | ||
| 9 | -#include <iostream> | ||
| 10 | - | ||
| 11 | //#include "ui_MainWindow.h" | 5 | //#include "ui_MainWindow.h" |
| 12 | #include "PaperGraphWidget.h" | 6 | #include "PaperGraphWidget.h" |
| 13 | 7 | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -33,6 +33,9 @@ | ... | @@ -33,6 +33,9 @@ |
| 33 | <Extensions>cpp;moc</Extensions> | 33 | <Extensions>cpp;moc</Extensions> |
| 34 | <SourceControlFiles>False</SourceControlFiles> | 34 | <SourceControlFiles>False</SourceControlFiles> |
| 35 | </Filter> | 35 | </Filter> |
| 36 | + <Filter Include="PCH"> | ||
| 37 | + <UniqueIdentifier>{23e088fd-f255-4f93-9c5e-f963b79d7a97}</UniqueIdentifier> | ||
| 38 | + </Filter> | ||
| 36 | </ItemGroup> | 39 | </ItemGroup> |
| 37 | <ItemGroup> | 40 | <ItemGroup> |
| 38 | <ClCompile Include="main.cpp"> | 41 | <ClCompile Include="main.cpp"> |
| ... | @@ -77,6 +80,9 @@ | ... | @@ -77,6 +80,9 @@ |
| 77 | <ClCompile Include="GeneratedFiles\Release\moc_MainWindow.cpp"> | 80 | <ClCompile Include="GeneratedFiles\Release\moc_MainWindow.cpp"> |
| 78 | <Filter>Generated Files\Release</Filter> | 81 | <Filter>Generated Files\Release</Filter> |
| 79 | </ClCompile> | 82 | </ClCompile> |
| 83 | + <ClCompile Include="stdafx.cpp"> | ||
| 84 | + <Filter>PCH</Filter> | ||
| 85 | + </ClCompile> | ||
| 80 | </ItemGroup> | 86 | </ItemGroup> |
| 81 | <ItemGroup> | 87 | <ItemGroup> |
| 82 | <CustomBuild Include="PaperGraphWidget.h"> | 88 | <CustomBuild Include="PaperGraphWidget.h"> |
| ... | @@ -114,5 +120,8 @@ | ... | @@ -114,5 +120,8 @@ |
| 114 | <ClInclude Include="GeneratedFiles\ui_MainWindow.h"> | 120 | <ClInclude Include="GeneratedFiles\ui_MainWindow.h"> |
| 115 | <Filter>Generated Files</Filter> | 121 | <Filter>Generated Files</Filter> |
| 116 | </ClInclude> | 122 | </ClInclude> |
| 123 | + <ClInclude Include="stdafx.h"> | ||
| 124 | + <Filter>PCH</Filter> | ||
| 125 | + </ClInclude> | ||
| 117 | </ItemGroup> | 126 | </ItemGroup> |
| 118 | </Project> | 127 | </Project> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | +#include "stdafx.h" | ||
| 1 | #include "PaperGraphWidget.h" | 2 | #include "PaperGraphWidget.h" |
| 2 | #include "NodeItem.h" | 3 | #include "NodeItem.h" |
| 3 | #include "GraphicsView.h" | 4 | #include "GraphicsView.h" |
| 4 | 5 | ||
| 5 | -#include <string> | ||
| 6 | -#include <QComboBox> | ||
| 7 | -#include <QMessageBox> | ||
| 8 | -#include <QtGui> | ||
| 9 | - | ||
| 10 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) | 6 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) |
| 11 | : QWidget(parent) | 7 | : QWidget(parent) |
| 12 | { | 8 | { | ... | ... |
| 1 | #ifndef PAPERGRAPHWIDGET_H | 1 | #ifndef PAPERGRAPHWIDGET_H |
| 2 | #define PAPERGRAPHWIDGET_H | 2 | #define PAPERGRAPHWIDGET_H |
| 3 | 3 | ||
| 4 | -#include <QtWidgets/QWidget> | 4 | +#include "stdafx.h" |
| 5 | -#include <QGraphicsScene> | ||
| 6 | - | ||
| 7 | -#include <fstream> | ||
| 8 | 5 | ||
| 9 | #include "GraphItem.h" | 6 | #include "GraphItem.h" |
| 10 | //#include "ui_PaperGraphWidget.h" | 7 | //#include "ui_PaperGraphWidget.h" |
| 11 | 8 | ||
| 12 | - | ||
| 13 | class PaperGraphWidget : public QWidget | 9 | class PaperGraphWidget : public QWidget |
| 14 | { | 10 | { |
| 15 | Q_OBJECT | 11 | Q_OBJECT | ... | ... |
| 1 | +#include "stdafx.h" | ||
| 1 | #include "PaperGraphWidget.h" | 2 | #include "PaperGraphWidget.h" |
| 2 | #include "MainWindow.h" | 3 | #include "MainWindow.h" |
| 3 | 4 | ||
| 4 | -#include <QtWidgets/QApplication> | ||
| 5 | -#include <QDebug> | ||
| 6 | - | ||
| 7 | -#include <algorithm> | ||
| 8 | -#include <exception> | ||
| 9 | -#include <fstream> | ||
| 10 | -#include <iterator> | ||
| 11 | -#include <string> | ||
| 12 | -#include <map> | ||
| 13 | -#include <vector> | ||
| 14 | - | ||
| 15 | -#include <boost/graph/fruchterman_reingold.hpp> | ||
| 16 | -//#include <boost/graph/kamada_kawai_spring_layout.hpp> | ||
| 17 | -#include <boost/graph/random_layout.hpp> | ||
| 18 | -#include <boost/graph/circle_layout.hpp> | ||
| 19 | -#include <boost/algorithm/string.hpp> //boost::split | ||
| 20 | -#include <boost/bimap.hpp> | ||
| 21 | - | ||
| 22 | -using namespace std; | ||
| 23 | - | ||
| 24 | /** | 5 | /** |
| 25 | * Constants | 6 | * Constants |
| 26 | */ | 7 | */ | ... | ... |
PaperGraph/stdafx.cpp
0 → 100644
| 1 | +#include "stdafx.h" |
PaperGraph/stdafx.h
0 → 100644
| 1 | +#pragma once | ||
| 2 | +#include <QColor> | ||
| 3 | +#include <QComboBox> | ||
| 4 | +#include <QDebug> | ||
| 5 | +#include <QFrame> | ||
| 6 | +#include <QGraphicsItem> | ||
| 7 | +#include <QGraphicsScene> | ||
| 8 | +#include <QGraphicsView> | ||
| 9 | +#include <QGridLayout> | ||
| 10 | +#include <QKeyEvent> | ||
| 11 | +#include <QList> | ||
| 12 | +#include <QMainWindow> | ||
| 13 | +#include <qmath.h> | ||
| 14 | +#include <QMessageBox> | ||
| 15 | +#include <QtGui> | ||
| 16 | +#include <QtWidgets/QApplication> | ||
| 17 | +#include <QtWidgets/QWidget> | ||
| 18 | +#include <QtWidgets> | ||
| 19 | + | ||
| 20 | +#include <boost/algorithm/string.hpp> //boost::split | ||
| 21 | +#include <boost/bimap.hpp> | ||
| 22 | +#include <boost/graph/adjacency_list.hpp> | ||
| 23 | +#include <boost/graph/circle_layout.hpp> | ||
| 24 | +#include <boost/graph/dijkstra_shortest_paths.hpp> | ||
| 25 | +#include <boost/graph/fruchterman_reingold.hpp> | ||
| 26 | +#include <boost/graph/graph_traits.hpp> | ||
| 27 | +#include <boost/graph/random_layout.hpp> | ||
| 28 | +#include <boost/graph/topology.hpp> | ||
| 29 | +#include <boost/regex.hpp> | ||
| 30 | + | ||
| 31 | +#include <algorithm> | ||
| 32 | +#include <exception> | ||
| 33 | +#include <fstream> | ||
| 34 | +#include <iostream> | ||
| 35 | +#include <iterator> | ||
| 36 | +#include <map> | ||
| 37 | +#include <string> | ||
| 38 | +#include <vector> | ||
| 39 | + | ||
| 40 | +using namespace boost; | ||
| 41 | +using namespace std; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment