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

Modified source code for added compatibility on MacOS #30

Open
wants to merge 21 commits into
base: michael
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e10db84
Modified AppVeyor build configuration settings
michizhou Jun 11, 2019
c56303d
Added installation of new software by AppVeyor
michizhou Jun 11, 2019
339892e
Modified AppVeyor build compilation settings
michizhou Jun 12, 2019
5645606
Changed paths for AppVeyor build libraries
michizhou Jun 12, 2019
548d888
Added return value to header function
michizhou Jun 12, 2019
e52ce30
Revised AppVeyor library compilation paths
michizhou Jun 12, 2019
0c5fd0e
Modified AppVeyor after build command script
michizhou Jun 13, 2019
7e186e0
Added Travis build instance
michizhou Jun 14, 2019
d8799ed
Modified Travis compiler environment settings
michizhou Jun 14, 2019
1b7fb81
Updated Travis build compiler configuration
michizhou Jun 17, 2019
fc05c3a
Modified source code for added compatibility on MacOS
michizhou Jul 17, 2019
525b13a
Changed features for rendering and UI functionality on MacOS
michizhou Jul 22, 2019
0013a21
Resolved MacOS bounding polygon selection and rendering issues
michizhou Jul 24, 2019
35e12f7
Added dependencies for debug group functions
michizhou Jul 24, 2019
b38e0ec
Added MacOS environment builds to Travis
michizhou Jul 24, 2019
246fe30
Modified OpenMP and Qt5 compilation settings
michizhou Jul 25, 2019
91116d1
Refactored helper functions and state constants
michizhou Jul 25, 2019
ccdc39a
Added onto comments and debug helper function
michizhou Jul 25, 2019
db06ce5
Modified debug helper function implementation
michizhou Jul 26, 2019
1964a44
Corrected mouse coordinate discrepancies with scaling
michizhou Jul 29, 2019
441b955
Addendum 1
michizhou Jul 31, 2019
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
30 changes: 27 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,37 @@ clone_folder: C:\projects\fish_deformation
branches:
only:
- master
- michael
install:
- git submodule update --init --recursive
- cinstall: python
build:
parallel: true
build_script:
- echo Running cmake...
- echo Running cmake ..
- cd c:\tools\vcpkg
- .\vcpkg.exe --triplet x64-windows install mpir mpfr
- cd c:\projects\fish_deformation
- set PATH=C:\Python%PYTHON%-x64;C:\Python%PYTHON%-x64\Scripts;%PATH%
- mkdir build
- cd build
- cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" ..
- msbuild %MSBuildOptions% fish_deformation
- cmake -G "Visual Studio 15 2017 Win64"
-DCMAKE_PREFIX_PATH="C:/Qt/5.10.1/msvc2017_64/lib/cmake"
-DMPFR_INCLUDE_DIR:PATH="C:/tools/vcpkg/installed/x64-windows/include"
-DMPFR_LIBRARIES:FILEPATH="C:/tools/vcpkg/installed/x64-windows/lib/mpfr.lib"
-DGMP_INCLUDE_DIR:PATH="C:/tools/vcpkg/installed/x64-windows/include"
-DGMP_LIBRARIES:FILEPATH="C:/tools/vcpkg/installed/x64-windows/lib/mpir.lib"
-DBOOST_ROOT="C:/Libraries/boost_1_65_1" ../
- set MSBuildOptions=/v:m /p:Configuration=Release /p:Platform=x64
- msbuild %MSBuildOptions% fish_deformation.sln
after_build:
- cd ..
- mkdir unwind
- copy build\src\Release\unwind.exe unwind
- copy build\src\Release\mpir.dll unwind
- cd C:\Qt\latest\msvc2017_64\bin
- windeployqt C:\projects\fish_deformation\unwind\unwind.exe
- cd C:\projects\fish_deformation
- 7z a unwind.zip unwind\
artifacts:
- path: unwind.zip
86 changes: 86 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
dist: trusty
sudo: true
language: cpp
cache: ccache
branches:
only:
- master
- michael
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- cmake
- g++-6
- gcc-6
- g++-7
- gcc-7
- libblas-dev
- libboost-filesystem-dev
- libboost-system-dev
- libboost-thread-dev
- libglu1-mesa-dev
- liblapack-dev
- libmpfr-dev
- libpython3-dev
- python3-setuptools
- qt5-default
- xorg-dev
homebrew:
packages:
- ccache
matrix:
include:
- os: linux
compiler: gcc-6
env:
- MATRIX_EVAL="export CC=gcc-6 CXX=g++-6 CONFIG=Release PYTHON=python3"
- os: linux
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3"
- os: linux # same config like above but with -DLIBIGL_USE_STATIC_LIBRARY=OFF to test static and header-only builds
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_USE_STATIC_LIBRARY=OFF'"
- os: linux
compiler: gcc-7
env:
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7'"
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- MATRIX_EVAL="export CONFIG=Release PYTHON=python3 LIBIGL_NUM_THREADS=1"
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- MATRIX_EVAL="export CONFIG=Release PYTHON=python3 LIBIGL_NUM_THREADS=1 CMAKE_EXTRA='-DLIBIGL_USE_STATIC_LIBRARY=OFF'"
- os: osx
osx_image: xcode10.2
compiler: clang
env:
- MATRIX_EVAL="export CONFIG=Release PYTHON=python3 LIBIGL_NUM_THREADS=1 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7'""

