Skip to content

Commit

Permalink
rearrange demo
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudev committed May 25, 2017
1 parent ab22b88 commit f58a1a8
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 191 deletions.
Expand Up @@ -17,7 +17,7 @@


MainWindow::MainWindow(QWidget* parent)
: CGAL::Qt::DemosMainWindow(parent)
: CGAL::Qt::DemosMainWindow(parent)
{
ui = new Ui::MainWindow;
ui->setupUi(this);
Expand Down Expand Up @@ -56,24 +56,6 @@ MainWindow::~MainWindow()
delete ui;
}

void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
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);
}
}
event->acceptProposedAction();
}

void MainWindow::updateViewerBBox()
{
m_pScene->update_bbox();
Expand All @@ -91,41 +73,35 @@ void MainWindow::updateViewerBBox()
m_pViewer->camera()->showEntireScene();
}

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

void MainWindow::on_actionRefine_loop_triggered()
{
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())
{
if(fileinfo.isFile() && fileinfo.isReadable()) {
int index = m_pScene->open(filename);
if(index >= 0)
{
if(index >= 0) {
QSettings settings;
settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath());
this->addToRecentFiles(filename);

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

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

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

void MainWindow::readSettings()
{
this->readState("MainWindow", Size|State);
Expand All @@ -137,10 +113,22 @@ void MainWindow::writeSettings()
std::cerr << "Write setting... done.\n";
}

void MainWindow::quit()
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
writeSettings();
close();
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);
}
}
event->acceptProposedAction();
}

void MainWindow::closeEvent(QCloseEvent *event)
Expand All @@ -167,18 +155,13 @@ void MainWindow::on_actionLoadPolyhedron_triggered()
}
}


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

void MainWindow::on_actionSave_snapshot_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pViewer->saveSnapshot(QString("snapshot.png"));
QApplication::restoreOverrideCursor();
}

void MainWindow::on_actionCopy_snapshot_triggered()
{
// copy snapshot to clipboard
Expand All @@ -191,6 +174,14 @@ void MainWindow::on_actionCopy_snapshot_triggered()
QApplication::restoreOverrideCursor();
}

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

void MainWindow::on_actionFit_triangles_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
Expand All @@ -214,3 +205,9 @@ void MainWindow::on_actionFit_vertices_triggered()
m_pViewer->update();
QApplication::restoreOverrideCursor();
}

void MainWindow::on_actionView_polyhedron_triggered()
{
m_pScene->toggle_view_poyhedron();
m_pViewer->update();
}
Expand Up @@ -17,6 +17,7 @@ class MainWindow :
public CGAL::Qt::DemosMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget* parent = 0);
~MainWindow();
Expand All @@ -33,9 +34,9 @@ protected slots:
void writeSettings();

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

// file menu
void on_actionLoadPolyhedron_triggered();
Expand Down

0 comments on commit f58a1a8

Please sign in to comment.