@ -81,16 +81,52 @@ updateTimer(new QTimer())
curvesWidgetLayout - > setMargin ( 2 ) ;
curvesWidgetLayout - > setMargin ( 2 ) ;
curvesWidgetLayout - > setSpacing ( 4 ) ;
curvesWidgetLayout - > setSpacing ( 4 ) ;
curvesWidgetLayout - > setSizeConstraint ( QLayout : : SetMinimumSize ) ;
curvesWidgetLayout - > setSizeConstraint ( QLayout : : SetMinimumSize ) ;
curvesWidgetLayout - > setAlignment ( Qt : : AlignTop ) ;
curvesWidget - > setLayout ( curvesWidgetLayout ) ;
curvesWidget - > setLayout ( curvesWidgetLayout ) ;
// Create curve list headings
QWidget * form = new QWidget ( this ) ;
QHBoxLayout * horizontalLayout ;
QLabel * label ;
QLabel * value ;
QLabel * mean ;
QLabel * variance ;
form - > setAutoFillBackground ( false ) ;
horizontalLayout = new QHBoxLayout ( form ) ;
horizontalLayout - > setSpacing ( 5 ) ;
horizontalLayout - > setMargin ( 0 ) ;
horizontalLayout - > setSizeConstraint ( QLayout : : SetMinimumSize ) ;
//horizontalLayout->addWidget(checkBox);
label = new QLabel ( form ) ;
label - > setText ( " Name " ) ;
horizontalLayout - > addWidget ( label ) ;
// Value
value = new QLabel ( form ) ;
value - > setText ( " Val " ) ;
horizontalLayout - > addWidget ( value ) ;
// Mean
mean = new QLabel ( form ) ;
mean - > setText ( " Mean " ) ;
horizontalLayout - > addWidget ( mean ) ;
// Variance
variance = new QLabel ( form ) ;
variance - > setText ( " Variance " ) ;
horizontalLayout - > addWidget ( variance ) ;
curvesWidgetLayout - > addWidget ( form ) ;
// Add and customize plot elements (right side)
// Add and customize plot elements (right side)
// Create the layout
// Create the layout
createLayout ( ) ;
createLayout ( ) ;
// Add the last actions
// Add the last actions
connect ( this , SIGNAL ( plotWindowPositionUpdated ( int ) ) , scrollbar , SLOT ( setValue ( int ) ) ) ;
//connect(this, SIGNAL(plotWindowPositionUpdated(int)), scrollbar, SLOT(setValue(int)));
connect ( scrollbar , SIGNAL ( sliderMoved ( int ) ) , this , SLOT ( setPlotWindowPosition ( int ) ) ) ;
//connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(setPlotWindowPosition(int)));
updateTimer - > setInterval ( 300 ) ;
updateTimer - > setInterval ( 300 ) ;
connect ( updateTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( refresh ( ) ) ) ;
connect ( updateTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( refresh ( ) ) ) ;
@ -131,6 +167,8 @@ void LinechartWidget::createLayout()
scalingLinearButton = createButton ( this ) ;
scalingLinearButton = createButton ( this ) ;
scalingLinearButton - > setDefaultAction ( setScalingLinear ) ;
scalingLinearButton - > setDefaultAction ( setScalingLinear ) ;
scalingLinearButton - > setCheckable ( true ) ;
scalingLinearButton - > setCheckable ( true ) ;
scalingLinearButton - > setToolTip ( tr ( " Set linear scale for Y axis " ) ) ;
scalingLinearButton - > setWhatsThis ( tr ( " Set linear scale for Y axis " ) ) ;
layout - > addWidget ( scalingLinearButton , 1 , 0 ) ;
layout - > addWidget ( scalingLinearButton , 1 , 0 ) ;
layout - > setColumnStretch ( 0 , 0 ) ;
layout - > setColumnStretch ( 0 , 0 ) ;
@ -138,13 +176,18 @@ void LinechartWidget::createLayout()
scalingLogButton = createButton ( this ) ;
scalingLogButton = createButton ( this ) ;
scalingLogButton - > setDefaultAction ( setScalingLogarithmic ) ;
scalingLogButton - > setDefaultAction ( setScalingLogarithmic ) ;
scalingLogButton - > setCheckable ( true ) ;
scalingLogButton - > setCheckable ( true ) ;
scalingLogButton - > setToolTip ( tr ( " Set logarithmic scale for Y axis " ) ) ;
scalingLogButton - > setWhatsThis ( tr ( " Set logarithmic scale for Y axis " ) ) ;
layout - > addWidget ( scalingLogButton , 1 , 1 ) ;
layout - > addWidget ( scalingLogButton , 1 , 1 ) ;
layout - > setColumnStretch ( 1 , 0 ) ;
layout - > setColumnStretch ( 1 , 0 ) ;
// Averaging spin box
// Averaging spin box
averageSpinBox = new QSpinBox ( this ) ;
averageSpinBox = new QSpinBox ( this ) ;
averageSpinBox - > setValue ( 200 ) ;
averageSpinBox - > setToolTip ( tr ( " Sliding window size to calculate mean and variance " ) ) ;
averageSpinBox - > setWhatsThis ( tr ( " Sliding window size to calculate mean and variance " ) ) ;
averageSpinBox - > setMinimum ( 2 ) ;
averageSpinBox - > setMinimum ( 2 ) ;
averageSpinBox - > setValue ( 200 ) ;
setAverageWindow ( 200 ) ;
averageSpinBox - > setMaximum ( 9999 ) ;
averageSpinBox - > setMaximum ( 9999 ) ;
layout - > addWidget ( averageSpinBox , 1 , 2 ) ;
layout - > addWidget ( averageSpinBox , 1 , 2 ) ;
layout - > setColumnStretch ( 2 , 0 ) ;
layout - > setColumnStretch ( 2 , 0 ) ;
@ -152,6 +195,8 @@ void LinechartWidget::createLayout()
// Log Button
// Log Button
logButton = new QToolButton ( this ) ;
logButton = new QToolButton ( this ) ;
logButton - > setToolTip ( tr ( " Start to log curve data into a CSV or TXT file " ) ) ;
logButton - > setWhatsThis ( tr ( " Start to log curve data into a CSV or TXT file " ) ) ;
logButton - > setText ( tr ( " Start Logging " ) ) ;
logButton - > setText ( tr ( " Start Logging " ) ) ;
layout - > addWidget ( logButton , 1 , 3 ) ;
layout - > addWidget ( logButton , 1 , 3 ) ;
layout - > setColumnStretch ( 3 , 0 ) ;
layout - > setColumnStretch ( 3 , 0 ) ;
@ -161,6 +206,8 @@ void LinechartWidget::createLayout()
QToolButton * timeButton = new QToolButton ( this ) ;
QToolButton * timeButton = new QToolButton ( this ) ;
timeButton - > setText ( tr ( " Ground Time " ) ) ;
timeButton - > setText ( tr ( " Ground Time " ) ) ;
timeButton - > setCheckable ( true ) ;
timeButton - > setCheckable ( true ) ;
timeButton - > setToolTip ( tr ( " Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time. " ) ) ;
timeButton - > setWhatsThis ( tr ( " Overwrite timestamp of data from vehicle with ground receive time. Helps if the plots are not visible because of missing or invalid onboard time. " ) ) ;
bool gTimeDefault = true ;
bool gTimeDefault = true ;
if ( activePlot ) activePlot - > enforceGroundTime ( gTimeDefault ) ;
if ( activePlot ) activePlot - > enforceGroundTime ( gTimeDefault ) ;
timeButton - > setChecked ( gTimeDefault ) ;
timeButton - > setChecked ( gTimeDefault ) ;
@ -169,18 +216,18 @@ void LinechartWidget::createLayout()
connect ( timeButton , SIGNAL ( clicked ( bool ) ) , activePlot , SLOT ( enforceGroundTime ( bool ) ) ) ;
connect ( timeButton , SIGNAL ( clicked ( bool ) ) , activePlot , SLOT ( enforceGroundTime ( bool ) ) ) ;
// Create the scroll bar
// Create the scroll bar
scrollbar = new QScrollBar ( Qt : : Horizontal , ui . diagramGroupBox ) ;
//scrollbar = new QScrollBar(Qt::Horizontal, ui.diagramGroupBox);
scrollbar - > setMinimum ( MIN_TIME_SCROLLBAR_VALUE ) ;
//scrollbar->setMinimum(MIN_TIME_SCROLLBAR_VALUE);
scrollbar - > setMaximum ( MAX_TIME_SCROLLBAR_VALUE ) ;
//scrollbar->setMaximum(MAX_TIME_SCROLLBAR_VALUE);
scrollbar - > setPageStep ( PAGESTEP_TIME_SCROLLBAR_VALUE ) ;
//scrollbar->setPageStep(PAGESTEP_TIME_SCROLLBAR_VALUE);
// Set scrollbar to maximum and disable it
// Set scrollbar to maximum and disable it
scrollbar - > setValue ( MIN_TIME_SCROLLBAR_VALUE ) ;
//scrollbar->setValue(MIN_TIME_SCROLLBAR_VALUE);
scrollbar - > setDisabled ( true ) ;
//scrollbar->setDisabled(true);
// scrollbar->setFixedHeight(20);
// scrollbar->setFixedHeight(20);
// Add scroll bar to layout and make sure it gets all available space
// Add scroll bar to layout and make sure it gets all available space
layout - > addWidget ( scrollbar , 1 , 5 ) ;
//layout->addWidget(scrollbar, 1, 5);
layout - > setColumnStretch ( 5 , 10 ) ;
layout - > setColumnStretch ( 5 , 10 ) ;
ui . diagramGroupBox - > setLayout ( layout ) ;
ui . diagramGroupBox - > setLayout ( layout ) ;
@ -406,6 +453,8 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
checkBox = new QCheckBox ( form ) ;
checkBox = new QCheckBox ( form ) ;
checkBox - > setCheckable ( true ) ;
checkBox - > setCheckable ( true ) ;
checkBox - > setObjectName ( curve ) ;
checkBox - > setObjectName ( curve ) ;
checkBox - > setToolTip ( tr ( " Enable the curve in the graph window " ) ) ;
checkBox - > setWhatsThis ( tr ( " Enable the curve in the graph window " ) ) ;
horizontalLayout - > addWidget ( checkBox ) ;
horizontalLayout - > addWidget ( checkBox ) ;
@ -431,12 +480,16 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
// Value
// Value
value = new QLabel ( form ) ;
value = new QLabel ( form ) ;
value - > setNum ( 0.00 ) ;
value - > setNum ( 0.00 ) ;
value - > setToolTip ( tr ( " Current value of " ) + curve ) ;
value - > setWhatsThis ( tr ( " Current value of " ) + curve ) ;
curveLabels - > insert ( curve , value ) ;
curveLabels - > insert ( curve , value ) ;
horizontalLayout - > addWidget ( value ) ;
horizontalLayout - > addWidget ( value ) ;
// Mean
// Mean
mean = new QLabel ( form ) ;
mean = new QLabel ( form ) ;
mean - > setNum ( 0.00 ) ;
mean - > setNum ( 0.00 ) ;
mean - > setToolTip ( tr ( " Arithmetic mean of " ) + curve ) ;
mean - > setWhatsThis ( tr ( " Arithmetic mean of " ) + curve ) ;
curveMeans - > insert ( curve , mean ) ;
curveMeans - > insert ( curve , mean ) ;
horizontalLayout - > addWidget ( mean ) ;
horizontalLayout - > addWidget ( mean ) ;
@ -449,6 +502,8 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
// Variance
// Variance
variance = new QLabel ( form ) ;
variance = new QLabel ( form ) ;
variance - > setNum ( 0.00 ) ;
variance - > setNum ( 0.00 ) ;
variance - > setToolTip ( tr ( " Variance of " ) + curve ) ;
variance - > setWhatsThis ( tr ( " Variance of " ) + curve ) ;
curveVariances - > insert ( curve , variance ) ;
curveVariances - > insert ( curve , variance ) ;
horizontalLayout - > addWidget ( variance ) ;
horizontalLayout - > addWidget ( variance ) ;
@ -584,14 +639,14 @@ void LinechartWidget::setPlotWindowPosition(quint64 position) {
// A relative position makes only sense if the plot is filled
// A relative position makes only sense if the plot is filled
if ( activePlot - > getDataInterval ( ) > activePlot - > getPlotInterval ( ) ) {
if ( activePlot - > getDataInterval ( ) > activePlot - > getPlotInterval ( ) ) {
//TODO @todo Implement the scrollbar enabling in a more elegant way
//TODO @todo Implement the scrollbar enabling in a more elegant way
scrollbar - > setDisabled ( false ) ;
//scrollbar->setDisabled(false);
quint64 scrollInterval = position - activePlot - > getMinTime ( ) - activePlot - > getPlotInterval ( ) ;
quint64 scrollInterval = position - activePlot - > getMinTime ( ) - activePlot - > getPlotInterval ( ) ;
pos = ( static_cast < double > ( scrollInterval ) / ( activePlot - > getDataInterval ( ) - activePlot - > getPlotInterval ( ) ) ) ;
pos = ( static_cast < double > ( scrollInterval ) / ( activePlot - > getDataInterval ( ) - activePlot - > getPlotInterval ( ) ) ) ;
} else {
} else {
scrollbar - > setDisabled ( true ) ;
//scrollbar->setDisabled(true);
pos = 1 ;
pos = 1 ;
}
}
plotWindowLock . unlock ( ) ;
plotWindowLock . unlock ( ) ;
@ -607,7 +662,8 @@ void LinechartWidget::setPlotWindowPosition(quint64 position) {
*
*
* @ param interval The time interval to plot
* @ param interval The time interval to plot
* */
* */
void LinechartWidget : : setPlotInterval ( quint64 interval ) {
void LinechartWidget : : setPlotInterval ( quint64 interval )
{
activePlot - > setPlotInterval ( interval ) ;
activePlot - > setPlotInterval ( interval ) ;
}
}
@ -618,7 +674,8 @@ void LinechartWidget::setPlotInterval(quint64 interval) {
*
*
* @ param checked The visibility of the curve : true to display the curve , false otherwise
* @ param checked The visibility of the curve : true to display the curve , false otherwise
* */
* */
void LinechartWidget : : takeButtonClick ( bool checked ) {
void LinechartWidget : : takeButtonClick ( bool checked )
{
QCheckBox * button = qobject_cast < QCheckBox * > ( QObject : : sender ( ) ) ;
QCheckBox * button = qobject_cast < QCheckBox * > ( QObject : : sender ( ) ) ;
@ -635,7 +692,8 @@ void LinechartWidget::takeButtonClick(bool checked) {
* @ param text The button text
* @ param text The button text
* @ param parent The parent object ( to ensure that the memory is freed after the deletion of the button )
* @ param parent The parent object ( to ensure that the memory is freed after the deletion of the button )
* */
* */
QToolButton * LinechartWidget : : createButton ( QWidget * parent ) {
QToolButton * LinechartWidget : : createButton ( QWidget * parent )
{
QToolButton * button = new QToolButton ( parent ) ;
QToolButton * button = new QToolButton ( parent ) ;
button - > setMinimumSize ( QSize ( 20 , 20 ) ) ;
button - > setMinimumSize ( QSize ( 20 , 20 ) ) ;
button - > setMaximumSize ( 60 , 20 ) ;
button - > setMaximumSize ( 60 , 20 ) ;