main.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * @file
  3. * @brief gvedit - simple graph editor and viewer
  4. */
  5. /*************************************************************************
  6. * Copyright (c) 2011 AT&T Intellectual Property
  7. * All rights reserved. This program and the accompanying materials
  8. * are made available under the terms of the Eclipse Public License v1.0
  9. * which accompanies this distribution, and is available at
  10. * https://www.eclipse.org/legal/epl-v10.html
  11. *
  12. * Contributors: Details at https://graphviz.org
  13. *************************************************************************/
  14. #include "config.h"
  15. #ifdef _WIN32
  16. #include "windows.h"
  17. #endif
  18. #include "mainwindow.h"
  19. #include <QApplication>
  20. #include <QCommandLineParser>
  21. #include <QFile>
  22. #include <stdio.h>
  23. #include <gvc/gvc.h>
  24. #include <common/globals.h>
  25. #ifdef _MSC_VER
  26. #pragma comment(lib, "cgraph.lib")
  27. #pragma comment(lib, "gvc.lib")
  28. #endif
  29. QTextStream errout(stderr, QIODevice::WriteOnly);
  30. int main(int argc, char *argv[]) {
  31. Q_INIT_RESOURCE(mdi);
  32. QStringList files;
  33. {
  34. // Scoped QCoreApplication for when X11 DISPLAY is not available
  35. QCoreApplication app(argc, argv);
  36. QCommandLineParser parser;
  37. parser.setApplicationDescription(
  38. QStringLiteral("gvedit - simple graph editor and viewer"));
  39. parser.addPositionalArgument(
  40. QStringLiteral("files"),
  41. QCoreApplication::translate("main", "files to open."),
  42. QStringLiteral("[files...]"));
  43. const QCommandLineOption helpOption(
  44. {
  45. QStringLiteral("?"),
  46. QStringLiteral("h"),
  47. QStringLiteral("help"),
  48. },
  49. QCoreApplication::translate("main",
  50. "Displays help on commandline options."));
  51. parser.addOption(helpOption);
  52. const QCommandLineOption scaleInputBy72Option(
  53. {
  54. QStringLiteral("s"),
  55. QStringLiteral("scale-input-by-72"),
  56. },
  57. QCoreApplication::translate("main", "Scale input by 72"));
  58. parser.addOption(scaleInputBy72Option);
  59. const QCommandLineOption verboseOption(
  60. {
  61. QStringLiteral("v"),
  62. QStringLiteral("verbose"),
  63. },
  64. QCoreApplication::translate("main", "Verbose mode"));
  65. parser.addOption(verboseOption);
  66. if (!parser.parse(app.arguments())) {
  67. parser.showHelp(1);
  68. }
  69. if (parser.isSet(helpOption)) {
  70. parser.showHelp(0);
  71. }
  72. if (parser.isSet(scaleInputBy72Option)) {
  73. PSinputscale = POINTS_PER_INCH;
  74. }
  75. if (parser.isSet(verboseOption)) {
  76. Verbose = 1;
  77. }
  78. files = parser.positionalArguments();
  79. }
  80. QApplication app(argc, argv);
  81. CMainWindow mainWin(files);
  82. mainWin.show();
  83. const int ret = app.exec();
  84. graphviz_exit(ret);
  85. }
  86. /**
  87. * @dir .
  88. * @brief simple graph editor and viewer
  89. */