Using QString now,
fileinfo works now
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <QVector>
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
#include <QStringList>
|
||||
#include <QMatrix4x4>
|
||||
#include <QQuaternion>
|
||||
#include <QOpenGLFunctions>
|
||||
@@ -41,16 +42,16 @@ class FileInterface : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileInterface(const char* path, QObject *parent)
|
||||
explicit FileInterface(QString path, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_models(new QVector<Model*>)
|
||||
, m_textureNames(new QVector<std::string>)
|
||||
, m_textureNames(new QStringList)
|
||||
{
|
||||
//open file
|
||||
m_file.open(path, std::ios::in | std::ios::binary);
|
||||
m_file.open(path.toStdString().c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if (!m_file.is_open())
|
||||
throw std::invalid_argument(std::string("ERROR: file not found: ") += path);
|
||||
throw std::invalid_argument(std::string("ERROR: file not found: ") += path.toStdString());
|
||||
|
||||
MainWindow* tmp = dynamic_cast<MainWindow*>(parent->parent()->parent());
|
||||
if(tmp != NULL)
|
||||
@@ -87,14 +88,14 @@ public:
|
||||
protected:
|
||||
QVector<Model*>* m_models;
|
||||
std::fstream m_file;
|
||||
QVector<std::string>* m_textureNames;
|
||||
QStringList* m_textureNames;
|
||||
BoundingBox m_sceneBbox;
|
||||
|
||||
virtual void import() = 0;
|
||||
|
||||
public:
|
||||
virtual QVector<Model*>* getModels() const { return m_models; };
|
||||
virtual QVector<std::string>* getTextureNames() const { return m_textureNames; };
|
||||
virtual QStringList* getTextureNames() const { return m_textureNames; };
|
||||
virtual BoundingBox getBoundingBox() const { return m_sceneBbox; };
|
||||
|
||||
signals:
|
||||
|
@@ -29,16 +29,17 @@ private:
|
||||
QVector<DrawInformation> m_drawList;
|
||||
BoundingBox m_boundings;
|
||||
|
||||
void loadTexture(const char* filePath, const char* fileName);
|
||||
void loadTexture(QString filePath, QString fileName);
|
||||
void clearData();
|
||||
|
||||
public slots:
|
||||
void loadFile(const char* filePath);
|
||||
void loadFile(QString filePath);
|
||||
void drawGeometry(QOpenGLShaderProgram *program);
|
||||
|
||||
signals:
|
||||
void requestResetView();
|
||||
void sendMessage(QString message, int severity);
|
||||
void requestUpdate();
|
||||
void sendFileInfo(QString name, QStringList textures, int vertices, int triangle);
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
@@ -15,6 +17,7 @@ private:
|
||||
Ui::MainWindowClass* ui;
|
||||
int m_curSeverity;
|
||||
void setupWidgets();
|
||||
QByteArray m_fileInfo;
|
||||
|
||||
|
||||
private slots:
|
||||
@@ -24,7 +27,8 @@ private slots:
|
||||
|
||||
public slots:
|
||||
void printMessage(QString message, int severity);
|
||||
void setFileInfo(QString name, QStringList textures, int vertices, int triangle);
|
||||
|
||||
signals:
|
||||
void loadFile(const char*);
|
||||
void loadFile(QString);
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@ enum ModelTyp {
|
||||
class MshFile : public FileInterface
|
||||
{
|
||||
public:
|
||||
explicit MshFile(const char* path, QObject *parent = Q_NULLPTR);
|
||||
explicit MshFile(QString path, QObject *parent = Q_NULLPTR);
|
||||
virtual ~MshFile();
|
||||
|
||||
private:
|
||||
|
@@ -22,7 +22,7 @@ public:
|
||||
~OglViewerWidget();
|
||||
|
||||
signals:
|
||||
void loadFile(const char*);
|
||||
void loadFile(QString);
|
||||
|
||||
private:
|
||||
struct {
|
||||
|
@@ -5,14 +5,14 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
QImage loadTga(const char* filePath, bool &success)
|
||||
QImage loadTga(QString filePath, bool &success)
|
||||
{
|
||||
QImage img;
|
||||
if (!img.load(filePath))
|
||||
{
|
||||
|
||||
// open the file
|
||||
std::fstream fsPicture(filePath, std::ios::in | std::ios::binary);
|
||||
std::fstream fsPicture(filePath.toStdString().c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if (!fsPicture.is_open())
|
||||
{
|
||||
|
Reference in New Issue
Block a user