Merge branch 'dev' into python-renderer

This commit is contained in:
Mario Hüttel 2020-04-19 00:41:08 +02:00
commit fb6e3a29af
6 changed files with 17855 additions and 20 deletions

View File

@ -33,8 +33,6 @@ pkg_check_modules(CAIRO REQUIRED cairo)
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(plugins) add_subdirectory(plugins)
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug") IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("${Yellow}Debug mode for translations used!${ColorReset}") message("${Yellow}Debug mode for translations used!${ColorReset}")
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/translations/output\") add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/translations/output\")
@ -44,13 +42,7 @@ else(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"/usr/share\") add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"/usr/share\")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_subdirectory(resources)
add_subdirectory(doxygen)
add_subdirectory(translations)
add_subdirectory(version)
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER})
aux_source_directory("widgets" LAYER_SOURCES) aux_source_directory("widgets" LAYER_SOURCES)
aux_source_directory("cell-selector" CELL_SELECTOR_SOURCES) aux_source_directory("cell-selector" CELL_SELECTOR_SOURCES)
@ -74,15 +66,29 @@ set(SOURCE_GENERATED
${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c ${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c
) )
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
SET_SOURCE_FILES_PROPERTIES(${SOURCE_GENERATED} PROPERTIES GENERATED 1) SET_SOURCE_FILES_PROPERTIES(${SOURCE_GENERATED} PROPERTIES GENERATED 1)
add_subdirectory(test)
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
add_subdirectory(resources)
add_subdirectory(doxygen)
add_subdirectory(translations)
add_subdirectory(version)
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER})
add_executable(${PROJECT_NAME} ${SOURCE} ${SOURCE_GENERATED}) add_executable(${PROJECT_NAME} ${SOURCE} ${SOURCE_GENERATED})
add_dependencies(${PROJECT_NAME} glib-resources) add_dependencies(${PROJECT_NAME} glib-resources)
add_dependencies(${PROJECT_NAME} version) add_dependencies(${PROJECT_NAME} version)
add_dependencies(${PROJECT_NAME} translations) add_dependencies(${PROJECT_NAME} translations)
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
install (TARGETS ${PROJECT_NAME} install (TARGETS ${PROJECT_NAME}
RUNTIME RUNTIME
DESTINATION bin DESTINATION bin
) )
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})

View File

@ -1,4 +1,4 @@
# Doxyfile 1.8.16 # Doxyfile 1.8.17
# This file describes the settings to be used by the documentation system # This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project. # doxygen (www.doxygen.org) for a project.
@ -309,7 +309,7 @@ OPTIMIZE_OUTPUT_SLICE = NO
# parses. With this tag you can assign which parser to use for a given # parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it # extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and # using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, Javascript, # language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
@ -535,8 +535,8 @@ HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# (class|struct|union) declarations. If set to NO, these declarations will be # declarations. If set to NO, these declarations will be included in the
# included in the documentation. # documentation.
# The default value is: NO. # The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO HIDE_FRIEND_COMPOUNDS = NO
@ -851,8 +851,10 @@ INPUT_ENCODING = UTF-8
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. # *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \ FILE_PATTERNS = *.c \
*.cc \ *.cc \
@ -928,7 +930,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to # Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/* # exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS = EXCLUDE_PATTERNS = */test/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the # (namespaces, classes, functions, etc.) that should be excluded from the
@ -1265,9 +1267,9 @@ HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that # documentation will contain a main index with vertical navigation menus that
# are dynamically created via Javascript. If disabled, the navigation index will # are dynamically created via JavaScript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML # consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have Javascript, # page. Disable this option to support browsers that do not have JavaScript,
# like the Qt help browser. # like the Qt help browser.
# The default value is: YES. # The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES. # This tag requires that the tag GENERATE_HTML is set to YES.
@ -1555,8 +1557,14 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES FORMULA_TRANSPARENT = YES
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
# to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details.
FORMULA_MACROFILE =
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side Javascript for the rendering # https://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When # installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path # enabled you may also need to install MathJax separately and configure the path
@ -1626,7 +1634,7 @@ MATHJAX_CODEFILE =
SEARCHENGINE = YES SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be # When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using Javascript. There # implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH # are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and # setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing

41
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
project(gds-render-test)
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-s" DEPENDS ${PROJECT_NAME})
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/catch-framework")
aux_source_directory("geometric" GEOMETRIC_TEST_SOURCES)
set(TEST_SOURCES
${GEOMETRIC_TEST_SOURCES}
)
set(DUT_SOURCES
"../geometric/vector-operations.c"
)
add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL "test-main.cpp" ${TEST_SOURCES} ${DUT_SOURCES})
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})

