Skip to content

Added Nef_S2 Qt5 visualization #3511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
71 changes: 65 additions & 6 deletions Nef_S2/examples/Nef_S2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,76 @@ project( Nef_S2_Examples )

cmake_minimum_required(VERSION 3.1)

find_package(CGAL QUIET)
if(POLICY CMP0053)
# Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
if(NOT POLICY CMP0070)
cmake_policy(SET CMP0053 OLD)
else()
cmake_policy(SET CMP0053 NEW)
endif()
endif()
if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()

find_package(CGAL)
find_package(Qt5 COMPONENTS Widgets OpenGL)

if ( CGAL_FOUND )

include_directories (BEFORE "include")

# create a target per cppfile
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program( "${cppfile}" )
endforeach()
create_single_source_cgal_program("nef_s2_construction.cpp")
create_single_source_cgal_program("nef_s2_exploration.cpp")
create_single_source_cgal_program("nef_s2_point_location.cpp")
create_single_source_cgal_program("nef_s2_simple.cpp")

if(Qt5_FOUND)
# The Qt5Widgets_INCLUDES also includes the include directories for
# dependencies QtCore and QtGui
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS})

# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
add_definitions(${Qt5Widgets_DEFINITIONS} ${Qt5OpenGL_DEFINITIONS})

# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# qt5_wrap_cpp(mocfiles include/CGAL/Nef_S2/Qt_widget_OpenGL.h
# include/CGAL/Nef_S2/Qt_widget_Nef_S2.h)

qt5_generate_moc(include/CGAL/Nef_S2/Qt_widget_OpenGL.h Qt_widget_OpenGL.h.moc.cpp)
qt5_generate_moc(include/CGAL/Nef_S2/Qt_widget_Nef_S2.h Qt_widget_Nef_S2.h.moc.cpp)


add_executable(nef_S2
"nef_S2.cpp"
"Qt_widget_OpenGL.h.moc.cpp"
"Qt_widget_Nef_S2.h.moc.cpp"
"Qt_widget_Nef_S2.cpp"
"Qt_widget_OpenGL.cpp" )
target_link_libraries(nef_S2 PRIVATE CGAL::CGAL)
if(CGAL_3RD_PARTY_LIBRARIES)
target_link_libraries(nef_S2 PRIVATE ${CGAL_3RD_PARTY_LIBRARIES})
endif()
target_link_libraries(nef_S2 PRIVATE ${CGAL_LIBRARIES} Qt5::Widgets Qt5::OpenGL glut GLU GL )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably do not need glut and GLU. And if you use the Qt5 OpenGL module, GL is not required either.



add_executable(draw_nef_s2
"draw_nef_s2.cpp"
"Qt_widget_OpenGL.h.moc.cpp"
"Qt_widget_Nef_S2.h.moc.cpp"
"Qt_widget_Nef_S2.cpp"
"Qt_widget_OpenGL.cpp")
target_link_libraries(draw_nef_s2 PRIVATE CGAL::CGAL)
if(CGAL_3RD_PARTY_LIBRARIES)
target_link_libraries(draw_nef_s2 PRIVATE ${CGAL_3RD_PARTY_LIBRARIES})
endif()
target_link_libraries(draw_nef_s2 PRIVATE ${CGAL_LIBRARIES} Qt5::Widgets Qt5::OpenGL glut GLU GL )
endif()

else()

Expand Down
91 changes: 91 additions & 0 deletions Nef_S2/examples/Nef_S2/Qt_widget_Nef_S2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "CGAL/Nef_S2/Qt_widget_Nef_S2.h"

namespace CGAL {
Qt_widget_Nef_S2::~Qt_widget_Nef_S2() {
for (size_t i=0;i<object_.size();i++) {
delete object_[i];
}
object_.clear();
}

Qt_widget_Nef_S2::Qt_widget_Nef_S2() :
Qt_widget_OpenGL(300,300,1.5) {

resize(window_width, window_height);
// this->setContextMenuPolicy(Qt::ActionsContextMenu);

main = new QMenu;
sub1 = main->addMenu("&Control");
sub2 = main->addMenu("&Render");
sub3 = main->addMenu("&Options");

QAction * qa;
qa = sub1->addAction("Reset");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotControlMenuReset()));
qa = sub1->addAction("Rotate");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotControlMenuRotate()));
qa = sub1->addAction("Scale");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotControlMenuScale()));
qa = sub1->addAction("Translate in XY");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotControlMenuTranslate()));

qa = sub2->addAction("Faces");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotRenderMenuFaces()));
qa = sub2->addAction("Skeleton");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotRenderMenuSkeleton()));
qa = sub2->addAction("Triangulation");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotRenderMenuTriangulation()));

qa = sub3->addAction("Toggle Axes");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotOptionsMenuAxes()));
qa = sub3->addAction("Toggle Unity Cube");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotOptionsMenuUnityCube()));

qa = main->addAction("&Next");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotNextObject()));
qa = main->addAction("&Previous");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotPrevObject()));
qa = main->addAction("&Toggle Fullscreen");
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotFullscreen()));
qa = main->addAction("&Quit");
QObject::connect(qa, SIGNAL(triggered()), qApp, SLOT(quit()));

qa = new QAction("Reset",this);
qa->setShortcut(Qt::Key_R);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotControlMenuReset()));
this->addAction(qa);

qa = new QAction("Toggle Axes",this);
qa->setShortcut(Qt::Key_A);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotOptionsMenuAxes()));
this->addAction(qa);

qa = new QAction("Toggle Unity Cube",this);
qa->setShortcut(Qt::Key_C);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotOptionsMenuUnityCube()));
this->addAction(qa);

qa = new QAction("Next",this);
qa->setShortcut(Qt::Key_Right);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotNextObject()));
this->addAction(qa);

qa = new QAction("Previous",this);
qa->setShortcut(Qt::Key_Left);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotPrevObject()));
this->addAction(qa);

qa = new QAction("Toggle Fullscreen",this);
qa->setShortcut(Qt::Key_F);
QObject::connect(qa, SIGNAL(triggered()), this, SLOT(slotFullscreen()));
this->addAction(qa);

qa = new QAction("Quit",this);
qa->setShortcut(Qt::Key_Q);
QObject::connect(qa, SIGNAL(triggered()), qApp, SLOT(quit()));
this->addAction(qa);
}


} //namespace CGAL

Loading