Commit 63f3e35b authored by GigAnon's avatar GigAnon

Removed obsolete files

parent 2ae959bc
#include "debugwindow.h"
#include "ui_debugwindow.h"
/*#include "strategieV2.h"
#include "table.h"*/
#include <QDebug>
DebugWindow* DebugWindow::_instance = NULL;
DebugWindow* DebugWindow::getInstance()
{
if (_instance == NULL)
_instance = new DebugWindow();
return _instance;
}
DebugWindow::DebugWindow() :
QMainWindow(), parent(NULL), attached(true), ready(false), ui(new Ui::DebugWindow)
#ifdef USE_PLOT
, plotWidget(0)
#endif
{
ui->setupUi(this);
this->setWindowTitle("Krabi Debug");
setGeometry(0, 0, 240, 600);
/*
connect(ui->actionRemove_objects, SIGNAL(triggered()), Table::getMainInstance(), SLOT(removeAllObjects()));
connect(ui->actionReset_objects, SIGNAL(triggered()), Table::getMainInstance(), SLOT(createObjects()));
connect(ui->actionHide_table, SIGNAL(toggled(bool)), Table::getMainInstance(), SLOT(hideTable(bool)));
connect(ui->actionDisplay_route, SIGNAL(toggled(bool)), Table::getMainInstance(), SLOT(displayRoute(bool)));
connect(ui->actionDisplay_strategy, SIGNAL(toggled(bool)), Table::getMainInstance(), SLOT(displayStrategy(bool)));
connect(ui->actionRemote_Mod, SIGNAL(toggled(bool)), Table::getMainInstance(), SLOT(setRemoteMod(bool))); */
connect(ui->actionBluetooth, SIGNAL(toggled(bool)), this, SLOT(displayBluetoothWindow(bool)));
connect(ui->actionBluetooth_Interface, SIGNAL(toggled(bool)), this, SLOT(displayBluetoothInterface(bool)));
connect(ui->actionOdometrie, SIGNAL(toggled(bool)), this, SLOT(displayOdometrieWindow(bool)));
connect(ui->actionAsserv_Window, SIGNAL(toggled(bool)), this, SLOT(displayAsservWindow(bool)));
connect(ui->actionSharps, SIGNAL(toggled(bool)), this, SLOT(displaySharpWindow(bool)));
connect(ui->actionWatches, SIGNAL(toggled(bool)), this, SLOT(displayWatchWindow(bool)));
connect(ui->actionSimulateur, SIGNAL(triggered(bool)), this, SLOT(perspectiveSimulateur()));
connect(ui->actionAsservissement, SIGNAL(triggered(bool)), this, SLOT(perspectiveAsserv()));
connect(ui->actionOdom_trie, SIGNAL(triggered(bool)), this, SLOT(perspectiveOdometrie()));
_instance = this;
/* bluetoothWindow = new BluetoothWindow();
bluetoothInterface = new BluetoothInterface();*/
odometrieWindow = new OdometrieWindow();
asservWindow = new AsservWindow();
//sharpWindow = new SharpWindow();
watchWindow = new WatchWindow();
ui->statusbar->insertWidget(0, statusLabel = new QLabel("..."));
ui->statusbar->insertWidget(1, statusButton = new QPushButton("On"));
QPushButton* bt = new QPushButton("Clear Plots");
ui->statusbar->insertWidget(2, bt);
connect(bt, SIGNAL(clicked(bool)), this, SLOT(clearPlots()));
statusButton->setFixedWidth(32);
//connect(statusButton, SIGNAL(pressed()), bluetoothWindow, SLOT(bluetoothToggle()));
update();
}
void DebugWindow::setParent(MainWindow* parent)
{
this->parent = parent;
}
void DebugWindow::hideWindows()
{
asservWindow->hide();
odometrieWindow->hide();
/*bluetoothWindow->hide();
bluetoothInterface->hide();*/
//sharpWindow->hide();
watchWindow->hide();
}
void DebugWindow::clearPlots()
{
#ifdef USE_PLOT
for(QMap<int, PlotCurve*>::iterator it = plotCurves.begin(); it != plotCurves.end(); ++it)
{
it.value()->curve->detach();
delete it.value()->curve;
}
plotCurves.clear();
#endif
}
void DebugWindow::perspectiveAsserv()
{
hideWindows();
asservWindow->move(mapToGlobal(QPoint(width() + 16, 0)));
asservWindow->show();
/*Table::getMainInstance()->displayRoute(true);
Table::getMainInstance()->displayStrategy(false);
Table::getMainInstance()->hideTable(true);
Table::getMainInstance()->removeAllObjects();
Table::getMainInstance()->clearRoute();*/
}
void DebugWindow::perspectiveOdometrie()
{
hideWindows();
odometrieWindow->move(mapToGlobal(QPoint(width() + 16, 0)));
odometrieWindow->show();
/*Table::getMainInstance()->displayRoute(true);
Table::getMainInstance()->displayStrategy(false);
Table::getMainInstance()->hideTable(true);
Table::getMainInstance()->removeAllObjects();
Table::getMainInstance()->clearRoute();*/
}
void DebugWindow::perspectiveSimulateur()
{
hideWindows();
/*Table::getMainInstance()->displayRoute(false);
Table::getMainInstance()->displayStrategy(true);
Table::getMainInstance()->hideTable(false);
Table::getMainInstance()->createObjects();
Table::getMainInstance()->clearRoute();*/
}
void DebugWindow::update()
{
#ifdef BLUETOOTH
/* if (bluetoothWindow->isConnecting())
{
statusLabel->setText("Bluetooth connecting...");
statusButton->setText("X");
}
else if (bluetoothWindow->isConnected())
{
statusLabel->setText("Bluetooth connected");
statusButton->setText("Off");
}
else
{
statusLabel->setText("No connection");
statusButton->setText("On");
}*/
#else
statusLabel->setText("Bluetooth not implemented in Qt4");
statusButton->hide();
#endif
}
bool DebugWindow::isAttached()
{
return attached;
}
void DebugWindow::setReady(bool ready)
{
this->ready = ready;
}
void DebugWindow::moveEvent(QMoveEvent*)
{
if (ready)
attached = false;
}
void DebugWindow::moveWithoutEvent(QPoint pos)
{
bool currentReady = ready;
ready = false;
move(pos);
ready = currentReady;
}
void DebugWindow::setText(QString text)
{
ui->infoField->setText(text);
}
void DebugWindow::displayBluetoothWindow(bool)
{
//toggleWindow(bluetoothWindow, ui->actionBluetooth);
}
void DebugWindow::displayBluetoothInterface(bool)
{
//toggleWindow(bluetoothInterface, ui->actionBluetooth_Interface);
}
void DebugWindow::displayOdometrieWindow(bool)
{
toggleWindow(odometrieWindow, ui->actionOdometrie);
}
void DebugWindow::displayAsservWindow(bool)
{
toggleWindow(asservWindow, ui->actionAsserv_Window);
}
void DebugWindow::displaySharpWindow(bool)
{
//toggleWindow(sharpWindow, ui->actionSharps);
}
void DebugWindow::displayWatchWindow(bool)
{
toggleWindow(watchWindow, ui->actionWatches);
}
void DebugWindow::toggleWindow(QWidget* window, QAction* action)
{
if (window->isHidden())
{
if (action != NULL)
action->setChecked(true);
window->show();
window->move(mapToGlobal(QPoint(width() + 16, 0)));
}
else
{
if (action != NULL)
action->setChecked(false);
window->hide();
}
}
void DebugWindow::closeEvent(QCloseEvent*)
{
/*bluetoothWindow->close();
bluetoothInterface->close();*/
odometrieWindow->close();
asservWindow->close();
//sharpWindow->close();
watchWindow->close();
}
/*
BluetoothWindow* DebugWindow::getBluetoothWindow()
{
return 0;//bluetoothWindow;
}
BluetoothInterface* DebugWindow::getBluetoothInterface()
{
return bluetoothInterface;
}*/
OdometrieWindow* DebugWindow::getOdometrieWindow()
{
return odometrieWindow;
}
AsservWindow* DebugWindow::getAsservWindow()
{
return asservWindow;
}
/*
SharpWindow* DebugWindow::getSharpWindow()
{
return sharpWindow;
}
*/
WatchWindow* DebugWindow::getWatchWindow()
{
return watchWindow;
}
void DebugWindow::plot(int /*index*/, QString /*title*/, float /*data*/, int /*timeTick*/)
{
#ifdef USE_PLOT
if (plotWidget == NULL)
{
plotWidget = new QwtPlot();
plotWidget->show();
ui->centralwidget->layout()->addWidget(plotWidget);
//plotWidget->setTitle("<font color='#444'>title</font>");
plotWidget->setCanvasBackground(QColor(Qt::white));
QwtLegend *legend = new QwtLegend;
legend->setFrameStyle(QFrame::Box);
plotWidget->insertLegend(legend, QwtPlot::BottomLegend);
plotWidget->setAxisTitle(QwtPlot::xBottom, "<font color='#000'>t (s)</font>");
//plotWidget->setAxisTitle(QwtPlot::yLeft, "<font color='#000'>v</font>");
plotWidget->setAxisAutoScale(QwtPlot::xBottom, true);
plotWidget->setAxisAutoScale(QwtPlot::yLeft, true);
}
QColor color[9] = {Qt::red, Qt::green, Qt::blue, Qt::magenta, Qt::gray, Qt::yellow, Qt::cyan, Qt::darkYellow, Qt::magenta};
if (!plotCurves.contains(index))
{
plotCurves[index] = new PlotCurve(new QwtPlotCurve(title));
plotCurves[index]->curve->attach(plotWidget);
plotCurves[index]->curve->setPen(QPen( color[index % 9] ));
}
bool draw = true;
/*if (data < 0.05f)
{
if (plotCurves[index]->nonSignificant)
draw = false;
plotCurves[index]->nonSignificant = true;
}
else
{
if (plotCurves[index]->nonSignificant)
plotCurves[index]->add(timeTick >= 0 ? (float)timeTick * 0.05f : Table::getMainInstance()->getCurrentTime() - 0.005, 0.f);
plotCurves[index]->nonSignificant = false;
}*/
if (draw)
{
plotCurves[index]->add(Table::getMainInstance()->getCurrentTime(), data);
plotCurves[index]->plot();
}
plotWidget->replot();
plotWidget->update();
#endif
}
#ifdef USE_PLOT
void PlotCurve::plot()
{
curve->setData(new QwtPointArrayData(&x[0],&y[0],(size_t)x.size()));
}
void PlotCurve::add(double x, double y)
{
this->x.push_back(x);
this->y.push_back(y);
}
#endif
#ifndef DEBUGWINDOW_H
#define DEBUGWINDOW_H
#include <QVBoxLayout>
#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
/*#include "bluetoothwindow.h"
#include "bluetoothinterface.h"*/
#include "odometriewindow.h"
#include "asservwindow.h"
//#include "sharpwindow.h"
#include "watchwindow.h"
// to use qwt_plot, please install the 'libqwt-dev' package
// add 'qwt' to CONFIG in .pro to enable this
// sudo apt-get install libqwt-dev (on the VM)
#ifdef USE_PLOT
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_legend.h>
#include <qwt_point_data.h>
#endif
namespace Ui {
class DebugWindow;
}
class MainWindow;
#ifdef USE_PLOT
struct PlotCurve
{
PlotCurve(QwtPlotCurve* curve) : curve(curve), nonSignificant(false) {}
void plot();
void add(double x, double y);
QwtPlotCurve* curve;
std::vector<double> x, y;
bool nonSignificant;
};
#endif
class DebugWindow : public QMainWindow
{
Q_OBJECT
public:
bool isAttached();
void setReady(bool ready);
void moveWithoutEvent(QPoint pos);
void setParent(MainWindow* parent);
void setText(QString text);
void plot(int index, QString title, float data, int timeTick = -1);
//BluetoothWindow* getBluetoothWindow();
//BluetoothInterface* getBluetoothInterface();
OdometrieWindow* getOdometrieWindow();
AsservWindow* getAsservWindow();
//SharpWindow* getSharpWindow();
WatchWindow* getWatchWindow();
static DebugWindow* getInstance();
signals:
public slots:
void displayBluetoothWindow(bool show);
void displayBluetoothInterface(bool show);
void displayOdometrieWindow(bool show);
void displayAsservWindow(bool show);
void displaySharpWindow(bool show);
void displayWatchWindow(bool show);
void update();
void perspectiveAsserv();
void perspectiveOdometrie();
void perspectiveSimulateur();
void hideWindows();
void clearPlots();
private:
explicit DebugWindow();
virtual void moveEvent ( QMoveEvent * event );
void closeEvent(QCloseEvent *event);
void toggleWindow(QWidget* window, QAction* action = NULL);
static DebugWindow* _instance;
Ui::DebugWindow *ui;
MainWindow *parent;
/*BluetoothWindow* bluetoothWindow;
BluetoothInterface* bluetoothInterface;*/
OdometrieWindow* odometrieWindow;
AsservWindow* asservWindow;
//SharpWindow* sharpWindow;
WatchWindow* watchWindow;
bool attached, ready;
QLabel* statusLabel;
QPushButton* statusButton;
// plot
#ifdef USE_PLOT
QwtPlot* plotWidget;
QMap<int, PlotCurve*> plotCurves;
#endif
};
#endif // DEBUGWINDOW_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment