Permalink
Browse files

Rendering unit tests

  • Loading branch information...
feragon committed Jul 30, 2017
1 parent d37203c commit 0ec5de8c4d831474988513ab026c32205cedcfb8
View
@@ -4,6 +4,7 @@ project(LC)
option(WITH_QT_UI "With QT user interface" ON)
option(WITH_LUACMDINTERFACE "Build Lua command line interface" ON)
option(WITH_UNITTESTS "Build unit tests" ON)
option(WITH_RENDERING_UNITTESTS "Build rendering unit tests (require GDK)" ON)
option(WITH_LIBOPENCAD "Use libopencad" ON)
#make doc/tests ?
@@ -25,6 +26,7 @@ message("Options:")
message(" - Qt user interface: ${WITH_QT_UI}")
message(" - Lua command line interface: ${WITH_LUACMDINTERFACE}")
message(" - Unit tests: ${WITH_UNITTESTS}")
message(" - Rendering unit tests: ${WITH_RENDERING_UNITTESTS}")
message(" - Documentation: ${WITH_DOCUMENTATION}")
message(" - LibreCAD DXF/DWG support: ${WITH_LCDXFDWG}")
message(" - Use libopencad: ${WITH_LIBOPENCAD}")
@@ -221,7 +221,8 @@ namespace lc {
* Increase the area on each side by increaseBy
*/
inline Area increaseBy (double increaseBy) const {
return Area(_minP - increaseBy, _maxP + increaseBy);
return Area(geo::Coordinate(_minP.x() - increaseBy, _minP.y() - increaseBy, _minP.z()),
geo::Coordinate(_maxP.x() + increaseBy, _maxP.y() + increaseBy, _maxP.z()));
}
/**
@@ -244,8 +244,10 @@ void DocumentCanvas::transY(int y) {
void DocumentCanvas::autoScale() {
auto extends = _entityContainer.boundingBox();
extends = extends.increaseBy(std::min(extends.width(), extends.height()) * 0.1);
double zoom = std::min(_deviceWidth / extends.width(), _deviceHeight / extends.height());
// this->zoom(zoom, false, extends.width() / 2 + extends.minP().x(), extends.height() / 2. + extends.minP().y(), _deviceWidth / 2., _deviceHeight / 2.);
this->zoom(zoom, false, extends.width() / 2 + extends.minP().x(), extends.height() / 2. + extends.minP().y(), _deviceWidth / 2., _deviceHeight / 2.);
}
void DocumentCanvas::render(std::function<void(LcPainter&)> before, std::function<void(LcPainter&)> after) {
View
@@ -210,7 +210,6 @@ int main(int argc, char** argv) {
if (fType == "png" || (fType != "pdf" && fType != "svg"))
static_cast<LcCairoPainter<CairoPainter::backend::Image>*>(lcPainter)->writePNG(fOut);
ofile.close();
lc::LuaCustomEntityManager::getInstance().removePlugins();
View
@@ -96,6 +96,48 @@ if(WITH_QT_UI)
include_directories(${LUA_INCLUDE_DIR})
endif(WITH_QT_UI)
if(WITH_RENDERING_UNITTESTS)
# GDK-Pixbuf
find_package(GDK-Pixbuf REQUIRED)
include_directories(${GDK-PIXBUF_INCLUDE_DIRS})
#GDK
find_package(GDK REQUIRED)
include_directories(${GDK_INCLUDE_DIRS})
#GLib
find_package(GLib)
include_directories(${GLib_INCLUDE_DIRS})
#GObject
find_package(GObject)
include_directories(${GOBJECT_INCLUDE_DIR})
# Cairo
find_package(Cairo 1.13 REQUIRED)
include_directories(${CAIRO_INCLUDE_DIRS})
# Pango
find_package(Pango 1.38 REQUIRED)
include_directories(${PANGO_INCLUDE_DIRS})
link_directories(${PANGO_LIBRARIES})
set(EXTRA_LIBS
${EXTRA_LIBS}
${CAIRO_LIBRARIES}
${PANGO_LIBRARIES}
${GDK-PIXBUF_LIBRARIES}
${GDK_LIBRARIES}
${GLib_LIBRARY}
${GOBJECT_LIBRARIES}
)
set(src
${src}
rendering/renderingtest.cpp
)
endif()
include_directories("${CMAKE_SOURCE_DIR}/lckernel")
include_directories("${CMAKE_SOURCE_DIR}/lcadluascript")
include_directories("${CMAKE_SOURCE_DIR}/lcviewernoqt")
@@ -0,0 +1,90 @@
# - Try to find Cairo
# Once done, this will define
#
# CAIRO_FOUND - system has Cairo
# CAIRO_INCLUDE_DIRS - the Cairo include directories
# CAIRO_LIBRARIES - link these to use Cairo
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_CAIRO cairo)
FIND_PATH(CAIRO_INCLUDE_DIRS
NAMES cairo.h
HINTS
${PC_CAIRO_INCLUDEDIR}
${PC_CAIRO_INCLUDE_DIRS}
"/opt/local/include/"
"${PROJECT_SOURCE_DIR}/../third_party/cairo/src"
PATH_SUFFIXES cairo
)
FIND_LIBRARY(CAIRO_LIBRARIES
NAMES cairo
HINTS
${PC_CAIRO_LIBDIR}
${PC_CAIRO_LIBRARY_DIRS}
"/opt/local/lib/"
"${PROJECT_SOURCE_DIR}/../third_party/cairo/lib"
PATH_SUFFIXES cairo
)
IF (CAIRO_INCLUDE_DIRS)
IF (EXISTS "${CAIRO_INCLUDE_DIRS}/cairo-version.h")
FILE(READ "${CAIRO_INCLUDE_DIRS}/cairo-version.h" CAIRO_VERSION_CONTENT)
STRING(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
SET(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
SET(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
SET(CAIRO_VERSION_MICRO "${CMAKE_MATCH_1}")
SET(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}")
ENDIF ()
ENDIF ()
SET(VERSION_OK TRUE)
IF (Cairo_FIND_VERSION)
IF (Cairo_FIND_VERSION_EXACT)
IF (NOT "${Cairo_FIND_VERSION}" VERSION_EQUAL "${CAIRO_VERSION}")
SET(VERSION_OK FALSE)
ENDIF ()
ELSE ()
IF ("${Cairo_FIND_VERSION}" VERSION_GREATER "${CAIRO_VERSION}")
SET(VERSION_OK FALSE)
ENDIF ()
ENDIF ()
ENDIF ()
if(VERSION_OK)
message(STATUS "Found Cairo ${CAIRO_VERSION} include dir: ${CAIRO_INCLUDE_DIRS}")
message(STATUS "Found Cairo ${CAIRO_VERSION} library: ${CAIRO_LIBRARIES}")
endif(VERSION_OK)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cairo DEFAULT_MSG CAIRO_INCLUDE_DIRS CAIRO_LIBRARIES VERSION_OK)
@@ -0,0 +1,40 @@
# Try to find gdk-pixbuf 2.0
# Once done, this will define :
# GDK-PIXBUF_FOUND
# GDK-PIXBUF_INCLUDE_DIRS
# GDK-PIXBUF_LIBRARIES
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_GDK-PIXBUF QUIET gdk-pixbuf-2.0)
# Main include dir
find_path(GDK-PIXBUF_INCLUDE_DIRS
NAMES
gdk-pixbuf/gdk-pixbuf.h
PATH_SUFFIXES
gdk-pixbuf-2.0
PATHS
/usr/include
/usr/local/include
$ENV{GDK-PIXBUF_DIR}/include
${PC_GDK_PIXBUF_includedir}
)
# Finally the library itself
find_library(GDK-PIXBUF_LIBRARIES
NAMES
gdk_pixbuf-2.0
PATHS
/usr/lib
/usr/local/lib
$ENV{GDK-PIXBUF_DIR}/lib
${PC_GDK_PIXBUF_libdir}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDK-PIXBUF DEFAULT_MSG GDK-PIXBUF_LIBRARIES GDK-PIXBUF_INCLUDE_DIRS)
mark_as_advanced(GDK-PIXBUF_INCLUDE_DIRS GDK-PIXBUF_LIBRARIES)
@@ -0,0 +1,40 @@
# Try to find gdk 3.0
# Once done, this will define :
# GDK_FOUND
# GDK_INCLUDE_DIRS
# GDK_LIBRARIES
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_GDK QUIET gdk-3.0)
# Main include dir
find_path(GDK_INCLUDE_DIRS
NAMES
gdk/gdk.h
PATH_SUFFIXES
gtk-3.0
PATHS
/usr/include
/usr/local/include
$ENV{GDK_DIR}/include
${PC_GDK_includedir}
)
# Finally the library itself
find_library(GDK_LIBRARIES
NAMES
gdk-3
PATHS
/usr/lib
/usr/local/lib
$ENV{GDK-PIXBUF_DIR}/lib
${PC_GDK_libdir}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDK DEFAULT_MSG GDK_LIBRARIES GDK_INCLUDE_DIRS)
mark_as_advanced(GDK_INCLUDE_DIRS GDK_LIBRARIES)
@@ -0,0 +1,83 @@
# FindGLib.cmake
# <https://github.com/nemequ/gnome-cmake>
#
# CMake support for GLib/GObject/GIO.
#
# License:
#
# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_search_module(GLib_PKG glib-2.0)
endif()
find_library(GLib_LIBRARY glib-2.0 HINTS ${GLib_PKG_LIBRARY_DIRS})
set(GLib glib-2.0)
if(GLib_LIBRARY AND NOT GLib_FOUND)
add_library(${GLib} SHARED IMPORTED)
set_property(TARGET ${GLib} PROPERTY IMPORTED_LOCATION "${GLib_LIBRARY}")
set_property(TARGET ${GLib} PROPERTY INTERFACE_COMPILE_OPTIONS "${GLib_PKG_CFLAGS_OTHER}")
find_path(GLib_INCLUDE_DIRS "glib.h"
HINTS ${GLib_PKG_INCLUDE_DIRS}
PATH_SUFFIXES "glib-2.0")
get_filename_component(GLib_LIBDIR "${GLib}" DIRECTORY)
find_path(GLib_CONFIG_INCLUDE_DIR "glibconfig.h"
HINTS
${GLib_LIBDIR}
${GLib_PKG_INCLUDE_DIRS}
PATHS
"${CMAKE_LIBRARY_PATH}"
PATH_SUFFIXES
"glib-2.0/include"
"glib-2.0")
unset(GLib_LIBDIR)
if(GLib_CONFIG_INCLUDE_DIR)
file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MAJOR_VERSION REGEX "^#define GLIB_MAJOR_VERSION +([0-9]+)")
string(REGEX REPLACE "^#define GLIB_MAJOR_VERSION ([0-9]+)$" "\\1" GLib_MAJOR_VERSION "${GLib_MAJOR_VERSION}")
file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MINOR_VERSION REGEX "^#define GLIB_MINOR_VERSION +([0-9]+)")
string(REGEX REPLACE "^#define GLIB_MINOR_VERSION ([0-9]+)$" "\\1" GLib_MINOR_VERSION "${GLib_MINOR_VERSION}")
file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MICRO_VERSION REGEX "^#define GLIB_MICRO_VERSION +([0-9]+)")
string(REGEX REPLACE "^#define GLIB_MICRO_VERSION ([0-9]+)$" "\\1" GLib_MICRO_VERSION "${GLib_MICRO_VERSION}")
set(GLib_VERSION "${GLib_MAJOR_VERSION}.${GLib_MINOR_VERSION}.${GLib_MICRO_VERSION}")
unset(GLib_MAJOR_VERSION)
unset(GLib_MINOR_VERSION)
unset(GLib_MICRO_VERSION)
list(APPEND GLib_INCLUDE_DIRS ${GLib_CONFIG_INCLUDE_DIR})
set_property(TARGET ${GLib} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GLib_INCLUDE_DIRS}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLib
REQUIRED_VARS
GLib_LIBRARY
GLib_INCLUDE_DIRS
VERSION_VAR
GLib_VERSION)
Oops, something went wrong.

0 comments on commit 0ec5de8

Please sign in to comment.