Node highlighting example. click file menu->node highlighting
Showing
10 changed files
with
213 additions
and
22 deletions
... | @@ -246,15 +246,6 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | ... | @@ -246,15 +246,6 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
246 | if (!graph) | 246 | if (!graph) |
247 | return; | 247 | return; |
248 | 248 | ||
249 | - //debug | ||
250 | - //-> x, y, w, h | ||
251 | - //현재 Graph의 bounding rect 출력 | ||
252 | - /*QPen oldPen = painter->pen(); | ||
253 | - QPen pen = oldPen; | ||
254 | - pen.setColor(Qt::red); | ||
255 | - painter->setPen(pen); | ||
256 | - painter->drawRect(QRectF(-SCREEN_SIZE/2, -SCREEN_SIZE/2, SCREEN_SIZE, SCREEN_SIZE));*/ | ||
257 | - | ||
258 | //print edges | 249 | //print edges |
259 | for (auto edge: edgeList) { | 250 | for (auto edge: edgeList) { |
260 | edge->paint(painter, option, widget); | 251 | edge->paint(painter, option, widget); |
... | @@ -266,6 +257,17 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | ... | @@ -266,6 +257,17 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
266 | } | 257 | } |
267 | } | 258 | } |
268 | 259 | ||
260 | +void GraphItem::path_highlighting(std::string start, std::string end) | ||
261 | +{ | ||
262 | + //path highlight | ||
263 | + //nodeList, edgeList 속성을 수정 | ||
264 | + for (auto& n: nodeList) { | ||
265 | + if (n->getLabel() == QString("Seongsoo Park")) { | ||
266 | + n->setColor(QColor(255, 0, 0)); | ||
267 | + } | ||
268 | + } | ||
269 | +} | ||
270 | + | ||
269 | //event handler | 271 | //event handler |
270 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | 272 | void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
271 | { | 273 | { | ... | ... |
PaperGraph/MainWindow.cpp
0 → 100644
1 | +#include "MainWindow.h" | ||
2 | + | ||
3 | +MainWindow::MainWindow(QWidget *parent) | ||
4 | + : QMainWindow(parent) | ||
5 | +{ | ||
6 | + //ui.setupUi(this); | ||
7 | + graphWidget = new PaperGraphWidget; | ||
8 | + setCentralWidget(graphWidget); | ||
9 | + | ||
10 | + /*QVBoxLayout *layout = new QVBoxLayout; | ||
11 | + layout->setMargin(5); | ||
12 | + graphWidget->setLayout(layout);*/ | ||
13 | + | ||
14 | + //create menu | ||
15 | + testAct = new QAction(tr("&Test"), this); | ||
16 | + testAct->setStatusTip(tr("Test Action")); | ||
17 | + connect(testAct, &QAction::triggered, this, &MainWindow::test_func); | ||
18 | + fileMenu = menuBar()->addMenu(tr("&File")); | ||
19 | + fileMenu->addAction(testAct); | ||
20 | + | ||
21 | + QString message = tr("test message"); | ||
22 | + statusBar()->showMessage(message); | ||
23 | + | ||
24 | + setMinimumSize(160, 160); | ||
25 | + resize(800, 600); | ||
26 | +} | ||
27 | + | ||
28 | +MainWindow::~MainWindow() | ||
29 | +{ | ||
30 | + | ||
31 | +} | ||
32 | + | ||
33 | +void MainWindow::print_graph(std::ifstream& fin) | ||
34 | +{ | ||
35 | + graphWidget->print_graph(fin); | ||
36 | +} | ||
37 | + | ||
38 | +void MainWindow::test_func() | ||
39 | +{ | ||
40 | + /*QMessageBox::information(this, "test", | ||
41 | + "test: "+QString::number(11));*/ | ||
42 | + graphWidget->path_highlight(); | ||
43 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
PaperGraph/MainWindow.h
0 → 100644
1 | +#ifndef MAINWINDOW_H | ||
2 | +#define MAINWINDOW_H | ||
3 | + | ||
4 | +#include <QMainWindow> | ||
5 | +#include <QtWidgets> | ||
6 | +#include <QGridLayout> | ||
7 | +#include <QtGui> | ||
8 | + | ||
9 | +#include <iostream> | ||
10 | + | ||
11 | +//#include "ui_MainWindow.h" | ||
12 | +#include "PaperGraphWidget.h" | ||
13 | + | ||
14 | +class MainWindow : public QMainWindow | ||
15 | +{ | ||
16 | + Q_OBJECT | ||
17 | + | ||
18 | +public: | ||
19 | + MainWindow(QWidget *parent = 0); | ||
20 | + ~MainWindow(); | ||
21 | + | ||
22 | + void print_graph(std::ifstream& fin); | ||
23 | + void test_func(); | ||
24 | + | ||
25 | +private: | ||
26 | + //Ui::MainWindow ui; | ||
27 | + PaperGraphWidget *graphWidget; | ||
28 | + | ||
29 | + QMenu *fileMenu; | ||
30 | + QAction *testAct; | ||
31 | +}; | ||
32 | + | ||
33 | +#endif // MAINWINDOW_H |
PaperGraph/MainWindow.ui
0 → 100644
1 | +<UI version="4.0" > | ||
2 | + <class>MainWindow</class> | ||
3 | + <widget class="QMainWindow" name="MainWindow" > | ||
4 | + <property name="objectName" > | ||
5 | + <string notr="true">MainWindow</string> | ||
6 | + </property> | ||
7 | + <property name="geometry" > | ||
8 | + <rect> | ||
9 | + <x>0</x> | ||
10 | + <y>0</y> | ||
11 | + <width>400</width> | ||
12 | + <height>300</height> | ||
13 | + </rect> | ||
14 | + </property> | ||
15 | + <property name="windowTitle" > | ||
16 | + <string>MainWindow</string> | ||
17 | + </property> | ||
18 | + <widget class="QMenuBar" name="menuBar" /> | ||
19 | + <widget class="QToolBar" name="mainToolBar" /> | ||
20 | + <widget class="QWidget" name="centralWidget" /> | ||
21 | + <widget class="QStatusBar" name="statusBar" /> | ||
22 | + </widget> | ||
23 | + <layoutDefault spacing="6" margin="11" /> | ||
24 | + <pixmapfunction></pixmapfunction> | ||
25 | + <resources/> | ||
26 | + <connections/> | ||
27 | +</UI> |
... | @@ -24,6 +24,10 @@ protected: | ... | @@ -24,6 +24,10 @@ protected: |
24 | public: | 24 | public: |
25 | NodeItem(double x, double y, QColor color, QString label); | 25 | NodeItem(double x, double y, QColor color, QString label); |
26 | 26 | ||
27 | + //getter setter | ||
28 | + QString getLabel() {return label;} | ||
29 | + void setColor(QColor color) {this->color=color;} | ||
30 | + | ||
27 | QRectF boundingRect() const override; | 31 | QRectF boundingRect() const override; |
28 | QPainterPath shape() const override; | 32 | QPainterPath shape() const override; |
29 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; | 33 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; | ... | ... |
... | @@ -150,6 +150,10 @@ | ... | @@ -150,6 +150,10 @@ |
150 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | 150 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> |
151 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | 151 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> |
152 | </ClCompile> | 152 | </ClCompile> |
153 | + <ClCompile Include="GeneratedFiles\Debug\moc_MainWindow.cpp"> | ||
154 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | ||
155 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
156 | + </ClCompile> | ||
153 | <ClCompile Include="GeneratedFiles\Debug\moc_PaperGraphWidget.cpp"> | 157 | <ClCompile Include="GeneratedFiles\Debug\moc_PaperGraphWidget.cpp"> |
154 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | 158 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> |
155 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | 159 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> |
... | @@ -168,6 +172,10 @@ | ... | @@ -168,6 +172,10 @@ |
168 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | 172 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> |
169 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | 173 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> |
170 | </ClCompile> | 174 | </ClCompile> |
175 | + <ClCompile Include="GeneratedFiles\Release\moc_MainWindow.cpp"> | ||
176 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | ||
177 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | ||
178 | + </ClCompile> | ||
171 | <ClCompile Include="GeneratedFiles\Release\moc_PaperGraphWidget.cpp"> | 179 | <ClCompile Include="GeneratedFiles\Release\moc_PaperGraphWidget.cpp"> |
172 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | 180 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> |
173 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | 181 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> |
... | @@ -175,6 +183,7 @@ | ... | @@ -175,6 +183,7 @@ |
175 | <ClCompile Include="GraphicsView.cpp" /> | 183 | <ClCompile Include="GraphicsView.cpp" /> |
176 | <ClCompile Include="GraphItem.cpp" /> | 184 | <ClCompile Include="GraphItem.cpp" /> |
177 | <ClCompile Include="main.cpp" /> | 185 | <ClCompile Include="main.cpp" /> |
186 | + <ClCompile Include="MainWindow.cpp" /> | ||
178 | <ClCompile Include="NodeItem.cpp" /> | 187 | <ClCompile Include="NodeItem.cpp" /> |
179 | <ClCompile Include="PaperGraphWidget.cpp" /> | 188 | <ClCompile Include="PaperGraphWidget.cpp" /> |
180 | </ItemGroup> | 189 | </ItemGroup> |
... | @@ -220,6 +229,7 @@ | ... | @@ -220,6 +229,7 @@ |
220 | </ItemGroup> | 229 | </ItemGroup> |
221 | <ItemGroup> | 230 | <ItemGroup> |
222 | <ClInclude Include="EdgeItem.h" /> | 231 | <ClInclude Include="EdgeItem.h" /> |
232 | + <ClInclude Include="GeneratedFiles\ui_MainWindow.h" /> | ||
223 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" /> | 233 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" /> |
224 | <CustomBuild Include="GraphicsView.h"> | 234 | <CustomBuild Include="GraphicsView.h"> |
225 | <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | 235 | <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> |
... | @@ -240,6 +250,24 @@ | ... | @@ -240,6 +250,24 @@ |
240 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | 250 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> |
241 | </CustomBuild> | 251 | </CustomBuild> |
242 | <ClInclude Include="GraphItem.h" /> | 252 | <ClInclude Include="GraphItem.h" /> |
253 | + <CustomBuild Include="MainWindow.h"> | ||
254 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
255 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing MainWindow.h...</Message> | ||
256 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
257 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
258 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
259 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing MainWindow.h...</Message> | ||
260 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
261 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
262 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
263 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing MainWindow.h...</Message> | ||
264 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
265 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
266 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
267 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing MainWindow.h...</Message> | ||
268 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
269 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
270 | + </CustomBuild> | ||
243 | <ClInclude Include="NodeItem.h" /> | 271 | <ClInclude Include="NodeItem.h" /> |
244 | </ItemGroup> | 272 | </ItemGroup> |
245 | <ItemGroup> | 273 | <ItemGroup> |
... | @@ -262,6 +290,26 @@ | ... | @@ -262,6 +290,26 @@ |
262 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command> | 290 | <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command> |
263 | </CustomBuild> | 291 | </CustomBuild> |
264 | </ItemGroup> | 292 | </ItemGroup> |
293 | + <ItemGroup> | ||
294 | + <CustomBuild Include="MainWindow.ui"> | ||
295 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs> | ||
296 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message> | ||
297 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs> | ||
298 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command> | ||
299 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs> | ||
300 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message> | ||
301 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs> | ||
302 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command> | ||
303 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs> | ||
304 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message> | ||
305 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs> | ||
306 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command> | ||
307 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs> | ||
308 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message> | ||
309 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs> | ||
310 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command> | ||
311 | + </CustomBuild> | ||
312 | + </ItemGroup> | ||
265 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | 313 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
266 | <ImportGroup Label="ExtensionTargets"> | 314 | <ImportGroup Label="ExtensionTargets"> |
267 | </ImportGroup> | 315 | </ImportGroup> | ... | ... |
... | @@ -68,6 +68,15 @@ | ... | @@ -68,6 +68,15 @@ |
68 | <ClCompile Include="EdgeItem.cpp"> | 68 | <ClCompile Include="EdgeItem.cpp"> |
69 | <Filter>Source Files</Filter> | 69 | <Filter>Source Files</Filter> |
70 | </ClCompile> | 70 | </ClCompile> |
71 | + <ClCompile Include="MainWindow.cpp"> | ||
72 | + <Filter>Source Files</Filter> | ||
73 | + </ClCompile> | ||
74 | + <ClCompile Include="GeneratedFiles\Debug\moc_MainWindow.cpp"> | ||
75 | + <Filter>Generated Files\Debug</Filter> | ||
76 | + </ClCompile> | ||
77 | + <ClCompile Include="GeneratedFiles\Release\moc_MainWindow.cpp"> | ||
78 | + <Filter>Generated Files\Release</Filter> | ||
79 | + </ClCompile> | ||
71 | </ItemGroup> | 80 | </ItemGroup> |
72 | <ItemGroup> | 81 | <ItemGroup> |
73 | <CustomBuild Include="PaperGraphWidget.h"> | 82 | <CustomBuild Include="PaperGraphWidget.h"> |
... | @@ -82,6 +91,12 @@ | ... | @@ -82,6 +91,12 @@ |
82 | <CustomBuild Include="GraphicsView.h"> | 91 | <CustomBuild Include="GraphicsView.h"> |
83 | <Filter>Header Files</Filter> | 92 | <Filter>Header Files</Filter> |
84 | </CustomBuild> | 93 | </CustomBuild> |
94 | + <CustomBuild Include="MainWindow.h"> | ||
95 | + <Filter>Header Files</Filter> | ||
96 | + </CustomBuild> | ||
97 | + <CustomBuild Include="MainWindow.ui"> | ||
98 | + <Filter>Form Files</Filter> | ||
99 | + </CustomBuild> | ||
85 | </ItemGroup> | 100 | </ItemGroup> |
86 | <ItemGroup> | 101 | <ItemGroup> |
87 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h"> | 102 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h"> |
... | @@ -96,5 +111,8 @@ | ... | @@ -96,5 +111,8 @@ |
96 | <ClInclude Include="EdgeItem.h"> | 111 | <ClInclude Include="EdgeItem.h"> |
97 | <Filter>Header Files</Filter> | 112 | <Filter>Header Files</Filter> |
98 | </ClInclude> | 113 | </ClInclude> |
114 | + <ClInclude Include="GeneratedFiles\ui_MainWindow.h"> | ||
115 | + <Filter>Generated Files</Filter> | ||
116 | + </ClInclude> | ||
99 | </ItemGroup> | 117 | </ItemGroup> |
100 | </Project> | 118 | </Project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) | 10 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) |
11 | : QWidget(parent) | 11 | : QWidget(parent) |
12 | { | 12 | { |
13 | - ui.setupUi(this); | 13 | + //ui.setupUi(this); |
14 | initscene(); | 14 | initscene(); |
15 | 15 | ||
16 | View *view = new View("temp view"); | 16 | View *view = new View("temp view"); |
... | @@ -33,19 +33,28 @@ PaperGraphWidget::PaperGraphWidget(QWidget *parent) | ... | @@ -33,19 +33,28 @@ PaperGraphWidget::PaperGraphWidget(QWidget *parent) |
33 | 33 | ||
34 | void PaperGraphWidget::print_graph(ifstream& fin) | 34 | void PaperGraphWidget::print_graph(ifstream& fin) |
35 | { | 35 | { |
36 | - QGraphicsItem *graph_item = new GraphItem(fin); | 36 | + //QGraphicsItem *graph_item = new GraphItem(fin); |
37 | - graph_item->setPos(0, 0); | 37 | + if (graphItem) |
38 | - scene->addItem(graph_item); | 38 | + throw std::exception("already have graph item"); |
39 | + | ||
40 | + graphItem = new GraphItem(fin); | ||
41 | + graphItem->setPos(0, 0); | ||
42 | + scene->addItem(graphItem); | ||
43 | +} | ||
44 | + | ||
45 | +void PaperGraphWidget::path_highlight() | ||
46 | +{ | ||
47 | + graphItem->path_highlighting(std::string(""), std::string("")); | ||
39 | } | 48 | } |
40 | 49 | ||
41 | void PaperGraphWidget::handleSelectionChanged(int idx) | 50 | void PaperGraphWidget::handleSelectionChanged(int idx) |
42 | { | 51 | { |
43 | - /*QMessageBox::information(this, "QCombobox", | 52 | + QMessageBox::information(this, "QCombobox", |
44 | - "idx: "+QString::number(idx));*/ | 53 | + "idx: "+QString::number(idx)); |
45 | - if (idx==0) { | 54 | + /*if (idx==0) { |
46 | } else if (idx==1) { | 55 | } else if (idx==1) { |
47 | } else { | 56 | } else { |
48 | - } | 57 | + }*/ |
49 | } | 58 | } |
50 | 59 | ||
51 | void PaperGraphWidget::initscene() | 60 | void PaperGraphWidget::initscene() | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | #include <fstream> | 7 | #include <fstream> |
8 | 8 | ||
9 | #include "GraphItem.h" | 9 | #include "GraphItem.h" |
10 | -#include "ui_PaperGraphWidget.h" | 10 | +//#include "ui_PaperGraphWidget.h" |
11 | 11 | ||
12 | 12 | ||
13 | class PaperGraphWidget : public QWidget | 13 | class PaperGraphWidget : public QWidget |
... | @@ -17,6 +17,7 @@ class PaperGraphWidget : public QWidget | ... | @@ -17,6 +17,7 @@ class PaperGraphWidget : public QWidget |
17 | public: | 17 | public: |
18 | PaperGraphWidget(QWidget *parent = 0); | 18 | PaperGraphWidget(QWidget *parent = 0); |
19 | void print_graph(ifstream& fin); | 19 | void print_graph(ifstream& fin); |
20 | + void path_highlight(); | ||
20 | 21 | ||
21 | private slots: | 22 | private slots: |
22 | void handleSelectionChanged(int idx); | 23 | void handleSelectionChanged(int idx); |
... | @@ -24,8 +25,9 @@ private slots: | ... | @@ -24,8 +25,9 @@ private slots: |
24 | private: | 25 | private: |
25 | void initscene(); | 26 | void initscene(); |
26 | 27 | ||
27 | - Ui::PaperGraphWidgetClass ui; | 28 | + //Ui::PaperGraphWidgetClass ui; |
28 | QGraphicsScene *scene; | 29 | QGraphicsScene *scene; |
30 | + GraphItem *graphItem; | ||
29 | }; | 31 | }; |
30 | 32 | ||
31 | #endif // PAPERGRAPHWIDGET_H | 33 | #endif // PAPERGRAPHWIDGET_H | ... | ... |
1 | #include "PaperGraphWidget.h" | 1 | #include "PaperGraphWidget.h" |
2 | +#include "MainWindow.h" | ||
3 | + | ||
2 | #include <QtWidgets/QApplication> | 4 | #include <QtWidgets/QApplication> |
3 | #include <QDebug> | 5 | #include <QDebug> |
4 | 6 | ||
... | @@ -28,18 +30,21 @@ int main(int argc, char *argv[]) | ... | @@ -28,18 +30,21 @@ int main(int argc, char *argv[]) |
28 | { | 30 | { |
29 | QApplication app(argc, argv); | 31 | QApplication app(argc, argv); |
30 | 32 | ||
31 | - PaperGraphWidget w; | 33 | + //PaperGraphWidget w; |
34 | + MainWindow m; | ||
32 | 35 | ||
33 | try { | 36 | try { |
34 | ifstream fin(PAPER_FILENAME); | 37 | ifstream fin(PAPER_FILENAME); |
35 | - w.print_graph(fin); | 38 | + //w.print_graph(fin); |
39 | + m.print_graph(fin); | ||
36 | fin.close(); | 40 | fin.close(); |
37 | } catch (const std::exception& e) { | 41 | } catch (const std::exception& e) { |
38 | qDebug() << "Error: " << e.what(); | 42 | qDebug() << "Error: " << e.what(); |
39 | return EXIT_FAILURE; | 43 | return EXIT_FAILURE; |
40 | } | 44 | } |
41 | 45 | ||
42 | - w.show(); | 46 | + //w.show(); |
47 | + m.show(); | ||
43 | 48 | ||
44 | return app.exec(); | 49 | return app.exec(); |
45 | } | 50 | } | ... | ... |
-
Please register or login to post a comment