mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
QT Viewer main structure.
CMake: added an entry at main CMake script that makes QTViewer an optional build. QT Viewer main structure only, libQGLViewer or any 3D functionality can be added to mainWindow as a widget later on.
This commit is contained in:
@@ -126,6 +126,8 @@ ADD_SUBDIRECTORY(../src/ifcwrap ifcwrap)
|
||||
# Build IfcParseExamples using separate CMakeLists.txt
|
||||
ADD_SUBDIRECTORY(../src/examples examples)
|
||||
|
||||
ADD_SUBDIRECTORY(../src/qtviewer qtviewer)
|
||||
|
||||
# CMake installation targets
|
||||
SET(include_files_geom
|
||||
../src/ifcgeom/IfcGeom.h
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
OPTION( QT_USE_QTVIEWER "IfcOpenShell QT GUI Viewer, QT environment required" OFF )
|
||||
|
||||
|
||||
IF (QT_USE_QTVIEWER)
|
||||
|
||||
|
||||
# Find QT header files
|
||||
SET(QT_MIN_VERSION "4.5.0")
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
|
||||
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
SET(CMAKE_PACKAGE_QTGUI TRUE)
|
||||
SET(CMAKE_PACKAGE_QTSVG TRUE)
|
||||
|
||||
# Find QT header files
|
||||
IF("$ENV{QT_INCLUDE_DIR}" STREQUAL "")
|
||||
SET(QT_INCLUDE_DIR "/usr/include/QT4/" CACHE FILEPATH "QT4 header files")
|
||||
MESSAGE(STATUS "Looking for QT4 include files in: ${QT_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "Use QT_INCLUDE_DIR to specify another directory")
|
||||
ELSE()
|
||||
SET(QT_INCLUDE_DIR $ENV{QT_INCLUDE_DIR} CACHE FILEPATH "QT4 header files")
|
||||
MESSAGE(STATUS "Looking for QT4 include files in: ${QT_INCLUDE_DIR}")
|
||||
ENDIF()
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(${QGLViewer_INCLUDE_DIR})
|
||||
|
||||
SET(QTviewer_SRCS
|
||||
../../src/qtviewer/mainwindow.h
|
||||
../../src/qtviewer/mainwindow.cpp
|
||||
../../src/qtviewer/main.cpp
|
||||
)
|
||||
SET(QTviewer_MOC_SRCS
|
||||
../../src/qtviewer/mainwindow.h
|
||||
)
|
||||
|
||||
QT_WRAP_CPP(QTviewer QTviewer_SRCS ${QTviewer_MOC_SRCS})
|
||||
|
||||
ADD_EXECUTABLE( QTviewer ${QTviewer_SRCS} ${QTviewer_MOC_SRCS})
|
||||
#http://www.qtcentre.org/wiki/index.php?title=Compiling_Qt4_apps_with_CMake
|
||||
|
||||
TARGET_LINK_libRARIES (QTviewer IfcParse IfcGeom ${QT_LIBRARIES} TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet)
|
||||
|
||||
|
||||
ENDIF (QT_USE_QTVIEWER)
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#ifndef QT_NO_OPENGL
|
||||
#include <QGLFormat>
|
||||
#endif
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
//QGLViewer viewer;
|
||||
|
||||
// Restore the previous viewer state.
|
||||
//viewer.restoreStateFromFile();
|
||||
|
||||
MainWindow window;
|
||||
//window.openFile(" ");
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <math.h>
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: QMainWindow()
|
||||
{
|
||||
|
||||
|
||||
IfcGeomObjects::Settings(IfcGeomObjects::USE_WORLD_COORDS,true);
|
||||
IfcGeomObjects::Settings(IfcGeomObjects::WELD_VERTICES,false);
|
||||
IfcGeomObjects::Settings(IfcGeomObjects::SEW_SHELLS,true);
|
||||
|
||||
|
||||
|
||||
QMenu *fileMenu = new QMenu(tr("&File"), this);
|
||||
QAction *openAction = fileMenu->addAction(tr("&Open..."));
|
||||
openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
|
||||
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
|
||||
quitAction->setShortcuts(QKeySequence::Quit);
|
||||
|
||||
menuBar()->addMenu(fileMenu);
|
||||
|
||||
QMenu *viewMenu = new QMenu(tr("&View"), this);
|
||||
m_backgroundAction = viewMenu->addAction(tr("&Background"));
|
||||
m_backgroundAction->setEnabled(false);
|
||||
m_backgroundAction->setCheckable(true);
|
||||
m_backgroundAction->setChecked(false);
|
||||
//connect(m_backgroundAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewBackground(bool)));
|
||||
|
||||
m_outlineAction = viewMenu->addAction(tr("&Outline"));
|
||||
m_outlineAction->setEnabled(false);
|
||||
m_outlineAction->setCheckable(true);
|
||||
m_outlineAction->setChecked(true);
|
||||
// connect(m_outlineAction, SIGNAL(toggled(bool)), (QWidget*)m_v, SLOT(setViewOutline(bool)));
|
||||
|
||||
menuBar()->addMenu(viewMenu);
|
||||
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||
|
||||
//setCentralWidget((QWidget*)m_v);
|
||||
setWindowTitle(tr("IfcOpenShell QT Viewer"));
|
||||
}
|
||||
|
||||
void MainWindow::openFile(const QString &path)
|
||||
{
|
||||
QString fileName;
|
||||
if (path.isNull())
|
||||
fileName = QFileDialog::getOpenFileName(this, tr("Open IFC"),
|
||||
m_currentPath, "IFC files (*.ifc)");
|
||||
else
|
||||
fileName = path;
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (!file.exists()) {
|
||||
QMessageBox::critical(this, tr("Open IFC"),
|
||||
QString("Could not open file '%1'.").arg(fileName));
|
||||
|
||||
m_outlineAction->setEnabled(false);
|
||||
m_backgroundAction->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
std::stringstream ss;
|
||||
if ( ! IfcGeomObjects::Init(fileName.toStdString(),&std::cout,&ss) ) {
|
||||
QMessageBox::critical(this, tr("Open IFC"),
|
||||
QString("[Error] unable to parse file '%1'. Or no geometrical entities found" ).arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
//connect((QWidget*)m_view, SIGNAL(drawNeeded()), this, SLOT(drawIfcObject()));
|
||||
|
||||
if (!fileName.startsWith(":/")) {
|
||||
m_currentPath = fileName;
|
||||
setWindowTitle(tr("%1 - IFCViewer").arg(m_currentPath));
|
||||
}
|
||||
|
||||
m_outlineAction->setEnabled(true);
|
||||
m_backgroundAction->setEnabled(true);
|
||||
|
||||
// resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::draw()
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <qobject.h>
|
||||
#include "../ifcgeom/IfcGeomObjects.h"
|
||||
|
||||
class ObjectsView;
|
||||
|
||||
class QGLViewer;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QGraphicsView;
|
||||
class QGraphicsScene;
|
||||
class QGraphicsRectItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void draw();
|
||||
|
||||
public slots:
|
||||
void openFile(const QString &path = QString());
|
||||
void setRenderer(QAction *action);
|
||||
|
||||
private:
|
||||
QAction *m_nativeAction;
|
||||
QAction *m_glAction;
|
||||
QAction *m_imageAction;
|
||||
QAction *m_highQualityAntialiasingAction;
|
||||
QAction *m_backgroundAction;
|
||||
QAction *m_outlineAction;
|
||||
|
||||
QString m_currentPath;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user