mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 11:20:21 +00:00
Swap interface into IfcViewerFull
Replace the old IfcViewerFull application tree with the interface-based viewer while preserving the IfcViewerFull target and build workflow. Generated with the assistance of an AI coding tool.
This commit is contained in:
+40
-35
@@ -1,3 +1,4 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
@@ -17,18 +18,40 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "InterfaceSettings.h"
|
||||
#include "components/Style.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
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
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("IfcViewer");
|
||||
app.setOrganizationName("IfcOpenShell");
|
||||
|
||||
// Request OpenGL 4.5 Core globally
|
||||
QSurfaceFormat fmt;
|
||||
fmt.setVersion(4, 5);
|
||||
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
||||
@@ -38,39 +61,21 @@ int main(int argc, char* argv[]) {
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("IfcOpenShell IFC Viewer");
|
||||
parser.setApplicationDescription("IfcOpenShell IFC viewer");
|
||||
parser.addHelpOption();
|
||||
parser.addPositionalArgument("files",
|
||||
"IFC file(s) and/or one .ifcfed federation to open",
|
||||
"[files...]");
|
||||
parser.addOption({{"c", "camera"},
|
||||
"Set camera: tx,ty,tz,dist,yaw,pitch", "params"});
|
||||
parser.addOption({{"b", "benchmark"},
|
||||
"Run N frames then print stats and exit", "frames"});
|
||||
parser.process(app);
|
||||
|
||||
MainWindow window;
|
||||
installUiFont();
|
||||
const auto applyStyle = [&app]() {
|
||||
app.setStyleSheet(ifcinterface::components::style::buildAppStyleSheet());
|
||||
};
|
||||
applyStyle();
|
||||
QObject::connect(&ifcinterface::InterfaceSettings::instance(),
|
||||
&ifcinterface::InterfaceSettings::themeChanged,
|
||||
&app,
|
||||
applyStyle);
|
||||
|
||||
ifcinterface::shell::MainWindow window;
|
||||
window.show();
|
||||
|
||||
auto args = parser.positionalArguments();
|
||||
QStringList file_args;
|
||||
QString fed_arg;
|
||||
for (const auto& a : args) {
|
||||
if (fed_arg.isEmpty() && a.endsWith(".ifcfed", Qt::CaseInsensitive)) {
|
||||
fed_arg = a;
|
||||
} else {
|
||||
file_args << a;
|
||||
}
|
||||
}
|
||||
if (!fed_arg.isEmpty()) window.openFederation(fed_arg);
|
||||
if (!file_args.isEmpty()) window.addFiles(file_args);
|
||||
|
||||
if (parser.isSet("camera")) {
|
||||
window.setPendingCamera(parser.value("camera"));
|
||||
}
|
||||
if (parser.isSet("benchmark")) {
|
||||
window.setPendingBenchmark(parser.value("benchmark").toInt());
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user