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