install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
- eval "${MATRIX_EVAL}"
- ccache --max-size=5.0G
- ccache -V && ccache --show-stats && ccache --zero-stats

script:
# Tutorials and tests
- mkdir build
- pushd build
- cmake ${CMAKE_EXTRA}
-DCMAKE_BUILD_TYPE=$CONFIG
-DLIBIGL_CHECK_UNDEFINED=ON
-DLIBIGL_WITH_CGAL=ON
../
- make -j8
- ctest --verbose
- popd
- rm -rf build
- ccache --show-stats
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ project(fish_deformation)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/voroffset/cmake)


if (APPLE)
set(CMAKE_PREFIX_PATH /usr/local/opt/qt/lib/cmake)
endif ()


#################################
Expand Down Expand Up @@ -110,8 +111,12 @@ file(GLOB CT_SRCS external/Segmentangling/ContourTree/*.cpp)
set(CT_INCLUDE_DIRS external/Segmentangling/ContourTree)
list(REMOVE_ITEM CT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/external/Segmentangling/ContourTree/main.cpp")
add_library(contourtree STATIC ${CT_SRCS})
target_compile_options(contourtree PRIVATE "-fopenmp")
target_link_libraries(contourtree Qt5::Core Qt5::Widgets -fopenmp spdlog)
if (NOT APPLE)
target_compile_options(contourtree PRIVATE "-fopenmp")
target_link_libraries(contourtree Qt5::Core Qt5::Widgets -fopenmp spdlog)
else ()
target_link_libraries(contourtree Qt5::Core Qt5::Widgets spdlog)
endif ()
target_include_directories(contourtree PUBLIC ${CT_INCLUDE_DIRS})
target_compile_definitions(contourtree PUBLIC CONTOUR_TREE_USE_SPDLOG)

Expand All @@ -125,7 +130,7 @@ list(FILTER UTILS_HEADER EXCLUDE REGEX cgal*)
add_library(utils STATIC ${UTILS_SRCS} ${UTILS_HEADER})
set_property(TARGET utils PROPERTY CXX_STANDARD 14)
set_property(TARGET utils PROPERTY CXX_STANDARD_REQUIRED ON)
target_link_libraries(utils igl::core igl::opengl igl::cgal igl::triangle spdlog Qt5::Core Qt5::Widgets spdlog)
target_link_libraries(utils igl::core igl::opengl igl::cgal igl::triangle spdlog Qt5::Core Qt5::Widgets spdlog glfw ${GLFW_LIBRARIES})
target_include_directories(utils PUBLIC ${UTILS_INCLUDE_DIRS})
target_include_directories(utils SYSTEM PUBLIC "${PROJECT_SOURCE_DIR}/external/glm")

Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ui/endpoint_selection_plugin.h"
#include "ui/bounding_polygon_plugin.h"
#include "ui/state.h"
#include "utils/utils.h"
#include "Logger.hpp"

State _state;
Expand Down Expand Up @@ -56,8 +57,7 @@ bool init(igl::opengl::glfw::Viewer& viewer) {
ct_logger->set_level(CONTOURTREE_LOGGER_LEVEL);
contourtree::Logger::setLogger(ct_logger);

glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(log_opengl_debug, NULL);
init_opengl_debug(log_opengl_debug);

return false;
}
Expand Down
26 changes: 17 additions & 9 deletions src/ui/bounding_polygon_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ void Bounding_Polygon_Menu::deinitialize() {
}

bool Bounding_Polygon_Menu::is_2d_widget_in_focus() {
double mouse_x, mouse_y;
glfwGetCursorPos(viewer->window, &mouse_x, &mouse_y);
glm::vec2 p(mouse_x, mouse_y);
glm::vec2 p(viewer->current_mouse_x, viewer->current_mouse_y);
return widget_2d.is_point_in_widget(p) && !mouse_in_popup;
}

Expand Down Expand Up @@ -344,11 +342,17 @@ bool Bounding_Polygon_Menu::post_draw() {
bool ret = FishUIViewerPlugin::post_draw();

int window_width, window_height;
glfwGetWindowSize(viewer->window, &window_width, &window_height);
get_window_size(viewer->window, &window_width, &window_height);
#ifdef __APPLE__
fwilliams marked this conversation as resolved.
Show resolved Hide resolved
glViewport(-window_width*view_hsplit, -(1.0+view_vsplit)*window_height/scaling_factor,
window_width, scaling_factor*(1.0-view_vsplit)*window_height);
widget_2d.position = glm::vec2(0.f, view_vsplit*window_height/(scaling_factor*scaling_factor*scaling_factor));
widget_2d.size = glm::vec2(window_width*view_hsplit/scaling_factor, (1.0-view_vsplit)*window_height/(scaling_factor*scaling_factor));
#else
glViewport(0, 0, window_width, window_height);

widget_2d.position = glm::vec2(0.f, view_vsplit*window_height);
widget_2d.size = glm::vec2(window_width*view_hsplit, (1.0-view_vsplit)*window_height);
#endif
ret = widget_2d.post_draw(state.cage.keyframe_for_index(current_cut_index), is_2d_widget_in_focus());

Eigen::Vector4f widget_3d_viewport(view_hsplit*window_width, view_vsplit*window_height,
Expand All @@ -364,6 +368,9 @@ bool Bounding_Polygon_Menu::post_draw() {
ImGui::SetNextWindowBgAlpha(0.5f);
float window_height_float = static_cast<float>(window_height);
float window_width_float = static_cast<float>(window_width);
#ifdef __APPLE__
window_height_float /= scaling_factor, window_width_float /= scaling_factor;
#endif
ImGui::SetNextWindowPos(ImVec2(0.f, (1.0-view_vsplit)*window_height_float), ImGuiSetCond_Always);
ImGui::SetNextWindowSize(ImVec2(window_width_float, window_height_float*view_vsplit), ImGuiSetCond_Always);
ImGui::Begin("Select Boundary", nullptr,
Expand Down Expand Up @@ -401,6 +408,9 @@ bool Bounding_Polygon_Menu::post_draw() {

ImGui::SameLine();
ImVec2 cursor_pos = ImGui::GetCursorScreenPos();
#ifdef __APPLE__
cursor_pos.x *= (1.0+keyframe_nudge_amount);
#endif
ImGui::PushItemWidth(ImGui::GetWindowWidth() - 2.f*cursor_pos.x);
if(ImGui::SliderFloat("", &current_cut_index,
static_cast<float>(state.cage.min_index()),
Expand Down Expand Up @@ -499,10 +509,8 @@ bool Bounding_Polygon_Menu::post_draw() {
ImVec2 popup_size = ImGui::GetWindowSize();
tf_widget.post_draw(!show_save_popup /* active */);

