code format

This commit is contained in:
2022-12-14 14:14:44 +03:00
parent 1dfca0aeab
commit cb944b62e4
85 changed files with 4451 additions and 3744 deletions

View File

@@ -1,25 +1,26 @@
/*
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qglview_window.h"
#include <QApplication>
#include <QDebug>
#include <QDir>
#include "qglview_window.h"
int main(int argc, char ** argv) {
QApplication a(argc, argv);
@@ -28,7 +29,7 @@ int main(int argc, char ** argv) {
w.show();
QStringList al(a.arguments());
al.pop_front();
foreach (QString s, al)
foreach(QString s, al)
w.loadFile(s);
return a.exec();
}

View File

@@ -1,29 +1,31 @@
/*
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qglview_window.h"
#include "renderer.h"
#include "glwidget.h"
#include "gltexture_manager.h"
#include "glwidget.h"
#include "qad_types.h"
#include "renderer.h"
#include <QGraphicsRectItem>
#include <QImageReader>
#include <QMessageBox>
#include "qad_types.h"
QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLViewWindow() {
@@ -33,11 +35,11 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
extensions = "All(" + supportedFormats().join(" ") + " *.qgl)";
extensions += ";;QGLEngine(*.qgl)";
//view->view()->camera()->setPos(QVector3D(2, 2, 2));
//view->view()->camera()->setAim(QVector3D());
//view->view()->camera()->flyToDistance(2.);
// view->setFrameShape(QFrame::NoFrame);
// view->view()->camera()->setPos(QVector3D(2, 2, 2));
// view->view()->camera()->setAim(QVector3D());
// view->view()->camera()->flyToDistance(2.);
// view->setFrameShape(QFrame::NoFrame);
view->view()->setMouseRotateEnabled(true);
view->view()->setMouseSelectionEnabled(true);
view->view()->setSelectionHaloEnabled(true);
@@ -70,10 +72,10 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
spinDOFSpeed->setValue(view->view()->feature(QGLView::qglDepthOfFieldAutoFocusSpeed).toDouble());
view->view()->start(-1);
startTimer(1000/60);
startTimer(1000 / 60);
connect(view->view(), SIGNAL(keyEvent(Qt::Key, Qt::KeyboardModifiers)), this, SLOT(view_keyEvent(Qt::Key, Qt::KeyboardModifiers)));
//connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
// connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
sceneTree->assignQGLView(view->view());
matEditor->assignQGLView(view->view());
objectEditor->assignQGLView(view->view());
@@ -82,14 +84,14 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
session.load();
//loadFile("axis.DAE.qgl");
//matEditor->setMaterial(const_cast<ObjectBase*>(view->view()->scene()->rootObject()->child(0))->material());
// loadFile("axis.DAE.qgl");
// matEditor->setMaterial(const_cast<ObjectBase*>(view->view()->scene()->rootObject()->child(0))->material());
/*Scene * sc = loadScene("truck.obj");
//view->view()->scene()->addScene(sc);
sc->rootObject()->moveY(-8);
for (int i = 0; i < 7; ++i) {
sc->rootObject()->moveY(2);
view->view()->scene()->addScene(sc);
sc->rootObject()->moveY(2);
view->view()->scene()->addScene(sc);
}
//view->view()->scene()->dump();
delete sc;*/
@@ -98,7 +100,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
QGLViewWindow::~QGLViewWindow() {
session.save();
//delete ps;
// delete ps;
}
@@ -111,8 +113,8 @@ void QGLViewWindow::changeEvent(QEvent * e) {
}
void QGLViewWindow::timerEvent(QTimerEvent * ) {
//static double t = 0.;
void QGLViewWindow::timerEvent(QTimerEvent *) {
// static double t = 0.;
//((RendererSimple*)(view->view()->renderer()))->mpos = view->view()->mapFromGlobal(QCursor::pos());
statusBar()->showMessage(QString("FPS: %1").arg(QString::number(view->view()->currentFPS(), 'f', 2)));
}
@@ -123,15 +125,18 @@ void QGLViewWindow::loadFile(const QString & path, bool import) {
QApplication::setOverrideCursor(Qt::WaitCursor);
QFileInfo fi(path);
Scene * s = nullptr;
if (fi.suffix().toLower() == "qgl") s = loadFromQGLFile(path);
else s = loadScene(path);
if (fi.suffix().toLower() == "qgl")
s = loadFromQGLFile(path);
else
s = loadScene(path);
QApplication::restoreOverrideCursor();
if (!s) {
QMessageBox::critical(this, "Import", "Can`t load " + path + "!");
return;
}
s->setName(fi.baseName());
if (import) view->scene()->addScene(s);
if (import)
view->scene()->addScene(s);
else {
TextureManager::clearSearchPathes();
view->scene()->assignFrom(s);
@@ -143,9 +148,9 @@ void QGLViewWindow::loadFile(const QString & path, bool import) {
void QGLViewWindow::on_actionReset_triggered() {
///view->view()->removeObject(axis, false);
/// view->view()->removeObject(axis, false);
view->view()->scene()->clear();
///view->view()->addObject(axis);
/// view->view()->addObject(axis);
}
@@ -153,7 +158,7 @@ void QGLViewWindow::on_actionImport_triggered() {
QStringList fl = QFileDialog::getOpenFileNames(this, "Select files", prev_path, extensions);
if (fl.isEmpty()) return;
prev_path = fl.back();
foreach (QString f, fl)
foreach(QString f, fl)
loadFile(f, true);
}
@@ -161,8 +166,7 @@ void QGLViewWindow::on_actionImport_triggered() {
void QGLViewWindow::on_actionSave_triggered() {
QString f = QFileDialog::getSaveFileName(this, "Select file", prev_path, "QGLView(*.qgl)");
if (f.isEmpty()) return;
if (f.right(4).toLower() != ".qgl")
f += ".qgl";
if (f.right(4).toLower() != ".qgl") f += ".qgl";
prev_path = f;
QApplication::setOverrideCursor(Qt::WaitCursor);
saveToQGLFile(f, view->scene());
@@ -175,11 +179,10 @@ void QGLViewWindow::on_actionSaveSelected_triggered() {
if (!sel_obj) return;
QString f = QFileDialog::getSaveFileName(this, "Select file", prev_path, "QGLView(*.qgl)");
if (f.isEmpty()) return;
if (f.right(4).toLower() != ".qgl")
f += ".qgl";
if (f.right(4).toLower() != ".qgl") f += ".qgl";
prev_path = f;
QApplication::setOverrideCursor(Qt::WaitCursor);
///saveToQGLFile(f, sel_obj);
/// saveToQGLFile(f, sel_obj);
QApplication::restoreOverrideCursor();
}
@@ -193,10 +196,9 @@ void QGLViewWindow::on_actionOpen_triggered() {
void QGLViewWindow::view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m) {
//qDebug() << k;
// qDebug() << k;
double spd = 0.2;
if (m.testFlag(Qt::ShiftModifier))
spd = 0.5;
if (m.testFlag(Qt::ShiftModifier)) spd = 0.5;
switch (k) {
case Qt::Key_W: view->view()->camera()->moveForward(spd); break;
case Qt::Key_S: view->view()->camera()->moveBackward(spd); break;
@@ -208,37 +210,37 @@ void QGLViewWindow::view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m) {
void QGLViewWindow::on_actionArrow_triggered(bool on) {
actionArrow ->setChecked(true);
actionMove ->setChecked(false);
actionArrow->setChecked(true);
actionMove->setChecked(false);
actionRotate->setChecked(false);
actionScale ->setChecked(false);
actionScale->setChecked(false);
view->view()->setCurrentAction(RendererService::haNoAction);
}
void QGLViewWindow::on_actionMove_triggered(bool on) {
actionArrow ->setChecked(false);
actionMove ->setChecked(true);
actionArrow->setChecked(false);
actionMove->setChecked(true);
actionRotate->setChecked(false);
actionScale ->setChecked(false);
actionScale->setChecked(false);
view->view()->setCurrentAction(RendererService::haMove);
}
void QGLViewWindow::on_actionRotate_triggered(bool on) {
actionArrow ->setChecked(false);
actionMove ->setChecked(false);
actionArrow->setChecked(false);
actionMove->setChecked(false);
actionRotate->setChecked(true);
actionScale ->setChecked(false);
actionScale->setChecked(false);
view->view()->setCurrentAction(RendererService::haRotate);
}
void QGLViewWindow::on_actionScale_triggered(bool on) {
actionArrow ->setChecked(false);
actionMove ->setChecked(false);
actionArrow->setChecked(false);
actionMove->setChecked(false);
actionRotate->setChecked(false);
actionScale ->setChecked(true);
actionScale->setChecked(true);
view->view()->setCurrentAction(RendererService::haScale);
}

View File

@@ -1,47 +1,50 @@
/*
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
QGLViewWindow
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QGLVIEWWINDOW_H
#define QGLVIEWWINDOW_H
#include <QTranslator>
#include <QInputDialog>
#include <QFileDialog>
#include <QColorDialog>
#include <QCloseEvent>
#include "formats/loader_assimp.h"
#include "formats/loader_qgl.h"
#include "session_manager.h"
#include "ui_qglview_window.h"
#include <QClipboard>
#include <QCloseEvent>
#include <QColorDialog>
#include <QFileDialog>
#include <QInputDialog>
#include <QRadioButton>
#include <QUrl>
#include <QSplitter>
#include <QThread>
#include <QTime>
#include <QSplitter>
#include "ui_qglview_window.h"
#include "formats/loader_qgl.h"
#include "formats/loader_assimp.h"
#include "session_manager.h"
//#include "renderer_rt.h"
#include <QTranslator>
#include <QUrl>
// #include "renderer_rt.h"
#include "qglview.h"
#include "ui_qglview_window.h"
class QGLViewWindow: public QMainWindow, public Ui::QGLViewWindow
{
class QGLViewWindow
: public QMainWindow
, public Ui::QGLViewWindow {
Q_OBJECT
public:
QGLViewWindow(QWidget * parent = 0);
~QGLViewWindow();
@@ -51,41 +54,41 @@ public:
private:
// Qt`s overloaded
void changeEvent(QEvent * e);
void timerEvent(QTimerEvent * );
void timerEvent(QTimerEvent *);
QString extensions;
QTranslator translator;
QString prev_path;
//GLPrimitiveCube * box;
// GLPrimitiveCube * box;
Material m;
SessionManager session;
bool isChanged;
private slots:
void on_groupShadows_clicked(bool val) {view->view()->setFeature(QGLView::qglShadowsEnabled, val);}
void on_groupEyeAccomodation_clicked(bool val) {view->view()->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
void on_groupBloom_clicked(bool val) {view->view()->setFeature(QGLView::qglBloomEnabled, val);}
void on_groupMotionBlur_clicked(bool val) {view->view()->setFeature(QGLView::qglMotionBlurEnabled, val);}
void on_groupReflections_clicked(bool val) {view->view()->setFeature(QGLView::qglReflectionsEnabled, val);}
void on_checkSoftShadows_clicked(bool val) {view->view()->setFeature(QGLView::qglShadowsSoftEnabled, val);}
void on_groupSSAO_clicked(bool val) {view->view()->setFeature(QGLView::qglSSAOEnabled, val);}
void on_groupDOF_clicked(bool val) {view->view()->setFeature(QGLView::qglDepthOfFieldEnabled, val);}
void on_checkDOFAutoFocus_clicked(bool val) {view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusEnabled, val);}
void on_spinDOFFocus_valueChanged(double val) {view->view()->setFeature(QGLView::qglDepthOfFieldFocus, val);}
void on_spinDOFDiaphragm_valueChanged(double val) {view->view()->setFeature(QGLView::qglDepthOfFieldDiaphragm, val);}
void on_spinDOFSpeed_valueChanged(double val) {view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusSpeed, val);}
void on_spinAccom_valueChanged(double val) {view->view()->setFeature(QGLView::qglEyeAccomodationTime, val);}
void on_spinAccomMS_valueChanged(double val) {view->view()->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
void on_checkReflectionsBlur_clicked(bool val) {view->view()->setFeature(QGLView::qglReflectionsBlur, val);}
void on_spinShadowmapSize_valueChanged(double val) {view->view()->setFeature(QGLView::qglShadowsMapSize, val);}
void on_spinMotionBlurFactor_valueChanged(double val) {view->view()->setFeature(QGLView::qglMotionBlurFactor, val);}
void on_spinMotionBlurSteps_valueChanged(int val) {view->view()->setFeature(QGLView::qglMotionBlurSteps, val);}
void on_spinBloomFactor_valueChanged(double val) {view->view()->setFeature(QGLView::qglBloomFactor, val);}
void on_spinBloomRadius_valueChanged(int val) {view->view()->setFeature(QGLView::qglBloomRadius, val);}
void on_spinBloomThreshold_valueChanged(double val) {view->view()->setFeature(QGLView::qglBloomThreshold, val);}
void on_spinSSAORadius_valueChanged(int val) {view->view()->setFeature(QGLView::qglSSAORadius, val);}
void on_groupShadows_clicked(bool val) { view->view()->setFeature(QGLView::qglShadowsEnabled, val); }
void on_groupEyeAccomodation_clicked(bool val) { view->view()->setFeature(QGLView::qglEyeAccomodationEnabled, val); }
void on_groupBloom_clicked(bool val) { view->view()->setFeature(QGLView::qglBloomEnabled, val); }
void on_groupMotionBlur_clicked(bool val) { view->view()->setFeature(QGLView::qglMotionBlurEnabled, val); }
void on_groupReflections_clicked(bool val) { view->view()->setFeature(QGLView::qglReflectionsEnabled, val); }
void on_checkSoftShadows_clicked(bool val) { view->view()->setFeature(QGLView::qglShadowsSoftEnabled, val); }
void on_groupSSAO_clicked(bool val) { view->view()->setFeature(QGLView::qglSSAOEnabled, val); }
void on_groupDOF_clicked(bool val) { view->view()->setFeature(QGLView::qglDepthOfFieldEnabled, val); }
void on_checkDOFAutoFocus_clicked(bool val) { view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusEnabled, val); }
void on_spinDOFFocus_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldFocus, val); }
void on_spinDOFDiaphragm_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldDiaphragm, val); }
void on_spinDOFSpeed_valueChanged(double val) { view->view()->setFeature(QGLView::qglDepthOfFieldAutoFocusSpeed, val); }
void on_spinAccom_valueChanged(double val) { view->view()->setFeature(QGLView::qglEyeAccomodationTime, val); }
void on_spinAccomMS_valueChanged(double val) { view->view()->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val); }
void on_checkReflectionsBlur_clicked(bool val) { view->view()->setFeature(QGLView::qglReflectionsBlur, val); }
void on_spinShadowmapSize_valueChanged(double val) { view->view()->setFeature(QGLView::qglShadowsMapSize, val); }
void on_spinMotionBlurFactor_valueChanged(double val) { view->view()->setFeature(QGLView::qglMotionBlurFactor, val); }
void on_spinMotionBlurSteps_valueChanged(int val) { view->view()->setFeature(QGLView::qglMotionBlurSteps, val); }
void on_spinBloomFactor_valueChanged(double val) { view->view()->setFeature(QGLView::qglBloomFactor, val); }
void on_spinBloomRadius_valueChanged(int val) { view->view()->setFeature(QGLView::qglBloomRadius, val); }
void on_spinBloomThreshold_valueChanged(double val) { view->view()->setFeature(QGLView::qglBloomThreshold, val); }
void on_spinSSAORadius_valueChanged(int val) { view->view()->setFeature(QGLView::qglSSAORadius, val); }
void on_actionExit_triggered() {close();}
void on_actionExit_triggered() { close(); }
void on_actionReset_triggered();
void on_actionImport_triggered();
void on_actionSave_triggered();
@@ -94,16 +97,16 @@ private slots:
void view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);
void on_pushButton_2_clicked() {view->view()->reloadShaders();}
void on_pushButton_2_clicked() { view->view()->reloadShaders(); }
void on_actionArrow_triggered(bool on);
void on_actionMove_triggered(bool on);
void on_actionRotate_triggered(bool on);
void on_actionScale_triggered(bool on);
void on_colorFogBack_colorChanged(const QColor & v) {view->view()->setFogColor(v);}
void on_spinFogDensity_valueChanged(double v) {view->view()->setFogDensity(v);}
void on_spinFogDecay_valueChanged(double v) {view->view()->setFogDecay(v);}
void on_colorFogBack_colorChanged(const QColor & v) { view->view()->setFogColor(v); }
void on_spinFogDensity_valueChanged(double v) { view->view()->setFogDensity(v); }
void on_spinFogDecay_valueChanged(double v) { view->view()->setFogDecay(v); }
void on_pushButton_3_clicked();
@@ -113,7 +116,6 @@ signals:
private:
QMatrix4x4 cam_mat;
};
#endif // QGLVIEWWINDOW_H