/Base/GUI/Slicer3SlicerBaseGUITest.cxx

https://github.com/LinjieChen/Slicer3 · C++ · 74 lines · 52 code · 10 blank · 12 comment · 2 complexity · 3b3871585b135ee0a1dc2c1b15147529 MD5 · raw file

  1. #include "vtkKWApplication.h"
  2. #include "vtkSlicerApplicationGUI.h"
  3. #include "vtkSlicerMainDesktopGUI.h"
  4. #include "vtkSlicerLogic.h"
  5. #include "vtkSlicerApplicationLogic.h"
  6. #include <vtksys/SystemTools.hxx>
  7. #include <vtksys/CommandLineArguments.hxx>
  8. // If I change the name of this function and library
  9. // in the CMakeLists.txt file, the linking throws an
  10. // undefined symbol error. So, changing the library
  11. // name to KWSlicer3Lib, and the function to
  12. // Kwslicer3lib_Init won't work. What am i missing?
  13. extern "C" int Slicerbasegui_Init (Tcl_Interp *interp );
  14. int slicer3_main( int argc, char *argv[] )
  15. {
  16. int ret;
  17. // Try including this tcl interpreter in the
  18. // in the vtkSlicerApplicationGUI class.
  19. Tcl_Interp *interp = vtkKWApplication::InitializeTcl (argc, argv, &cerr);
  20. if (!interp ) {
  21. cerr << "Error: InitializeTcl failed" << endl ;
  22. return 1;
  23. }
  24. // Initialize our classses wrapped in Tcl.
  25. // Tcl requires a call to wrap them.
  26. Slicerbasegui_Init (interp);
  27. vtkSlicerApplicationGUI *app;
  28. vtkSlicerMainDesktopGUI *gui;
  29. vtkSlicerApplicationLogic *logic;
  30. // normally we'd not allocate here, but that
  31. // we'd point to already instantiated object.
  32. logic = vtkSlicerApplicationLogic::New ( );
  33. app = vtkSlicerApplicationGUI::New ( );
  34. app->ConfigureApplication ( );
  35. gui = vtkSlicerMainDesktopGUI::New ( );
  36. gui->SetLogic ( logic );
  37. gui->BuildGUI ( app );
  38. gui->AddGUIObservers ( );
  39. gui->AddLogicObservers ( );
  40. ret = app->StartApplication ( );
  41. logic->Delete ( );
  42. gui->Delete ( );
  43. // something causes unhappiness in app->Delete
  44. app->Delete ( );
  45. return ret;
  46. }
  47. #ifdef _WIN32
  48. #include "windows.h"
  49. int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
  50. {
  51. int argc;
  52. char **argv;
  53. vtksys::SystemTools::ConvertWindowsCommandLineToUnixArguments( lpCmdLine, &argc, &argv );
  54. int ret = slicer3_main ( argc, argv );
  55. for (int i = 0; i < argc; i++) { delete [] argv[i]; }
  56. delete [] argv;
  57. return ret;
  58. }
  59. #else
  60. int main(int argc, char *argv[])
  61. {
  62. return slicer3_main ( argc, argv );
  63. }
  64. #endif