Skip to content

Commit

Permalink
fix incoherent tab/whitespace in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudev committed May 25, 2017
1 parent 9a9d69f commit ab22b88
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 339 deletions.
Expand Up @@ -19,198 +19,198 @@
MainWindow::MainWindow(QWidget* parent)
: CGAL::Qt::DemosMainWindow(parent)
{
ui = new Ui::MainWindow;
ui->setupUi(this);
ui = new Ui::MainWindow;
ui->setupUi(this);

// saves some pointers from ui, for latter use.
m_pViewer = ui->viewer;
// saves some pointers from ui, for latter use.
m_pViewer = ui->viewer;

// does not save the state of the viewer
m_pViewer->setStateFileName(QString::null);
// does not save the state of the viewer
m_pViewer->setStateFileName(QString::null);

// accepts drop events
setAcceptDrops(true);
// accepts drop events
setAcceptDrops(true);

// setups scene
m_pScene = new Scene;
m_pViewer->setScene(m_pScene);
// setups scene
m_pScene = new Scene;
m_pViewer->setScene(m_pScene);

// connects actionQuit (Ctrl+Q) and qApp->quit()
connect(ui->actionQuit, SIGNAL(triggered()),
this, SLOT(quit()));
// connects actionQuit (Ctrl+Q) and qApp->quit()
connect(ui->actionQuit, SIGNAL(triggered()),
this, SLOT(quit()));

this->addRecentFiles(ui->menuFile, ui->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString)));
this->addRecentFiles(ui->menuFile, ui->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString)));

//this->addAboutDemo(":/cgal/VSA_demo/resources/about.html");
// accessible as alias name: http://doc.qt.io/qt-5/resources.html
this->addAboutDemo(":/cgal/VSA_demo/about.html");
this->addAboutCGAL();
//this->addAboutDemo(":/cgal/VSA_demo/resources/about.html");
// accessible as alias name: http://doc.qt.io/qt-5/resources.html
this->addAboutDemo(":/cgal/VSA_demo/about.html");
this->addAboutCGAL();

readSettings();
readSettings();
}

MainWindow::~MainWindow()
{
delete ui;
delete ui;
}

void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}

void MainWindow::dropEvent(QDropEvent *event)
{
Q_FOREACH(QUrl url, event->mimeData()->urls()) {
QString filename = url.toLocalFile();
if(!filename.isEmpty()) {
QTextStream(stderr) << QString("dropEvent(\"%1\")\n").arg(filename);
open(filename);
}
Q_FOREACH(QUrl url, event->mimeData()->urls()) {
QString filename = url.toLocalFile();
if(!filename.isEmpty()) {
QTextStream(stderr) << QString("dropEvent(\"%1\")\n").arg(filename);
open(filename);
}
event->acceptProposedAction();
}
event->acceptProposedAction();
}

void MainWindow::updateViewerBBox()
{
m_pScene->update_bbox();
const Scene::Bbox bbox = m_pScene->bbox();
const double xmin = bbox.xmin();
const double ymin = bbox.ymin();
const double zmin = bbox.zmin();
const double xmax = bbox.xmax();
const double ymax = bbox.ymax();
const double zmax = bbox.zmax();
qglviewer::Vec
vec_min(xmin, ymin, zmin),
vec_max(xmax, ymax, zmax);
m_pViewer->setSceneBoundingBox(vec_min,vec_max);
m_pViewer->camera()->showEntireScene();
m_pScene->update_bbox();
const Scene::Bbox bbox = m_pScene->bbox();
const double xmin = bbox.xmin();
const double ymin = bbox.ymin();
const double zmin = bbox.zmin();
const double xmax = bbox.xmax();
const double ymax = bbox.ymax();
const double zmax = bbox.zmax();
qglviewer::Vec
vec_min(xmin, ymin, zmin),
vec_max(xmax, ymax, zmax);
m_pViewer->setSceneBoundingBox(vec_min,vec_max);
m_pViewer->camera()->showEntireScene();
}

void MainWindow::on_actionView_polyhedron_triggered()
{
m_pScene->toggle_view_poyhedron();
m_pScene->toggle_view_poyhedron();
m_pViewer->update();
}

void MainWindow::on_actionRefine_loop_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->refine_loop();
QApplication::restoreOverrideCursor();
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->refine_loop();
QApplication::restoreOverrideCursor();
m_pViewer->update();
}


void MainWindow::open(QString filename)
{
QFileInfo fileinfo(filename);
if(fileinfo.isFile() && fileinfo.isReadable())
QFileInfo fileinfo(filename);
if(fileinfo.isFile() && fileinfo.isReadable())
{
int index = m_pScene->open(filename);
if(index >= 0)
{
int index = m_pScene->open(filename);
if(index >= 0)
{
QSettings settings;
settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath());
this->addToRecentFiles(filename);

// update bbox
updateViewerBBox();
m_pViewer->update();
}
QSettings settings;
settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath());
this->addToRecentFiles(filename);

// update bbox
updateViewerBBox();
m_pViewer->update();
}
}
}

