Skip to content

Commit

Permalink
- Remember the size of the dialogs
Browse files Browse the repository at this point in the history
- Fix #1
  • Loading branch information
martonmiklos committed Feb 22, 2019
1 parent 853194c commit 2e10800
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 5 deletions.
5 changes: 5 additions & 0 deletions include/rqt_plot_qtcharts/dialogaxes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <QDialog>

#include <rqt_gui_cpp/plugin.h>

namespace Ui {
class DialogAxes;
}
Expand All @@ -18,6 +20,9 @@ class DialogAxes : public QDialog
~DialogAxes();
void refreshAxisList();

void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);

private slots:
void on_toolButtonAddAxis_clicked();
void on_toolButtonRemoveAxis_clicked();
Expand Down
5 changes: 5 additions & 0 deletions include/rqt_plot_qtcharts/dialogaxisproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <QDialog>
#include <QShowEvent>

#include <rqt_gui_cpp/plugin.h>

namespace Ui {
class DialogAxisProperties;
}
Expand All @@ -21,6 +23,9 @@ class DialogAxisProperties : public QDialog

void showEvent(QShowEvent *event);

void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);

PlotLineSeries *series() const;
void setSeries(PlotLineSeries *series);

Expand Down
10 changes: 10 additions & 0 deletions include/rqt_plot_qtcharts/dialogplotseriesproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "plotlineseries.h"

#include <QCloseEvent>
#include <QDialog>

#include <rqt_gui_cpp/plugin.h>

namespace Ui {
class DialogPlotSeriesProperties;
}
Expand All @@ -17,11 +20,17 @@ class DialogPlotSeriesProperties : public QDialog
DialogPlotSeriesProperties(QWidget *parent = 0);
~DialogPlotSeriesProperties();

void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);

PlotLineSeries *series() const;
void setSeries(PlotLineSeries *series);

void updateAxesComboBox();

QByteArray geometry() const;
void setGeometry(const QByteArray &geometry);

private slots:
void on_toolButtonSelectColor_clicked();
void on_DialogPlotSeriesProperties_accepted();
Expand All @@ -31,6 +40,7 @@ private slots:

PlotLineSeries *m_series = nullptr;
QColor m_color = Qt::red;
QByteArray m_geometry;
};

#endif // DIALOGPLOTSERIESPROPERTIES_H
6 changes: 5 additions & 1 deletion include/rqt_plot_qtcharts/dialogseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <QDialog>

#include <rqt_gui_cpp/plugin.h>

namespace Ui {
class DialogSeries;
}
Expand All @@ -18,9 +20,11 @@ class DialogSeries : public QDialog
explicit DialogSeries(QWidget *parent = 0);
~DialogSeries();

void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);

private slots:
void on_tableViewSeries_doubleClicked(const QModelIndex &index);

void on_tableViewSeries_customContextMenuRequested(const QPoint &pos);

private:
Expand Down
10 changes: 10 additions & 0 deletions src/rqt_plot_qtcharts/dialogaxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ void DialogAxes::refreshAxisList()
ui->tableViewAxesList->horizontalHeader()->setSectionResizeMode(VerticalAxesModel::Col_Visible, QHeaderView::ResizeToContents);
}

void DialogAxes::saveSettings(qt_gui_cpp::Settings &instance_settings) const
{
instance_settings.setValue("DialogAxes.geometry", saveGeometry());
}

void DialogAxes::restoreSettings(const qt_gui_cpp::Settings &instance_settings)
{
restoreGeometry(instance_settings.value("DialogAxes.geometry").toByteArray());
}

void DialogAxes::on_toolButtonAddAxis_clicked()
{
VerticalAxis *axis = new VerticalAxis();
Expand Down
10 changes: 10 additions & 0 deletions src/rqt_plot_qtcharts/dialogaxisproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ void DialogAxisProperties::showEvent(QShowEvent *event)
QDialog::showEvent(event);
}

void DialogAxisProperties::saveSettings(qt_gui_cpp::Settings &instance_settings) const
{
instance_settings.setValue("DialogAxisProperties.geometry", saveGeometry());
}

void DialogAxisProperties::restoreSettings(const qt_gui_cpp::Settings &instance_settings)
{
restoreGeometry(instance_settings.value("DialogAxisProperties.geometry").toByteArray());
}


void DialogAxisProperties::on_checkBoxAutoScale_toggled(bool checked)
{
Expand Down
20 changes: 20 additions & 0 deletions src/rqt_plot_qtcharts/dialogplotseriesproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ DialogPlotSeriesProperties::~DialogPlotSeriesProperties()
delete ui;
}