double mouse_x, mouse_y;
glfwGetCursorPos(viewer->window, &mouse_x, &mouse_y);
bool in_window_x = (mouse_x >= popup_pos[0]) && (mouse_x <= (popup_pos[0] + popup_size[0]));
bool in_window_y = (mouse_y >= popup_pos[1]) && (mouse_y <= (popup_pos[1] + popup_size[1]));
bool in_window_x = (viewer->current_mouse_x >= popup_pos[0]) && (viewer->current_mouse_x <= (popup_pos[0] + popup_size[0]));
bool in_window_y = (viewer->current_mouse_y >= popup_pos[1]) && (viewer->current_mouse_y <= (popup_pos[1] + popup_size[1]));
mouse_in_popup = (in_window_x && in_window_y);

ImGui::Separator();
Expand Down
1 change: 1 addition & 0 deletions src/ui/bounding_polygon_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Bounding_Polygon_Menu : public FishUIViewerPlugin {

void post_draw_transfer_function();

float scaling_factor = 2.0; // Scaling factor for window sizes of the two menus
float view_hsplit = 0.5; // Horizontal split for the two menus (normalized distance
float view_vsplit = 0.2; // Vertical split for the bottom menu (normalized distance from the bottom)

Expand Down
35 changes: 23 additions & 12 deletions src/ui/bounding_widget_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "bounding_polygon_plugin.h"

#include "utils/utils.h"

#include <igl/opengl/create_shader_program.h>
#include <igl/opengl/glfw/Viewer.h>
#include <imgui/imgui.h>
Expand Down Expand Up @@ -143,9 +145,13 @@ struct BlitData {
Bounding_Polygon_Widget::Bounding_Polygon_Widget(State& state) : state(state) {}

glm::vec2 Bounding_Polygon_Widget::convert_position_mainwindow_to_keyframe(const glm::vec2& p) const {
#ifdef __APPLE__
glm::vec2 window_ll = glm::vec2(position.x, size.y);
glm::vec2 window_ur = window_ll + glm::vec2(macos_widget_scaling_factor*size.y, macos_widget_scaling_factor*size.y);
#else
glm::vec2 window_ll = position;
glm::vec2 window_ur = position + size;

#endif
// Map mouse into [0, 1]^2 in the subwindow
glm::vec2 normalized_mouse = (p - window_ll) / (window_ur - window_ll);

Expand All @@ -163,11 +169,16 @@ glm::vec2 Bounding_Polygon_Widget::convert_position_keyframe_to_ndc(const glm::v
bool Bounding_Polygon_Widget::is_point_in_widget(glm::ivec2 p) const {

int window_width, window_height;
glfwGetWindowSize(viewer->window, &window_width, &window_height);
get_window_size(viewer->window, &window_width, &window_height);

const glm::ivec2 p_tx(p.x, window_height - p.y);
#ifdef __APPLE__
const glm::ivec2 ll = glm::ivec2(position.x, size.y);
const glm::ivec2 ur = ll + glm::ivec2(macos_widget_scaling_factor*size.y, macos_widget_scaling_factor*size.y);
#else
const glm::ivec2 ll = position;
const glm::ivec2 ur = position + size;
#endif
return p_tx.x >= ll.x && p_tx.x <= ur.x && p_tx.y >= ll.y && p_tx.y <= ur.y;
}

Expand All @@ -189,7 +200,7 @@ void Bounding_Polygon_Widget::update_selection() {
};

glm::ivec2 window_size;
glfwGetWindowSize(viewer->window, &window_size.x, &window_size.y);
get_window_size(viewer->window, &window_size.x, &window_size.y);
glm::vec2 current_mouse = { viewer->current_mouse_x, window_size.y - viewer->current_mouse_y }; // In main window pixel space
glm::vec2 kf_mouse = convert_position_mainwindow_to_keyframe(current_mouse); // In keyframe ndc

Expand Down Expand Up @@ -297,7 +308,7 @@ void Bounding_Polygon_Widget::initialize(igl::opengl::glfw::Viewer* viewer, Boun

bool Bounding_Polygon_Widget::mouse_move(int mouse_x, int mouse_y, bool in_focus) {
glm::ivec2 window_size;
glfwGetWindowSize(viewer->window, &window_size.x, &window_size.y);
get_window_size(viewer->window, &window_size.x, &window_size.y);

mouse_state.current_position = glm::ivec2(mouse_x, mouse_y);
if (!in_focus) { //!is_point_in_widget(glm::ivec2(mouse_x, mouse_y)) ||
Expand Down Expand Up @@ -415,7 +426,7 @@ bool Bounding_Polygon_Widget::mouse_move(int mouse_x, int mouse_y, bool in_focus

bool Bounding_Polygon_Widget::mouse_down(int button, int modifier, bool in_focus) {
glm::ivec2 window_size;
glfwGetWindowSize(viewer->window, &window_size.x, &window_size.y);
get_window_size(viewer->window, &window_size.x, &window_size.y);

bool left_mouse = glfwGetMouseButton(viewer->window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS;
bool right_mouse = glfwGetMouseButton(viewer->window, GLFW_MOUSE_BUTTON_2) == GLFW_PRESS;
Expand Down Expand Up @@ -563,7 +574,7 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
//
// Render the slice of the volume for this keyframe into an OpenGL texture
//
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Render slice");
push_gl_debug_group("Render slice");
{
glUseProgram(plane.program);
glBindVertexArray(empty_vao);
Expand Down Expand Up @@ -600,13 +611,13 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
glBindVertexArray(0);
glUseProgram(0);
}
glPopDebugGroup();
pop_gl_debug_group();


//
// Render the bounding-box, center, and axes into the same texture
//
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Render polygon");
push_gl_debug_group("Render polygon");
{
const glm::vec2 centroid_2d = G2f(kf->centroid_2d());
const glm::vec2 r_axis = G2f(kf->right_rotated_2d()), u_axis = G2f(kf->up_rotated_2d());
Expand All @@ -633,7 +644,7 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
// Render rotation handle
if (mouse_state.is_rotate_modifier_down && in_focus) {
glm::ivec2 window_size;
glfwGetWindowSize(viewer->window, &window_size.x, &window_size.y);
get_window_size(viewer->window, &window_size.x, &window_size.y);
glm::vec2 current_mouse = { viewer->current_mouse_x, window_size.y - viewer->current_mouse_y };
glm::vec2 kf_mouse = convert_position_mainwindow_to_keyframe(current_mouse);

Expand All @@ -647,7 +658,7 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
}
}
}
glPopDebugGroup();
pop_gl_debug_group();

// Restore the framebuffer and viewport
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Expand All @@ -658,7 +669,7 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
//
// Blit the texture we just rendered to the screen
//
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Texture Blit");
push_gl_debug_group("Texture Blit");
{
int width;
int height;
Expand Down Expand Up @@ -709,7 +720,7 @@ bool Bounding_Polygon_Widget::post_draw(BoundingCage::KeyFrameIterator kf, bool
glBindVertexArray(0);
glUseProgram(0);
}
glPopDebugGroup();
pop_gl_debug_group();
glEnable(GL_DEPTH_TEST);

return false;
Expand Down
Loading