Compare commits

..

1 Commits

Author SHA1 Message Date
itdominator 64d5584698 Update 'README.md' 2021-04-26 21:07:42 +00:00
9 changed files with 260 additions and 353 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>600</width>
<height>600</height> <height>400</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -38,11 +38,8 @@
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features"> <property name="features">
<set>QDockWidget::DockWidgetFloatable</set> <set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable</set>
</property> </property>
<property name="allowedAreas"> <property name="allowedAreas">
<set>Qt::RightDockWidgetArea</set> <set>Qt::RightDockWidgetArea</set>
@ -71,31 +68,42 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QTreeWidget" name="treeWidget">
<item> <property name="showDropIndicator" stdset="0">
<widget class="QComboBox" name="dirDropDownList"> <bool>false</bool>
<property name="focusPolicy"> </property>
<enum>Qt::ClickFocus</enum> <property name="dragEnabled">
</property> <bool>true</bool>
</widget> </property>
</item> <property name="dragDropMode">
<item> <enum>QAbstractItemView::DragOnly</enum>
<widget class="QTreeWidget" name="fileTreeWidget"> </property>
<property name="autoExpandDelay"> <property name="selectionBehavior">
<number>0</number> <enum>QAbstractItemView::SelectItems</enum>
</property> </property>
<property name="headerHidden"> <property name="verticalScrollMode">
<bool>true</bool> <enum>QAbstractItemView::ScrollPerPixel</enum>
</property> </property>
</widget> <property name="headerHidden">
</item> <bool>true</bool>
</layout> </property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources>
<include location="../Resources/Resources.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>584</width> <width>400</width>
<height>645</height> <height>358</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -290,15 +290,77 @@
<string>Light</string> <string>Light</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0" colspan="4"> <item row="1" column="1">
<widget class="QLabel" name="labelAmbCoeff"> <widget class="QSpinBox" name="light_R_SB">
<property name="text"> <property name="maximumSize">
<string>Ambientcoefficient:</string> <size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="5"> <item row="1" column="3">
<widget class="QSlider" name="light_G_S"> <widget class="QLabel" name="label_7">
<property name="text">
<string>G:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="labelAttFac">
<property name="text">
<string>Attenuationfactor:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QSpinBox" name="light_G_SB">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="label_8">
<property name="text">
<string>B:</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QSpinBox" name="light_B_SB">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSlider" name="light_R_S">
<property name="maximum"> <property name="maximum">
<number>255</number> <number>255</number>
</property> </property>
@ -310,6 +372,55 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="8">
<widget class="QSlider" name="light_B_S">
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QRadioButton" name="radioDirectLight">
<property name="text">
<string>Directional light</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="4" colspan="2">
<widget class="QDoubleSpinBox" name="attFac">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="4" colspan="2"> <item row="2" column="4" colspan="2">
<widget class="QDoubleSpinBox" name="ambCoef"> <widget class="QDoubleSpinBox" name="ambCoef">
<property name="enabled"> <property name="enabled">
@ -335,44 +446,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="4" colspan="2"> <item row="1" column="5">
<widget class="QDoubleSpinBox" name="attFac"> <widget class="QSlider" name="light_G_S">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>R:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QRadioButton" name="radioDirectLight">
<property name="text">
<string>Directional light</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QSlider" name="light_B_S">
<property name="maximum"> <property name="maximum">
<number>255</number> <number>255</number>
</property> </property>
@ -384,92 +459,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="0" colspan="4">
<widget class="QSpinBox" name="light_R_SB"> <widget class="QLabel" name="labelAmbCoeff">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="0" column="4" colspan="3">
<widget class="QRadioButton" name="radioPointLight">
<property name="text"> <property name="text">
<string>Point light</string> <string>Ambientcoefficient:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSlider" name="light_R_S">
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>G:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QSpinBox" name="light_G_SB">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="labelAttFac">
<property name="text">
<string>Attenuationfactor:</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="label_8">
<property name="text">
<string>B:</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QSpinBox" name="light_B_SB">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -480,6 +473,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4" colspan="3">
<widget class="QRadioButton" name="radioPointLight">
<property name="text">
<string>Point light</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -489,21 +489,7 @@
<string>General</string> <string>General</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="3" colspan="3">
<widget class="QCheckBox" name="checkBackfaceCulling">
<property name="text">
<string>Backface Culling</string>
</property>
</widget>
</item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QLabel" name="labelZoomSpeed">
<property name="text">
<string>Zoom speed:</string>
</property>
</widget>
</item>
<item row="1" column="6">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -516,7 +502,14 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="5"> <item row="1" column="1">
<widget class="QLabel" name="labelZoomSpeed">
<property name="text">
<string>Zoom speed:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="spinZSpeed"> <widget class="QSpinBox" name="spinZSpeed">
<property name="suffix"> <property name="suffix">
<string>%</string> <string>%</string>
@ -532,41 +525,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3" colspan="4"> <item row="0" column="1" colspan="2">
<widget class="QLabel" name="label"> <widget class="QCheckBox" name="checkBackfaceCulling">
<property name="text"> <property name="text">
<string>Directory Drop Down List:</string> <string>Backface Culling</string>
</property>
</widget>
</item>
<item row="4" column="3" colspan="4">
<widget class="QListWidget" name="dirListWidget"/>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>*** &quot;BF1_ModTools&quot; Goes To &quot;C:/BF1_ModTools/Assets/Shipped Worlds/&quot;
&quot;BF2_ModTools&quot; Goes To &quot;C:/BF2_ModTools/assets/Sides/&quot;</string>
</property>
</widget>
</item>
<item row="5" column="5">
<widget class="QPushButton" name="removeItem">
<property name="text">
<string>--</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QPushButton" name="addItem">
<property name="text">
<string>+</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -6,6 +6,7 @@
#include <QByteArray> #include <QByteArray>
#include <QLabel> #include <QLabel>
struct Material; struct Material;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
@ -25,14 +26,13 @@ private:
int m_curSeverity; int m_curSeverity;
FileInfoWindow* m_infoWindow; FileInfoWindow* m_infoWindow;
QStringList m_filters;
// functions // functions
private: private:
void setupWidgets(); void setupWidgets();
void updateAssetTree(QString); void getAssetLibrary();
void openFileDialog(); void searchMeshFiles(QString path);
void openFile(QString); void openFile();
void takeScreenShot(); void takeScreenShot();
void aboutTool(); void aboutTool();
@ -44,12 +44,6 @@ public slots:
void printMessage(QString message, int severity); void printMessage(QString message, int severity);
void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle); void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
// private slots
private slots:
void setupAssetLibrary();
void on_fileTreeWidget_doubleClicked();
void on_dirDropDownList_currentTextChanged(const QString &arg1);
// signals // signals
signals: signals:
void loadFile(QString); void loadFile(QString);

