mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Added output panel (for debug info, etc.)
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QSplitter>
|
||||
#include <sstream>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "ParseIfcFile.h"
|
||||
#include "IfcViewerWidget.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
@@ -19,7 +19,18 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
this->resize(800, 600); //temporary reasonable initial size
|
||||
|
||||
m_glWidget = new IfcViewerWidget(this);
|
||||
setCentralWidget(m_glWidget);
|
||||
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();
|
||||
@@ -69,6 +80,13 @@ void MainWindow::createConnections()
|
||||
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);
|
||||
}
|
||||
|
||||
void MainWindow::appendToOutputText(const QString& message)
|
||||
{
|
||||
m_outputText->appendPlainText(message);
|
||||
}
|
||||
|
||||
void MainWindow::openFile()
|
||||
@@ -96,8 +114,10 @@ void MainWindow::openFile()
|
||||
return;
|
||||
}
|
||||
|
||||
ParseIfcFile parser;
|
||||
parser.Parse(filePath.toStdString());
|
||||
QString message = tr("Opening file: %1\n").arg(filePath);
|
||||
appendToOutputText(message);
|
||||
|
||||
m_parser.Parse(filePath.toStdString());
|
||||
|
||||
m_currentPath = filePath;
|
||||
setWindowTitle(tr("%1 - IFCViewer").arg(fileName));
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <QString>
|
||||
#include <QAction>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "ParseIfcFile.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
@@ -21,6 +24,7 @@ private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createConnections();
|
||||
void appendToOutputText(const QString& message);
|
||||
private:
|
||||
QMenu *fileMenu;
|
||||
QAction *openAction;
|
||||
@@ -35,7 +39,11 @@ private:
|
||||
QAction *m_outlineAction;
|
||||
|
||||
QString m_currentPath;
|
||||
|
||||
QOpenGLWidget *m_glWidget;
|
||||
QPlainTextEdit *m_outputText;
|
||||
|
||||
ParseIfcFile m_parser;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -4,12 +4,43 @@
|
||||
#define IfcSchema Ifc2x3
|
||||
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"
|
||||
|
||||
ParseIfcFile::ParseIfcFile() {}
|
||||
|
||||
ParseIfcFile::~ParseIfcFile() {}
|
||||
|
||||
void ParseIfcFile::outputMsg(const std::string& msg)
|
||||
{
|
||||
emit parsingInfo(QString::fromStdString(msg));
|
||||
}
|
||||
|
||||
void ParseIfcFile::Parse(const std::string& filePath)
|
||||
{
|
||||
//IfcParse::IfcFile ifcFile(filePath);
|
||||
IfcParse::IfcFile file(filePath);
|
||||
|
||||
IfcGeom::IteratorSettings settings;
|
||||
settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
|
||||
settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, false);
|
||||
|
||||
IfcGeom::Iterator* it = new IfcGeom::Iterator(settings, &file);
|
||||
if (!it->initialize()) {
|
||||
outputMsg("Error: Iterator failed to initialize! Aborting.");
|
||||
delete it;
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
//const IfcGeom::BRepElement* bRepElem = it->get_native();
|
||||
const IfcGeom::TriangulationElement* triElem = static_cast<const IfcGeom::TriangulationElement*>(it->get());
|
||||
outputMsg(triElem->type() + ": " + triElem->name());
|
||||
|
||||
const boost::shared_ptr<IfcGeom::Representation::Triangulation>& triElemGeom = triElem->geometry_pointer();
|
||||
|
||||
// materials
|
||||
const std::vector<IfcGeom::Material>& elemMats = triElemGeom->materials();
|
||||
for (auto mat : elemMats) {
|
||||
outputMsg(" " + mat.original_name());
|
||||
}
|
||||
} while (it->next());
|
||||
}
|
||||
@@ -1,10 +1,20 @@
|
||||
#ifndef PARSEIFCFILE_H
|
||||
#define PARSEIFCFILE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
|
||||
class ParseIfcFile
|
||||
class ParseIfcFile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void parsingInfo(const QString& info);
|
||||
|
||||
private:
|
||||
void outputMsg(const std::string& msg);
|
||||
|
||||
public:
|
||||
ParseIfcFile();
|
||||
~ParseIfcFile();
|
||||
|
||||
Reference in New Issue
Block a user