3 #include <QApplication> 4 #include <QSplashScreen> 6 #include <QCommandLineParser> 7 #include <QDesktopWidget> 8 #include <QFontDatabase> 13 qsrand(time(
nullptr));
18 while( settings.value(
"previousFunnySubtitle").toInt() == n)
22 settings.setValue(
"previousFunnySubtitle", n);
26 case 0:
return "PlotJuggler does it better";
27 case 1:
return "Talk is cheap, show me the data!";
28 case 2:
return "The visualization tool that you deserve";
29 case 3:
return "Who needs Matlab?";
30 case 4:
return "Changing the world, one plot at a time";
31 case 5:
return "\"Harry Plotter\" was also an option";
32 case 6:
return "I like the smell of plots in the morning";
33 case 7:
return "Timeseries, timeseries everywhere...";
34 case 8:
return "I didn't find a better name...";
35 case 9:
return "\"It won't take long to implement that\"\n" 37 case 10:
return "Visualize data responsibly";
38 case 11:
return "How could you live without it?";
39 case 12:
return "This time you will find that nasty bug!";
40 case 13:
return "Now, with less bugs than usual!";
41 case 14:
return "You log them, I visualize them";
42 case 15:
return "The fancy timeseries visualization tool";
43 case 16:
return "Send me a PR with your splashscreen phrase!";
45 default:
return "I don't always visualize data,\n" 46 "but when I do, I use PlotJuggler";
50 int main(
int argc,
char *argv[])
52 QApplication
app(argc, argv);
54 app.setOrganizationName(
"IcarusTechnology");
55 app.setApplicationName(
"PlotJuggler");
58 QFile styleFile(
"://style/stylesheet.qss" );
59 styleFile.open( QFile::ReadOnly );
62 QString style( styleFile.readAll() );
63 app.setStyleSheet( style );
65 QString VERSION_STRING = QString(
"%1.%2.%3").
66 arg(PJ_MAJOR_VERSION).
67 arg(PJ_MINOR_VERSION).
68 arg(PJ_PATCH_VERSION);
70 app.setApplicationVersion(VERSION_STRING);
73 parser.setApplicationDescription(
"PlotJuggler: the time series visualization tool that you deserve ");
74 parser.addVersionOption();
75 parser.addHelpOption();
77 QCommandLineOption nosplash_option(QStringList() <<
"n" <<
"nosplash",
78 "Don't display the splashscreen");
79 parser.addOption(nosplash_option);
81 QCommandLineOption test_option(QStringList() <<
"t" <<
"test",
82 "Generate test curves at startup");
83 parser.addOption(test_option);
85 QCommandLineOption loadfile_option(QStringList() <<
"d" <<
"datafile",
86 "Load a file containing data",
88 parser.addOption(loadfile_option);
90 QCommandLineOption layout_option(QStringList() <<
"l" <<
"layout",
91 "Load a file containing the layout configuration",
93 parser.addOption(layout_option);
95 QCommandLineOption publish_option(QStringList() <<
"p" <<
"publish",
96 "Automatically start publisher when loading the layout file" );
97 parser.addOption(publish_option);
99 QCommandLineOption buffersize_option(QStringList() <<
"buffer_size",
100 QCoreApplication::translate(
"main",
"Change the maximum size of the streaming buffer (minimum: 10 default: 60)"),
101 QCoreApplication::translate(
"main",
"seconds") );
102 parser.addOption(buffersize_option);
104 parser.process( *qApp );
106 if( parser.isSet(publish_option) && !parser.isSet(layout_option) )
108 std::cerr <<
"Option [ -p / --publish ] is invalid unless [ -l / --layout ] is used too." << std::endl;
125 if( !parser.isSet(nosplash_option) && !( parser.isSet(loadfile_option) || parser.isSet(layout_option) ) )
128 QPixmap main_pixmap(
":/splash/resources/splash_2.2.jpg");
130 int font_id = QFontDatabase::addApplicationFont(
"://resources/DejaVuSans-ExtraLight.ttf");
131 QString family = QFontDatabase::applicationFontFamilies(font_id).at(0);
133 font.setStyleStrategy(QFont::PreferAntialias);
136 painter.begin( &main_pixmap);
137 painter.setPen(QColor(255, 255, 255));
138 painter.setRenderHint(QPainter::TextAntialiasing,
true);
143 const int margin = 20;
144 const int text_height = 100;
145 const int text_width = main_pixmap.width() - margin*2;
146 QPoint topleft(margin, main_pixmap.height() - text_height);
147 QSize rect_size(text_width, text_height);
148 font.setPointSize( 16 );
149 painter.setFont( font );
150 painter.drawText( QRect(topleft, rect_size),
151 Qt::AlignHCenter | Qt::AlignVCenter, subtitle );
154 const int text_width = 100;
155 QPoint topleft( main_pixmap.width() - text_width, 0);
156 QSize rect_size( text_width, 40 );
157 font.setPointSize( 14 );
158 painter.setFont( font );
159 painter.drawText( QRect(topleft, rect_size),
160 Qt::AlignHCenter | Qt::AlignVCenter, VERSION_STRING );
165 QSplashScreen splash(main_pixmap);
166 QDesktopWidget* desktop = QApplication::desktop();
167 const int scrn = desktop->screenNumber(QCursor::pos());
168 const QPoint currentDesktopsCenter = desktop->availableGeometry(scrn).center();
169 splash.move(currentDesktopsCenter - splash.rect().center());
175 const auto deadline = QDateTime::currentDateTime().addMSecs( 100*(30 + subtitle.size()*0.4) );
178 while( QDateTime::currentDateTime() < deadline && !splash.isHidden() )
181 QThread::msleep(100);
QString getFunnySubtitle()
TFSIMD_FORCE_INLINE const tfScalar & w() const
int main(int argc, char *argv[])