|
@@ -21,18 +21,21 @@
|
|
|
|
|
|
#include <ctkCommandLineParser.h>
|
|
#include <ctkCommandLineParser.h>
|
|
|
|
|
|
-#include <QCoreApplication>
|
|
|
|
|
|
+#include <QApplication>
|
|
#include <QTextStream>
|
|
#include <QTextStream>
|
|
#include <QFile>
|
|
#include <QFile>
|
|
|
|
+#include <QPixmap>
|
|
|
|
+#include <QPainter>
|
|
|
|
|
|
#include <cstdlib>
|
|
#include <cstdlib>
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
int main(int argc, char* argv[])
|
|
{
|
|
{
|
|
- QCoreApplication app(argc, argv);
|
|
|
|
|
|
+ // QPixmap (used below) requires QApplication (instead of QCoreApplication)
|
|
|
|
+ QApplication app(argc, argv);
|
|
// This is used by QSettings
|
|
// This is used by QSettings
|
|
- QCoreApplication::setOrganizationName("CommonTK");
|
|
|
|
- QCoreApplication::setApplicationName("CLIModuleTour");
|
|
|
|
|
|
+ QApplication::setOrganizationName("CommonTK");
|
|
|
|
+ QApplication::setApplicationName("CLIModuleTour");
|
|
|
|
|
|
ctkCommandLineParser parser;
|
|
ctkCommandLineParser parser;
|
|
// Use Unix-style argument names
|
|
// Use Unix-style argument names
|
|
@@ -42,6 +45,13 @@ int main(int argc, char* argv[])
|
|
parser.addArgument("help", "h", QVariant::Bool, "Show this help text");
|
|
parser.addArgument("help", "h", QVariant::Bool, "Show this help text");
|
|
parser.addArgument("xml", "", QVariant::Bool, "Print a XML description of this modules command line interface");
|
|
parser.addArgument("xml", "", QVariant::Bool, "Print a XML description of this modules command line interface");
|
|
|
|
|
|
|
|
+ parser.addArgument("integer", "", QVariant::Int, "Show this help text");
|
|
|
|
+ parser.addArgument("", "b", QVariant::Bool, "Show this help text");
|
|
|
|
+ parser.addArgument("double", "d", QVariant::Double, "Show this help text");
|
|
|
|
+ parser.addArgument("floatVector", "f", QVariant::String, "Show this help text");
|
|
|
|
+ parser.addArgument("enumeration", "e", QVariant::String, "Show this help text");
|
|
|
|
+ parser.addArgument("", "p", QVariant::String, "Show this help text");
|
|
|
|
+
|
|
// Parse the command line arguments
|
|
// Parse the command line arguments
|
|
bool ok = false;
|
|
bool ok = false;
|
|
QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
|
|
QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
|
|
@@ -65,8 +75,25 @@ int main(int argc, char* argv[])
|
|
xmlDescription.open(QIODevice::ReadOnly);
|
|
xmlDescription.open(QIODevice::ReadOnly);
|
|
QTextStream(stdout, QIODevice::WriteOnly) << xmlDescription.readAll();
|
|
QTextStream(stdout, QIODevice::WriteOnly) << xmlDescription.readAll();
|
|
}
|
|
}
|
|
|
|
+ if(parsedArgs.contains("p"))
|
|
|
|
+ {
|
|
|
|
+ QTextStream(stdout, QIODevice::WriteOnly) << parsedArgs["p"].toString();
|
|
|
|
+ }
|
|
|
|
|
|
// Do something
|
|
// Do something
|
|
|
|
+ // do we have enough information (input/output)?
|
|
|
|
+ if(parser.unparsedArguments().count() >= 2)
|
|
|
|
+ {
|
|
|
|
+ QString input = parser.unparsedArguments().at(0);
|
|
|
|
+ QString output = parser.unparsedArguments().at(1);
|
|
|
|
+
|
|
|
|
+ QPixmap pix(input);
|
|
|
|
+ QPainter painter(&pix);
|
|
|
|
+ painter.setPen(Qt::white);
|
|
|
|
+ painter.setFont(QFont("Arial", 15));
|
|
|
|
+ painter.drawText(pix.rect(),Qt::AlignBottom|Qt::AlignLeft,"Result image produced by ctkCLIModuleTour");
|
|
|
|
+ pix.save(output, "JPEG");
|
|
|
|
+ }
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
return EXIT_SUCCESS;
|
|
}
|
|
}
|