text in FileInfoWindow can be marked and copied,
code cleaning
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include "ui_FileInfoWindow.h"
|
||||
|
||||
class FileInfoWindow : public QWidget
|
||||
@@ -8,13 +7,21 @@ class FileInfoWindow : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileInfoWindow(QWidget *parent = Q_NULLPTR);
|
||||
~FileInfoWindow();
|
||||
FileInfoWindow(QWidget *parent = Q_NULLPTR)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FileInfoWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
|
||||
ui->scrollArea->widget()->setStyleSheet("background-color: #ffffff");
|
||||
};
|
||||
|
||||
~FileInfoWindow() { delete ui; };
|
||||
|
||||
private:
|
||||
Ui::FileInfoWindow* ui;
|
||||
|
||||
public:
|
||||
void setBasicText(QString text);
|
||||
void setDetailText(QString text);
|
||||
void setBasicText(QString text) { ui->basic->setText(text); };
|
||||
void setDetailText(QString text) { ui->detail->setText(text); };
|
||||
};
|
@@ -1,17 +1,13 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QOpenGlTexture>
|
||||
#include <fstream>
|
||||
#include <QVector>
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
#include <QMatrix4x4>
|
||||
#include <QQuaternion>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGlTexture>
|
||||
#include <QObject>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QRegExp>
|
||||
#include <..\Header\MainWindow.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
struct BoundingBox {
|
||||
QQuaternion rotation;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#include "..\Header\FileInterface.h"
|
||||
#include <QObject>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QVector>
|
||||
#include "FileInterface.h"
|
||||
|
||||
|
||||
struct DrawInformation {
|
||||
unsigned int offset;
|
||||
@@ -22,20 +22,28 @@ public:
|
||||
GeometryEngine(QObject *parent = Q_NULLPTR);
|
||||
virtual ~GeometryEngine();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
QOpenGLBuffer m_arrayBuf;
|
||||
QOpenGLBuffer m_indexBuf;
|
||||
QVector<Material>* m_materials = Q_NULLPTR;
|
||||
QVector<DrawInformation> m_drawList;
|
||||
BoundingBox m_boundings;
|
||||
Material* m_defaultMaterial;
|
||||
BoundingBox m_boundings;
|
||||
QVector<DrawInformation> m_drawList;
|
||||
|
||||
// functions
|
||||
private:
|
||||
void clearData();
|
||||
|
||||
public slots:
|
||||
void loadFile(QString filePath);
|
||||
public:
|
||||
void drawGeometry(QOpenGLShaderProgram *program, bool wireframe);
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void loadFile(QString filePath);
|
||||
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void requestResetView();
|
||||
void sendMessage(QString message, int severity);
|
||||
|
@@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <qwidget.h>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include "ui_MainWindow.h"
|
||||
#include "..\Header\FileInfoWindow.h"
|
||||
#include "FileInfoWindow.h"
|
||||
#include <QByteArray>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
struct Material;
|
||||
|
||||
@@ -18,27 +17,32 @@ public:
|
||||
MainWindow(QWidget *parent = Q_NULLPTR);
|
||||
~MainWindow();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
Ui::MainWindowClass* ui;
|
||||
int m_curSeverity;
|
||||
void setupWidgets();
|
||||
|
||||
QByteArray m_fileInfo;
|
||||
QLabel* m_output;
|
||||
int m_curSeverity;
|
||||
|
||||
FileInfoWindow* m_infoWindow;
|
||||
|
||||
// functions
|
||||
private:
|
||||
void setupWidgets();
|
||||
void openFile();
|
||||
void aboutFile();
|
||||
void aboutTool();
|
||||
void takeScreenShot();
|
||||
void aboutTool();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent * e) Q_DECL_OVERRIDE;
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void printMessage(QString message, int severity);
|
||||
void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void loadFile(QString);
|
||||
};
|
||||
|
@@ -1,14 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "geometryengine.h"
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QMatrix4x4>
|
||||
#include <QQuaternion>
|
||||
#include <QVector2D>
|
||||
#include <QBasicTimer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QMatrix4x4>
|
||||
#include "GeometryEngine.h"
|
||||
#include "SettingsWindow.h"
|
||||
|
||||
|
||||
class GeometryEngine;
|
||||
@@ -21,10 +17,26 @@ public:
|
||||
explicit OglViewerWidget(QWidget *parent = 0);
|
||||
~OglViewerWidget();
|
||||
|
||||
signals:
|
||||
void loadFile(QString);
|
||||
|
||||
// attributes
|
||||
private:
|
||||
QOpenGLShaderProgram m_program;
|
||||
GeometryEngine *m_dataEngine;
|
||||
|
||||
QVector4D m_backgroundColorOn = { 0.02f, 0.02f, 0.02f, 1.0f };
|
||||
QVector4D m_backgroundColorOff = { 0.5f, 0.8f, 1.0f, 1.0f };
|
||||
|
||||
bool m_wireframe = false;
|
||||
bool m_lightOn = false;
|
||||
|
||||
struct {
|
||||
QVector4D position = { 1,1,1,0 };
|
||||
QVector3D intensities = { 1.0,1.0,1.0 };
|
||||
float attenuationFactor = 0.0f;
|
||||
float ambientCoefficient = 0.005f;
|
||||
} m_light;
|
||||
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
struct {
|
||||
bool left = false;
|
||||
bool right = false;
|
||||
@@ -37,53 +49,37 @@ private:
|
||||
bool z = true;
|
||||
} m_rotDirections;
|
||||
|
||||
struct {
|
||||
QVector4D position = { 1,1,1,0 };
|
||||
QVector3D intensities = { 1.0,1.0,1.0 };
|
||||
float attenuationFactor = 0.0f;
|
||||
float ambientCoefficient = 0.005f;
|
||||
} m_light;
|
||||
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
QVector4D m_backgroundColorOn = {0.02f, 0.02f, 0.02f, 1.0f};
|
||||
QVector4D m_backgroundColorOff = { 0.5f, 0.8f, 1.0f, 1.0f };
|
||||
|
||||
QOpenGLShaderProgram m_program;
|
||||
GeometryEngine *m_dataEngine;
|
||||
|
||||
QMatrix4x4 m_projection;
|
||||
QVector3D m_translation;
|
||||
QQuaternion m_rotation;
|
||||
|
||||
bool m_wireframe = false;
|
||||
bool m_lightOn = false;
|
||||
|
||||
double m_zSpeed = 1.0;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
|
||||
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
|
||||
void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE;
|
||||
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
|
||||
// functions
|
||||
private:
|
||||
void initShaders();
|
||||
void setConnections();
|
||||
void resetView();
|
||||
void updateLightPosition();
|
||||
|
||||
protected:
|
||||
void initializeGL() Q_DECL_OVERRIDE;
|
||||
void resizeGL(int w, int h) Q_DECL_OVERRIDE;
|
||||
void paintGL() Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void initShaders();
|
||||
void setConnections();
|
||||
void updateLightPosition();
|
||||
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
|
||||
|
||||
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void resetView();
|
||||
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
|
||||
void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE;
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void changeDirection(int direction);
|
||||
void toggleAxis(int axis);
|
||||
void toggleWireframe();
|
||||
void toggleLight();
|
||||
void showSettings();
|
||||
@@ -93,7 +89,9 @@ public slots:
|
||||
void setAttFac(double value);
|
||||
void setAmbCoef(double value);
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void sendMessage(QString message, int severity);
|
||||
void loadFile(QString);
|
||||
};
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "ui_SettingsWindow.h"
|
||||
#include <QVector3D>
|
||||
|
||||
|
||||
class SettingsWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@@ -3,7 +3,6 @@
|
||||
#include <QImage>
|
||||
#include <QColor>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
QImage loadTga(QString filePath, bool &success)
|
||||
{
|
||||
@@ -67,7 +66,7 @@ QImage loadTga(QString filePath, bool &success)
|
||||
int valb = vui8Pixels.at(y * ui32Width * ui32BpP / 8 + x * ui32BpP / 8);
|
||||
|
||||
QColor value(valr, valg, valb);
|
||||
img.setPixelColor(x, ui32Width - 1 - y, value);
|
||||
img.setPixel(x, ui32Width - 1 - y, value.rgba());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +96,7 @@ QImage loadTga(QString filePath, bool &success)
|
||||
else
|
||||
color.setRgb(qRgb(tempData[2], tempData[1], tempData[0]));
|
||||
|
||||
img.setPixelColor(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color);
|
||||
img.setPixel(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color.rgba());
|
||||
tmp_pixelIndex++;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +116,7 @@ QImage loadTga(QString filePath, bool &success)
|
||||
else
|
||||
color.setRgb(qRgb(tempData[2], tempData[1], tempData[0]));
|
||||
|
||||
img.setPixelColor(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color);
|
||||
img.setPixel(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color.rgba());
|
||||
tmp_pixelIndex++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user