void MainWindow::readSettings()
{
this->readState("MainWindow", Size|State);
this->readState("MainWindow", Size|State);
}

void MainWindow::writeSettings()
{
this->writeState("MainWindow");
std::cerr << "Write setting... done.\n";
this->writeState("MainWindow");
std::cerr << "Write setting... done.\n";
}

void MainWindow::quit()
{
writeSettings();
close();
writeSettings();
close();
}

void MainWindow::closeEvent(QCloseEvent *event)
{
writeSettings();
event->accept();
writeSettings();
event->accept();
}

void MainWindow::on_actionLoadPolyhedron_triggered()
{
QSettings settings;
QString directory = settings.value("OFF open directory",
QDir::current().dirName()).toString();
QStringList filenames =
QFileDialog::getOpenFileNames(this,
tr("Load polyhedron..."),
directory,
tr("OFF files (*.off)\n"
"All files (*)"));
if(!filenames.isEmpty()) {
Q_FOREACH(QString filename, filenames) {
open(filename);
}
QSettings settings;
QString directory = settings.value("OFF open directory",
QDir::current().dirName()).toString();
QStringList filenames =
QFileDialog::getOpenFileNames(this,
tr("Load polyhedron..."),
directory,
tr("OFF files (*.off)\n"
"All files (*)"));
if(!filenames.isEmpty()) {
Q_FOREACH(QString filename, filenames) {
open(filename);
}
}
}


void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m)
{
m_pViewer->setAddKeyFrameKeyboardModifiers(m);
m_pViewer->setAddKeyFrameKeyboardModifiers(m);
}

void MainWindow::on_actionSave_snapshot_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pViewer->saveSnapshot(QString("snapshot.png"));
QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}
void MainWindow::on_actionCopy_snapshot_triggered()
{
// copy snapshot to clipboard
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
QClipboard *qb = QApplication::clipboard();
m_pViewer->makeCurrent();
m_pViewer->raise();
QImage snapshot = m_pViewer->grabFrameBuffer(true);
qb->setImage(snapshot);
QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}

void MainWindow::on_actionFit_triangles_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->fit_triangles();
m_pViewer->update();
QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}

void MainWindow::on_actionFit_edges_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->fit_edges();
m_pViewer->update();
QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}

void MainWindow::on_actionFit_vertices_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->fit_vertices();
m_pViewer->update();
QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor();
}
Expand Up @@ -9,55 +9,54 @@ class QDropEvent;
class Scene;
class Viewer;
namespace Ui {
class MainWindow;
class MainWindow;
}


class MainWindow :
public CGAL::Qt::DemosMainWindow
public CGAL::Qt::DemosMainWindow
{
Q_OBJECT
Q_OBJECT
public:
MainWindow(QWidget* parent = 0);
~MainWindow();
MainWindow(QWidget* parent = 0);
~MainWindow();

public slots:
void updateViewerBBox();
void open(QString filename);
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);
public slots:
void updateViewerBBox();
void open(QString filename);
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);

protected slots:
protected slots:
// settings
void quit();
void readSettings();
void writeSettings();

// settings
void quit();
void readSettings();
void writeSettings();
// drag & drop
void dropEvent(QDropEvent *event);
void closeEvent(QCloseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);

// drag & drop
void dropEvent(QDropEvent *event);
void closeEvent(QCloseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
// file menu
void on_actionLoadPolyhedron_triggered();

// file menu
void on_actionLoadPolyhedron_triggered();
// edit menu
void on_actionSave_snapshot_triggered();
void on_actionCopy_snapshot_triggered();

// edit menu
void on_actionSave_snapshot_triggered();
void on_actionCopy_snapshot_triggered();
// algorithm menu
void on_actionRefine_loop_triggered();
void on_actionFit_triangles_triggered();
void on_actionFit_edges_triggered();
void on_actionFit_vertices_triggered();

// algorithm menu
void on_actionRefine_loop_triggered();
void on_actionFit_triangles_triggered();
void on_actionFit_edges_triggered();
void on_actionFit_vertices_triggered();

// view menu
void on_actionView_polyhedron_triggered();
// view menu
void on_actionView_polyhedron_triggered();

private:
Scene* m_pScene;
Viewer* m_pViewer;
Ui::MainWindow* ui;
Scene* m_pScene;
Viewer* m_pViewer;
Ui::MainWindow* ui;
};

#endif // ifndef MAINWINDOW_H

0 comments on commit ab22b88

Please sign in to comment.