조성현

add reset action

......@@ -256,7 +256,7 @@ void GraphItem::path_highlighting(std::string start, std::string end)
void GraphItem::reset_color()
{
for (auto& n: nodeList) {
n->setColor(QColor());
n->setColor(QColor(Qt::green));
}
}
......
......@@ -60,7 +60,6 @@ public:
//methods
void path_highlighting(std::string start, std::string end);
void reset_color();
//
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
......
......@@ -4,20 +4,14 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
//ui.setupUi(this);
graphWidget = new PaperGraphWidget;
setCentralWidget(graphWidget);
/*QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(5);
graphWidget->setLayout(layout);*/
//create menu
testAct = new QAction(tr("&Test"), this);
testAct->setStatusTip(tr("Test Action"));
connect(testAct, &QAction::triggered, this, &MainWindow::test_func);
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(testAct);
createActions();
createMenus();
QString message = tr("test message");
statusBar()->showMessage(message);
......@@ -36,10 +30,39 @@ void MainWindow::print_graph(std::ifstream& fin)
graphWidget->print_graph(fin);
}
void MainWindow::test_func()
//////////////////////////////////////////////////////////////////
// private methods
//////////////////////////////////////////////////////////////////
void MainWindow::createActions()
{
testHighlightAct = new QAction(tr("&Highlight"), this);
testHighlightAct->setStatusTip(tr("Highlighting node"));
connect(testHighlightAct, &QAction::triggered, this, &MainWindow::test_highlighting);
resetColorAct = new QAction(tr("&Reset"), this);
resetColorAct->setStatusTip(tr("Reset all node's color"));
connect(resetColorAct, &QAction::triggered, this, &MainWindow::reset_color);
}
void MainWindow::createMenus()
{
actionMenu = menuBar()->addMenu(tr("&Actions"));
actionMenu->addAction(testHighlightAct);
actionMenu->addAction(resetColorAct);
}
//////////////////////////////////////////////////////////////////
// slots
//////////////////////////////////////////////////////////////////
void MainWindow::test_highlighting()
{
/*QMessageBox::information(this, "test",
"test: "+QString::number(11));*/
graphWidget->path_highlight();
//graphWidget->update();
}
void MainWindow::reset_color()
{
graphWidget->reset_color();
}
\ No newline at end of file
......
......@@ -2,7 +2,6 @@
#define MAINWINDOW_H
#include "stdafx.h"
//#include "ui_MainWindow.h"
#include "PaperGraphWidget.h"
class MainWindow : public QMainWindow
......@@ -14,14 +13,22 @@ public:
~MainWindow();
void print_graph(std::ifstream& fin);
void test_func();
/*void test_highlighting();*/
private:
//Ui::MainWindow ui;
PaperGraphWidget *graphWidget;
QMenu *fileMenu;
QAction *testAct;
QMenu *actionMenu;
QAction *testHighlightAct;
QAction *resetColorAct;
private:
void createActions();
void createMenus();
private slots:
void test_highlighting();
void reset_color();
};
#endif // MAINWINDOW_H
......
......@@ -218,29 +218,7 @@
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="PaperGraphWidget.ui">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="EdgeItem.h" />
<ClInclude Include="GeneratedFiles\ui_MainWindow.h" />
<ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" />
<ClInclude Include="stdafx.h" />
<CustomBuild Include="GraphicsView.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
......@@ -301,26 +279,6 @@
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="MainWindow.ui">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Uic%27ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"</Command>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
......
......@@ -88,9 +88,6 @@
<CustomBuild Include="PaperGraphWidget.h">
<Filter>Header Files</Filter>
</CustomBuild>
<CustomBuild Include="PaperGraphWidget.ui">
<Filter>Form Files</Filter>
</CustomBuild>
<CustomBuild Include="PaperGraphWidget.qrc">
<Filter>Resource Files</Filter>
</CustomBuild>
......@@ -100,14 +97,8 @@
<CustomBuild Include="MainWindow.h">
<Filter>Header Files</Filter>
</CustomBuild>
<CustomBuild Include="MainWindow.ui">
<Filter>Form Files</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h">
<Filter>Generated Files</Filter>
</ClInclude>
<ClInclude Include="NodeItem.h">
<Filter>Header Files</Filter>
</ClInclude>
......@@ -117,9 +108,6 @@
<ClInclude Include="EdgeItem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GeneratedFiles\ui_MainWindow.h">
<Filter>Generated Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>PCH</Filter>
</ClInclude>
......
......@@ -6,7 +6,6 @@
PaperGraphWidget::PaperGraphWidget(QWidget *parent)
: QWidget(parent)
{
//ui.setupUi(this);
initscene();
View *view = new View("temp view");
......@@ -44,6 +43,12 @@ void PaperGraphWidget::path_highlight()
scene->update();
}
void PaperGraphWidget::reset_color()
{
graphItem->reset_color();
scene->update();
}
void PaperGraphWidget::handleSelectionChanged(int idx)
{
QMessageBox::information(this, "QCombobox",
......
......@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "GraphItem.h"
//#include "ui_PaperGraphWidget.h"
class PaperGraphWidget : public QWidget
{
......@@ -13,7 +12,9 @@ class PaperGraphWidget : public QWidget
public:
PaperGraphWidget(QWidget *parent = 0);
void print_graph(ifstream& fin);
void path_highlight();
void reset_color();
private slots:
void handleSelectionChanged(int idx);
......@@ -21,7 +22,6 @@ private slots:
private:
void initscene();
//Ui::PaperGraphWidgetClass ui;
QGraphicsScene *scene;
GraphItem *graphItem = nullptr;
};
......