17618
test/catch-framework/catch.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
#include <catch.hpp>
#include <limits>
extern "C" {
#include <gds-render/geometric/vector-operations.h>
}
TEST_CASE("geometric/vector-operations/vector_2d_add", "[GEOMETRIC]")
{
struct vector_2d res;
struct vector_2d a;
struct vector_2d b;
a.x = 1;
a.y = 2;
b.x = 2;
b.y = 6;
vector_2d_add(&res, &a, &b);
REQUIRE(res.x == Approx(a.x + b.x));
REQUIRE(res.y == Approx(a.y + b.y));
}
TEST_CASE("geometric/vector-operations/vector_2d_calculate_angle_between", "[GEOMETRIC]")
{
double angle;
struct vector_2d a;
struct vector_2d b;
a.x = 1;
a.y = 0;
b.x = 0;
b.y = 1;
angle = vector_2d_calculate_angle_between(&a, &a);
REQUIRE(angle == Approx(0.0));
angle = vector_2d_calculate_angle_between(&a, &b);
REQUIRE(angle == Approx(90.0 / 180.0 * M_PI));
}
TEST_CASE("geometric/vector-operations/vector_2d_subtract", "[GEOMETRIC]")
{
struct vector_2d res;
struct vector_2d a;
struct vector_2d b;
a.x = 1;
a.y = 2;
b.x = 2;
b.y = 6;
vector_2d_subtract(&res, &a, &b);
REQUIRE(res.x == Approx(a.x - b.x));
REQUIRE(res.y == Approx(a.y - b.y));
}
TEST_CASE("geometric/vector-operations/vector_2d_abs", "[GEOMETRIC]")
{
struct vector_2d c;
struct vector_2d a;
struct vector_2d b;
double a_len, b_len, c_len;
a.x = 1;
a.y = 0;
b.x = 0;
b.y = 2;
c.x = 3;
c.y = 4;
a_len = vector_2d_abs(&a);
b_len = vector_2d_abs(&b);
c_len = vector_2d_abs(&c);
REQUIRE(a_len == Approx(1.0));
REQUIRE(b_len == Approx(2.0));
REQUIRE(c_len == Approx(5.0));
}
TEST_CASE("geometric/vector-operations/vector_2d_scalar_multipy", "[GEOMETRIC]")
{
struct vector_2d c;
struct vector_2d a;
struct vector_2d b;
double mult;
a.x = 1;
a.y = 0;
b.x = 0;
b.y = 2;
mult = vector_2d_scalar_multipy(&a, &b);
REQUIRE(mult == Approx(0.0));
a.x = 1;
a.y = 1;
b.x = 1;
b.y = 1;
mult = vector_2d_scalar_multipy(&a, &b);
REQUIRE(mult == Approx(2.0));
}
TEST_CASE("geometric/vector-operations/vector_2d_normalize", "[GEOMETRIC]")
{
struct vector_2d a;
a.x = 1;
a.y = 0;
vector_2d_normalize(&a);
REQUIRE(a.x == Approx(1.0));
REQUIRE(a.y == Approx(0.0));
a.x = 1;
a.y = -1;
vector_2d_normalize(&a);
REQUIRE(a.x == Approx(1.0/sqrt(2)));
REQUIRE(a.y == Approx(-1.0/sqrt(2)));
}
TEST_CASE("geometric/vector-operations/vector_2d_rotate", "[GEOMETRIC]")
{
struct vector_2d a;
a.x = 1;
a.y = 0;
vector_2d_rotate(&a, M_PI/2);
REQUIRE(a.x == Approx(0.0).scale(0.001));
REQUIRE(a.y == Approx(1.0));
a.x = 0;
a.y = 1;
vector_2d_rotate(&a, -M_PI/2);
vector_2d_rotate(&a, M_PI);
REQUIRE(a.x == Approx(-1.0));
REQUIRE(a.y == Approx(0.0).scale(0.001));
}
TEST_CASE("geometric/vector-operations/vector_2d_scale", "[GEOMETRIC]")
{
struct vector_2d a;
a.x = 1;
a.y = 0;
vector_2d_scale(&a, 2.0);
REQUIRE(a.x == Approx(2.0));
REQUIRE(a.y == Approx(0.0));
a.x = 1;
a.y = -3;
vector_2d_scale(&a, 0.5);
REQUIRE(a.x == Approx(0.5));
REQUIRE(a.y == Approx(-1.5));
}

2
test/test-main.cpp Normal file
View File

@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch-framework/catch.hpp"