|
@@ -36,8 +36,9 @@
|
|
|
|
|
|
#ifdef CTK_WRAP_PYTHONQT_USE_VTK
|
|
|
# include "ctkTestWrappedQListOfVTKObject.h"
|
|
|
-# include "ctkTestWrappedVTKSlot.h"
|
|
|
+# include "ctkTestWrappedVTKObserver.h"
|
|
|
# include "ctkTestWrappedVTKQInvokable.h"
|
|
|
+# include "ctkTestWrappedVTKSlot.h"
|
|
|
# include <vtkDebugLeaks.h>
|
|
|
#endif
|
|
|
|
|
@@ -65,80 +66,90 @@ int main(int argc, char** argv)
|
|
|
{
|
|
|
#ifdef CTK_WRAP_PYTHONQT_USE_VTK
|
|
|
vtkDebugLeaks::SetExitError(true);
|
|
|
+ ctkTestWrappedVTKObserver testWrappedVTKObserver;
|
|
|
#endif
|
|
|
|
|
|
- QApplication app(argc, argv);
|
|
|
+ int exitCode = EXIT_FAILURE;
|
|
|
+ {
|
|
|
+ QApplication app(argc, argv);
|
|
|
|
|
|
- ctkCommandLineParser parser;
|
|
|
- // Use Unix-style argument names
|
|
|
- parser.setArgumentPrefix("--", "-");
|
|
|
+ ctkCommandLineParser parser;
|
|
|
+ // Use Unix-style argument names
|
|
|
+ parser.setArgumentPrefix("--", "-");
|
|
|
|
|
|
- // Add command line argument names
|
|
|
- parser.addArgument("help", "h", QVariant::Bool, "Print usage information and exit.");
|
|
|
- parser.addArgument("interactive", "I", QVariant::Bool, "Enable interactive mode");
|
|
|
+ // Add command line argument names
|
|
|
+ parser.addArgument("help", "h", QVariant::Bool, "Print usage information and exit.");
|
|
|
+ parser.addArgument("interactive", "I", QVariant::Bool, "Enable interactive mode");
|
|
|
|
|
|
- // Parse the command line arguments
|
|
|
- bool ok = false;
|
|
|
- QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
|
|
|
- if (!ok)
|
|
|
- {
|
|
|
- QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: "
|
|
|
- << parser.errorString() << "\n";
|
|
|
- return EXIT_FAILURE;
|
|
|
- }
|
|
|
+ // Parse the command line arguments
|
|
|
+ bool ok = false;
|
|
|
+ QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
|
|
|
+ if (!ok)
|
|
|
+ {
|
|
|
+ QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: "
|
|
|
+ << parser.errorString() << "\n";
|
|
|
+ return EXIT_FAILURE;
|
|
|
+ }
|
|
|
|
|
|
- // Show a help message
|
|
|
- if (parsedArgs.contains("help") || parsedArgs.contains("h"))
|
|
|
- {
|
|
|
- QTextStream(stdout, QIODevice::WriteOnly) << "ctkSimplePythonShell\n"
|
|
|
- << "Usage\n\n"
|
|
|
- << " ctkSimplePythonShell [options] [<path-to-python-script> ...]\n\n"
|
|
|
- << "Options\n"
|
|
|
- << parser.helpText();
|
|
|
- return EXIT_SUCCESS;
|
|
|
- }
|
|
|
+ // Show a help message
|
|
|
+ if (parsedArgs.contains("help") || parsedArgs.contains("h"))
|
|
|
+ {
|
|
|
+ QTextStream(stdout, QIODevice::WriteOnly) << "ctkSimplePythonShell\n"
|
|
|
+ << "Usage\n\n"
|
|
|
+ << " ctkSimplePythonShell [options] [<path-to-python-script> ...]\n\n"
|
|
|
+ << "Options\n"
|
|
|
+ << parser.helpText();
|
|
|
+ return EXIT_SUCCESS;
|
|
|
+ }
|
|
|
|
|
|
- ctkSimplePythonManager pythonManager;
|
|
|
+ ctkSimplePythonManager pythonManager;
|
|
|
|
|
|
- ctkPythonConsole console;
|
|
|
- console.initialize(&pythonManager);
|
|
|
- console.setAttribute(Qt::WA_QuitOnClose, true);
|
|
|
- console.resize(600, 280);
|
|
|
- console.show();
|
|
|
+ ctkPythonConsole console;
|
|
|
+ console.initialize(&pythonManager);
|
|
|
+ console.setAttribute(Qt::WA_QuitOnClose, true);
|
|
|
+ console.resize(600, 280);
|
|
|
+ console.show();
|
|
|
|
|
|
- console.setProperty("isInteractive", parsedArgs.contains("interactive"));
|
|
|
+ console.setProperty("isInteractive", parsedArgs.contains("interactive"));
|
|
|
|
|
|
- QStringList list;
|
|
|
- list << "qt.QPushButton";
|
|
|
- console.completer()->setAutocompletePreferenceList(list);
|
|
|
+ QStringList list;
|
|
|
+ list << "qt.QPushButton";
|
|
|
+ console.completer()->setAutocompletePreferenceList(list);
|
|
|
|
|
|
- pythonManager.addObjectToPythonMain("_ctkPythonConsoleInstance", &console);
|
|
|
+ pythonManager.addObjectToPythonMain("_ctkPythonConsoleInstance", &console);
|
|
|
|
|
|
- ctkTestWrappedQProperty testWrappedQProperty;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedQPropertyInstance", &testWrappedQProperty);
|
|
|
+ ctkTestWrappedQProperty testWrappedQProperty;
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedQPropertyInstance", &testWrappedQProperty);
|
|
|
|
|
|
- ctkTestWrappedQInvokable testWrappedQInvokable;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedQInvokableInstance", &testWrappedQInvokable);
|
|
|
+ ctkTestWrappedQInvokable testWrappedQInvokable;
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedQInvokableInstance", &testWrappedQInvokable);
|
|
|
|
|
|
- ctkTestWrappedSlot testWrappedSlot;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedSlotInstance", &testWrappedSlot);
|
|
|
+ ctkTestWrappedSlot testWrappedSlot;
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedSlotInstance", &testWrappedSlot);
|
|
|
|
|
|
-#ifdef CTK_WRAP_PYTHONQT_USE_VTK
|
|
|
- ctkTestWrappedVTKQInvokable testWrappedVTKQInvokable;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedVTKQInvokableInstance", &testWrappedVTKQInvokable);
|
|
|
+ #ifdef CTK_WRAP_PYTHONQT_USE_VTK
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedVTKObserverInstance", &testWrappedVTKObserver);
|
|
|
|
|
|
- ctkTestWrappedVTKSlot testWrappedVTKSlot;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedVTKSlotInstance", &testWrappedVTKSlot);
|
|
|
+ ctkTestWrappedVTKQInvokable testWrappedVTKQInvokable;
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedVTKQInvokableInstance", &testWrappedVTKQInvokable);
|
|
|
|
|
|
- ctkTestWrappedQListOfVTKObject testWrappedQListOfVTKObject;
|
|
|
- pythonManager.addObjectToPythonMain("_testWrappedQListOfVTKObjectInstance", &testWrappedQListOfVTKObject);
|
|
|
-#endif
|
|
|
+ ctkTestWrappedVTKSlot testWrappedVTKSlot;
|
|
|
+ pythonManager.addObjectToPythonMain("_testWrappedVTKSlotInstance", &testWrappedVTKSlot);
|
|
|
|
|
|
- ctkCallback callback;
|
|
|
- callback.setCallbackData(&pythonManager);
|
|
|
- pythonManager.setProperty("scripts", parser.unparsedArguments());
|
|
|
- callback.setCallback(executeScripts);
|
|
|
- QTimer::singleShot(0, &callback, SLOT(invoke()));
|
|
|
+ // ctkTestWrappedQListOfVTKObject testWrappedQListOfVTKObject;
|
|
|
+ // pythonManager.addObjectToPythonMain("_testWrappedQListOfVTKObjectInstance", &testWrappedQListOfVTKObject);
|
|
|
+ #endif
|
|
|
|
|
|
- return app.exec();
|
|
|
+ ctkCallback callback;
|
|
|
+ callback.setCallbackData(&pythonManager);
|
|
|
+ pythonManager.setProperty("scripts", parser.unparsedArguments());
|
|
|
+ callback.setCallback(executeScripts);
|
|
|
+ QTimer::singleShot(0, &callback, SLOT(invoke()));
|
|
|
+
|
|
|
+ exitCode = app.exec();
|
|
|
+ }
|
|
|
+#ifdef CTK_WRAP_PYTHONQT_USE_VTK
|
|
|
+ testWrappedVTKObserver.getTable()->Modified();
|
|
|
+#endif
|
|
|
+ return exitCode;
|
|
|
}
|