Merge branch 'dev' into japanese-translations
This commit is contained in:
commit
3546c9a7f9
@ -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)
|
||||
add_subdirectory(plugins)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("${Yellow}Debug mode for translations used!${ColorReset}")
|
||||
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\")
|
||||
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("cell-selector" CELL_SELECTOR_SOURCES)
|
||||
@ -74,15 +66,29 @@ set(SOURCE_GENERATED
|
||||
${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)
|
||||
|
||||
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_dependencies(${PROJECT_NAME} glib-resources)
|
||||
add_dependencies(${PROJECT_NAME} version)
|
||||
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}
|
||||
RUNTIME
|
||||
DESTINATION bin
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.16
|
||||
# Doxyfile 1.8.17
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# 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
|
||||
# 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
|
||||
# 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,
|
||||
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
|
||||
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
|
||||
@ -535,8 +535,8 @@ HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# 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
|
||||
# included in the documentation.
|
||||
# declarations. If set to NO, these declarations will be included in the
|
||||
# documentation.
|
||||
# The default value is: 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,
|
||||
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
|
||||
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
|
||||
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
|
||||
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
|
||||
# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
|
||||
# *.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 \
|
||||
*.cc \
|
||||
@ -928,7 +930,7 @@ EXCLUDE_SYMLINKS = NO
|
||||
# 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_PATTERNS =
|
||||
EXCLUDE_PATTERNS = */test/*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (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
|
||||
# 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
|
||||
# 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.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
@ -1555,8 +1557,14 @@ FORMULA_FONTSIZE = 10
|
||||
|
||||
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
|
||||
# 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
|
||||
# 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
|
||||
@ -1626,7 +1634,7 @@ MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
@ -80,6 +80,7 @@ enum gds_record {
|
||||
STRANS = 0x1A01,
|
||||
BOX = 0x2D00,
|
||||
LAYER = 0x0D02,
|
||||
DATATYPE = 0x0E02,
|
||||
WIDTH = 0x0F03,
|
||||
PATHTYPE = 0x2102,
|
||||
COLROW = 0x1302,
|
||||
@ -867,6 +868,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
case LIBNAME:
|
||||
case SNAME:
|
||||
case LAYER:
|
||||
case DATATYPE:
|
||||
case STRNAME:
|
||||
break;
|
||||
default:
|
||||
@ -1003,6 +1005,16 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
}
|
||||
GDS_INF("\t\tAdded layer %d\n", (int)current_graphics->layer);
|
||||
break;
|
||||
case DATATYPE:
|
||||
if (!current_graphics) {
|
||||
GDS_WARN("Datatype has to be defined inside graphics object. Probably unknown object. Implement it yourself!");
|
||||
break;
|
||||
}
|
||||
current_graphics->datatype = gds_convert_signed_int16(workbuff);
|
||||
if (current_graphics->datatype < 0)
|
||||
GDS_WARN("Datatype negative!");
|
||||
GDS_INF("\t\tAdded datatype %d\n", (int)current_graphics->datatype);
|
||||
break;
|
||||
case MAG:
|
||||
if (rec_data_length != 8) {
|
||||
GDS_WARN("Magnification is not an 8 byte real. Results may be wrong");
|
||||
|
@ -101,7 +101,7 @@ struct gds_graphics {
|
||||
enum path_type path_render_type; /**< @brief Line cap */
|
||||
int width_absolute; /**< @brief Width. Not used for objects other than paths */
|
||||
int16_t layer; /**< @brief Layer the graphic object is on */
|
||||
uint16_t datatype;
|
||||
int16_t datatype; /**< @brief Data type of graphic object */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -35,10 +35,17 @@
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
|
||||
/**
|
||||
* @brief calculate_cell_bounding_box Calculate bounding box of gds cell
|
||||
* @param box Resulting boundig box. Will be uüdated and not overwritten
|
||||
* @brief Calculate bounding box of a gds cell.
|
||||
*
|
||||
* This function updates a given bounding box with the dimensions of a
|
||||
* gds_cell. Please note that the handling of path miter points is not complete yet.
|
||||
* If a path object is the outmost object of your cell at any edge,
|
||||
* the resulting bounding box might be the wrong size. The devistion from the real size
|
||||
* is guaranteed to be within the width of the path object.
|
||||
*
|
||||
* @param box Resulting boundig box. Will be updated and not overwritten
|
||||
* @param cell Toplevel cell
|
||||
* @warning Path handling not yet implemented correctly.
|
||||
* @warning Handling of Path graphic objects not yet implemented correctly.
|
||||
*/
|
||||
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell);
|
||||
|
||||
|
41
test/CMakeLists.txt
Normal file
41
test/CMakeLists.txt
Normal file
@ -0,0 +1,41 @@
|
||||
project(gds-render-test)
|
||||
|
||||
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-r compact" "-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
17618
test/catch-framework/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
160
test/geometric/vector-operations.cpp
Normal file
160
test/geometric/vector-operations.cpp
Normal 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
2
test/test-main.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch-framework/catch.hpp"
|
Loading…
Reference in New Issue
Block a user