View File

@ -22,19 +22,19 @@ public:
// attributes // attributes
private: private:
QFile m_file; QFile file;
QStringList m_listOfDirs;
QVector3D m_bgColorOn = { 5, 5, 5 }; QVector3D m_bgColorOn = { 5, 5, 5 };
QVector3D m_bgColorOff = { 128, 204, 255 }; QVector3D m_bgColorOff = { 128, 204, 255 };
QVector3D m_lightColor = { 255,255,255 };
bool m_bfCulling = false; bool m_bfCulling = false;
bool m_light = false; bool m_light = false;
bool m_headlight = false;
bool m_autoColor = true; int m_lightType = 1; // 1 = direct, 2 = point
QVector3D m_lightColor = { 255,255,255 };
float m_attenuation = 0.0f; float m_attenuation = 0.0f;
float m_ambient = 0.005f; float m_ambient = 0.005f;
int m_lightType = 1; // 1 = direct, 2 = point bool m_headlight = false;
bool m_autoColor = true;
// functions // functions
private: private:
@ -47,8 +47,6 @@ public:
bool isBfCulling() const; bool isBfCulling() const;
bool isLight() const; bool isLight() const;
QStringList getListOfDirs();
int getLightType() const; int getLightType() const;
QVector3D getLightColor() const; QVector3D getLightColor() const;
float getAttenuation() const; float getAttenuation() const;
@ -71,9 +69,4 @@ public:
void setHeadlight(bool value); void setHeadlight(bool value);
void setAutoColor(int value); void setAutoColor(int value);
void updateDirectories(QString path); };
// signals
signals:
void dirsChanged();
};

View File

@ -24,9 +24,6 @@ private slots:
void backgroundColorOnChanged(); void backgroundColorOnChanged();
void lightColorChanged(); void lightColorChanged();
void on_addItem_clicked();
void on_removeItem_clicked();
signals: signals:
void updateBGColorOff(QVector3D value); void updateBGColorOff(QVector3D value);
void updateBGColorOn(QVector3D value); void updateBGColorOn(QVector3D value);
@ -37,6 +34,5 @@ signals:
void sendBackfaceCulling(bool value); void sendBackfaceCulling(bool value);
void sendZommSpeed(int percent); void sendZommSpeed(int percent);
void changeLightType(int value); void changeLightType(int value);
void pathChanged(QString path);
}; };

