diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4356b16fe..fd27d70549 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ on: - 'src/ifcparse/**' - 'src/ifcquery/**' - 'src/ifcwrap/**' - - 'src/qtviewer/**' - 'src/svgfill/**' - 'src/serializers/**' - 'conda/**' diff --git a/.gitignore b/.gitignore index bea934e8a0..4fd39e7e47 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ /src/examples/out/ /src/ifcmax/out/ /src/ifcwrap/out/ -/src/qtviewer/out/ /src/ifctester/webapp/public/pyodide/ /win/BuildDepsCache*.txt diff --git a/README.md b/README.md index a44a6ff78c..db0912cfde 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,6 @@ The IfcOpenShell C++ codebase is split into multiple interal libraries: | ifcjni | Internal library for IfcOpenShell | LGPL-3.0-or-later\* | | ifcparse | Internal library for IfcOpenShell | LGPL-3.0-or-later\* | | ifcwrap | Internal library for IfcOpenShell | LGPL-3.0-or-later\* | -| qtviewer | Internal library for IfcOpenShell | LGPL-3.0-or-later\* | | serializers | Internal library for IfcOpenShell | LGPL-3.0-or-later\* | [LGPL]: https://github.com/IfcOpenShell/IfcOpenShell/tree/master/COPYING.LESSER "LGPL-3.0-or-later" diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index aca5cb63c8..27e0f52cef 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -79,7 +79,6 @@ option(BUILD_DOCUMENTATION "Build IfcOpenShell Documentation." OFF) option(BUILD_EXAMPLES "Build example applications." ON) option(BUILD_GEOMSERVER "Build IfcGeomServer executable (Open CASCADE is required)." ON) option(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF) -option(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer" OFF) # QtViewer requires Qt6 option(BUILD_IFCMODEL_UI "Build minimal Qt IFC model UI prototype" OFF) option(BUILD_BONSAIVIEWER "Build Bonsai Viewer" OFF) # Requires Qt6 + OpenGL 4.5 option(BUILD_IFCOPENSHELL_PARSE_TESTS "Build C++ unit tests for IfcParse (fetches Catch2 v3)" OFF) @@ -708,10 +707,6 @@ if(BUILD_IFCPYTHON) add_subdirectory(../src/ifcwrap ifcwrap) endif() -if(BUILD_QTVIEWER) - add_subdirectory(../src/qtviewer qtviewer) -endif() - if(BUILD_IFCMODEL_UI) add_subdirectory(../src/ifcmodel-ui ifcmodel-ui) endif() diff --git a/conda/recipe.yaml b/conda/recipe.yaml index 3d43c9539d..547db1194d 100644 --- a/conda/recipe.yaml +++ b/conda/recipe.yaml @@ -284,11 +284,6 @@ about: Internal library for IfcOpenShell LGPL-3.0-or-later* - - qtviewer - Internal library for IfcOpenShell - LGPL-3.0-or-later* - serializers Internal library for IfcOpenShell diff --git a/src/qtviewer/CITATION.cff b/src/qtviewer/CITATION.cff deleted file mode 100644 index c6d441fe57..0000000000 --- a/src/qtviewer/CITATION.cff +++ /dev/null @@ -1,18 +0,0 @@ -# This CITATION.cff file was generated with cffinit. -# Visit https://bit.ly/cffinit to generate yours today! - -cff-version: 1.2.0 -title: qtviewer -message: >- - If you use this software, please cite it using the - metadata from this file. -type: software -authors: - - name: IfcOpenShell contributors -repository-code: >- - https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/qtviewer -abstract: Internal library for IfcOpenShell -keywords: - - IfcOpenShell - - IFC -license: LGPL-3.0-or-later diff --git a/src/qtviewer/CMakeLists.txt b/src/qtviewer/CMakeLists.txt deleted file mode 100644 index d1390b382d..0000000000 --- a/src/qtviewer/CMakeLists.txt +++ /dev/null @@ -1,104 +0,0 @@ -################################################################################ -# # -# 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 . # -# # -################################################################################ - -message("Running CMakeLists.txt in /src/qtviewer") - -# Specify the Qt version and components to use -set(QT_VERSION 6 CACHE STRING "Qt version") -set(QT_COMPONENTS - Core - Gui - OpenGL - OpenGLWidgets - Widgets - CACHE STRING - "Qt components" -) - -find_package(Qt${QT_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED PATHS ${QT_DIR}) - -if(Qt${QT_VERSION}_FOUND) - message(STATUS "Found Qt Version: ${Qt${QT_VERSION}_VERSION}") -endif() - -message(STATUS "OSG_DIR: ${OSG_DIR}") -set(OSG_COMPONENTS osgDB osgGA osgUtil osgViewer CACHE STRING "OSG components") - -# Do not add "PATHS " in find_package for OpenSceneGraph CMake config to work -# on appleSiliconMacOS + Homebrew -find_package(OpenSceneGraph COMPONENTS ${OSG_COMPONENTS} REQUIRED) - -if(OPENSCENEGRAPH_FOUND) - message(STATUS "Found OpenSceneGraph Version: ${OPENSCENEGRAPH_VERSION}") -endif() - -set(targetName "QtViewer") - -# Scan for .qrc files and add to build process -set(CMAKE_AUTORCC ON) - -set(RESOURCE_FILES resources/qt_resources.qrc resources/qt_res.rc) - -# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist -# generated by CMake. This variable contains the .icns file name, -# without the path. -set(MACOSX_BUNDLE_ICON_FILE ifcosLogo.icns) - -# The following tells CMake where to find and install the file itself. -set(app_icon_macos "resources/ifcosLogo.icns") -set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - -add_executable( - ${targetName} - MessageLogger.h - IfcViewerWidget.h - IfcViewerWidget.cpp - ParseIfcFile.h - ParseIfcFile.cpp - MainWindow.h - MainWindow.cpp - main.cpp - ${RESOURCE_FILES} - ${app_icon_macos} -) - -set_target_properties( - ${targetName} - PROPERTIES AUTOMOC On WIN32_EXECUTABLE ON MACOSX_BUNDLE ON RESOURCE "${RESOURCE_FILES}" -) - -target_link_libraries( - ${targetName} - ${IFCOPENSHELL_LIBRARIES} - ${OpenCASCADE_LIBRARIES} - ${OPENSCENEGRAPH_LIBRARIES} - Qt${QT_VERSION}::Core - Qt${QT_VERSION}::Gui - Qt${QT_VERSION}::OpenGL - Qt${QT_VERSION}::OpenGLWidgets - Qt${QT_VERSION}::Widgets -) - -target_include_directories(${targetName} PUBLIC ${QT_DIR}/include ${OPENSCENEGRAPH_INCLUDE_DIRS}) - -get_target_property(targetIncludeDirs ${targetName} INCLUDE_DIRECTORIES) -message(STATUS "target_include_directories: ${targetIncludeDirs}") - -install(TARGETS ${targetName}) -ifcopenshell_deploy_qt_runtime(${targetName}) diff --git a/src/qtviewer/IfcViewerWidget.cpp b/src/qtviewer/IfcViewerWidget.cpp deleted file mode 100644 index 0e8fcb3e21..0000000000 --- a/src/qtviewer/IfcViewerWidget.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "IfcViewerWidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "MainWindow.h" -#include "MessageLogger.h" -#include "osg/Geode" -#include "osg/Geometry" -#include "osg/Group" -#include "osg/StateSet" -#include "osg/Vec3" -#include "osg/ref_ptr" -#include "osgGA/TrackballManipulator" - -IfcViewerWidget::IfcViewerWidget(qreal dpiScale, QWidget *parent) : - QOpenGLWidget(parent), - m_dpiScale(dpiScale), - m_graphicsWindow(new osgViewer::GraphicsWindowEmbedded( - this->x(), this->y(), - this->width(), this->height() - )), - m_viewer(new osgViewer::Viewer), - root(new osg::Group) -{ - m_clearColor = osg::Vec4(0.8, 0.8, 0.8, 1.0); - - //debug - override - //std::string filePath = "/Users/onizudb/Downloads/IFC/wallAtOrigin.ifc"; - //std::string filePath = "/Users/onizudb/Downloads/IFC/FromAC_IFC4ref.ifc"; - //this->loadFile(filePath); -} - -void IfcViewerWidget::initializeGL() -{ - MessageLogger::log("Press `Cmd/Ctrl + o` or use the File menu to open an IFC file"); - - // Set up the rendering context, load shaders and other resources, etc.: - - // Set the root node as the scene data for the viewer - m_viewer->setSceneData(root); - - osg::StateSet* state = root->getOrCreateStateSet(); - state->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); - - m_viewer->getCamera()->setViewport(0, 0, this->width(), this->height()); - m_viewer->getCamera()->setClearColor(m_clearColor); - m_viewer->getCamera()->setGraphicsContext(m_graphicsWindow); - - // set camera manipulator, etc. - setupViewController(); - - m_viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); - m_viewer->realize(); -} - -void IfcViewerWidget::resizeGL(int w, int h) -{ - this->getEventQueue()->windowResize(this->x() * m_dpiScale, this->y() * m_dpiScale, w * m_dpiScale, h * m_dpiScale); - m_graphicsWindow->resized(this->x() * m_dpiScale, this->y() * m_dpiScale, w * m_dpiScale, h * m_dpiScale); - - m_viewer->getCamera()->setViewport(0, 0, this->width() * m_dpiScale, this->height() * m_dpiScale); - - const float aspectRatio = static_cast(w) / static_cast(h); - m_viewer->getCamera()->setProjectionMatrixAsPerspective(30.0f, aspectRatio, 1.0f, 1000.0f); -} - -void IfcViewerWidget::paintGL() -{ - // Render OSG scene - m_viewer->frame(); -} - -void IfcViewerWidget::mouseMoveEvent(QMouseEvent *event) -{ - this->getEventQueue()->mouseMotion(event->position().x() * m_dpiScale, event->position().y() * m_dpiScale); -} - -void IfcViewerWidget::mousePressEvent(QMouseEvent *event) -{ - unsigned int button = this->getMouseButtonNum(event); - this->getEventQueue()->mouseButtonPress(event->position().x() * m_dpiScale, event->position().y() * m_dpiScale, button); -} - -void IfcViewerWidget::mouseReleaseEvent(QMouseEvent *event) -{ - unsigned int button = this->getMouseButtonNum(event); - this->getEventQueue()->mouseButtonRelease(event->position().x() * m_dpiScale, event->position().y() * m_dpiScale, button); -} - -void IfcViewerWidget::wheelEvent(QWheelEvent *event) -{ - int delta = event->angleDelta().y(); - osgGA::GUIEventAdapter::ScrollingMotion motion = delta > 0 ? - osgGA::GUIEventAdapter::SCROLL_UP : osgGA::GUIEventAdapter::SCROLL_DOWN; - this->getEventQueue()->mouseScroll(motion); -} - -bool IfcViewerWidget::event(QEvent* event) -{ - bool handled = QOpenGLWidget::event(event); - this->update(); - return handled; -} - -osgGA::EventQueue* IfcViewerWidget::getEventQueue() const -{ - osgGA::EventQueue* eventQueue = m_graphicsWindow->getEventQueue(); - return eventQueue; -} - -unsigned int IfcViewerWidget::getMouseButtonNum(QMouseEvent* event) -{ - unsigned int button = 0; - switch (event->button()){ - case Qt::LeftButton: - button = 1; - break; - case Qt::MiddleButton: - button = 2; - break; - case Qt::RightButton: - button = 3; - break; - default: - break; - } - return button; -} - -void IfcViewerWidget::setupViewController() -{ - setMouseTracking(false); - m_mouseHandler = new osgGA::TrackballManipulator; - m_mouseHandler->setAllowThrow(false); - m_viewer->setCameraManipulator(m_mouseHandler); -} - -void IfcViewerWidget::loadFile(const std::string& filePath) -{ - std::vector> matrixTransforms; - - if(!m_parser.Parse(filePath, matrixTransforms)) { - MessageLogger::log("Failed to prepare IFC geometry"); - return; - } - - MessageLogger::log("\nIFC geometry prepared"); - - for (auto matrixTransform : matrixTransforms) { - root->addChild(matrixTransform); - } - - // set initial camera position - orientScene(root); - - // request redraw - update(); -} - -void IfcViewerWidget::orientScene(osg::ref_ptr rootGroup) -{ - // Get the bounding-box - osg::ComputeBoundsVisitor cbv; - rootGroup->accept(cbv); - const osg::BoundingBox& bb = cbv.getBoundingBox(); - - // Center (average of opposite corners of bb) - osg::Vec3d center = (bb.corner(0) + bb.corner(7)) * 0.5; - - // Radius (distance between the center and the corner) - // assuming corner(7) has maximum x,y,z coords - float radius = (bb.corner(7) - center).length(); - - // Calc. eye position - osg::Vec3d eye = center + osg::Vec3d(radius * 3, -radius * 3, 0.0); - - osg::Vec3d up = osg::Vec3d(0.0, 0.0, 1.0); - - // Set the camera's view matrix - // In case a cameraManipulator is set, lookAt position setting does not work on the camera - // as it is overridden. - // So set it on the manipulator and reapply it to the viewer - if (m_mouseHandler.valid()) - { - m_mouseHandler->setHomePosition(eye, center, up); - } - - m_viewer->setCameraManipulator(m_mouseHandler); - - auto log = [center, radius, eye]() { - MessageLogger::log("center: " + std::to_string(center.length())); - MessageLogger::log("radius: " + std::to_string(radius)); - MessageLogger::log("center: " + std::to_string(center.x()) + ", " + std::to_string(center.y()) + ", " + std::to_string(center.z())); - MessageLogger::log("eye: " + std::to_string(eye.x()) + ", " + std::to_string(eye.y()) + ", " + std::to_string(eye.z())); - }; - //log(); -} diff --git a/src/qtviewer/IfcViewerWidget.h b/src/qtviewer/IfcViewerWidget.h deleted file mode 100644 index 3b0b1c15c9..0000000000 --- a/src/qtviewer/IfcViewerWidget.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef IFCVIEWERWIDGET_H -#define IFCVIEWERWIDGET_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "ParseIfcFile.h" -#include "osg/Vec4" - -class IfcViewerWidget : public QOpenGLWidget -{ - Q_OBJECT - -public: - IfcViewerWidget( - qreal dpiScale, - QWidget *parent = nullptr - ); - -public slots: - void loadFile(const std::string& filePath); - -protected: - virtual void initializeGL() override; // to set up resources, state - virtual void resizeGL(int w, int h) override; // to set up viewport, projection, etc. - virtual void paintGL() override; // to render OpenGL scene - - virtual void mousePressEvent(QMouseEvent *event) override; - virtual void mouseMoveEvent(QMouseEvent *event) override; - virtual void mouseReleaseEvent(QMouseEvent *event) override; - virtual void wheelEvent(QWheelEvent *event) override; - virtual bool event(QEvent* event) override; - -private: - qreal m_dpiScale; - QMatrix4x4 m_projection; - osg::Vec4 m_clearColor; - osg::ref_ptr m_mouseHandler; - osg::ref_ptr m_graphicsWindow; - osg::ref_ptr m_viewer; - osg::ref_ptr root; // OSG root node - - ParseIfcFile m_parser; - - osgGA::EventQueue* getEventQueue() const; - unsigned int getMouseButtonNum(QMouseEvent* event); - - void setupViewController(); - - void orientScene(osg::ref_ptr rootGroup); -}; - -#endif // IFCVIEWERWIDGET_H diff --git a/src/qtviewer/MainWindow.cpp b/src/qtviewer/MainWindow.cpp deleted file mode 100644 index fa46ed2b87..0000000000 --- a/src/qtviewer/MainWindow.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MainWindow.h" -#include "MessageLogger.h" -#include "IfcViewerWidget.h" - -MainWindow::MainWindow(qreal dpiScale, QWidget *parent) - : QMainWindow(parent), m_dpiScale(dpiScale) -{ - this->setWindowTitle("IfcOpenShell Viewer"); - this->resize(800, 600); //temporary reasonable initial size - - m_glWidget = new IfcViewerWidget(m_dpiScale, this); - QSizePolicy glSizePolicy = m_glWidget->sizePolicy(); - glSizePolicy.setVerticalStretch(3); - m_glWidget->setSizePolicy(glSizePolicy); - - m_outputText = new QPlainTextEdit(this); - m_outputText->setReadOnly(true); - - QSplitter* splitter = new QSplitter(Qt::Vertical, this); - splitter->addWidget(m_glWidget); - splitter->addWidget(m_outputText); - - setCentralWidget(splitter); - - createActions(); - createMenus(); - createConnections(); -} - -void MainWindow::createActions() -{ - openAction = new QAction(tr("&Open"), this); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); - - quitAction = new QAction(tr("E&xit"), this); - quitAction->setShortcut(QKeySequence::Quit); - - m_backgroundAction = new QAction(tr("&Background")); - m_backgroundAction->setEnabled(false); - m_backgroundAction->setCheckable(true); - m_backgroundAction->setChecked(false); - - m_outlineAction = new QAction(tr("&Outline")); - m_outlineAction->setEnabled(false); - m_outlineAction->setCheckable(true); - m_outlineAction->setChecked(false); -} - -void MainWindow::createMenus() -{ - QMenuBar *menuBar = new QMenuBar(); - setMenuBar(menuBar); - - fileMenu = new QMenu(tr("&File"), menuBar); - menuBar->addMenu(fileMenu); - - fileMenu->addAction(openAction); - fileMenu->addAction(quitAction); - - viewMenu = new QMenu(tr("&View"), menuBar); - menuBar->addMenu(viewMenu); - - viewMenu->addAction(m_backgroundAction); - viewMenu->addAction(m_outlineAction); -} - -void MainWindow::createConnections() -{ - connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - //connect(m_backgroundAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewBackground(bool))); - //connect(m_outlineAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewOutline(bool))); - - //connect(&m_parser, &ParseIfcFile::parsingInfo, this, &MainWindow::appendToOutputText); - connect(&MessageLogger::getInstance(), SIGNAL(logMessage(QString)), this, SLOT(appendToOutputText(QString))); - - connect(this, SIGNAL(loadFileInViewerWidget(const std::string&)), m_glWidget, SLOT(loadFile(const std::string&))); -} - -void MainWindow::appendToOutputText(const QString& message) -{ - m_outputText->appendPlainText(message); -} - -void MainWindow::openFile() -{ - QString filePath = QFileDialog::getOpenFileName(this, tr("Open IFC File"), - ".", tr("IFC Files (*.ifc)")); - - QFileInfo fileInfo(filePath); - QString fileName = fileInfo.fileName(); - - if (fileName.isEmpty()) - return; - - // Check if the file is a Qt resource file - if (fileName.startsWith(":/")) - return; - - QFile file(filePath); - if (!file.exists()) { - QMessageBox::critical(this, tr("Open IFC"), - QString("Could not open '%1'.").arg(filePath)); - - m_outlineAction->setEnabled(false); - m_backgroundAction->setEnabled(false); - return; - } - - QString message = tr("Opening file: %1\n").arg(filePath); - appendToOutputText(message); - - setWindowTitle(tr("%1 - IFCViewer").arg(fileName)); - - m_outlineAction->setEnabled(true); - m_backgroundAction->setEnabled(true); - - emit loadFileInViewerWidget(filePath.toStdString()); -} diff --git a/src/qtviewer/MainWindow.h b/src/qtviewer/MainWindow.h deleted file mode 100644 index 467a48cbdf..0000000000 --- a/src/qtviewer/MainWindow.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(qreal dpiScale, QWidget *parent = nullptr); - -signals: - void loadFileInViewerWidget(const std::string& filePath); - -public slots: - void openFile(); - void appendToOutputText(const QString& message); - -private: - void createActions(); - void createMenus(); - void createConnections(); -private: - qreal m_dpiScale; - - QMenu *fileMenu; - QAction *openAction; - QAction *quitAction; - - QMenu *viewMenu; - QAction *m_nativeAction; - QAction *m_glAction; - QAction *m_imageAction; - QAction *m_highQualityAntialiasingAction; - QAction *m_backgroundAction; - QAction *m_outlineAction; - - QOpenGLWidget *m_glWidget; - QPlainTextEdit *m_outputText; -}; - -#endif // MAINWINDOW_H diff --git a/src/qtviewer/MessageLogger.h b/src/qtviewer/MessageLogger.h deleted file mode 100644 index 41c6a29a65..0000000000 --- a/src/qtviewer/MessageLogger.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MESSAGELOGGER_H -#define MESSAGELOGGER_H - -#include -#include - -// SINGLETON -class MessageLogger : public QObject -{ - Q_OBJECT - -signals: - void logMessage(const QString& message); - -public: - static MessageLogger& getInstance() - { - static MessageLogger instance; - return instance; - } - - // Convenience function to log a message - static void log(const std::string& message) - { - getInstance().emitMessage(message); - } - -private slots: - void emitMessage(const std::string& message) - { - emit logMessage(QString::fromStdString(message)); - } - -private: - MessageLogger() {} - ~MessageLogger() {} - - // Disable copy constructor for MessageLogger - MessageLogger(const MessageLogger&) = delete; - - // Disable copy assignment operator for MessageLogger - MessageLogger& operator=(const MessageLogger&) = delete; -}; - -#endif // MESSAGELOGGER_H diff --git a/src/qtviewer/ParseIfcFile.cpp b/src/qtviewer/ParseIfcFile.cpp deleted file mode 100644 index dfb85f871f..0000000000 --- a/src/qtviewer/ParseIfcFile.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "ParseIfcFile.h" -#include "../ifcgeom/hybrid_kernel.h" - -#include "MessageLogger.h" -#include "osg/Array" -#include "osg/Geometry" -#include "osg/Material" -#include "osg/Matrixd" -#include "osg/MatrixTransform" -#include "osg/PrimitiveSet" -#include "osg/ref_ptr" -#include "osg/StateAttribute" -#include "osg/StateSet" -#include "osg/Vec4" - -#include // size_t -#include -#include -#include - -ParseIfcFile::ParseIfcFile() {} - -ParseIfcFile::~ParseIfcFile() {} - -bool ParseIfcFile::Parse( - const std::string& filePath, - std::vector>& matrixTransforms -) { - ifcopenshell::file file(filePath); - ifcopenshell::geometry::Settings settings; - settings.set("use-world-coords", false); - settings.set("weld-vertices", false); - settings.set("apply-default-materials", true); - - IfcGeom::Iterator* it = new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings), settings, &file); - if (!it->initialize()) { - MessageLogger::log("Error: Iterator failed to initialize! Aborting."); - delete it; - return false; - } - - std::string lastId; - std::vector> lastGeometrySet; - - do { - //const IfcGeom::BRepElement* bRepElem = it->get_native(); - const IfcGeom::TriangulationElement* triElem = static_cast(it->get()); - - // Print element info - std::string elemInfo = triElem->type(); - elemInfo += triElem->name() == "" ? "" : ": " + triElem->name(); - MessageLogger::log(elemInfo); - - const std::string id = triElem->geometry().id(); - - //MessageLogger::log("id: " + id); - - // Transformation Matrix - std::vector matrixData; - auto transform4x4 = triElem->transformation().data()->components(); - for (int col = 0; col<4; col++) - { - for (int row =0; row<3; row++) - { - matrixData.push_back(transform4x4(row,col)); - } - - } - - // Debugging: - std::string matrixStr = ""; - int col = 0; - int row = 0; - for (auto d : matrixData) { - matrixStr += std::to_string(d) + " "; - if (++col == 3) { - std::string lastCol = (row == 3) ? "1" : "0"; - matrixStr += lastCol + "\n"; - col = 0; - row++; - } - } - //MessageLogger::log(matrixStr); // Print matrix data - - const osg::Matrixd matrixd ( - matrixData[0], matrixData[1], matrixData[2], 0, - matrixData[3], matrixData[4], matrixData[5], 0, - matrixData[6], matrixData[7], matrixData[8], 0, - matrixData[9], matrixData[10], matrixData[11], 1 - ); - - const osg::ref_ptr matrixTransform = new osg::MatrixTransform; - matrixTransform->setMatrix(matrixd); - - if (id == lastId) { - for (auto geometry : lastGeometrySet) { - matrixTransform->addChild(geometry); - } - matrixTransforms.push_back(matrixTransform); - continue; - } - - const boost::shared_ptr& triElemGeom = triElem->geometry_pointer(); - - const std::vector& elemFaces = triElemGeom->faces(); - const std::vector& elemVertices = triElemGeom->verts(); - const std::vector& elemNormals = triElemGeom->normals(); - const std::vector& elemMats = triElemGeom->materials(); - const std::vector& elemMatIds = triElemGeom->material_ids(); - - std::map> uniqueMaterials; - - std::map> elemFaces_grouped; - auto fit = elemFaces.begin(); - for (const int& matId : elemMatIds) { - for (int i = 0; i < 3; ++i) { - elemFaces_grouped[matId].push_back(*fit++); - } - } - - if (fit != elemFaces.end()) - MessageLogger::log("** Failed to map the faces to material IDs!"); - - std::vector> geometrySet; - - for (const auto& group : elemFaces_grouped) { - int matId = group.first; - const std::vector& fVertIds = group.second; - - osg::ref_ptr osgVertices = new osg::Vec3Array; - osg::ref_ptr osgNormals = new osg::Vec3Array; - - for (size_t i = 0; i < fVertIds.size(); i += 3) { - buildTriangleNodes( - fVertIds, elemVertices, elemNormals, i, - osgVertices, osgNormals - ); - } - - osg::ref_ptr geometry = new osg::Geometry; - - geometry->setVertexArray(osgVertices); - geometry->setNormalArray(osgNormals); - geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX); - - osg::ref_ptr drawArrays = new osg::DrawArrays( - osg::PrimitiveSet::TRIANGLES, 0, osgVertices->size()); - geometry->addPrimitiveSet(drawArrays); - - osg::ref_ptr osgMaterial = getOsgMaterial(elemMats[matId]); - geometry->getOrCreateStateSet()->setAttributeAndModes(osgMaterial.get()); - - matrixTransform->addChild(geometry); - - geometrySet.push_back(geometry); - } - - matrixTransforms.push_back(matrixTransform); - - lastId = id; - lastGeometrySet = geometrySet; - - } while (it->next()); - - return true; -} - -void ParseIfcFile::buildTriangleNodes( - const std::vector& fVertIds, - const std::vector& elemVertices, - const std::vector& elemNormals, - size_t index, - osg::ref_ptr osgVertices, - osg::ref_ptr osgNormals) -{ - auto addVertexAndNormal = [fVertIds, elemVertices, elemNormals, osgVertices, osgNormals](size_t i) { - - size_t initVertIndex = 3 * fVertIds[i]; - size_t x_vertIndex = initVertIndex; - size_t y_vertIndex = initVertIndex + 1; - size_t z_vertIndex = initVertIndex + 2; - - osgVertices->push_back(osg::Vec3 ( - elemVertices[x_vertIndex], - elemVertices[y_vertIndex], - elemVertices[z_vertIndex] - )); - - osgNormals->push_back(osg::Vec3 ( - elemNormals[x_vertIndex], - elemNormals[y_vertIndex], - elemNormals[z_vertIndex] - )); - }; - - addVertexAndNormal(index); - addVertexAndNormal(index + 1); - addVertexAndNormal(index + 2); -} - -osg::ref_ptr ParseIfcFile::getOsgMaterial(const ifcopenshell::geometry::taxonomy::style::ptr& material) -{ - ifcopenshell::geometry::taxonomy::colour diffuseColor = material->diffuse; - osg::Vec4 matOsgDiffuseColor( - diffuseColor.r(), - diffuseColor.g(), - diffuseColor.b(), - material->transparency); - - osg::ref_ptr osgMaterial = new osg::Material; - osgMaterial->setDiffuse(osg::Material::FRONT_AND_BACK, matOsgDiffuseColor); - - return osgMaterial; -} diff --git a/src/qtviewer/ParseIfcFile.h b/src/qtviewer/ParseIfcFile.h deleted file mode 100644 index f3370f3c20..0000000000 --- a/src/qtviewer/ParseIfcFile.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef PARSEIFCFILE_H -#define PARSEIFCFILE_H - -#include "../ifcgeom/Iterator.h" -#include "osg/Geometry" -#include "osg/Material" -#include "osg/MatrixTransform" -#include "osg/ref_ptr" - -#include -#include -#include -#include - -class ParseIfcFile : public QObject { - - public: - ParseIfcFile(); - ~ParseIfcFile(); - - bool Parse( - const std::string& filePath, - std::vector>& matrixTransforms); - - private: - void buildTriangleNodes( - const std::vector& fVertIds, - const std::vector& elemVertices, - const std::vector& elemNormals, - size_t index, - osg::ref_ptr osgVertices, - osg::ref_ptr osgNormals); - - osg::ref_ptr getOsgMaterial(const ifcopenshell::geometry::taxonomy::style::ptr& material); -}; - -#endif // PARSEIFCFILE_H diff --git a/src/qtviewer/main.cpp b/src/qtviewer/main.cpp deleted file mode 100644 index d986e6751e..0000000000 --- a/src/qtviewer/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "MainWindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - // Set the icon in the window title-bar on mswindows - // and dock icon on macos. - // "icon" alias defined in .qrc file - QIcon appIcon(":/icon"); - app.setWindowIcon(appIcon); - // File icon set with: - // mswindows - .rc file - // macos - .icns file (using CMake) - - qreal dpiScale = app.devicePixelRatio(); - - MainWindow window(dpiScale); - - window.show(); - - return app.exec(); -} diff --git a/src/qtviewer/resources/ifcopenshell_logo.ico b/src/qtviewer/resources/ifcopenshell_logo.ico deleted file mode 100644 index df8e7eed7d..0000000000 Binary files a/src/qtviewer/resources/ifcopenshell_logo.ico and /dev/null differ diff --git a/src/qtviewer/resources/ifcopenshell_logo.png b/src/qtviewer/resources/ifcopenshell_logo.png deleted file mode 100644 index c6d7aa7ee5..0000000000 Binary files a/src/qtviewer/resources/ifcopenshell_logo.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.icns b/src/qtviewer/resources/ifcosLogo.icns deleted file mode 100644 index aa4aa1aca8..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.icns and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-100.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-100.png deleted file mode 100644 index b4c24c3853..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-100.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-1024.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-1024.png deleted file mode 100644 index 8b304dcda0..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-1024.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-114.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-114.png deleted file mode 100644 index bc6e7819a0..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-114.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-120.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-120.png deleted file mode 100644 index 10e5a914d4..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-120.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-128.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-128.png deleted file mode 100644 index ebc78e6ff7..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-128.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-144.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-144.png deleted file mode 100644 index 58c4ee9606..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-144.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-152.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-152.png deleted file mode 100644 index 69c235cf2c..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-152.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-16.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-16.png deleted file mode 100644 index a224e3b277..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-16.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-167.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-167.png deleted file mode 100644 index f574e0ecb2..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-167.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-172.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-172.png deleted file mode 100644 index 787c331ebc..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-172.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-180.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-180.png deleted file mode 100644 index fc283da79e..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-180.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-196.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-196.png deleted file mode 100644 index d3dde8d8f1..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-196.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-20.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-20.png deleted file mode 100644 index a022a649da..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-20.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-256.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-256.png deleted file mode 100644 index ac24a41145..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-256.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-29.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-29.png deleted file mode 100644 index c3323bb400..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-29.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-32.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-32.png deleted file mode 100644 index 8c0fe16c59..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-32.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-40.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-40.png deleted file mode 100644 index 640fd0ce08..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-40.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-48.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-48.png deleted file mode 100644 index 17d13a6dc1..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-48.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-50.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-50.png deleted file mode 100644 index c7a8034ae9..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-50.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-512.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-512.png deleted file mode 100644 index 23fb7c50e5..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-512.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-55.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-55.png deleted file mode 100644 index f87a20384b..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-55.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-57.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-57.png deleted file mode 100644 index 53fd85caa8..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-57.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-58.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-58.png deleted file mode 100644 index 1f2828eb82..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-58.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-60.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-60.png deleted file mode 100644 index 8dd4f42626..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-60.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-64.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-64.png deleted file mode 100644 index bf3bd22bb6..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-64.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-72.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-72.png deleted file mode 100644 index 85f01d6857..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-72.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-76.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-76.png deleted file mode 100644 index 0d0a8e0d00..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-76.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-80.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-80.png deleted file mode 100644 index 4173ac6806..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-80.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-87.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-87.png deleted file mode 100644 index 651149b5ed..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-87.png and /dev/null differ diff --git a/src/qtviewer/resources/ifcosLogo.iconset/Icon-88.png b/src/qtviewer/resources/ifcosLogo.iconset/Icon-88.png deleted file mode 100644 index 2f44ab9eed..0000000000 Binary files a/src/qtviewer/resources/ifcosLogo.iconset/Icon-88.png and /dev/null differ diff --git a/src/qtviewer/resources/qt_res.aps b/src/qtviewer/resources/qt_res.aps deleted file mode 100644 index 48959dca7b..0000000000 Binary files a/src/qtviewer/resources/qt_res.aps and /dev/null differ diff --git a/src/qtviewer/resources/qt_res.rc b/src/qtviewer/resources/qt_res.rc deleted file mode 100644 index 06595be934..0000000000 --- a/src/qtviewer/resources/qt_res.rc +++ /dev/null @@ -1,37 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "ifcopenshell_logo.ico" diff --git a/src/qtviewer/resources/qt_resources.qrc b/src/qtviewer/resources/qt_resources.qrc deleted file mode 100644 index 9adc51b707..0000000000 --- a/src/qtviewer/resources/qt_resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - ifcopenshell_logo.png - - diff --git a/src/qtviewer/resources/resource.h b/src/qtviewer/resources/resource.h deleted file mode 100644 index 7112d62142..0000000000 --- a/src/qtviewer/resources/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by qt_res.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif