mirror of https://github.com/CGAL/cgal
cleanup demo/AABB_tree
This commit is contained in:
parent
f9c213735b
commit
abb9080102
|
|
@ -8,52 +8,28 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
if(NOT POLICY CMP0070 AND POLICY CMP0053)
|
||||
# Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
|
||||
cmake_policy(SET CMP0053 OLD)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0071)
|
||||
cmake_policy(SET CMP0071 NEW)
|
||||
endif()
|
||||
|
||||
# Include this package's headers first
|
||||
include_directories(BEFORE ./ ./include)
|
||||
|
||||
# Find CGAL and CGAL Qt6
|
||||
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt6)
|
||||
|
||||
# Find Qt6 itself
|
||||
find_package(Qt6 QUIET COMPONENTS OpenGLWidgets Widgets OpenGL Qml)
|
||||
find_package(Qt6 QUIET COMPONENTS Gui)
|
||||
|
||||
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
||||
|
||||
qt6_wrap_ui(UI_FILES MainWindow.ui)
|
||||
|
||||
include(AddFileDependencies)
|
||||
|
||||
qt6_generate_moc("MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp")
|
||||
add_file_dependencies(MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h")
|
||||
|
||||
qt6_generate_moc("Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp")
|
||||
add_file_dependencies(Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h")
|
||||
|
||||
qt6_generate_moc("Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp")
|
||||
add_file_dependencies(Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h")
|
||||
|
||||
qt6_add_resources(CGAL_Qt6_RESOURCE_FILES AABB_demo.qrc)
|
||||
|
||||
add_file_dependencies(
|
||||
AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp")
|
||||
|
||||
add_executable(
|
||||
AABB_demo AABB_demo.cpp ${UI_FILES} ${CGAL_Qt6_RESOURCE_FILES}
|
||||
#${CGAL_Qt6_MOC_FILES}
|
||||
)
|
||||
# Link with Qt libraries
|
||||
target_link_libraries(AABB_demo PRIVATE Qt6::OpenGLWidgets Qt6::Widgets Qt6::OpenGL Qt6::Qml
|
||||
target_link_libraries(AABB_demo PRIVATE Qt6::Gui
|
||||
CGAL::CGAL CGAL::CGAL_Qt6)
|
||||
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS AABB_demo)
|
||||
|
|
|
|||
|
|
@ -13,10 +13,8 @@
|
|||
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: CGAL::Qt::DemosMainWindow(parent), myEngine(new QJSEngine(this))
|
||||
: CGAL::Qt::DemosMainWindow(parent)
|
||||
{
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
|
|
@ -40,25 +38,12 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
connect(this, SIGNAL(openRecentFile(QString)),
|
||||
this, SLOT(open(QString)));
|
||||
|
||||
QJSValue mainWindow = myEngine->newQObject(this);
|
||||
myEngine->globalObject().setProperty("main_window", mainWindow);
|
||||
readSettings();
|
||||
std::ifstream script("init.js");
|
||||
if(script.good()){
|
||||
std::string line;
|
||||
while(getline(script, line)){
|
||||
myEngine->evaluate(line.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_pViewer->makeCurrent();
|
||||
// AF I thought this helps to avoid the exception when the program
|
||||
// terminates, but it does not
|
||||
myEngine->globalObject().setProperty("main_window", QJSValue());
|
||||
myEngine->collectGarbage();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
@ -80,13 +65,6 @@ void MainWindow::dropEvent(QDropEvent *event)
|
|||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::hello() const
|
||||
{
|
||||
std::cout << "Hhello world" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateViewerBBox()
|
||||
{
|
||||
m_pScene->update_bbox();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QJSEngine>
|
||||
#include <CGAL/Qt/DemosMainWindow.h>
|
||||
|
||||
class QDragEnterEvent;
|
||||
|
|
@ -13,38 +11,6 @@ namespace Ui {
|
|||
class MainWindow;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
struct Foo : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
QJSEngine* myEngine;
|
||||
|
||||
Foo()
|
||||
: myEngine(new QJSEngine(this))
|
||||
{
|
||||
QJSValue baz = myEngine->newQObject(this);
|
||||
myEngine->.globalObject().setProperty("baz", baz);
|
||||
}
|
||||
|
||||
void bar()
|
||||
{
|
||||
std::cout << "bar()" << std::endl;
|
||||
myEngine->evaluate("baz.hello()");
|
||||
}
|
||||
|
||||
public slots:
|
||||
void hello() const // if not a slot it must be
|
||||
{
|
||||
std::cout << "called hello()" << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class MainWindow :
|
||||
public CGAL::Qt::DemosMainWindow
|
||||
{
|
||||
|
|
@ -54,8 +20,6 @@ public:
|
|||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
|
||||
void hello() const;
|
||||
void updateViewerBBox();
|
||||
void open(QString filename);
|
||||
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);
|
||||
|
|
@ -113,7 +77,6 @@ public:
|
|||
void on_actionView_cutting_plane_triggered();
|
||||
|
||||
private:
|
||||
QJSEngine* myEngine;
|
||||
Scene* m_pScene;
|
||||
Viewer* m_pViewer;
|
||||
Ui::MainWindow* ui;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
|
|
@ -77,7 +76,6 @@ private:
|
|||
};
|
||||
|
||||
public:
|
||||
QOpenGLContext* context;
|
||||
void draw(CGAL::QGLViewer*);
|
||||
void update_bbox();
|
||||
Bbox bbox() { return m_bbox; }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#include "Viewer.h"
|
||||
#include "Scene.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <CGAL/Qt/CreateOpenGLContext.h>
|
||||
|
||||
Viewer::Viewer(QWidget* parent)
|
||||
: CGAL::QGLViewer(parent),
|
||||
m_pScene(nullptr),
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
main_window.hello();
|
||||
main_window.hello();
|
||||
Loading…
Reference in New Issue