View File

@ -2,7 +2,6 @@
#include "..\Header\OglViewerWidget.h" #include "..\Header\OglViewerWidget.h"
#include "..\Header\FileInterface.h" #include "..\Header\FileInterface.h"
#include "..\Header\OutputDevice.h" #include "..\Header\OutputDevice.h"
#include "..\Header\SettingsManager.h"
#include <QSurfaceFormat> #include <QSurfaceFormat>
#include <QSignalMapper> #include <QSignalMapper>
#include <QToolButton> #include <QToolButton>
@ -11,9 +10,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QPalette> #include <QPalette>
#include <QResizeEvent> #include <QResizeEvent>
#include <QDirIterator>
#include <QFileInfo>
#define WINDOW_NAME "Mesh Viewer" #define WINDOW_NAME "Mesh Viewer"
@ -45,9 +41,6 @@ MainWindow::MainWindow(QWidget *parent)
// set default text to file info // set default text to file info
m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open"; m_fileInfo = "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open";
ui->dirDropDownList->addItem("BF1_ModTools", "C:/BF1_ModTools/Assets/Shipped Worlds/");
ui->dirDropDownList->addItem("BF2_ModTools", "C:/BF2_ModTools/assets/Sides/");
// add widgets to the window // add widgets to the window
setupWidgets(); setupWidgets();
@ -56,9 +49,7 @@ MainWindow::MainWindow(QWidget *parent)
styleSheet.open(QIODevice::ReadOnly); styleSheet.open(QIODevice::ReadOnly);
this->setStyleSheet(styleSheet.readAll()); this->setStyleSheet(styleSheet.readAll());
// setup dropdown getAssetLibrary();
setupAssetLibrary();
connect(SettingsManager::getInstance(), &SettingsManager::dirsChanged, this, &MainWindow::setupAssetLibrary);
printMessage("MeshViewer by Anakin", 0); printMessage("MeshViewer by Anakin", 0);
} }
@ -70,8 +61,10 @@ MainWindow::~MainWindow()
delete m_infoWindow; delete m_infoWindow;
} }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// functions // functions
void MainWindow::setupWidgets() void MainWindow::setupWidgets()
{ {
// Ogl Viewer // Ogl Viewer
@ -80,11 +73,11 @@ void MainWindow::setupWidgets()
connect(this, &MainWindow::loadFile, viewer, &OglViewerWidget::loadFile); connect(this, &MainWindow::loadFile, viewer, &OglViewerWidget::loadFile);
// open file // open file
QToolButton *openFileDialog = new QToolButton(this); QToolButton *openFile = new QToolButton(this);
openFileDialog->setObjectName("openFile"); openFile->setObjectName("openFile");
openFileDialog->setToolTip("open file"); openFile->setToolTip("open file");
connect(openFileDialog, &QToolButton::pressed, this, &MainWindow::openFileDialog); connect(openFile, &QToolButton::pressed, this, &MainWindow::openFile);
ui->mainToolBar->addWidget(openFileDialog); ui->mainToolBar->addWidget(openFile);
// screenshot // screenshot
QToolButton *screenshot = new QToolButton(this); QToolButton *screenshot = new QToolButton(this);
@ -167,31 +160,39 @@ void MainWindow::setupWidgets()
m_output->setAlignment(Qt::AlignTop); m_output->setAlignment(Qt::AlignTop);
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))); m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
m_output->raise(); m_output->raise();
} }
void MainWindow::updateAssetTree(QString path) void MainWindow::getAssetLibrary()
{ {
QTreeWidgetItem* item = new QTreeWidgetItem;
item->setData(0, Qt::DisplayRole, "Wuhu");
ui->treeWidget->addTopLevelItem(item);
ui->fileTreeWidget->clear(); searchMeshFiles("D:/workspaces/Visual Studio 2015/Projects/OpenGL/Release");
QDirIterator itterator(path, QStringList() << "*.msh" << "*.MSH" << "*.mesh" << "*.MESH",
QDir::Files, QDirIterator::Subdirectories);
while (itterator.hasNext()) {
QTreeWidgetItem* sub = new QTreeWidgetItem(ui->fileTreeWidget);
sub->setData(0, Qt::DisplayRole, itterator.fileName());
sub->setData(1, Qt::DisplayRole, itterator.fileInfo().absoluteFilePath());
itterator.next();
}
} }
void MainWindow::openFileDialog() void MainWindow::searchMeshFiles(QString path)
{
QDir directory(path);
directory.setNameFilters(QStringList("*.msh"));
QStringList childDirectories = directory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
QStringList fileNames = directory.entryList(QDir::Files);
for (auto &it : childDirectories)
qDebug() << it;
for (auto &it : fileNames)
qDebug() << it;
}
void MainWindow::openFile()
{ {
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)"); QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
openFile(fileName);
}
void MainWindow::openFile(QString fileName)
{
if(!fileName.isEmpty()) if(!fileName.isEmpty())
emit loadFile(fileName); emit loadFile(fileName);
} }
@ -233,35 +234,6 @@ void MainWindow::resizeEvent(QResizeEvent * e)
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// slots // slots
void MainWindow::setupAssetLibrary()
{
// get all directories and put them in the dropdown.
while (ui->dirDropDownList->count() != 0)
ui->dirDropDownList->removeItem(0);
QStringList tmp_list = SettingsManager::getInstance()->getListOfDirs();
for (QString &it : tmp_list)
ui->dirDropDownList->addItem(it, it);
// choose the current path and display it.
if (ui->dirDropDownList->currentData().isValid())
updateAssetTree(ui->dirDropDownList->currentData().toString());
}
void MainWindow::on_fileTreeWidget_doubleClicked()
{
QString clickedFile = ui->fileTreeWidget->currentItem()->text(1);
openFile(clickedFile);
}
void MainWindow::on_dirDropDownList_currentTextChanged(const QString &arg1)
{
QString selectedDir;
selectedDir = ui->dirDropDownList->itemData(ui->dirDropDownList->currentIndex()).toString();
printMessage(arg1 + " : " + selectedDir, 0);
updateAssetTree(selectedDir);
}
void MainWindow::printMessage(QString message, int severity) void MainWindow::printMessage(QString message, int severity)
{ {
if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity) if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity)

