+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Canvas::Canvas(const QSurfaceFormat& format, QWidget *parent)
styleFile.open( QFile::ReadOnly );
setStyleSheet(styleFile.readAll());
currentTransform = QMatrix4x4();
currentTransform.setToIdentity();
resetTransform();

anim.setDuration(100);
}
Expand Down Expand Up @@ -67,6 +67,10 @@ void Canvas::invert_zoom(bool d)
update();
}

void Canvas::setResetTransformOnLoad(bool d) {
resetTransformOnLoad = d;
}

void Canvas::resetTransform() {
currentTransform.setToIdentity();
// apply some rotations to define initial orientation
Expand All @@ -90,7 +94,9 @@ void Canvas::load_mesh(Mesh* m, bool is_reload)

// Reset other camera parameters
zoom = 1;
resetTransform();
if (resetTransformOnLoad) {
resetTransform();
}
}
meshInfo = QStringLiteral("Triangles: %1\nX: [%2, %3]\nY: [%4, %5]\nZ: [%6, %7]").arg(m->triCount());
for(int dIdx = 0; dIdx < 3; dIdx++) meshInfo = meshInfo.arg(lower[dIdx]).arg(upper[dIdx]);
Expand Down
2 changes: 2 additions & 0 deletions src/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Canvas : public QOpenGLWidget, protected QOpenGLFunctions
void draw_axes(bool d);
void invert_zoom(bool d);
void set_drawMode(enum DrawMode mode);
void setResetTransformOnLoad(bool d);

public slots:
void set_status(const QString& s);
Expand Down Expand Up @@ -75,6 +76,7 @@ public slots:
enum DrawMode drawMode;
bool drawAxes;
bool invertZoom;
bool resetTransformOnLoad;
Q_PROPERTY(float perspective MEMBER perspective WRITE set_perspective);
QPropertyAnimation anim;

Expand Down
16 changes: 16 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const QString Window::DRAW_AXES_KEY = "drawAxes";
const QString Window::PROJECTION_KEY = "projection";
const QString Window::DRAW_MODE_KEY = "drawMode";
const QString Window::WINDOW_GEOM_KEY = "windowGeometry";
const QString Window::RESET_TRANSFORM_ON_LOAD_KEY = "resetTransformOnLoad";

Window::Window(QWidget *parent) :
QMainWindow(parent),
Expand All @@ -28,6 +29,7 @@ Window::Window(QWidget *parent) :
autoreload_action(new QAction("Autoreload", this)),
save_screenshot_action(new QAction("Save Screenshot", this)),
hide_menuBar_action(new QAction("Hide Menu Bar", this)),
resetTransformOnLoadAction(new QAction("Reset rotation on load",this)),
recent_files(new QMenu("Open recent", this)),
recent_files_group(new QActionGroup(this)),
recent_files_clear_action(new QAction("Clear recent files", this)),
Expand Down Expand Up @@ -131,6 +133,11 @@ Window::Window(QWidget *parent) :
QObject::connect(invert_zoom_action, &QAction::triggered,
this, &Window::on_invertZoom);

view_menu->addAction(resetTransformOnLoadAction);
resetTransformOnLoadAction->setCheckable(true);
QObject::connect(resetTransformOnLoadAction, &QAction::triggered,
this, &Window::on_resetTransformOnLoad);

view_menu->addAction(hide_menuBar_action);
hide_menuBar_action->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_C);
hide_menuBar_action->setCheckable(true);
Expand All @@ -150,6 +157,10 @@ void Window::load_persist_settings(){
canvas->invert_zoom(invert_zoom);
invert_zoom_action->setChecked(invert_zoom);

bool resetTransformOnLoad = settings.value(RESET_TRANSFORM_ON_LOAD_KEY, true).toBool();
canvas->setResetTransformOnLoad(resetTransformOnLoad);
resetTransformOnLoadAction->setChecked(resetTransformOnLoad);

autoreload_action->setChecked(settings.value(AUTORELOAD_KEY, true).toBool());

bool draw_axes = settings.value(DRAW_AXES_KEY, false).toBool();
Expand Down Expand Up @@ -300,6 +311,11 @@ void Window::on_invertZoom(bool d)
QSettings().setValue(INVERT_ZOOM_KEY, d);
}

void Window::on_resetTransformOnLoad(bool d) {
canvas->setResetTransformOnLoad(d);
QSettings().setValue(RESET_TRANSFORM_ON_LOAD_KEY, d);
}

void Window::on_watched_change(const QString& filename)
{
if (autoreload_action->isChecked())
Expand Down
3 changes: 3 additions & 0 deletions src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private slots:
void on_drawMode(QAction* mode);
void on_drawAxes(bool d);
void on_invertZoom(bool d);
void on_resetTransformOnLoad(bool d);
void on_watched_change(const QString& filename);
void on_reload();
void on_autoreload_triggered(bool r);
Expand Down Expand Up @@ -71,6 +72,7 @@ private slots:
QAction* const autoreload_action;
QAction* const save_screenshot_action;
QAction* const hide_menuBar_action;
QAction* const resetTransformOnLoadAction;

QMenu* const recent_files;
QActionGroup* const recent_files_group;
Expand All @@ -83,6 +85,7 @@ private slots:
const static QString PROJECTION_KEY;
const static QString DRAW_MODE_KEY;
const static QString WINDOW_GEOM_KEY;
const static QString RESET_TRANSFORM_ON_LOAD_KEY;

QString current_file;
QString lookup_folder;
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载