Compare commits
20 Commits
master
...
developeme
Author | SHA1 | Date |
---|---|---|
Anakin | 54b87b5de7 | |
Anakin | 68387fe7a7 | |
Anakin | 44732057b6 | |
Maxim Stewart | 2d34492517 | |
Maxim Stewart | 3f2713bd16 | |
Maxim Stewart | c2f7118ed6 | |
Maxim Stewart | c6d82f5f55 | |
Anakin | 33fafb29a8 | |
Maxim Stewart | 6141263f45 | |
Maxim Stewart | e59dd980bd | |
Maxim Stewart | 1e71ebed47 | |
Maxim Stewart | d908894265 | |
Maxim Stewart | bddc7ea852 | |
Maxim Stewart | 0372a4ad8c | |
Maxim Stewart | e768ae9af8 | |
Maxim Stewart | b089fcdaf6 | |
Maxim Stewart | cdda1922fa | |
Maxim Stewart | 031c620f52 | |
Maxim Stewart | 7a41f2d9bf | |
Maxim Stewart | b2efa83e17 |
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -38,8 +38,11 @@
|
|||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="floating">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable</set>
|
||||
<set>QDockWidget::DockWidgetFloatable</set>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::RightDockWidgetArea</set>
|
||||
|
@ -68,42 +71,31 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectItems</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="dirDropDownList">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="fileTreeWidget">
|
||||
<property name="autoExpandDelay">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="../Resources/Resources.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>358</height>
|
||||
<width>584</width>
|
||||
<height>645</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -290,77 +290,15 @@
|
|||
<string>Light</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="light_R_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="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QLabel" name="labelAmbCoeff">
|
||||
<property name="text">
|
||||
<string>G:</string>
|
||||
<string>Ambientcoefficient:</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">
|
||||
<item row="1" column="5">
|
||||
<widget class="QSlider" name="light_G_S">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
|
@ -372,55 +310,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QDoubleSpinBox" name="ambCoef">
|
||||
<property name="enabled">
|
||||
|
@ -446,8 +335,44 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QSlider" name="light_G_S">
|
||||
<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="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">
|
||||
<number>255</number>
|
||||
</property>
|
||||
|
@ -459,17 +384,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QLabel" name="labelAmbCoeff">
|
||||
<property name="text">
|
||||
<string>Ambientcoefficient:</string>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="light_R_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7" colspan="2">
|
||||
<widget class="QCheckBox" name="checkHeadlight">
|
||||
<property name="text">
|
||||
<string>Headlight</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -480,6 +407,79 @@
|
|||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7" colspan="2">
|
||||
<widget class="QCheckBox" name="checkHeadlight">
|
||||
<property name="text">
|
||||
<string>Headlight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -489,7 +489,21 @@
|
|||
<string>General</string>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QLabel" name="labelZoomSpeed">
|
||||
<property name="text">
|
||||
<string>Zoom speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -502,14 +516,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<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">
|
||||
<item row="1" column="5">
|
||||
<widget class="QSpinBox" name="spinZSpeed">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
|
@ -525,29 +532,41 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBackfaceCulling">
|
||||
<item row="2" column="3" colspan="4">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Backface Culling</string>
|
||||
<string>Directory Drop Down List:</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>*** "BF1_ModTools" Goes To "C:/BF1_ModTools/Assets/Shipped Worlds/"
|
||||
"BF2_ModTools" Goes To "C:/BF2_ModTools/assets/Sides/"</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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <QByteArray>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
struct Material;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
|
@ -26,13 +25,14 @@ private:
|
|||
int m_curSeverity;
|
||||
|
||||
FileInfoWindow* m_infoWindow;
|
||||
QStringList m_filters;
|
||||
|
||||
// functions
|
||||
private:
|
||||
void setupWidgets();
|
||||
void getAssetLibrary();
|
||||
void searchMeshFiles(QString path);
|
||||
void openFile();
|
||||
void updateAssetTree(QString);
|
||||
void openFileDialog();
|
||||
void openFile(QString);
|
||||
void takeScreenShot();
|
||||
void aboutTool();
|
||||
|
||||
|
@ -44,6 +44,12 @@ public slots:
|
|||
void printMessage(QString message, int severity);
|
||||
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:
|
||||
void loadFile(QString);
|
||||
|
|
|
@ -22,19 +22,19 @@ public:
|
|||
|
||||
// attributes
|
||||
private:
|
||||
QFile file;
|
||||
QFile m_file;
|
||||
QStringList m_listOfDirs;
|
||||
|
||||
QVector3D m_bgColorOn = { 5, 5, 5 };
|
||||
QVector3D m_bgColorOff = { 128, 204, 255 };
|
||||
QVector3D m_lightColor = { 255,255,255 };
|
||||
bool m_bfCulling = false;
|
||||
bool m_light = false;
|
||||
|
||||
int m_lightType = 1; // 1 = direct, 2 = point
|
||||
QVector3D m_lightColor = { 255,255,255 };
|
||||
float m_attenuation = 0.0f;
|
||||
float m_ambient = 0.005f;
|
||||
bool m_headlight = false;
|
||||
bool m_autoColor = true;
|
||||
float m_attenuation = 0.0f;
|
||||
float m_ambient = 0.005f;
|
||||
int m_lightType = 1; // 1 = direct, 2 = point
|
||||
|
||||
// functions
|
||||
private:
|
||||
|
@ -47,6 +47,8 @@ public:
|
|||
bool isBfCulling() const;
|
||||
bool isLight() const;
|
||||
|
||||
QStringList getListOfDirs();
|
||||
|
||||
int getLightType() const;
|
||||
QVector3D getLightColor() const;
|
||||
float getAttenuation() const;
|
||||
|
@ -69,4 +71,9 @@ public:
|
|||
void setHeadlight(bool value);
|
||||
void setAutoColor(int value);
|
||||
|
||||
void updateDirectories(QString path);
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void dirsChanged();
|
||||
};
|
|
@ -24,6 +24,9 @@ private slots:
|
|||
void backgroundColorOnChanged();
|
||||
void lightColorChanged();
|
||||
|
||||
void on_addItem_clicked();
|
||||
void on_removeItem_clicked();
|
||||
|
||||
signals:
|
||||
void updateBGColorOff(QVector3D value);
|
||||
void updateBGColorOn(QVector3D value);
|
||||
|
@ -34,5 +37,6 @@ signals:
|
|||
void sendBackfaceCulling(bool value);
|
||||
void sendZommSpeed(int percent);
|
||||
void changeLightType(int value);
|
||||
void pathChanged(QString path);
|
||||
|
||||
};
|
|
@ -2,6 +2,7 @@
|
|||
#include "..\Header\OglViewerWidget.h"
|
||||
#include "..\Header\FileInterface.h"
|
||||
#include "..\Header\OutputDevice.h"
|
||||
#include "..\Header\SettingsManager.h"
|
||||
#include <QSurfaceFormat>
|
||||
#include <QSignalMapper>
|
||||
#include <QToolButton>
|
||||
|
@ -10,6 +11,9 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPalette>
|
||||
#include <QResizeEvent>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
#define WINDOW_NAME "Mesh Viewer"
|
||||
|
||||
|
@ -41,6 +45,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
// set default text to file info
|
||||
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
|
||||
setupWidgets();
|
||||
|
||||
|
@ -49,7 +56,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
styleSheet.open(QIODevice::ReadOnly);
|
||||
this->setStyleSheet(styleSheet.readAll());
|
||||
|
||||
getAssetLibrary();
|
||||
// setup dropdown
|
||||
setupAssetLibrary();
|
||||
connect(SettingsManager::getInstance(), &SettingsManager::dirsChanged, this, &MainWindow::setupAssetLibrary);
|
||||
|
||||
printMessage("MeshViewer by Anakin", 0);
|
||||
}
|
||||
|
@ -61,10 +70,8 @@ MainWindow::~MainWindow()
|
|||
delete m_infoWindow;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
|
||||
void MainWindow::setupWidgets()
|
||||
{
|
||||
// Ogl Viewer
|
||||
|
@ -73,11 +80,11 @@ void MainWindow::setupWidgets()
|
|||
connect(this, &MainWindow::loadFile, viewer, &OglViewerWidget::loadFile);
|
||||
|
||||
// open file
|
||||
QToolButton *openFile = new QToolButton(this);
|
||||
openFile->setObjectName("openFile");
|
||||
openFile->setToolTip("open file");
|
||||
connect(openFile, &QToolButton::pressed, this, &MainWindow::openFile);
|
||||
ui->mainToolBar->addWidget(openFile);
|
||||
QToolButton *openFileDialog = new QToolButton(this);
|
||||
openFileDialog->setObjectName("openFile");
|
||||
openFileDialog->setToolTip("open file");
|
||||
connect(openFileDialog, &QToolButton::pressed, this, &MainWindow::openFileDialog);
|
||||
ui->mainToolBar->addWidget(openFileDialog);
|
||||
|
||||
// screenshot
|
||||
QToolButton *screenshot = new QToolButton(this);
|
||||
|
@ -160,39 +167,31 @@ void MainWindow::setupWidgets()
|
|||
m_output->setAlignment(Qt::AlignTop);
|
||||
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
|
||||
m_output->raise();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::getAssetLibrary()
|
||||
void MainWindow::updateAssetTree(QString path)
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||
item->setData(0, Qt::DisplayRole, "Wuhu");
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
|
||||
searchMeshFiles("D:/workspaces/Visual Studio 2015/Projects/OpenGL/Release");
|
||||
ui->fileTreeWidget->clear();
|
||||
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::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()
|
||||
void MainWindow::openFileDialog()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::openFile(QString fileName)
|
||||
{
|
||||
if(!fileName.isEmpty())
|
||||
emit loadFile(fileName);
|
||||
}
|
||||
|
@ -234,6 +233,35 @@ void MainWindow::resizeEvent(QResizeEvent * e)
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
{
|
||||
if (!ui->statusBar->currentMessage().isEmpty() && severity < m_curSeverity)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "..\Header\SettingsManager.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -7,7 +8,7 @@
|
|||
SettingsManager::SettingsManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
file.setFileName("meshviewer.config");
|
||||
m_file.setFileName("meshviewer.config");
|
||||
readFromFile();
|
||||
}
|
||||
|
||||
|
@ -28,10 +29,10 @@ SettingsManager* SettingsManager::getInstance(QObject *parent)
|
|||
|
||||
void SettingsManager::readFromFile()
|
||||
{
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
if (m_file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
|
||||
QByteArray stream = file.readAll();
|
||||
QByteArray stream = m_file.readAll();
|
||||
QList<QByteArray> lines = stream.split('\n');
|
||||
|
||||
for (auto& it : lines)
|
||||
|
@ -85,34 +86,45 @@ void SettingsManager::readFromFile()
|
|||
{
|
||||
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(";");
|
||||
}
|
||||
|
||||
}
|
||||
file.close();
|
||||
m_file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsManager::writeToFile()
|
||||
{
|
||||
file.open(QIODevice::WriteOnly);
|
||||
m_file.open(QIODevice::WriteOnly);
|
||||
|
||||
file.write(QString("<bgOn>%1;%2;%3\n").arg(m_bgColorOn.x()).arg(m_bgColorOn.y()).arg(m_bgColorOn.z()).toUtf8());
|
||||
file.write(QString("<bgOff>%1;%2;%3\n").arg(m_bgColorOff.x()).arg(m_bgColorOff.y()).arg(m_bgColorOff.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("<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());
|
||||
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("<bfCul>%1\n").arg(m_bfCulling).toUtf8());
|
||||
file.write(QString("<liOn>%1\n").arg(m_light).toUtf8());
|
||||
file.write(QString("<heLi>%1\n").arg(m_headlight).toUtf8());
|
||||
file.write(QString("<auCo>%1\n").arg(m_autoColor).toUtf8());
|
||||
m_file.write(QString("<bfCul>%1\n").arg(m_bfCulling).toUtf8());
|
||||
m_file.write(QString("<liOn>%1\n").arg(m_light).toUtf8());
|
||||
m_file.write(QString("<heLi>%1\n").arg(m_headlight).toUtf8());
|
||||
m_file.write(QString("<auCo>%1\n").arg(m_autoColor).toUtf8());
|
||||
|
||||
file.write(QString("<liTy>%1\n").arg(m_lightType).toUtf8());
|
||||
file.write(QString("<atFa>%1\n").arg(m_attenuation).toUtf8());
|
||||
file.write(QString("<amCo>%1\n").arg(m_ambient).toUtf8());
|
||||
m_file.write(QString("<liTy>%1\n").arg(m_lightType).toUtf8());
|
||||
m_file.write(QString("<atFa>%1\n").arg(m_attenuation).toUtf8());
|
||||
m_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());
|
||||
|
||||
file.close();
|
||||
m_file.close();
|
||||
}
|
||||
|
||||
// getter ///////////////////////////////////////////////////////////////
|
||||
|
||||
QStringList SettingsManager::getListOfDirs()
|
||||
{
|
||||
return m_listOfDirs;
|
||||
}
|
||||
|
||||
QVector3D SettingsManager::getBgColorOn() const
|
||||
{
|
||||
return m_bgColorOn;
|
||||
|
@ -220,3 +232,12 @@ void SettingsManager::setAutoColor(int value)
|
|||
m_autoColor = true;
|
||||
}
|
||||
|
||||
void SettingsManager::updateDirectories(QString path)
|
||||
{
|
||||
if (m_listOfDirs.contains(path))
|
||||
m_listOfDirs.removeAll(path);
|
||||
else
|
||||
m_listOfDirs.append(path);
|
||||
|
||||
emit dirsChanged();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "..\Header\SettingsWindow.h"
|
||||
#include "..\Header\SettingsManager.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// constructor/destructor
|
||||
|
@ -18,6 +19,11 @@ SettingsWindow::SettingsWindow(QWidget * parent)
|
|||
// set default values
|
||||
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_G_SB->setValue((int)(sm->getBgColorOff()[1]));
|
||||
ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2]));
|
||||
|
@ -51,7 +57,7 @@ SettingsWindow::SettingsWindow(QWidget * parent)
|
|||
connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling);
|
||||
connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor);
|
||||
connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType);
|
||||
|
||||
connect(this, &SettingsWindow::pathChanged, sm, &SettingsManager::updateDirectories);
|
||||
}
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
|
@ -181,3 +187,22 @@ void SettingsWindow::lightColorChanged()
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue