add OuputDevice as singleton to manage output to statusbar,
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QOpenGlTexture>
|
||||
#include <fstream>
|
||||
#include <QVector>
|
||||
@@ -7,7 +6,6 @@
|
||||
#include <QMatrix4x4>
|
||||
#include <QQuaternion>
|
||||
#include <QRegExp>
|
||||
#include "MainWindow.h"
|
||||
|
||||
struct BoundingBox {
|
||||
QQuaternion rotation;
|
||||
@@ -54,14 +52,12 @@ struct Material {
|
||||
std::uint8_t dataValues[2] = { 0 };
|
||||
};
|
||||
|
||||
class FileInterface : public QObject
|
||||
class FileInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileInterface(QString path, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_models(new QVector<Model*>)
|
||||
explicit FileInterface(QString path)
|
||||
: m_models(new QVector<Model*>)
|
||||
, m_materials(new QVector<Material>)
|
||||
{
|
||||
//open file
|
||||
@@ -70,10 +66,6 @@ public:
|
||||
if (!m_file.is_open())
|
||||
throw std::invalid_argument(std::string("ERROR: file not found: ") += path.toStdString());
|
||||
|
||||
MainWindow* tmp = dynamic_cast<MainWindow*>(parent->parent()->parent());
|
||||
if(tmp != NULL)
|
||||
connect(this, SIGNAL(sendMessage(QString, int)), tmp, SLOT(printMessage(QString, int)));
|
||||
|
||||
m_filepath = path.left(path.lastIndexOf(QRegExp("/|\\\\")));
|
||||
|
||||
};
|
||||
@@ -138,6 +130,4 @@ public:
|
||||
return defMaterial;
|
||||
};
|
||||
|
||||
signals:
|
||||
void sendMessage(QString msg, int severity);
|
||||
};
|
@@ -46,7 +46,6 @@ public slots:
|
||||
// signals
|
||||
signals:
|
||||
void requestResetView();
|
||||
void sendMessage(QString message, int severity);
|
||||
void requestUpdate();
|
||||
void sendFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@ enum ModelTyp {
|
||||
class MshFile : public FileInterface
|
||||
{
|
||||
public:
|
||||
explicit MshFile(QString path, QObject *parent = Q_NULLPTR);
|
||||
explicit MshFile(QString path);
|
||||
virtual ~MshFile();
|
||||
|
||||
private:
|
||||
|
@@ -91,7 +91,6 @@ public slots:
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void sendMessage(QString message, int severity);
|
||||
void loadFile(QString);
|
||||
};
|
||||
|
||||
|
27
QtMeshViewer/Header/OutputDevice.h
Normal file
27
QtMeshViewer/Header/OutputDevice.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
class OutputDevice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
OutputDevice(QObject *parent = Q_NULLPTR) : QObject(parent) {};
|
||||
|
||||
public:
|
||||
OutputDevice(OutputDevice const&) = delete;
|
||||
void operator=(OutputDevice const&) = delete;
|
||||
|
||||
~OutputDevice() {};
|
||||
|
||||
static OutputDevice* getInstance(QObject *parent = Q_NULLPTR) {
|
||||
static OutputDevice* instance = new OutputDevice(parent);
|
||||
return instance;
|
||||
};
|
||||
|
||||
void print(QString message, int severity) { emit sendMessage(message, severity); };
|
||||
|
||||
signals:
|
||||
void sendMessage(QString message, int severity);
|
||||
|
||||
};
|
Reference in New Issue
Block a user