Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Oct 6, 2017
1 parent 8987272 commit 5673815
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 41 deletions.
2 changes: 1 addition & 1 deletion include/PlotJuggler/dataloader_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DataLoader{

virtual const std::vector<const char*>& compatibleFileExtensions() const = 0;

virtual PlotDataMap readDataFromFile(const QString& file_name) = 0;
virtual PlotDataMap readDataFromFile(const QString& file_name, bool use_previous_configuration) = 0;

virtual const char* name() const = 0;

Expand Down
27 changes: 20 additions & 7 deletions plotter_gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ MainWindow::MainWindow(const QCommandLineParser &commandline_parser, QWidget *pa
this, SLOT(onActionLoadStreamer(QString)) );

ui->actionDeleteAllData->setEnabled( _test_option );
ui->actionReloadPrevious->setEnabled( false );

if( _test_option )
{
Expand Down Expand Up @@ -351,10 +352,12 @@ void MainWindow::createActions()
connect(ui->actionSaveLayout, &QAction::triggered, this, &MainWindow::onActionSaveLayout );
connect(ui->actionLoadLayout, &QAction::triggered, this, &MainWindow::onActionLoadLayout );
connect(ui->actionLoadData, &QAction::triggered, this, &MainWindow::onActionLoadDataFile );
connect(ui->actionLoadRecentDatafile, &QAction::triggered, this, &MainWindow::onActionReloadDataFileFromSettings );
connect(ui->actionLoadRecentDatafile, &QAction::triggered, this, &MainWindow::onActionReloadRecentDataFile );
connect(ui->actionLoadRecentLayout, &QAction::triggered, this, &MainWindow::onActionReloadRecentLayout );
connect(ui->actionDeleteAllData, &QAction::triggered, this, &MainWindow::onDeleteLoadedData );

connect(ui->actionReloadPrevious, &QAction::triggered, this, &MainWindow::onReloadDatafile );

//---------------------------------------------

QSettings settings( "IcarusTechnology", "PlotJuggler");
Expand Down Expand Up @@ -859,6 +862,11 @@ void MainWindow::onActionLoadDataFile(bool reload_from_settings)
onActionLoadDataFileImpl(filename, false );
}

void MainWindow::onReloadDatafile()
{

}

void MainWindow::importPlotDataMap(const PlotDataMap& new_data, bool delete_older)
{
// overwrite the old user_defined map
Expand Down Expand Up @@ -987,10 +995,11 @@ void MainWindow::onActionLoadDataFileImpl(QString filename, bool reuse_last_conf

_loaded_datafile = filename;
ui->actionDeleteAllData->setEnabled( true );
ui->actionReloadPrevious->setEnabled( true );

PlotDataMap mapped_data;
try{
mapped_data = _last_dataloader->readDataFromFile( filename );
mapped_data = _last_dataloader->readDataFromFile( filename, reuse_last_configuration );
}
catch(std::exception &ex)
{
Expand All @@ -1012,7 +1021,7 @@ void MainWindow::onActionLoadDataFileImpl(QString filename, bool reuse_last_conf
}


void MainWindow::onActionReloadDataFileFromSettings()
void MainWindow::onActionReloadRecentDataFile()
{
onActionLoadDataFile( true );
}
Expand Down Expand Up @@ -1066,6 +1075,7 @@ void MainWindow::onActionLoadStreamer(QString streamer_name)
ui->actionStopStreaming->setEnabled(true);
ui->actionDeleteAllData->setEnabled( false );
ui->actionDeleteAllData->setToolTip("Stop streaming to be able to delete the data");
ui->actionReloadPrevious->setEnabled( false );

ui->pushButtonStreaming->setEnabled(true);
ui->pushButtonStreaming->setChecked(true);
Expand Down Expand Up @@ -1229,13 +1239,16 @@ void MainWindow::onActionLoadLayoutFromFile(QString filename, bool load_data)

QMessageBox::StandardButton reload_previous;
reload_previous = QMessageBox::question(0, tr("Wait!"),
tr("Do you want to reload the previous datafile and its configuration?\n\n[%1]\n").arg(filename),
QMessageBox::Yes | QMessageBox::No,
tr("Do you want to reload the previous datafile and its configuration?\n\n %1 \n\n"
"Yes: reload both the file and the previous configuration.\n"
"YesToAll: reload the file but change the previous configuration.\n"
"No: use the already loaded data.\n").arg(filename),
QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes );

if( reload_previous == QMessageBox::Yes )
if( reload_previous != QMessageBox::No )
{
onActionLoadDataFileImpl( filename, true );
onActionLoadDataFileImpl( filename, reload_previous == QMessageBox::YesToAll );
}
}

Expand Down
4 changes: 3 additions & 1 deletion plotter_gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ private slots:

void onActionLoadDataFile(bool reload_from_settings = false);

void onReloadDatafile();

void onActionLoadDataFileImpl(QString filename, bool reuse_last_configuration = false );

void onActionReloadDataFileFromSettings();
void onActionReloadRecentDataFile();

void onActionReloadRecentLayout();

Expand Down
6 changes: 6 additions & 0 deletions plotter_gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ background: white;
</property>
<addaction name="actionLoadData"/>
<addaction name="actionLoadRecentDatafile"/>
<addaction name="actionReloadPrevious"/>
<addaction name="actionDeleteAllData"/>
<addaction name="separator"/>
<addaction name="actionLoadLayout"/>
Expand Down Expand Up @@ -547,6 +548,11 @@ background: white;
<string>Clear buffer</string>
</property>
</action>
<action name="actionReloadPrevious">
<property name="text">
<string>Reload previous</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down
6 changes: 3 additions & 3 deletions plugins/DataLoadCSV/dataload_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int DataLoadCSV::parseHeader(QFile *file,
return linecount;
}

PlotDataMap DataLoadCSV::readDataFromFile(const QString &file_name)
PlotDataMap DataLoadCSV::readDataFromFile(const QString &file_name, bool use_previous_configuration)
{
const int TIME_INDEX_NOT_DEFINED = -2;

Expand Down Expand Up @@ -175,7 +175,7 @@ PlotDataMap DataLoadCSV::readDataFromFile(const QString &file_name)
}
}

if( time_index == TIME_INDEX_NOT_DEFINED)
if( time_index == TIME_INDEX_NOT_DEFINED && !use_previous_configuration)
{
QStringList field_names;
field_names.push_back( "INDEX (auto-generated)" );
Expand All @@ -193,9 +193,9 @@ PlotDataMap DataLoadCSV::readDataFromFile(const QString &file_name)
// vector is supposed to have only one element
time_index = dialog->getSelectedRowNumber().at(0) -1;
_default_time_axis = field_names.at( time_index + 1 ) ;
settings.setValue("DataLoadCSV/default_time_axis", _default_time_axis);
}

settings.setValue("DataLoadCSV/default_time_axis", _default_time_axis);
//-----------------

while (!inB.atEnd())
Expand Down
2 changes: 1 addition & 1 deletion plugins/DataLoadCSV/dataload_csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DataLoadCSV: public QObject, DataLoader
DataLoadCSV();
virtual const std::vector<const char*>& compatibleFileExtensions() const override;

virtual PlotDataMap readDataFromFile(const QString& file_name ) override;
virtual PlotDataMap readDataFromFile(const QString& file_name, bool use_previous_configuration ) override;

virtual ~DataLoadCSV();

Expand Down
49 changes: 22 additions & 27 deletions plugins/ROS/DataLoadROS/dataload_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ size_t getAvailableRAM()
return info.freeram;
}

PlotDataMap DataLoadROS::readDataFromFile(const QString &file_name)
PlotDataMap DataLoadROS::readDataFromFile(const QString &file_name, bool use_previous_configuration)
{
if( _bag ) _bag->close();

Expand Down Expand Up @@ -88,38 +88,33 @@ PlotDataMap DataLoadROS::readDataFromFile(const QString &file_name)

DialogSelectRosTopics* dialog = new DialogSelectRosTopics( all_topics, _default_topic_names );

std::set<std::string> topic_selected;

if( dialog->exec() == static_cast<int>(QDialog::Accepted) )
if( !use_previous_configuration )
{
_default_topic_names.clear();

const auto& selected_items = dialog->getSelectedItems();
for(const auto& item: selected_items)
if( dialog->exec() == static_cast<int>(QDialog::Accepted) )
{
std::string ss_topic = item.toStdString();
topic_selected.insert( ss_topic );
_default_topic_names = dialog->getSelectedItems();

// change the names in load_configuration
_default_topic_names.push_back( item );
}
// load the rules
if( dialog->checkBoxUseRenamingRules()->isChecked())
{
_rules = RuleEditing::getRenamingRules();
}
else{
_rules.clear();
}
for(const auto& it: _rules)
{
RosIntrospectionFactory::parser().registerRenamingRules( ROSType(it.first) , it.second );
// load the rules
if( dialog->checkBoxUseRenamingRules()->isChecked())
{
_rules = RuleEditing::getRenamingRules();
}
else{
_rules.clear();
}
for(const auto& it: _rules) {
RosIntrospectionFactory::parser().registerRenamingRules( ROSType(it.first) , it.second );
}
}
settings.setValue("DataLoadROS/default_topics", _default_topic_names);
}

settings.setValue("DataLoadROS/default_topics", _default_topic_names);

//-----------------------------------
std::set<std::string> topic_selected;
for(const auto& topic: _default_topic_names)
{
topic_selected.insert( topic.toStdString() );
}

QProgressDialog progress_dialog;
progress_dialog.setLabelText("Loading... please wait");
progress_dialog.setWindowModality( Qt::ApplicationModal );
Expand Down
2 changes: 1 addition & 1 deletion plugins/ROS/DataLoadROS/dataload_ros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DataLoadROS: public QObject, DataLoader
DataLoadROS();
virtual const std::vector<const char*>& compatibleFileExtensions() const override;

virtual PlotDataMap readDataFromFile(const QString& file_name ) override;
virtual PlotDataMap readDataFromFile(const QString& file_name, bool use_previous_configuration ) override;

virtual const char* name() const override { return "DataLoad ROS bags"; }

Expand Down

0 comments on commit 5673815

Please sign in to comment.