-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,403 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mkdir -p build | ||
cd build | ||
qmake ../Project1/ | ||
qmake ../project1/ | ||
make -j2 | ||
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <QtGui/QApplication> | ||
#include "mainwindow.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
|
||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#include "mainwindow.h" | ||
#include "ui_mainwindow.h" | ||
#include "twoD.h" | ||
#include <QTextStream> | ||
#include <iostream> | ||
#include <fstream> | ||
|
||
using namespace std; | ||
|
||
map<string, vector<pair<int,int> > > _GenericPieces; | ||
MainWindow::MainWindow(QWidget *parent) : | ||
QMainWindow(parent), | ||
ui(new Ui::MainWindow) | ||
{ | ||
ui->setupUi(this); | ||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void MainWindow::on_show_clicked() | ||
{ | ||
if (ui->show->text() == "Mark Reachability") | ||
{ | ||
ui->show->setText("Save"); | ||
ui->tableWidget->setRowCount(ui->xCord->value()); | ||
ui->tableWidget->setColumnCount(ui->yCord->value()); | ||
for (size_t i = 0; i < ui->yCord->value(); i++) | ||
ui->tableWidget->setColumnWidth(i,ui->tableWidget->rowHeight(0)); | ||
|
||
for (size_t row = 0; row < ui->xCord->value(); row++) | ||
for (size_t col = 0; col < ui->yCord->value(); col++) | ||
{ | ||
QString v; | ||
if (ui->xCordCurrent->value()-1 == row && ui->yCordCurrent->value()-1 == col) | ||
v = "*"; | ||
QTableWidgetItem *item = new QTableWidgetItem(v); | ||
ui->tableWidget->setItem(row,col,item); | ||
} | ||
} | ||
else if (ui->show->text() == "Save") | ||
{ | ||
vector<pair<int, int> > reachability; | ||
reachability.push_back(make_pair(ui->xCordCurrent->value()-1, ui->yCordCurrent->value()-1)); | ||
for (size_t row = 0; row < ui->tableWidget->rowCount(); row++) | ||
for (size_t col = 0; col < ui->tableWidget->columnCount(); col++) | ||
{ | ||
if (ui->tableWidget->item(row,col)->text() == "1") | ||
{ | ||
reachability.push_back(make_pair(row,col)); | ||
} | ||
} | ||
stringstream s; | ||
s << "Generic Peice " << _GenericPieces.size() +1; | ||
_GenericPieces[s.str()] = reachability; | ||
ui->peiceList->addItem(QString(s.str().c_str())); | ||
ui->show->setText("Show"); | ||
} | ||
else | ||
{ | ||
twoD obj (ui->xCord->value(), ui->yCord->value(), ui->xCordCurrent->value(), ui->yCordCurrent->value(), _GenericPieces); | ||
|
||
QString filename("temp"); | ||
{ | ||
QFile file(filename); | ||
cout << ui->obstacleList->toPlainText().toStdString(); | ||
|
||
if ( file.open(QFile::WriteOnly) ) { | ||
cout << "file opened for writing" << endl; | ||
QTextStream outStream(&file); | ||
outStream << ui->obstacleList->toPlainText(); | ||
} | ||
} | ||
vector<pair<int,int> > obstacles; | ||
{ | ||
ifstream file(filename); | ||
cout << "file opened for reading" << endl; | ||
while(file.good() && !file.eof()) | ||
{ | ||
int x,y; | ||
file >> x; | ||
if (file.good()) | ||
{ | ||
file >> y; | ||
obstacles.push_back(make_pair(x,y)); | ||
cout << "Added obstacle at " << x << "," << y << endl; | ||
} | ||
} | ||
} | ||
|
||
obj.set_obstacles( obstacles.size(), obstacles); | ||
|
||
|
||
obj.compute_distances(ui->peiceList->currentText().toStdString()); | ||
obj.display(); | ||
|
||
ui->tableWidget->setRowCount(ui->xCord->value()); | ||
ui->tableWidget->setColumnCount(ui->yCord->value()); | ||
for (size_t i = 0; i < ui->yCord->value(); i++) | ||
ui->tableWidget->setColumnWidth(i,ui->tableWidget->rowHeight(0)); | ||
|
||
const twoD::Array2D &data(obj.GetData()); | ||
for (size_t row = 0; row < data.size(); row++) | ||
for (size_t col = 0; col < data.at(row).size(); col++) | ||
{ | ||
const size_t num(data.at(row).at(col)); | ||
QString val; | ||
// if ((row == ui->yCordCurrent->value()-1) && (col == ui->xCordCurrent->value()-1)) | ||
// val = "*"; | ||
// else if (num == 0) | ||
// val = QString(); | ||
if (num == 999) | ||
val = "X"; | ||
else | ||
val = QString::number(num); | ||
QTableWidgetItem *item = new QTableWidgetItem(val); | ||
ui->tableWidget->setItem(row,col,item); | ||
} | ||
} | ||
} | ||
|
||
|
||
void MainWindow::on_peiceList_currentIndexChanged(const QString &arg1) | ||
{ | ||
if (arg1.isEmpty()) | ||
{ | ||
ui->show->setText("Mark Reachability"); | ||
} | ||
else | ||
ui->show->setText("Show"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
|
||
namespace Ui { | ||
class MainWindow; | ||
} | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit MainWindow(QWidget *parent = 0); | ||
~MainWindow(); | ||
|
||
private slots: | ||
void on_show_clicked(); | ||
|
||
void on_peiceList_currentIndexChanged(const QString &arg1); | ||
|
||
private: | ||
Ui::MainWindow *ui; | ||
}; | ||
|
||
#endif // MAINWINDOW_H |
Oops, something went wrong.