Added ability to create multiple graphing windows that act separately.
Added ability to right check on signals in main view and graph them directly.
This commit is contained in:
+36
-2
@@ -120,6 +120,26 @@ void GraphingWindow::closeEvent(QCloseEvent *event)
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
void GraphingWindow::changeEvent(QEvent *event)
|
||||
{
|
||||
QWidget::changeEvent(event);
|
||||
if (event->type() == QEvent::ActivationChange)
|
||||
{
|
||||
if(this->isActiveWindow())
|
||||
{
|
||||
setWindowOpacity(1);
|
||||
ui->graphingView->repaint();
|
||||
qDebug() << "Show";
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowOpacity(0.25);
|
||||
// widget is now inactive
|
||||
qDebug() << "Hide";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingWindow::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
@@ -268,6 +288,8 @@ void GraphingWindow::gotCenterTimeID(int32_t ID, double timestamp)
|
||||
//{
|
||||
//}
|
||||
|
||||
qDebug() << "Trying to center graph on timestamp: " << timestamp;
|
||||
|
||||
QCPRange range = ui->graphingView->xAxis->range();
|
||||
double offset = range.size() / 2.0;
|
||||
if (!secondsMode) timestamp *= 1000000.0; //timestamp is always in seconds when being passed so convert if necessary
|
||||
@@ -1312,6 +1334,17 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
ui->graphingView->graph()->setBrush(fillBrush);
|
||||
}
|
||||
|
||||
double xRange = (xmaxval - xminval);
|
||||
double yRange = (ymaxval - yminval);
|
||||
double xMid = xminval + (xRange / 2.0);
|
||||
double yMid = yminval + (yRange / 2.0);
|
||||
|
||||
//creates a slightly larger view than the actual boundary values to give some padding
|
||||
xminval = xMid - (xRange / 1.95);
|
||||
xmaxval = xMid + (xRange / 1.95);
|
||||
yminval = yMid - (yRange / 1.85);
|
||||
ymaxval = yMid + (yRange / 1.85);
|
||||
|
||||
qDebug() << "xmin: " << xminval;
|
||||
qDebug() << "xmax: " << xmaxval;
|
||||
qDebug() << "ymin: " << yminval;
|
||||
@@ -1320,10 +1353,11 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
if (needScaleSetup)
|
||||
{
|
||||
needScaleSetup = false;
|
||||
ui->graphingView->xAxis->setRange(xminval, xmaxval);
|
||||
ui->graphingView->yAxis->setRange(yminval, ymaxval);
|
||||
ui->graphingView->xAxis->setRange(xminval, xmaxval);
|
||||
ui->graphingView->axisRect()->setupFullAxesBox();
|
||||
}
|
||||
//always recalculate Y range so that new graphs actually show up in view
|
||||
ui->graphingView->yAxis->setRange(yminval, ymaxval);
|
||||
|
||||
ui->graphingView->replot();
|
||||
}
|
||||
|
||||
+5
-2
@@ -45,6 +45,9 @@ public:
|
||||
~GraphingWindow();
|
||||
void showEvent(QShowEvent*);
|
||||
|
||||
public slots:
|
||||
void createGraph(GraphParams ¶ms, bool createGraphParam = true);
|
||||
|
||||
private slots:
|
||||
void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);
|
||||
void axisDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
|
||||
@@ -66,8 +69,7 @@ private slots:
|
||||
void rescaleAxis(QCPAxis* axis);
|
||||
void rescaleToData();
|
||||
void toggleFollowMode();
|
||||
void addNewGraph();
|
||||
void createGraph(GraphParams ¶ms, bool createGraphParam = true);
|
||||
void addNewGraph();
|
||||
void appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector<double> &x, QVector<double> &y);
|
||||
void editSelectedGraph();
|
||||
void updatedFrames(int);
|
||||
@@ -99,6 +101,7 @@ private:
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void changeEvent(QEvent *event);
|
||||
};
|
||||
|
||||
#endif // GRAPHINGWINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user