Skip to content
Snippets Groups Projects
Commit 07d4f566 authored by Jake's avatar Jake
Browse files

Graph in GUI

parent 405d4cca
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ void ControlWorker::getNodes()
/* Add nodes */
for (size_t i = 0; i < num_nodes; i++) {
graph_add_node_id(cgraph, nd[i].block, nd[i].name, blockDefs[nd[i].type], NULL);
graph_add_node_id(cgraph, nd[i].block, nd[i].name, blockDefs[nd[i].type]);
}
/* Set sources */
......@@ -86,11 +86,11 @@ void ControlWorker::getNodes()
/* This is a massive hack... */
/* Could be done with popen, but fuck it */
FILE * dotfile = fopen("/tmp/ucart-tmp-graph.dot", "rw");
FILE * dotfile = fopen("/tmp/ucart-tmp-graph.dot", "w");
if (dotfile) {
export_dot(cgraph, dotfile, 0);
fclose(dotfile);
if (int dot_exit = QProcess::execute("dot /tmp/ucart-tmp/graph.dot -Tpng -o /tmp/ucart-tmp-graph.png")) {
if (int dot_exit = QProcess::execute("dot /tmp/ucart-tmp-graph.dot -Tpng -o /tmp/ucart-tmp-graph.png")) {
warnx("dot returned nonzero value (%d)", dot_exit);
} else {
emit(graphRendered(QString("/tmp/ucart-tmp-graph.png")));
......
......@@ -50,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(controlWorker, SIGNAL (gotParams(QStringList)), this, SLOT (newParams(QStringList)));
connect(controlWorker, SIGNAL (gotParamValue(QString, QString, float)), this, SLOT (newParamValue(QString, QString, float)));
connect(controlWorker, SIGNAL (gotConstantBlocks(QStringList)), this, SLOT (newConstantBlocks(QStringList)));
connect(controlWorker, SIGNAL (graphRendered(QString)), this, SLOT (newControlGraph(QString)));
connect(controlWorker, SIGNAL (paramSet(QString, QString)), controlWorker, SLOT (getParamValue(QString, QString)));
/* Signals to control worker */
......@@ -298,3 +299,12 @@ void MainWindow::newControlGraph(QString graph)
{
findChild<QLabel *>("graphImage")->setPixmap(QPixmap(graph));
}
void MainWindow::on_pbActualToWaypoint_clicked()
{
QString str("[" + findChild<QLineEdit *>("xActual")->text() + ", "+
findChild<QLineEdit *>("yActual")->text() + ", " +
findChild<QLineEdit *>("zActual")->text() + "]");
setpointList->appendRow(new QStandardItem(str));
}
......@@ -57,6 +57,8 @@ private slots:
void on_pbDeleteSetpoint_clicked();
void on_pbActualToWaypoint_clicked();
private:
Ui::MainWindow *ui;
pid_t backendPid;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<height>596</height>
<width>1369</width>
<height>995</height>
</rect>
</property>
<property name="windowTitle">
......@@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="backend">
<attribute name="title">
......@@ -142,19 +142,43 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="graphImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Refresh to display controller graph</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1333</width>
<height>727</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="graphImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>32</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
......@@ -307,6 +331,9 @@
<underline>true</underline>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLabel {color : red; }</string>
</property>
<property name="text">
<string>NO CONTROL GRAPH LOADED!</string>
</property>
......@@ -483,6 +510,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbActualToWaypoint">
<property name="text">
<string>To Waypoint</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
......@@ -665,6 +699,75 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="autonavEnabled">
<property name="text">
<string>Auto</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delay</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="autonavDelay">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>1500</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbSaveWaypoints">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbLoadWaypoints">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
......@@ -700,7 +803,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<width>1369</width>
<height>30</height>
</rect>
</property>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment