Files
IfcOpenShell/src/ifcviewer-full/main.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
3.2 KiB
C++
Raw Normal View History

2026-05-15 07:18:26 +10:00
// This file was generated with the assistance of an AI coding tool.
2026-04-11 16:30:10 +10:00
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
2026-05-15 07:18:26 +10:00
#include "MainWindow.h"
2026-05-15 07:22:31 +10:00
#include "ViewerSettings.h"
2026-05-15 07:18:26 +10:00
#include "components/Style.h"
2026-04-11 16:30:10 +10:00
#include <QApplication>
#include <QCommandLineParser>
2026-05-15 07:18:26 +10:00
#include <QFont>
#include <QFontDatabase>
#include <QSurfaceFormat>
2026-04-11 16:30:10 +10:00
2026-05-15 07:18:26 +10:00
namespace {
void installUiFont() {
const int font_id = QFontDatabase::addApplicationFont(
":/fonts/DMSans-VariableFont_opsz,wght.ttf");
QString family;
if (font_id >= 0) {
const QStringList families = QFontDatabase::applicationFontFamilies(font_id);
if (!families.isEmpty()) {
family = families.front();
}
}
if (!family.isEmpty()) {
QApplication::setFont(QFont(family, 10));
}
}
} // namespace
2026-04-11 16:30:10 +10:00
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
app.setApplicationName("IfcViewer");
app.setOrganizationName("IfcOpenShell");
QSurfaceFormat fmt;
fmt.setVersion(4, 5);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setDepthBufferSize(24);
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
fmt.setSamples(4);
QSurfaceFormat::setDefaultFormat(fmt);
QCommandLineParser parser;
2026-05-15 07:18:26 +10:00
parser.setApplicationDescription("IfcOpenShell IFC viewer");
2026-04-11 16:30:10 +10:00
parser.addHelpOption();
parser.process(app);
2026-05-15 07:18:26 +10:00
installUiFont();
const auto applyStyle = [&app]() {
2026-05-15 07:22:31 +10:00
app.setStyleSheet(ifcviewerfull::components::style::buildAppStyleSheet());
2026-05-15 07:18:26 +10:00
};
applyStyle();
2026-05-15 07:22:31 +10:00
QObject::connect(&ifcviewerfull::ViewerSettings::instance(),
&ifcviewerfull::ViewerSettings::themeChanged,
2026-05-15 07:18:26 +10:00
&app,
applyStyle);
2026-05-15 07:22:31 +10:00
ifcviewerfull::shell::MainWindow window;
2026-05-15 07:18:26 +10:00
window.show();
2026-04-11 16:30:10 +10:00
return app.exec();
}