조성현

add reset action

...@@ -256,7 +256,7 @@ void GraphItem::path_highlighting(std::string start, std::string end) ...@@ -256,7 +256,7 @@ void GraphItem::path_highlighting(std::string start, std::string end)
256 void GraphItem::reset_color() 256 void GraphItem::reset_color()
257 { 257 {
258 for (auto& n: nodeList) { 258 for (auto& n: nodeList) {
259 - n->setColor(QColor()); 259 + n->setColor(QColor(Qt::green));
260 } 260 }
261 } 261 }
262 262
......
...@@ -60,7 +60,6 @@ public: ...@@ -60,7 +60,6 @@ public:
60 //methods 60 //methods
61 void path_highlighting(std::string start, std::string end); 61 void path_highlighting(std::string start, std::string end);
62 void reset_color(); 62 void reset_color();
63 - //
64 63
65 protected: 64 protected:
66 void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 65 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
......
...@@ -4,20 +4,14 @@ ...@@ -4,20 +4,14 @@
4 MainWindow::MainWindow(QWidget *parent) 4 MainWindow::MainWindow(QWidget *parent)
5 : QMainWindow(parent) 5 : QMainWindow(parent)
6 { 6 {
7 - //ui.setupUi(this);
8 graphWidget = new PaperGraphWidget; 7 graphWidget = new PaperGraphWidget;
9 setCentralWidget(graphWidget); 8 setCentralWidget(graphWidget);
10 9
11 /*QVBoxLayout *layout = new QVBoxLayout; 10 /*QVBoxLayout *layout = new QVBoxLayout;
12 layout->setMargin(5); 11 layout->setMargin(5);
13 graphWidget->setLayout(layout);*/ 12 graphWidget->setLayout(layout);*/
14 - 13 + createActions();
15 - //create menu 14 + createMenus();
16 - testAct = new QAction(tr("&Test"), this);
17 - testAct->setStatusTip(tr("Test Action"));
18 - connect(testAct, &QAction::triggered, this, &MainWindow::test_func);
19 - fileMenu = menuBar()->addMenu(tr("&File"));
20 - fileMenu->addAction(testAct);
21 15
22 QString message = tr("test message"); 16 QString message = tr("test message");
23 statusBar()->showMessage(message); 17 statusBar()->showMessage(message);
...@@ -36,10 +30,39 @@ void MainWindow::print_graph(std::ifstream& fin) ...@@ -36,10 +30,39 @@ void MainWindow::print_graph(std::ifstream& fin)
36 graphWidget->print_graph(fin); 30 graphWidget->print_graph(fin);
37 } 31 }
38 32
39 -void MainWindow::test_func() 33 +//////////////////////////////////////////////////////////////////
34 +// private methods
35 +//////////////////////////////////////////////////////////////////
36 +void MainWindow::createActions()
37 +{
38 + testHighlightAct = new QAction(tr("&Highlight"), this);
39 + testHighlightAct->setStatusTip(tr("Highlighting node"));
40 + connect(testHighlightAct, &QAction::triggered, this, &MainWindow::test_highlighting);
41 +
42 + resetColorAct = new QAction(tr("&Reset"), this);
43 + resetColorAct->setStatusTip(tr("Reset all node's color"));
44 + connect(resetColorAct, &QAction::triggered, this, &MainWindow::reset_color);
45 +}
46 +
47 +void MainWindow::createMenus()
48 +{
49 + actionMenu = menuBar()->addMenu(tr("&Actions"));
50 + actionMenu->addAction(testHighlightAct);
51 + actionMenu->addAction(resetColorAct);
52 +}
53 +
54 +//////////////////////////////////////////////////////////////////
55 +// slots
56 +//////////////////////////////////////////////////////////////////
57 +void MainWindow::test_highlighting()
40 { 58 {
41 /*QMessageBox::information(this, "test", 59 /*QMessageBox::information(this, "test",
42 - "test: "+QString::number(11));*/ 60 + "test: "+QString::number(11));*/
43 graphWidget->path_highlight(); 61 graphWidget->path_highlight();
44 //graphWidget->update(); 62 //graphWidget->update();
63 +}
64 +
65 +void MainWindow::reset_color()
66 +{
67 + graphWidget->reset_color();
45 } 68 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
2 #define MAINWINDOW_H 2 #define MAINWINDOW_H
3 3
4 #include "stdafx.h" 4 #include "stdafx.h"
5 -//#include "ui_MainWindow.h"
6 #include "PaperGraphWidget.h" 5 #include "PaperGraphWidget.h"
7 6
8 class MainWindow : public QMainWindow 7 class MainWindow : public QMainWindow
...@@ -14,14 +13,22 @@ public: ...@@ -14,14 +13,22 @@ public:
14 ~MainWindow(); 13 ~MainWindow();
15 14
16 void print_graph(std::ifstream& fin); 15 void print_graph(std::ifstream& fin);
17 - void test_func(); 16 + /*void test_highlighting();*/
18 17
19 private: 18 private:
20 - //Ui::MainWindow ui;
21 PaperGraphWidget *graphWidget; 19 PaperGraphWidget *graphWidget;
22 20
23 - QMenu *fileMenu; 21 + QMenu *actionMenu;
24 - QAction *testAct; 22 + QAction *testHighlightAct;
23 + QAction *resetColorAct;
24 +
25 +private:
26 + void createActions();
27 + void createMenus();
28 +
29 +private slots:
30 + void test_highlighting();
31 + void reset_color();
25 }; 32 };
26 33
27 #endif // MAINWINDOW_H 34 #endif // MAINWINDOW_H
......
...@@ -218,29 +218,7 @@ ...@@ -218,29 +218,7 @@
218 </CustomBuild> 218 </CustomBuild>
219 </ItemGroup> 219 </ItemGroup>
220 <ItemGroup> 220 <ItemGroup>
221 - <CustomBuild Include="PaperGraphWidget.ui">
222 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
223 - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message>
224 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
225 - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
226 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
227 - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
228 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
229 - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
230 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
231 - <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message>
232 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
233 - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
234 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
235 - <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
236 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
237 - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
238 - </CustomBuild>
239 - </ItemGroup>
240 - <ItemGroup>
241 <ClInclude Include="EdgeItem.h" /> 221 <ClInclude Include="EdgeItem.h" />
242 - <ClInclude Include="GeneratedFiles\ui_MainWindow.h" />
243 - <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" />
244 <ClInclude Include="stdafx.h" /> 222 <ClInclude Include="stdafx.h" />
245 <CustomBuild Include="GraphicsView.h"> 223 <CustomBuild Include="GraphicsView.h">
246 <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> 224 <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
...@@ -301,26 +279,6 @@ ...@@ -301,26 +279,6 @@
301 <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command> 279 <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
302 </CustomBuild> 280 </CustomBuild>
303 </ItemGroup> 281 </ItemGroup>
304 - <ItemGroup>
305 - <CustomBuild Include="MainWindow.ui">
306 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
307 - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message>
308 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
309 - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
310 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
311 - <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
312 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
313 - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
314 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
315 - <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message>
316 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
317 - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
318 - <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
319 - <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
320 - <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
321 - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
322 - </CustomBuild>
323 - </ItemGroup>
324 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 282 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
325 <ImportGroup Label="ExtensionTargets"> 283 <ImportGroup Label="ExtensionTargets">
326 </ImportGroup> 284 </ImportGroup>
......
...@@ -88,9 +88,6 @@ ...@@ -88,9 +88,6 @@
88 <CustomBuild Include="PaperGraphWidget.h"> 88 <CustomBuild Include="PaperGraphWidget.h">
89 <Filter>Header Files</Filter> 89 <Filter>Header Files</Filter>
90 </CustomBuild> 90 </CustomBuild>
91 - <CustomBuild Include="PaperGraphWidget.ui">
92 - <Filter>Form Files</Filter>
93 - </CustomBuild>
94 <CustomBuild Include="PaperGraphWidget.qrc"> 91 <CustomBuild Include="PaperGraphWidget.qrc">
95 <Filter>Resource Files</Filter> 92 <Filter>Resource Files</Filter>
96 </CustomBuild> 93 </CustomBuild>
...@@ -100,14 +97,8 @@ ...@@ -100,14 +97,8 @@
100 <CustomBuild Include="MainWindow.h"> 97 <CustomBuild Include="MainWindow.h">
101 <Filter>Header Files</Filter> 98 <Filter>Header Files</Filter>
102 </CustomBuild> 99 </CustomBuild>
103 - <CustomBuild Include="MainWindow.ui">
104 - <Filter>Form Files</Filter>
105 - </CustomBuild>
106 </ItemGroup> 100 </ItemGroup>
107 <ItemGroup> 101 <ItemGroup>
108 - <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h">
109 - <Filter>Generated Files</Filter>
110 - </ClInclude>
111 <ClInclude Include="NodeItem.h"> 102 <ClInclude Include="NodeItem.h">
112 <Filter>Header Files</Filter> 103 <Filter>Header Files</Filter>
113 </ClInclude> 104 </ClInclude>
...@@ -117,9 +108,6 @@ ...@@ -117,9 +108,6 @@
117 <ClInclude Include="EdgeItem.h"> 108 <ClInclude Include="EdgeItem.h">
118 <Filter>Header Files</Filter> 109 <Filter>Header Files</Filter>
119 </ClInclude> 110 </ClInclude>
120 - <ClInclude Include="GeneratedFiles\ui_MainWindow.h">
121 - <Filter>Generated Files</Filter>
122 - </ClInclude>
123 <ClInclude Include="stdafx.h"> 111 <ClInclude Include="stdafx.h">
124 <Filter>PCH</Filter> 112 <Filter>PCH</Filter>
125 </ClInclude> 113 </ClInclude>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
6 PaperGraphWidget::PaperGraphWidget(QWidget *parent) 6 PaperGraphWidget::PaperGraphWidget(QWidget *parent)
7 : QWidget(parent) 7 : QWidget(parent)
8 { 8 {
9 - //ui.setupUi(this);
10 initscene(); 9 initscene();
11 10
12 View *view = new View("temp view"); 11 View *view = new View("temp view");
...@@ -44,6 +43,12 @@ void PaperGraphWidget::path_highlight() ...@@ -44,6 +43,12 @@ void PaperGraphWidget::path_highlight()
44 scene->update(); 43 scene->update();
45 } 44 }
46 45
46 +void PaperGraphWidget::reset_color()
47 +{
48 + graphItem->reset_color();
49 + scene->update();
50 +}
51 +
47 void PaperGraphWidget::handleSelectionChanged(int idx) 52 void PaperGraphWidget::handleSelectionChanged(int idx)
48 { 53 {
49 QMessageBox::information(this, "QCombobox", 54 QMessageBox::information(this, "QCombobox",
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
4 #include "stdafx.h" 4 #include "stdafx.h"
5 5
6 #include "GraphItem.h" 6 #include "GraphItem.h"
7 -//#include "ui_PaperGraphWidget.h"
8 7
9 class PaperGraphWidget : public QWidget 8 class PaperGraphWidget : public QWidget
10 { 9 {
...@@ -13,7 +12,9 @@ class PaperGraphWidget : public QWidget ...@@ -13,7 +12,9 @@ class PaperGraphWidget : public QWidget
13 public: 12 public:
14 PaperGraphWidget(QWidget *parent = 0); 13 PaperGraphWidget(QWidget *parent = 0);
15 void print_graph(ifstream& fin); 14 void print_graph(ifstream& fin);
15 +
16 void path_highlight(); 16 void path_highlight();
17 + void reset_color();
17 18
18 private slots: 19 private slots:
19 void handleSelectionChanged(int idx); 20 void handleSelectionChanged(int idx);
...@@ -21,7 +22,6 @@ private slots: ...@@ -21,7 +22,6 @@ private slots:
21 private: 22 private:
22 void initscene(); 23 void initscene();
23 24
24 - //Ui::PaperGraphWidgetClass ui;
25 QGraphicsScene *scene; 25 QGraphicsScene *scene;
26 GraphItem *graphItem = nullptr; 26 GraphItem *graphItem = nullptr;
27 }; 27 };
......