1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#include "gui/quality/aoqplotwindow.h"
#include <gtkmm/main.h>
#include <gtkmm/filechooserdialog.h>
#include "version.h"
int main(int argc, char *argv[])
{
// We have to 'lie' about argc to create(..), because of a bug in older gtkmms.
int altArgc = 1;
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(altArgc, argv, "", Gio::APPLICATION_HANDLES_OPEN);
AOQPlotWindow window;
bool openGUI = true;
int argi = 1;
std::vector<AOQPlotWindow::PlotSavingData> savedPlots;
while(argi < argc && argv[argi][0]=='-')
{
std::string p;
if(argv[argi][1] == '-')
p = &argv[argi][2];
else
p = &argv[argi][1];
if(p=="help" || p=="h")
{
std::cout << "Syntax: aoqplot [<options>] [<observation>]\n\n"
"<observation> can be a measurement set for opening a single observation.\n"
"To get statistics for a (remote) observation consisting of multiple measurement\n"
"sets, specify a measurement set specifier instead (generally a .ref, .vds\n"
".gvds or .gds file).\n"
"\n"
"Options can be:\n"
"-help\n"
" Show syntax help.\n"
"-version\n"
" Print version info and exit.\n"
"-save [filename prefix] [statistic name]\n"
" Save every plot for the given kind of statistic as a PDF file. This\n"
" will prevent the GUI from opening. You can repeat this parameter to save\n"
" multiple kinds at once. A list of allowed names can be retrieved with\n"
" 'aoquality liststats'. Some common ones are: StandardDeviation, Variance, Mean,\n"
" RFIPercentage, RFIRatio, Count.\n"
"\n"
"AOQPlot is part of the AOFlagger software package, written by André Offringa\n"
" (offringa@gmail.com). This AOQPlot belongs to AOFlagger " << AOFLAGGER_VERSION_STR << " (" << AOFLAGGER_VERSION_DATE_STR << ")\n";
return 0;
}
else if(p=="save")
{
AOQPlotWindow::PlotSavingData newPlot;
newPlot.filenamePrefix = argv[argi+1];
newPlot.statisticKind = QualityTablesFormatter::NameToKind(argv[argi+2]);
argi += 2;
openGUI = false;
savedPlots.push_back(newPlot);
}
else if(p == "version")
{
std::cout << "AOQplot " << AOFLAGGER_VERSION_STR << " (" << AOFLAGGER_VERSION_DATE_STR << ")\n";
return 0;
}
else {
std::cout << "Bad parameter specified: " << argv[argi] << '\n';
return 1;
}
++argi;
}
if(openGUI)
window.show_all();
if(argc>argi)
{
std::vector<std::string> files;
for(int i=argi; i!=argc; ++i)
files.push_back(argv[i]);
if(openGUI)
window.Open(files);
else
window.OpenWithoutGUI(files);
} else {
if(!openGUI)
{
std::cout << "No observation specified.\n";
return 1;
}
Gtk::FileChooserDialog fileDialog(window, "Open observation set");
fileDialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);
fileDialog.add_button("_Open", Gtk::RESPONSE_OK);
Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
filter->set_name("Observation sets (*.{vds,gds,ref,MS})");
filter->add_pattern("*.vds");
filter->add_pattern("*.gds");
filter->add_pattern("*.gvds");
filter->add_pattern("*.ref");
filter->add_pattern("*.MS");
fileDialog.add_filter(filter);
if(fileDialog.run() == Gtk::RESPONSE_OK)
{
window.Open(fileDialog.get_filename());
}
else return 0;
}
for(std::vector<AOQPlotWindow::PlotSavingData>::const_iterator plot=savedPlots.begin(); plot!=savedPlots.end(); ++plot)
{
window.Save(*plot);
}
if(openGUI)
app->run(window);
return 0;
}
|