View File

@ -1,5 +1,4 @@
#include "..\Header\SettingsManager.h" #include "..\Header\SettingsManager.h"
#include "qdebug.h"
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -8,7 +7,7 @@
SettingsManager::SettingsManager(QObject *parent) SettingsManager::SettingsManager(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
m_file.setFileName("meshviewer.config"); file.setFileName("meshviewer.config");
readFromFile(); readFromFile();
} }
@ -29,10 +28,10 @@ SettingsManager* SettingsManager::getInstance(QObject *parent)
void SettingsManager::readFromFile() void SettingsManager::readFromFile()
{ {
if (m_file.open(QIODevice::ReadOnly)) if (file.open(QIODevice::ReadOnly))
{ {
QByteArray stream = m_file.readAll(); QByteArray stream = file.readAll();
QList<QByteArray> lines = stream.split('\n'); QList<QByteArray> lines = stream.split('\n');
for (auto& it : lines) for (auto& it : lines)
@ -86,45 +85,34 @@ void SettingsManager::readFromFile()
{ {
m_ambient = it.right(it.size() - it.indexOf('>') - 1).toFloat(); m_ambient = it.right(it.size() - it.indexOf('>') - 1).toFloat();
} }
else if (it.startsWith("<qkList>"))
{
m_listOfDirs = QString(it.right(it.size() - it.indexOf('>') - 1)).split(";");
}
} }
m_file.close(); file.close();
} }
} }
void SettingsManager::writeToFile() void SettingsManager::writeToFile()
{ {
m_file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
m_file.write(QString("<bgOn>%1;%2;%3\n").arg(m_bgColorOn.x()).arg(m_bgColorOn.y()).arg(m_bgColorOn.z()).toUtf8()); file.write(QString("<bgOn>%1;%2;%3\n").arg(m_bgColorOn.x()).arg(m_bgColorOn.y()).arg(m_bgColorOn.z()).toUtf8());
m_file.write(QString("<bgOff>%1;%2;%3\n").arg(m_bgColorOff.x()).arg(m_bgColorOff.y()).arg(m_bgColorOff.z()).toUtf8()); file.write(QString("<bgOff>%1;%2;%3\n").arg(m_bgColorOff.x()).arg(m_bgColorOff.y()).arg(m_bgColorOff.z()).toUtf8());
m_file.write(QString("<liCo>%1;%2;%3\n").arg(m_lightColor.x()).arg(m_lightColor.y()).arg(m_lightColor.z()).toUtf8()); file.write(QString("<liCo>%1;%2;%3\n").arg(m_lightColor.x()).arg(m_lightColor.y()).arg(m_lightColor.z()).toUtf8());
m_file.write(QString("<bfCul>%1\n").arg(m_bfCulling).toUtf8()); file.write(QString("<bfCul>%1\n").arg(m_bfCulling).toUtf8());
m_file.write(QString("<liOn>%1\n").arg(m_light).toUtf8()); file.write(QString("<liOn>%1\n").arg(m_light).toUtf8());
m_file.write(QString("<heLi>%1\n").arg(m_headlight).toUtf8()); file.write(QString("<heLi>%1\n").arg(m_headlight).toUtf8());
m_file.write(QString("<auCo>%1\n").arg(m_autoColor).toUtf8()); file.write(QString("<auCo>%1\n").arg(m_autoColor).toUtf8());
m_file.write(QString("<liTy>%1\n").arg(m_lightType).toUtf8()); file.write(QString("<liTy>%1\n").arg(m_lightType).toUtf8());
m_file.write(QString("<atFa>%1\n").arg(m_attenuation).toUtf8()); file.write(QString("<atFa>%1\n").arg(m_attenuation).toUtf8());
m_file.write(QString("<amCo>%1\n").arg(m_ambient).toUtf8()); file.write(QString("<amCo>%1\n").arg(m_ambient).toUtf8());
if(!m_listOfDirs.isEmpty())
m_file.write(QString("<qkList>%1\n").arg(m_listOfDirs.join(";")).toUtf8());
m_file.close(); file.close();
} }
// getter /////////////////////////////////////////////////////////////// // getter ///////////////////////////////////////////////////////////////
QStringList SettingsManager::getListOfDirs()
{
return m_listOfDirs;
}
QVector3D SettingsManager::getBgColorOn() const QVector3D SettingsManager::getBgColorOn() const
{ {
return m_bgColorOn; return m_bgColorOn;
@ -232,12 +220,3 @@ void SettingsManager::setAutoColor(int value)
m_autoColor = true; m_autoColor = true;
} }
void SettingsManager::updateDirectories(QString path)
{
if (m_listOfDirs.contains(path))
m_listOfDirs.removeAll(path);
else
m_listOfDirs.append(path);
emit dirsChanged();
}