void DialogPlotSeriesProperties::saveSettings(qt_gui_cpp::Settings &instance_settings) const
{
instance_settings.setValue("DialogPlotSeriesProperties.geometry", saveGeometry());
}

void DialogPlotSeriesProperties::restoreSettings(const qt_gui_cpp::Settings &instance_settings)
{
restoreGeometry(instance_settings.value("DialogPlotSeriesProperties.geometry").toByteArray());
}

PlotLineSeries *DialogPlotSeriesProperties::series() const
{
return m_series;
Expand Down Expand Up @@ -69,3 +79,13 @@ void DialogPlotSeriesProperties::on_DialogPlotSeriesProperties_accepted()
m_series->setWidth(ui->doubleSpinBoxWidth->value());
m_series->setVerticalAxis(VerticalAxesManager::instance()->axes().at(ui->comboBoxYAxis->currentIndex()));
}

QByteArray DialogPlotSeriesProperties::geometry() const
{
return m_geometry;
}

void DialogPlotSeriesProperties::setGeometry(const QByteArray &geometry)
{
m_geometry = geometry;
}
10 changes: 10 additions & 0 deletions src/rqt_plot_qtcharts/dialogseries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ DialogSeries::~DialogSeries()
delete ui;
}

void DialogSeries::saveSettings(qt_gui_cpp::Settings &instance_settings) const
{
instance_settings.setValue("DialogSeries.geometry", saveGeometry());
}

void DialogSeries::restoreSettings(const qt_gui_cpp::Settings &instance_settings)
{
restoreGeometry(instance_settings.value("DialogSeries.geometry").toByteArray());
}

void DialogSeries::on_tableViewSeries_doubleClicked(const QModelIndex &index)
{
if (!m_seriesPropertiesDialog)
Expand Down
15 changes: 11 additions & 4 deletions src/rqt_plot_qtcharts/rqt_plot_qtcharts_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PlotQtChartsWidget::PlotQtChartsWidget(QWidget *parent) :
ui->setupUi(this);

m_axesDialog = new DialogAxes(this);
m_seriesDialog = new DialogSeries(this);

m_subscriber = m_nodeHandle.subscribe("/tiva_arm/PIDoutput", 1, &PlotQtChartsWidget::debugCallback, this);

m_axisX = new QValueAxis(this);
Expand All @@ -30,6 +32,7 @@ PlotQtChartsWidget::PlotQtChartsWidget(QWidget *parent) :
this, &PlotQtChartsWidget::axisAdded);
connect(VerticalAxesManager::instance(), &VerticalAxesManager::axisRemoved,
this, &PlotQtChartsWidget::axisRemoved);

}

PlotQtChartsWidget::~PlotQtChartsWidget()
Expand All @@ -42,13 +45,19 @@ void PlotQtChartsWidget::saveSettings(qt_gui_cpp::Settings &instance_settings) c
instance_settings.setValue("lastTopic", ui->lineEditTopic->text());
saveAxes(instance_settings);
saveSeries(instance_settings);

m_seriesDialog->saveSettings(instance_settings);
m_axesDialog->saveSettings(instance_settings);
}

void PlotQtChartsWidget::restoreSettings(const qt_gui_cpp::Settings &instance_settings)
{
ui->lineEditTopic->setText(instance_settings.value("lastTopic", "/").toString());
restoreAxes(instance_settings);
restoreSeries(instance_settings);

m_seriesDialog->restoreSettings(instance_settings);
m_axesDialog->restoreSettings(instance_settings);
}


Expand Down Expand Up @@ -205,8 +214,6 @@ PlotLineSeries *SeriesRemoveAction::series() const

void PlotQtChartsWidget::on_toolButtonSeries_clicked()
{
if (!m_seriesDialog)
m_seriesDialog = new DialogSeries(this);
m_seriesDialog->show();
}

Expand All @@ -233,9 +240,9 @@ void PlotQtChartsWidget::seriesAdded(PlotLineSeries *newSeries)
});

ui->zoomableChartWidget->chart()->addSeries(newSeries);
ui->zoomableChartWidget->chart()->setAxisX(m_axisX, newSeries);
ui->zoomableChartWidget->chart()->axes(Qt::Horizontal, newSeries).append(m_axisX);
if (newSeries->verticalAxis())
ui->zoomableChartWidget->chart()->setAxisY(newSeries->verticalAxis(), newSeries);
ui->zoomableChartWidget->chart()->axes(Qt::Vertical, newSeries).append(newSeries->verticalAxis());
ui->zoomableChartWidget->connectLegendMarkerEvents();
}

Expand Down

0 comments on commit 2e10800

Please sign in to comment.