Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce environment variables to skip dialogs to automate PlotJuggler usage #811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ Note that this also affect the desktop launcher.

You can find find the detailed instructions here: [COMPILE.md](COMPILE.md).

## Auto start previously used streaming plugin
When loading a layout that includes a streaming plugin, PlotJuggler asks `Start the previously used streaming plugin?`, in order to automatically
click on `Yes`, you can set the environment variable: `PLOTJUGGLER_ACCEPT_PREVIOUSLY_USED_STREAMING_PLUGIN=1` and this dialog will be skipped.

## Automatically choose 'Create empty placeholders' when data from a layout is missing
When loading a layout some timeseries may be missing, PlotJuggler may ask `One or more timeseries in the layout haven't been loaded yet, What do you want to do?`, with the options: `Remove curves from plots` and `Create empty placeholders`. To automate choosing `Create empty placeholders` you can set the environment variable: `PLOTJUGGLER_CHOOSE_EMPTY_PLACEHOLDERS_ON_MISSING_TIMESERIES=1` and the dialog will be skipped chosing that option.


# Sponsorship and commercial support

PlotJuggler required a lot of work to be developed; my goal is to build the most
Expand Down
29 changes: 25 additions & 4 deletions plotjuggler_app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,20 @@ void MainWindow::checkAllCurvesFromLayout(const QDomElement& root)
QPushButton* buttonPlaceholder =
msgBox.addButton(tr("Create empty placeholders"), QMessageBox::YesRole);
msgBox.setDefaultButton(buttonPlaceholder);
msgBox.exec();
if (msgBox.clickedButton() == buttonPlaceholder)

const char* env_var = std::getenv("PLOTJUGGLER_CHOOSE_EMPTY_PLACEHOLDERS_ON_MISSING_TIMESERIES");
bool skip_msg_box = (env_var != nullptr && env_var[0] == '1');
if(skip_msg_box){
qDebug() << "Environment variable PLOTJUGGLER_CHOOSE_EMPTY_PLACEHOLDERS_ON_MISSING_TIMESERIES set."
<< " Skipping dialog.\n";
// To enable the user to choose manually in the future
setenv("PLOTJUGGLER_CHOOSE_EMPTY_PLACEHOLDERS_ON_MISSING_TIMESERIES", "0", 1);
}
if (!skip_msg_box){
msgBox.exec();
}

if (skip_msg_box || msgBox.clickedButton() == buttonPlaceholder)
{
for (auto& name : missing_curves)
{
Expand Down Expand Up @@ -2059,9 +2071,18 @@ bool MainWindow::loadLayoutFromFile(QString filename)
QPushButton* yes = msgBox.addButton(tr("Yes"), QMessageBox::YesRole);
QPushButton* no = msgBox.addButton(tr("No"), QMessageBox::RejectRole);
msgBox.setDefaultButton(yes);
msgBox.exec();

if (msgBox.clickedButton() == yes)
const char* env_var = std::getenv("PLOTJUGGLER_ACCEPT_PREVIOUSLY_USED_STREAMING_PLUGIN");
bool skip_msg_box = (env_var != nullptr && env_var[0] == '1');
if (skip_msg_box){
qDebug() << "Environment variable PLOTJUGGLER_ACCEPT_PREVIOUSLY_USED_STREAMING_PLUGIN set."
<< " Skipping dialog.\n";
}
else{
msgBox.exec();
}

if (skip_msg_box || msgBox.clickedButton() == yes)
{
if (_data_streamer.count(streamer_name) != 0)
{
Expand Down