View File

@ -1,7 +1,6 @@
#include "..\Header\SettingsWindow.h" #include "..\Header\SettingsWindow.h"
#include "..\Header\SettingsManager.h" #include "..\Header\SettingsManager.h"
#include <QFileDialog>
#include <QListWidgetItem>
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// constructor/destructor // constructor/destructor
@ -19,11 +18,6 @@ SettingsWindow::SettingsWindow(QWidget * parent)
// set default values // set default values
SettingsManager* sm = SettingsManager::getInstance(this); SettingsManager* sm = SettingsManager::getInstance(this);
// set dirList for passing to Main and then fill settings manager dir list window
QStringList tmp_directories = sm->getListOfDirs();
for (auto &it : tmp_directories)
ui->dirListWidget->insertItem(0, it);
ui->lightOff_R_SB->setValue((int)(sm->getBgColorOff()[0])); ui->lightOff_R_SB->setValue((int)(sm->getBgColorOff()[0]));
ui->lightOff_G_SB->setValue((int)(sm->getBgColorOff()[1])); ui->lightOff_G_SB->setValue((int)(sm->getBgColorOff()[1]));
ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2])); ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2]));
@ -57,7 +51,7 @@ SettingsWindow::SettingsWindow(QWidget * parent)
connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling); connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling);
connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor); connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor);
connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType); connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType);
connect(this, &SettingsWindow::pathChanged, sm, &SettingsManager::updateDirectories);
} }
SettingsWindow::~SettingsWindow() SettingsWindow::~SettingsWindow()
@ -187,22 +181,3 @@ void SettingsWindow::lightColorChanged()
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50)); ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
} }
} }
void SettingsWindow::on_addItem_clicked()
{
QString dirName = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home",
QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks);
if (!SettingsManager::getInstance()->getListOfDirs().contains(dirName))
{
ui->dirListWidget->insertItem(0, dirName);
emit pathChanged(dirName);
}
}
void SettingsWindow::on_removeItem_clicked()
{
QListWidgetItem* tmp = ui->dirListWidget->takeItem(ui->dirListWidget->currentRow());
emit pathChanged(tmp->text());
delete tmp;
}

View File

@ -1,3 +1,12 @@
https://git.rwth-aachen.de/carstenf/OpenGL
Pulled from here as backup of work that I did under the develop branch. I hope to come back to this and port to Python using this as a reference for logic and how-to.
Below is original README text.
# MshViewer # MshViewer
I started to learn OpenGL. Therefore i decided to implement a .msh viewer for SWBFII assets, since the old one I started to learn OpenGL. Therefore i decided to implement a .msh viewer for SWBFII assets, since the old one