Skip to content
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

Develop #4

Merged
merged 7 commits into from
Apr 11, 2016
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
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ endif()

#### SCHNAPPS PATH / SCHNAPPS_SOURCE_DIR
set(SCHNAPPS_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
set(SCHNAPPS_SOURCE_DIR ${SCHNAPPS_PATH}/schnapps)
set(SCHNAPPS_SOURCE_DIR ${SCHNAPPS_PATH})

#### CGOGN_PATH / CGOGN_SOURCE_DIR
set(CGOGN_PATH "${SCHNAPPS_PATH}/../CGoGN_2")
set(CGOGN_SOURCE_DIR ${CGOGN_PATH}/cgogn)
set(CGOGN_SOURCE_DIR ${CGOGN_PATH})

set(CGOGN_THIRDPARTY_EIGEN3_INCLUDE_DIR "${CGOGN_PATH}/thirdparty/eigen-3.2.8" CACHE PATH "Include directory for find_package(Eigen3)")

#### Build configuration
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
Expand All @@ -28,4 +30,4 @@ set(SCHNAPPS_THIRDPARTY_DIR ${SCHNAPPS_PATH}/thirdparty)
find_package(Qt5Widgets REQUIRED)

add_subdirectory(${SCHNAPPS_THIRDPARTY_DIR})
add_subdirectory(${SCHNAPPS_SOURCE_DIR})
add_subdirectory(${SCHNAPPS_SOURCE_DIR}/schnapps)
28 changes: 26 additions & 2 deletions schnapps/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,34 @@ project(schnapps_core

set(HEADER_FILES
schnapps.h
camera.h
view.h
view_dialog_list.h
view_button_area.h
plugin.h
plugin_processing.h
plugin_interaction.h
map_handler.h
)

set(SOURCE_FILES
schnapps.cpp
camera.cpp
view.cpp
view_dialog_list.cpp
view_button_area.cpp
plugin_interaction.cpp
map_handler.cpp
)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
qt5_add_resources(RCC_FILES
${SCHNAPPS_PATH}/schnapps/resources/resources.qrc
)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${RCC_FILES})

# use of target_compile_options to have a transitive c++11 flag
if(NOT MSVC)
Expand All @@ -27,13 +45,19 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d")

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${SCHNAPPS_THIRDPARTY_QOGLVIEWER_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CGOGN_THIRDPARTY_EIGEN3_INCLUDE_DIR}>
$<BUILD_INTERFACE:${SCHNAPPS_SOURCE_DIR}>
$<BUILD_INTERFACE:${CGOGN_SOURCE_DIR}>
${CMAKE_CURRENT_BINARY_DIR}
$<INSTALL_INTERFACE:include/schnapps/core>
)

target_link_libraries(${PROJECT_NAME} QOGLViewer Qt5::Widgets)
target_link_libraries(${PROJECT_NAME}
${CGOGN_PATH}/../CGoGN_2-build/lib/libcgogn_core.dylib
${CGOGN_PATH}/../CGoGN_2-build/lib/libcgogn_rendering.dylib
QOGLViewer
Qt5::Widgets
)

install(DIRECTORY .
DESTINATION include/schnapps/core
Expand Down
167 changes: 167 additions & 0 deletions schnapps/core/camera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*******************************************************************************
* SCHNApps *
* Copyright (C) 2015, IGG Group, ICube, University of Strasbourg, France *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/

#include <schnapps/core/camera.h>
#include <schnapps/core/schnapps.h>
#include <schnapps/core/view.h>

namespace schnapps
{

unsigned int Camera::camera_count_ = 0;

Camera::Camera(const QString& name, SCHNApps* schnapps) :
name_(name),
schnapps_(schnapps),
draw_(false),
draw_path_(false),
fit_to_views_bounding_box_(true)
{
++camera_count_;
connect(this->frame(), SIGNAL(modified()), this, SLOT(frame_modified()));
}

Camera::~Camera()
{}

void Camera::set_projection_type(int t)
{
this->setType(qoglviewer::Camera::Type(t));
emit(projection_type_changed(t));
foreach (View* view, schnapps_->get_view_set().values())
view->update();
}

void Camera::set_draw(bool b)
{
draw_ = b;
emit(draw_changed(b));
foreach (View* view, schnapps_->get_view_set().values())
view->update();
}

void Camera::set_draw_path(bool b)
{
draw_path_ = b;
emit(draw_path_changed(b));
foreach (View* view, schnapps_->get_view_set().values())
view->update();
}

QString Camera::to_string()
{
QString res;
QTextStream str(&res);
qoglviewer::Vec pos = this->position();
qoglviewer::Quaternion ori = this->orientation();
str << pos[0] << " " << pos[1] << " " << pos[2] << " ";
str << ori[0] << " " << ori[1] << " " << ori[2] << " " << ori[3];
return res;
}

void Camera::from_string(QString cam)
{
QTextStream str(&cam);
qoglviewer::Vec pos = this->position();
qoglviewer::Quaternion ori = this->orientation();
str >> pos[0];
str >> pos[1];
str >> pos[2];
str >> ori[0];
str >> ori[1];
str >> ori[2];
str >> ori[3];
this->setPosition(pos);
this->setOrientation(ori);
}

void Camera::link_view(View* view)
{
if(view && !views_.contains(view))
{
views_.push_back(view);
fit_to_views_bounding_box();
connect(view, SIGNAL(bounding_box_changed()), this, SLOT(fit_to_views_bounding_box()));
}
}

void Camera::unlink_view(View* view)
{
if (views_.removeOne(view))
{
fit_to_views_bounding_box();
disconnect(view, SIGNAL(bounding_box_changed()), this, SLOT(fit_to_views_bounding_box()));
}
}

void Camera::frame_modified()
{
if(draw_ || draw_path_)
{
foreach (View* view, schnapps_->get_view_set().values())
view->update();
}
else
{
foreach (View* view, views_)
view->update();
}
}

void Camera::fit_to_views_bounding_box()
{
if (fit_to_views_bounding_box_)
{
qoglviewer::Vec bb_min;
qoglviewer::Vec bb_max;

if (!views_.empty())
{
views_.first()->get_bb(bb_min, bb_max);

foreach (View* v, views_)
{
qoglviewer::Vec minbb;
qoglviewer::Vec maxbb;
v->get_bb(minbb, maxbb);
for(unsigned int dim = 0; dim < 3; ++dim)
{
if(minbb[dim] < bb_min[dim])
bb_min[dim] = minbb[dim];
if(maxbb[dim] > bb_max[dim])
bb_max[dim] = maxbb[dim];
}
}
}
else
{
bb_min.setValue(0, 0, 0);
bb_max.setValue(0, 0, 0);
}

this->setSceneBoundingBox(bb_min, bb_max);
this->showEntireScene();
}
}

} // namespace schnapps
Loading