Commit c1ec14bc authored by Dick Hollenbeck's avatar Dick Hollenbeck

merge in a year's worth of CERN work

parents e8ad48ad edc43c19
...@@ -414,6 +414,6 @@ void CALLBACK tessErrorCB( GLenum errorCode ) ...@@ -414,6 +414,6 @@ void CALLBACK tessErrorCB( GLenum errorCode )
errorStr = gluErrorString( errorCode ); errorStr = gluErrorString( errorCode );
// DEBUG // // DEBUG //
D( printf( "Tess ERROR: %s\n", errorStr ); ) DBG( printf( "Tess ERROR: %s\n", errorStr ); )
#endif #endif
} }
...@@ -115,7 +115,7 @@ int VRML_MODEL_PARSER::readMaterial( FILE* file, int* LineNum ) ...@@ -115,7 +115,7 @@ int VRML_MODEL_PARSER::readMaterial( FILE* file, int* LineNum )
} }
} }
D( printf( "ReadMaterial error: material not found\n" ) ); DBG( printf( "ReadMaterial error: material not found\n" ) );
return 0; return 0;
} }
...@@ -207,7 +207,7 @@ int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum ) ...@@ -207,7 +207,7 @@ int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
...@@ -241,7 +241,7 @@ int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum ) ...@@ -241,7 +241,7 @@ int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
...@@ -271,7 +271,7 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum ) ...@@ -271,7 +271,7 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
......
...@@ -197,19 +197,19 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -197,19 +197,19 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ],
material->m_DiffuseColor ) ) material->m_DiffuseColor ) )
{ {
D( printf("diffuseColor parsing error") ); DBG( printf("diffuseColor parsing error") );
} }
if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ],
material->m_SpecularColor ) ) material->m_SpecularColor ) )
{ {
D( printf("specularColor parsing error") ); DBG( printf("specularColor parsing error") );
} }
if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ],
material->m_EmissiveColor ) ) material->m_EmissiveColor ) )
{ {
D( printf("emissiveColor parsing error") ); DBG( printf("emissiveColor parsing error") );
} }
wxStringTokenizer values; wxStringTokenizer values;
...@@ -221,7 +221,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -221,7 +221,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "ambienterror" ) ); DBG( printf( "ambienterror" ) );
} }
values.SetString( properties[ wxT( "shininess" ) ] ); values.SetString( properties[ wxT( "shininess" ) ] );
...@@ -232,7 +232,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -232,7 +232,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "shininess error" ) ); DBG( printf( "shininess error" ) );
} }
values.SetString( properties[ wxT( "transparency" ) ] ); values.SetString( properties[ wxT( "transparency" ) ] );
...@@ -243,7 +243,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -243,7 +243,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "trans error") ); DBG( printf( "trans error") );
} }
material->SetMaterial(); material->SetMaterial();
...@@ -303,7 +303,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -303,7 +303,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
} }
D( printf( "ReadMaterial error: material not found\n" ) ); DBG( printf( "ReadMaterial error: material not found\n" ) );
} }
} }
...@@ -373,7 +373,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, ...@@ -373,7 +373,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
tokens.GetNextToken().ToDouble( &rotation.z ) && tokens.GetNextToken().ToDouble( &rotation.z ) &&
tokens.GetNextToken().ToDouble( &angle ) ) ) tokens.GetNextToken().ToDouble( &angle ) ) )
{ {
D( printf("rotation read error") ); DBG( printf("rotation read error") );
} }
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits *
...@@ -407,7 +407,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, ...@@ -407,7 +407,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
if( points.size() % 3 != 0 ) if( points.size() % 3 != 0 )
{ {
D( printf( "Number of points is incorrect" ) ); DBG( printf( "Number of points is incorrect" ) );
return; return;
} }
......
...@@ -39,7 +39,7 @@ option( KICAD_SCRIPTING_MODULES ...@@ -39,7 +39,7 @@ option( KICAD_SCRIPTING_MODULES
option( KICAD_SCRIPTING_WXPYTHON option( KICAD_SCRIPTING_WXPYTHON
"set this option ON to build wxpython implementation for wx interface building in python and py.shell" "set this option ON to build wxpython implementation for wx interface building in python and py.shell"
) )
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled: # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
# PYTHON_EXECUTABLE can be defined when invoking cmake # PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 ) # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
...@@ -230,12 +230,27 @@ include( ExternalProject ) ...@@ -230,12 +230,27 @@ include( ExternalProject )
#================================================ #================================================
include( CheckFindPackageResult ) include( CheckFindPackageResult )
# Turn on wxWidgets compatibility mode for some classes
add_definitions(-DWX_COMPATIBILITY)
####################### #######################
# Find OpenGL library # # Find OpenGL library #
####################### #######################
find_package( OpenGL QUIET ) find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" ) check_find_package_result( OPENGL_FOUND "OpenGL" )
#####################
# Find GLEW library #
#####################
find_package(GLEW)
check_find_package_result(GLEW_FOUND "GLEW")
######################
# Find Cairo library #
######################
find_package(Cairo 1.8.1 QUIET)
check_find_package_result(CAIRO_FOUND "Cairo")
# Download boost and possibly build parts of it # Download boost and possibly build parts of it
################################################# #################################################
include( download_boost ) include( download_boost )
...@@ -360,6 +375,7 @@ add_subdirectory( cvpcb ) ...@@ -360,6 +375,7 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema ) add_subdirectory( eeschema )
add_subdirectory( gerbview ) add_subdirectory( gerbview )
add_subdirectory( kicad ) add_subdirectory( kicad )
add_subdirectory( lib_dxf )
add_subdirectory( pcbnew ) add_subdirectory( pcbnew )
add_subdirectory( polygon ) add_subdirectory( polygon )
add_subdirectory( pagelayout_editor ) add_subdirectory( pagelayout_editor )
...@@ -375,12 +391,14 @@ add_subdirectory( tools ) ...@@ -375,12 +391,14 @@ add_subdirectory( tools )
add_dependencies( pcbnew boost ) add_dependencies( pcbnew boost )
add_dependencies( eeschema boost ) add_dependencies( eeschema boost )
add_dependencies( cvpcb boost ) add_dependencies( cvpcb boost )
add_dependencies( gal boost )
add_dependencies( common boost ) add_dependencies( common boost )
add_dependencies( pcbcommon boost ) add_dependencies( pcbcommon boost )
add_dependencies( 3d-viewer boost ) add_dependencies( 3d-viewer boost )
add_dependencies( pcad2kicadpcb boost ) add_dependencies( pcad2kicadpcb boost )
add_dependencies( polygon boost ) add_dependencies( polygon boost )
add_dependencies( pl_editor boost ) add_dependencies( pl_editor boost )
add_dependencies( pnsrouter boost )
############# #############
......
# - Try to find the CAIRO library
# Once done this will define
#
# CAIRO_ROOT_DIR - Set this variable to the root installation of CAIRO
#
# Read-Only variables:
# CAIRO_FOUND - system has the CAIRO library
# CAIRO_INCLUDE_DIR - the CAIRO include directory
# CAIRO_LIBRARIES - The libraries needed to use CAIRO
# CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8)
#=============================================================================
# Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if (UNIX)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_CAIRO cairo)
endif (PKG_CONFIG_FOUND)
endif (UNIX)
SET(_CAIRO_ROOT_HINTS
$ENV{CAIRO}
${CAIRO_ROOT_DIR}
)
SET(_CAIRO_ROOT_PATHS
$ENV{CAIRO}/src
/usr
/usr/local
)
SET(_CAIRO_ROOT_HINTS_AND_PATHS
HINTS ${_CAIRO_ROOT_HINTS}
PATHS ${_CAIRO_ROOT_PATHS}
)
FIND_PATH(CAIRO_INCLUDE_DIR
NAMES
cairo.h
HINTS
${_CAIRO_INCLUDEDIR}
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
include
"include/cairo"
)
IF(WIN32 AND NOT CYGWIN)
# MINGW should go here too
IF(MSVC)
# Implementation details:
# We are using the libraries located in the VC subdir instead of the parent directory eventhough :
FIND_LIBRARY(CAIRO_DEBUG
NAMES
cairod
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
FIND_LIBRARY(CAIRO_RELEASE
NAMES
cairo
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
if(NOT CAIRO_DEBUG)
set(CAIRO_DEBUG ${CAIRO_RELEASE})
endif(NOT CAIRO_DEBUG)
set( CAIRO_LIBRARIES
optimized ${CAIRO_RELEASE} debug ${CAIRO_DEBUG}
)
else()
set( CAIRO_LIBRARIES ${CAIRO_RELEASE})
endif()
MARK_AS_ADVANCED(CAIRO_DEBUG CAIRO_RELEASE)
ELSEIF(MINGW)
# same player, for MingW
FIND_LIBRARY(CAIRO
NAMES
cairo
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
)
MARK_AS_ADVANCED(CAIRO)
set( CAIRO_LIBRARIES ${CAIRO})
ELSE(MSVC)
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
FIND_LIBRARY(CAIRO
NAMES
cairo
HINTS
${_CAIRO_LIBDIR}
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
MARK_AS_ADVANCED(CAIRO)
set( CAIRO_LIBRARIES ${CAIRO} )
ENDIF(MSVC)
ELSE(WIN32 AND NOT CYGWIN)
FIND_LIBRARY(CAIRO_LIBRARY
NAMES
cairo
HINTS
${_CAIRO_LIBDIR}
${_CAIRO_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"local/lib"
)
MARK_AS_ADVANCED(CAIRO_LIBRARY)
# compat defines
SET(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
ENDIF(WIN32 AND NOT CYGWIN)
# if (CAIRO_INCLUDE_DIR)
# file(READ "${CAIRO_INCLUDE_DIR}/gcore/gdal_version.h" _wxgisgdal_VERSION_H_CONTENTS)
# string(REGEX REPLACE ".*# define[ \t]+GDAL_RELEASE_NAME[ \t]+\"([0-9A-Za-z.]+)\".*"
# "\\1" CAIRO_VERSION ${_wxgisgdal_VERSION_H_CONTENTS})
# set(CAIRO_VERSION ${CAIRO_VERSION} CACHE INTERNAL "The version number for wxgisgdal libraries")
# endif (CAIRO_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
# if (CAIRO_VERSION)
# find_package_handle_standard_args(CAIRO
# REQUIRED_VARS
# CAIRO_LIBRARIES
# CAIRO_INCLUDE_DIR
# VERSION_VAR
# CAIRO_VERSION
# FAIL_MESSAGE
# "Could NOT find CAIRO, try to set the path to CAIRO root folder in the system variable CAIRO_ROOT_DIR"
# )
# else (CAIRO_VERSION)
find_package_handle_standard_args(CAIRO "Could NOT find CAIRO, try to set the path to CAIRO root folder in the system variable CAIRO"
CAIRO_LIBRARIES
CAIRO_INCLUDE_DIR
)
# endif (CAIRO_VERSION)
MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES)
# Copyright (c) 2009 Boudewijn Rempt <boud@valdyas.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# - try to find glew library and include files
# GLEW_INCLUDE_DIR, where to find GL/glew.h, etc.
# GLEW_LIBRARIES, the libraries to link against
# GLEW_FOUND, If false, do not try to use GLEW.
# Also defined, but not for general use are:
# GLEW_GLEW_LIBRARY = the full path to the glew library.
IF (WIN32)
IF(CYGWIN)
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h)
FIND_LIBRARY( GLEW_GLEW_LIBRARY glew32
${OPENGL_LIBRARY_DIR}
/usr/lib/w32api
/usr/X11R6/lib
)
ELSE(CYGWIN)
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
$ENV{GLEW_ROOT_PATH}/include
)
FIND_LIBRARY( GLEW_GLEW_LIBRARY
NAMES glew glew32 glew32s
PATHS
$ENV{GLEW_ROOT_PATH}/lib
${OPENGL_LIBRARY_DIR}
)
ENDIF(CYGWIN)
ELSE (WIN32)
IF (APPLE)
# These values for Apple could probably do with improvement.
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
/System/Library/Frameworks/GLEW.framework/Versions/A/Headers
/opt/local/include
${OPENGL_LIBRARY_DIR}
)
FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW
/opt/local/lib
)
ELSE (APPLE)
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
/usr/include/GL
/usr/openwin/share/include
/usr/openwin/include
/usr/X11R6/include
/usr/include/X11
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglew
)
FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW
/usr/openwin/lib
/usr/X11R6/lib
)
ENDIF (APPLE)
ENDIF (WIN32)
SET( GLEW_FOUND "NO" )
IF(GLEW_INCLUDE_DIR)
IF(GLEW_GLEW_LIBRARY)
# Is -lXi and -lXmu required on all platforms that have it?
# If not, we need some way to figure out what platform we are on.
SET( GLEW_LIBRARIES
${GLEW_GLEW_LIBRARY}
${GLEW_cocoa_LIBRARY}
)
SET( GLEW_FOUND "YES" )
#The following deprecated settings are for backwards compatibility with CMake1.4
SET (GLEW_LIBRARY ${GLEW_LIBRARIES})
SET (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR})
ENDIF(GLEW_GLEW_LIBRARY)
ENDIF(GLEW_INCLUDE_DIR)
IF(GLEW_FOUND)
IF(NOT GLEW_FIND_QUIETLY)
MESSAGE(STATUS "Found Glew: ${GLEW_LIBRARIES}")
ENDIF(NOT GLEW_FIND_QUIETLY)
ELSE(GLEW_FOUND)
IF(GLEW_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Glew")
ENDIF(GLEW_FIND_REQUIRED)
ENDIF(GLEW_FOUND)
MARK_AS_ADVANCED(
GLEW_INCLUDE_DIR
GLEW_GLEW_LIBRARY
GLEW_Xmu_LIBRARY
GLEW_Xi_LIBRARY
)
# CMake script file to process a GLSL source file, so it can be included
# in C array and compiled in to an application.
# number of input files
list( LENGTH inputFiles shadersNumber )
# check if GLSL source files were updated since the last time
set( update "FALSE" )
foreach( inputFile ${inputFiles} )
if( ${inputFile} IS_NEWER_THAN ${outputFile} )
set( update "TRUE" )
endif( ${inputFile} IS_NEWER_THAN ${outputFile} )
endforeach( inputFile ${inputFiles} )
if( NOT update )
message( "Headers are up-to-date" )
return()
endif( NOT update )
# write header
file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMake.
#ifndef SHADER_SRC_H
#define SHADER_SRC_H
const unsigned int shaders_number = ${shadersNumber};
const char* shaders_src[] =
{\n" )
foreach( inputFile ${inputFiles} )
# put the input file name into the output file
file( APPEND ${outputFile} "\n// ${inputFile}" )
# process the input file
file( READ ${inputFile} contents )
# remove /* */ comments
string( REGEX REPLACE "/\\*.*\\*/" "" contents "${contents}" )
# remove // comments
string( REGEX REPLACE "//[^\n]*" "" contents "${contents}" )
# remove whitespaces at the beginning of each line
string( REGEX REPLACE "\n([\t ])*" "\n" contents "${contents}" )
# remove unnecessary spaces
string( REGEX REPLACE " *([\\*/+&\\|,=<>\(\)]) *" "\\1" contents "${contents}" )
# remove empty lines & wrap every line in "" and add '\n' at the end of each line
string( REGEX REPLACE "\n+" "\\\\n\"\n\"" contents "${contents}" )
# remove unnecessary " & \n from the beginning and the end of contents
string( REGEX REPLACE "^\\\\n\"" "" contents "${contents}" )
string( REGEX REPLACE "\"$" "," contents "${contents}" )
file( APPEND ${outputFile} "${contents}" )
endforeach( inputFile ${inputFiles} )
# write footer
file( APPEND ${outputFile} "};
#endif /* SHADER_SRC_H */" )
So, finally we've got an integrated interactive, push-and-sometimes-shove router, although with a very limited user interface:
- Edit->Interactive router launches the tool,
- while routing: 'V' key places a via,
- '+' and '-' keys cycle through available layers,
- '/' key switches track posture.
Via/track dimensions are taken from the netclasses.
There are no other options available for the time being - promise to add them soon :)
Tom
\ No newline at end of file
...@@ -3,12 +3,65 @@ include_directories(BEFORE ${INC_BEFORE}) ...@@ -3,12 +3,65 @@ include_directories(BEFORE ${INC_BEFORE})
include_directories( include_directories(
./dialogs ./dialogs
./dialog_about ./dialog_about
${CAIRO_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
../3d-viewer ../3d-viewer
../pcbnew ../pcbnew
../polygon ../polygon
${INC_AFTER} ${INC_AFTER}
) )
# Generate header files containing shader programs
# Order of input files is significant
add_custom_command(
OUTPUT gal/opengl/shader_src.h
COMMAND ${CMAKE_COMMAND}
-DinputFiles="${PROJECT_SOURCE_DIR}/common/gal/opengl/shader.vert\\;${PROJECT_SOURCE_DIR}/common/gal/opengl/shader.frag"
-DoutputFile="shader_src.h"
-P ${CMAKE_MODULE_PATH}/Shaders.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/common/gal/opengl
COMMENT "Generating headers containing GLSL source code"
)
add_custom_target(
shader_headers ALL
DEPENDS gal/opengl/shader_src.h
)
set(GAL_SRCS
# Common part
drawpanel_gal.cpp
painter.cpp
worksheet_viewitem.cpp
gal/graphics_abstraction_layer.cpp
gal/stroke_font.cpp
gal/color4d.cpp
view/wx_view_controls.cpp
# OpenGL GAL
gal/opengl/opengl_gal.cpp
gal/opengl/shader.cpp
gal/opengl/vertex_item.cpp
gal/opengl/vertex_container.cpp
gal/opengl/cached_container.cpp
gal/opengl/noncached_container.cpp
gal/opengl/vertex_manager.cpp
gal/opengl/gpu_manager.cpp
gal/opengl/opengl_compositor.cpp
# Cairo GAL
gal/cairo/cairo_gal.cpp
gal/cairo/cairo_compositor.cpp
)
add_library(gal STATIC ${GAL_SRCS})
add_dependencies(gal shader_headers)
# Only for win32 cross compilation using MXE
if(WIN32 AND MSYS)
add_definitions(-DGLEW_STATIC)
endif(WIN32 AND MSYS)
set(COMMON_ABOUT_DLG_SRCS set(COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp dialog_about/AboutDialog_main.cpp
dialog_about/dialog_about.cpp dialog_about/dialog_about.cpp
...@@ -95,6 +148,32 @@ set(COMMON_SRCS ...@@ -95,6 +148,32 @@ set(COMMON_SRCS
zoom.cpp zoom.cpp
) )
enable_language(C CXX ASM)
set_source_files_properties(system/fcontext.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
set(COMMON_SRCS
${COMMON_SRCS}
view/view.cpp
view/view_item.cpp
view/view_group.cpp
math/math_util.cpp
system/fcontext.s
tool/tool_base.cpp
tool/tool_manager.cpp
tool/tool_dispatcher.cpp
tool/tool_event.cpp
tool/tool_interactive.cpp
tool/action_manager.cpp
tool/context_menu.cpp
geometry/seg.cpp
geometry/shape_line_chain.cpp
geometry/shape_collisions.cpp
geometry/shape_index.cpp
)
add_library(common STATIC ${COMMON_SRCS}) add_library(common STATIC ${COMMON_SRCS})
set(PCB_COMMON_SRCS set(PCB_COMMON_SRCS
...@@ -151,6 +230,10 @@ set(PCB_COMMON_SRCS ...@@ -151,6 +230,10 @@ set(PCB_COMMON_SRCS
fp_lib_table.cpp fp_lib_table.cpp
) )
set(PCB_COMMON_SRCS
${PCB_COMMON_SRCS}
../pcbnew/pcb_painter.cpp
)
# add -DPCBNEW to compilation of these PCBNEW sources # add -DPCBNEW to compilation of these PCBNEW sources
set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
#include "../eeschema/dialogs/dialog_schematic_find.h" #include "../eeschema/dialogs/dialog_schematic_find.h"
const wxString traceFindReplace( wxT( "KicadFindReplace" ) );
enum textbox { enum textbox {
ID_TEXTBOX_LIST = 8010 ID_TEXTBOX_LIST = 8010
}; };
...@@ -190,8 +194,28 @@ bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText ) ...@@ -190,8 +194,28 @@ bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText )
wxCHECK_MSG( IsReplaceable(), false, wxCHECK_MSG( IsReplaceable(), false,
wxT( "Attempt to replace text in <" ) + GetClass() + wxT( "> item." ) ); wxT( "Attempt to replace text in <" ) + GetClass() + wxT( "> item." ) );
return aText.Replace( aSearchData.GetFindString(), wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText.Upper() : aText;
aSearchData.GetReplaceString(), false ) != 0;
int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
aSearchData.GetFindString() :
aSearchData.GetFindString().Upper() );
if( result == wxNOT_FOUND )
return false;
wxString prefix = aText.Left( result );
wxString suffix;
if( aSearchData.GetFindString().length() + result < aText.length() )
suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
GetChars( suffix ) );
aText = prefix + aSearchData.GetReplaceString() + suffix;
return true;
} }
...@@ -222,6 +246,22 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) ...@@ -222,6 +246,22 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
} }
const BOX2I EDA_ITEM::ViewBBox() const
{
// Basic fallback
return BOX2I( VECTOR2I( GetBoundingBox().GetOrigin() ),
VECTOR2I( GetBoundingBox().GetSize() ) );
}
void EDA_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
// Basic fallback
aCount = 1;
aLayers[0] = 0;
}
#if defined(DEBUG) #if defined(DEBUG)
// A function that should have been in wxWidgets // A function that should have been in wxWidgets
......
This diff is collapsed.
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <macros.h> #include <macros.h>
#include <id.h> #include <id.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <class_drawpanel_gal.h>
#include <class_base_screen.h> #include <class_base_screen.h>
#include <wxstruct.h> #include <wxstruct.h>
...@@ -84,10 +85,17 @@ END_EVENT_TABLE() ...@@ -84,10 +85,17 @@ END_EVENT_TABLE()
EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
const wxPoint& pos, const wxSize& size ) : const wxPoint& pos, const wxSize& size ) :
#if wxCHECK_VERSION( 2, 9, 5 )
wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL )
#else
wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL | wxALWAYS_SHOW_SB ) wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL | wxALWAYS_SHOW_SB )
#endif
{ {
wxASSERT( parent ); wxASSERT( parent );
#if wxCHECK_VERSION( 2, 9, 5 )
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
#endif
m_scrollIncrementX = std::min( size.x / 8, 10 ); m_scrollIncrementX = std::min( size.x / 8, 10 );
m_scrollIncrementY = std::min( size.y / 8, 10 ); m_scrollIncrementY = std::min( size.y / 8, 10 );
...@@ -288,6 +296,19 @@ void EDA_DRAW_PANEL::RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackg ...@@ -288,6 +296,19 @@ void EDA_DRAW_PANEL::RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackg
} }
void EDA_DRAW_PANEL::Refresh( bool eraseBackground, const wxRect* rect )
{
if( GetParent()->IsGalCanvasActive() )
{
GetParent()->GetGalCanvas()->Refresh();
}
else
{
wxScrolledWindow::Refresh( eraseBackground, rect );
}
}
wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition()
{ {
wxSize size = GetClientSize() / 2; wxSize size = GetClientSize() / 2;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/wx.h>
#include <wx/frame.h>
#include <wx/window.h>
#include <wx/event.h>
#include <wx/colour.h>
#include <wx/filename.h>
#include <class_drawpanel_gal.h>
#include <view/view.h>
#include <view/wx_view_controls.h>
#include <pcb_painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <gal/opengl/opengl_gal.h>
#include <gal/cairo/cairo_gal.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
#define METRIC_UNIT_LENGTH (1e9)
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize,
GalType aGalType ) :
wxWindow( aParentWindow, aWindowId, aPosition, aSize )
{
m_gal = NULL;
m_currentGal = GAL_TYPE_NONE;
m_view = NULL;
m_painter = NULL;
m_eventDispatcher = NULL;
SwitchBackend( aGalType );
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
// Initial display settings
m_gal->SetLookAtPoint( VECTOR2D( 0, 0 ) );
m_gal->SetZoomFactor( 1.0 );
m_gal->ComputeWorldScreenMatrix();
m_painter = new KIGFX::PCB_PAINTER( m_gal );
m_view = new KIGFX::VIEW( true );
m_view->SetPainter( m_painter );
m_view->SetGAL( m_gal );
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
/* Generic events for the Tool Dispatcher */
Connect( wxEVT_MOTION, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
m_refreshTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
this->SetFocus();
}
EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
{
if( m_painter )
delete m_painter;
if( m_viewControls )
delete m_viewControls;
if( m_view )
delete m_view;
if( m_gal )
delete m_gal;
}
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
{
m_pendingRefresh = false;
m_lastRefresh = wxGetLocalTimeMillis();
m_gal->BeginDrawing();
m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
m_gal->ClearScreen();
m_view->ClearTargets();
// Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
m_gal->DrawGrid();
m_view->Redraw();
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
m_gal->EndDrawing();
}
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
{
m_gal->ResizeScreen( aEvent.GetSize().x, aEvent.GetSize().y );
m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
{
wxPaintEvent redrawEvent;
wxPostEvent( this, redrawEvent );
}
void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
{
if( m_pendingRefresh )
return;
wxLongLong t = wxGetLocalTimeMillis();
wxLongLong delta = t - m_lastRefresh;
if( delta >= MinRefreshPeriod )
{
wxPaintEvent redrawEvent;
wxPostEvent( this, redrawEvent );
m_pendingRefresh = true;
}
else
{
// One shot timer
m_refreshTimer.Start( ( MinRefreshPeriod - delta ).ToLong(), true );
m_pendingRefresh = true;
}
}
void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
{
// Protect from refreshing during backend switch
m_pendingRefresh = true;
m_refreshTimer.Stop();
// Do not do anything if the currently used GAL is correct
if( aGalType == m_currentGal && m_gal != NULL )
return;
delete m_gal;
switch( aGalType )
{
case GAL_TYPE_OPENGL:
m_gal = new KIGFX::OPENGL_GAL( this, this, this );
break;
case GAL_TYPE_CAIRO:
m_gal = new KIGFX::CAIRO_GAL( this, this, this );
break;
case GAL_TYPE_NONE:
return;
}
m_gal->SetWorldUnitLength( 1.0 / METRIC_UNIT_LENGTH * 2.54 ); // 1 inch in nanometers
m_gal->SetScreenDPI( 106 ); // Display resolution setting
m_gal->ComputeWorldScreenMatrix();
wxSize size = GetClientSize();
m_gal->ResizeScreen( size.GetX(), size.GetY() );
if( m_painter )
m_painter->SetGAL( m_gal );
if( m_view )
{
m_view->SetGAL( m_gal );
m_view->RecacheAllItems( true );
}
m_currentGal = aGalType;
m_pendingRefresh = false;
}
void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
{
if( !m_eventDispatcher )
{
aEvent.Skip();
return;
}
else
{
m_eventDispatcher->DispatchWxEvent( aEvent );
}
Refresh();
}
void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
{
// Getting focus is necessary in order to receive key events properly
SetFocus();
}
void EDA_DRAW_PANEL_GAL::skipEvent( wxEvent& aEvent )
{
// This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events
aEvent.Skip();
}
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
#include <trigo.h> // RotatePoint #include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL #include <class_drawpanel.h> // EDA_DRAW_PANEL
// until bzr rev 4410, Y position of vertical justification
// of multiline texts was incorrectly calculated for BOTTOM
// and CENTER vertical justification. (Only the first line was justified)
// If this line is left uncommented, the bug is fixed, but
// creates a (very minor) issue for existing texts, mainly in Pcbnew
// because the text position is sometimes critical.
#define FIX_MULTILINE_VERT_JUSTIF
// Conversion to application internal units defined at build time. // Conversion to application internal units defined at build time.
#if defined( PCBNEW ) #if defined( PCBNEW )
...@@ -90,6 +97,16 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const ...@@ -90,6 +97,16 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold ); return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
} }
/**
* Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
*/
int EDA_TEXT::GetInterline( int aTextThickness ) const
{
int thickness = aTextThickness <= 0 ? m_Thickness : aTextThickness;
return (( m_Size.y * 14 ) / 10) + thickness;
}
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{ {
...@@ -98,6 +115,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -98,6 +115,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
wxArrayString* list = NULL; wxArrayString* list = NULL;
wxString text = m_Text; wxString text = m_Text;
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness; int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
int linecount = 1;
if( m_MultilineAllowed ) if( m_MultilineAllowed )
{ {
...@@ -109,12 +127,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -109,12 +127,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
text = list->Item( aLine ); text = list->Item( aLine );
else else
text = list->Item( 0 ); text = list->Item( 0 );
linecount = list->GetCount();
} }
} }
// calculate the H and V size // calculate the H and V size
int dx = LenSize( text ); int dx = LenSize( text );
int dy = GetInterline(); int dy = GetInterline( aThickness );
/* Creates bounding box (rectangle) for an horizontal text */ /* Creates bounding box (rectangle) for an horizontal text */
wxSize textsize = wxSize( dx, dy ); wxSize textsize = wxSize( dx, dy );
...@@ -175,7 +195,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -175,7 +195,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
break; break;
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_VJUSTIFY_CENTER:
rect.SetY( rect.GetY() - (dy / 2) ); rect.SetY( rect.GetY() - ( dy / 2) );
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
...@@ -183,6 +203,30 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const ...@@ -183,6 +203,30 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
break; break;
} }
if( linecount > 1 )
{
#ifdef FIX_MULTILINE_VERT_JUSTIF
int yoffset;
linecount -= 1;
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
yoffset = linecount * GetInterline() / 2;
rect.SetY( rect.GetY() - yoffset );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
yoffset = linecount * GetInterline( aThickness );
rect.SetY( rect.GetY() - yoffset );
break;
}
#endif
}
rect.Inflate( thickness / 2 ); rect.Inflate( thickness / 2 );
rect.Normalize(); // Make h and v sizes always >= 0 rect.Normalize(); // Make h and v sizes always >= 0
...@@ -227,15 +271,31 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, ...@@ -227,15 +271,31 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
offset.y = GetInterline(); offset.y = GetInterline();
#ifdef FIX_MULTILINE_VERT_JUSTIF
if( list->Count() > 1 )
{
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
pos.y -= ( list->Count() - 1 ) * offset.y / 2;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
pos.y -= ( list->Count() - 1 ) * offset.y;
break;
}
}
#endif
RotatePoint( &offset, m_Orient ); RotatePoint( &offset, m_Orient );
for( unsigned i = 0; i<list->Count(); i++ ) for( unsigned i = 0; i<list->Count(); i++ )
{ {
wxString txt = list->Item( i ); wxString txt = list->Item( i );
drawOneLineOfText( aClipBox, aDC, aOffset, aColor, drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
aDrawMode, aFillMode, aDrawMode, aFillMode, txt, pos );
i ? UNSPECIFIED_COLOR : aAnchor_color,
txt, pos );
pos += offset; pos += offset;
} }
...@@ -243,15 +303,21 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, ...@@ -243,15 +303,21 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
} }
else else
drawOneLineOfText( aClipBox, aDC, aOffset, aColor, drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
aDrawMode, aFillMode, aDrawMode, aFillMode, m_Text, m_Pos );
aAnchor_color, m_Text, m_Pos );
// Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR )
{
GRDrawAnchor( aClipBox, aDC,
m_Pos.x + aOffset.x, m_Pos.y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color );
}
} }
void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor, const wxPoint& aOffset, EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color,
wxString& aText, wxPoint aPos ) wxString& aText, wxPoint aPos )
{ {
int width = m_Thickness; int width = m_Thickness;
...@@ -262,14 +328,6 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, ...@@ -262,14 +328,6 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
if( aDrawMode != UNSPECIFIED_DRAWMODE ) if( aDrawMode != UNSPECIFIED_DRAWMODE )
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
// Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR )
{
GRDrawAnchor( aClipBox, aDC,
aPos.x + aOffset.x, aPos.y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color );
}
if( aFillMode == SKETCH ) if( aFillMode == SKETCH )
width = -width; width = -width;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http:O//www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cairo_compositor.cpp
* @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and
* later compositing into a single image (Cairo flavour).
*/
#include <gal/cairo/cairo_compositor.h>
#include <wx/log.h>
using namespace KIGFX;
CAIRO_COMPOSITOR::CAIRO_COMPOSITOR( cairo_t** aMainContext ) :
m_current( 0 ), m_currentContext( aMainContext ), m_mainContext( *aMainContext )
{
}
CAIRO_COMPOSITOR::~CAIRO_COMPOSITOR()
{
clean();
}
void CAIRO_COMPOSITOR::Initialize()
{
// Nothing has to be done
}
void CAIRO_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
{
clean();
m_width = aWidth;
m_height = aHeight;
m_stride = cairo_format_stride_for_width( CAIRO_FORMAT_ARGB32, m_width );
m_bufferSize = m_stride * m_height;
}
unsigned int CAIRO_COMPOSITOR::CreateBuffer()
{
// Pixel storage
BitmapPtr bitmap( new unsigned int[m_bufferSize] );
memset( bitmap.get(), 0x00, m_bufferSize * sizeof(int) );
// Create the Cairo surface
cairo_surface_t* surface = cairo_image_surface_create_for_data(
(unsigned char*) bitmap.get(),
CAIRO_FORMAT_ARGB32, m_width,
m_height, m_stride );
cairo_t* context = cairo_create( surface );
#ifdef __WXDEBUG__
cairo_status_t status = cairo_status( context );
wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, "Cairo context creation error" );
#endif /* __WXDEBUG__ */
// Set default settings for the buffer
cairo_set_antialias( context, CAIRO_ANTIALIAS_SUBPIXEL );
cairo_set_line_join( context, CAIRO_LINE_JOIN_ROUND );
cairo_set_line_cap( context, CAIRO_LINE_CAP_ROUND );
// Use the same transformation matrix as the main context
cairo_get_matrix( m_mainContext, &m_matrix );
cairo_set_matrix( context, &m_matrix );
// Store the new buffer
CAIRO_BUFFER buffer = { context, surface, bitmap };
m_buffers.push_back( buffer );
return usedBuffers();
}
void CAIRO_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
{
wxASSERT_MSG( aBufferHandle <= usedBuffers(), wxT( "Tried to use a not existing buffer" ) );
// Get currently used transformation matrix, so it can be applied to the new buffer
cairo_get_matrix( *m_currentContext, &m_matrix );
m_current = aBufferHandle - 1;
*m_currentContext = m_buffers[m_current].context;
// Apply the current transformation matrix
cairo_set_matrix( *m_currentContext, &m_matrix );
}
void CAIRO_COMPOSITOR::ClearBuffer()
{
// Clear the pixel storage
memset( m_buffers[m_current].bitmap.get(), 0x00, m_bufferSize * sizeof(int) );
}
void CAIRO_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{
wxASSERT_MSG( aBufferHandle <= usedBuffers(), wxT( "Tried to use a not existing buffer" ) );
// Reset the transformation matrix, so it is possible to composite images using
// screen coordinates instead of world coordinates
cairo_get_matrix( m_mainContext, &m_matrix );
cairo_identity_matrix( m_mainContext );
// Draw the selected buffer contents
cairo_set_source_surface( m_mainContext, m_buffers[aBufferHandle - 1].surface, 0.0, 0.0 );
cairo_paint( m_mainContext );
// Restore the transformation matrix
cairo_set_matrix( m_mainContext, &m_matrix );
}
void CAIRO_COMPOSITOR::clean()
{
CAIRO_BUFFERS::const_iterator it;
for( it = m_buffers.begin(); it != m_buffers.end(); ++it )
{
cairo_destroy( it->context );
cairo_surface_destroy( it->surface );
}
m_buffers.clear();
}
This diff is collapsed.
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
*
* Color class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <gal/color4d.h>
using namespace KIGFX;
COLOR4D::COLOR4D( EDA_COLOR_T aColor )
{
r = g_ColorRefs[aColor].m_Red / 255.0;
g = g_ColorRefs[aColor].m_Green / 255.0;
b = g_ColorRefs[aColor].m_Blue / 255.0;
a = 1.0;
}
#ifdef WX_COMPATIBILITY
COLOR4D::COLOR4D( const wxColour& aColor )
{
r = aColor.Red();
g = aColor.Green();
b = aColor.Blue();
a = aColor.Alpha();
}
#endif
const bool COLOR4D::operator==( const COLOR4D& aColor )
{
return a == aColor.a && r == aColor.r && g == aColor.g && b == aColor.b;
}
const bool COLOR4D::operator!=( const COLOR4D& aColor )
{
return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b;
}
void COLOR4D::ToHSV( double& aOutH, double& aOutS, double& aOutV ) const
{
double min, max, delta;
min = r < g ? r : g;
min = min < b ? min : b;
max = r > g ? r : g;
max = max > b ? max : b;
aOutV = max; // v
delta = max - min;
if( max > 0.0 )
{
aOutS = ( delta / max ); // s
}
else
{
// r = g = b = 0 // s = 0, v is undefined
aOutS = 0.0;
aOutH = NAN; // its now undefined
return;
}
if( r >= max ) // > is bogus, just keeps compiler happy
aOutH = ( g - b ) / delta; // between yellow & magenta
else if( g >= max )
aOutH = 2.0 + ( b - r ) / delta; // between cyan & yellow
else
aOutH = 4.0 + ( r - g ) / delta; // between magenta & cyan
aOutH *= 60.0; // degrees
if( aOutH < 0.0 )
aOutH += 360.0;
}
void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
{
double hh, p, q, t, ff;
long i;
if( aInS <= 0.0 ) // < is bogus, just shuts up warnings
{
r = aInV;
g = aInV;
b = aInV;
return;
}
hh = aInH;
if( hh >= 360.0 )
hh = 0.0;
hh /= 60.0;
i = (long) hh;
ff = hh - i;
p = aInV * ( 1.0 - aInS );
q = aInV * ( 1.0 - ( aInS * ff ) );
t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) );
switch( i )
{
case 0:
r = aInV;
g = t;
b = p;
break;
case 1:
r = q;
g = aInV;
b = p;
break;
case 2:
r = p;
g = aInV;
b = t;
break;
case 3:
r = p;
g = q;
b = aInV;
break;
case 4:
r = t;
g = p;
b = aInV;
break;
case 5:
default:
r = aInV;
g = p;
b = q;
break;
}
}
COLOR4D& COLOR4D::Saturate( double aFactor )
{
double h, s, v;
ToHSV( h, s, v );
FromHSV( h, aFactor, 1.0 );
return *this;
}
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
*
* Graphics Abstraction Layer (GAL) - base class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/log.h>
#include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h>
using namespace KIGFX;
GAL::GAL() :
strokeFont( this )
{
// Set the default values for the internal variables
SetIsFill( false );
SetIsStroke( true );
SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
SetZoomFactor( 1.0 );
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
SetFlip( false, false );
SetLineWidth( 1.0 );
// Set grid defaults
SetGridVisibility( true );
SetGridStyle( GRID_STYLE_LINES );
SetGridOriginMarkerSize( 15 );
SetGridDrawThreshold( 10 );
SetCoarseGrid( 10 );
SetGridLineWidth( 0.5 );
// Initialize the cursor shape
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
SetCursorSize( 80 );
SetCursorEnabled( false );
strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
}
GAL::~GAL()
{
}
void GAL::SetTextAttributes( const EDA_TEXT* aText )
{
strokeFont.SetGlyphSize( VECTOR2D( aText->GetSize() ) );
strokeFont.SetHorizontalJustify( aText->GetHorizJustify() );
strokeFont.SetVerticalJustify( aText->GetVertJustify() );
strokeFont.SetBold( aText->IsBold() );
strokeFont.SetItalic( aText->IsItalic() );
strokeFont.SetMirrored( aText->IsMirrored() );
}
void GAL::ComputeWorldScreenMatrix()
{
ComputeWorldScale();
worldScreenMatrix.SetIdentity();
MATRIX3x3D translation;
translation.SetIdentity();
translation.SetTranslation( 0.5 * screenSize );
MATRIX3x3D scale;
scale.SetIdentity();
scale.SetScale( VECTOR2D( worldScale, worldScale ) );
MATRIX3x3D flip;
flip.SetIdentity();
flip.SetScale( VECTOR2D( flipX, flipY ) );
MATRIX3x3D lookat;
lookat.SetIdentity();
lookat.SetTranslation( -lookAtPoint );
worldScreenMatrix = translation * flip * scale * lookat * worldScreenMatrix;
screenWorldMatrix = worldScreenMatrix.Inverse();
}
void GAL::DrawGrid()
{
if( !gridVisibility )
return;
SetTarget( TARGET_NONCACHED );
// Draw the origin marker
double origSize = static_cast<double>( gridOriginMarkerSize ) / worldScale;
SetLayerDepth( GAL::GRID_DEPTH );
SetIsFill( false );
SetIsStroke( true );
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
SetLineWidth( gridLineWidth / worldScale );
DrawLine( gridOrigin + VECTOR2D( -origSize, -origSize ),
gridOrigin + VECTOR2D( origSize, origSize ) );
DrawLine( gridOrigin + VECTOR2D( -origSize, origSize ),
gridOrigin + VECTOR2D( origSize, -origSize ) );
DrawCircle( gridOrigin, origSize * 0.7 );
// Draw the grid
// For the drawing the start points, end points and increments have
// to be calculated in world coordinates
VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
VECTOR2D worldEndPoint = screenWorldMatrix * screenSize;
int gridScreenSizeDense = round( gridSize.x * worldScale );
int gridScreenSizeCoarse = round( gridSize.x * static_cast<double>( gridTick ) * worldScale );
// Compute the line marker or point radius of the grid
double marker = 2.0 * gridLineWidth / worldScale;
double doubleMarker = 2.0 * marker;
// Check if the grid would not be too dense
if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) > gridDrawThreshold )
{
// Compute grid variables
int gridStartX = round( worldStartPoint.x / gridSize.x );
int gridEndX = round( worldEndPoint.x / gridSize.x );
int gridStartY = round( worldStartPoint.y / gridSize.y );
int gridEndY = round( worldEndPoint.y / gridSize.y );
// Swap the coordinates, if they have not the right order
SWAP( gridEndX, <, gridStartX );
SWAP( gridEndY, <, gridStartY );
// Correct the index, else some lines are not correctly painted
gridStartX -= 1;
gridStartY -= 1;
gridEndX += 1;
gridEndY += 1;
// Draw the grid behind all other layers
SetLayerDepth( depthRange.y * 0.75 );
if( gridStyle == GRID_STYLE_LINES )
{
SetIsFill( false );
SetIsStroke( true );
SetStrokeColor( gridColor );
// Now draw the grid, every coarse grid line gets the double width
for( int j = gridStartY; j < gridEndY; j += 1 )
{
if( j % gridTick == 0 && gridScreenSizeDense > gridDrawThreshold )
SetLineWidth( doubleMarker );
else
SetLineWidth( marker );
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold )
|| gridScreenSizeDense > gridDrawThreshold )
{
drawGridLine( VECTOR2D( gridStartX * gridSize.x, j * gridSize.y ),
VECTOR2D( gridEndX * gridSize.x, j * gridSize.y ) );
}
}
for( int i = gridStartX; i < gridEndX; i += 1 )
{
if( i % gridTick == 0 && gridScreenSizeDense > gridDrawThreshold )
SetLineWidth( doubleMarker );
else
SetLineWidth( marker );
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridDrawThreshold )
|| gridScreenSizeDense > gridDrawThreshold )
{
drawGridLine( VECTOR2D( i * gridSize.x, gridStartY * gridSize.y ),
VECTOR2D( i * gridSize.x, gridEndY * gridSize.y ) );
}
}
}
else // Dotted grid
{
bool tickX, tickY;
SetIsFill( true );
SetIsStroke( false );
SetFillColor( gridColor );
for( int j = gridStartY; j < gridEndY; j += 1 )
{
if( j % gridTick == 0 && gridScreenSizeDense > gridDrawThreshold )
tickY = true;
else
tickY = false;
for( int i = gridStartX; i < gridEndX; i += 1 )
{
if( i % gridTick == 0 && gridScreenSizeDense > gridDrawThreshold )
tickX = true;
else
tickX = false;
if( tickX || tickY || gridScreenSizeDense > gridDrawThreshold )
{
double radius = ( tickX && tickY ) ? doubleMarker : marker;
DrawRectangle( VECTOR2D( i * gridSize.x - radius,
j * gridSize.y - radius ),
VECTOR2D( i * gridSize.x + radius,
j * gridSize.y + radius ) );
}
}
}
}
}
}
VECTOR2D GAL::GetGridPoint( VECTOR2D aPoint ) const
{
VECTOR2D pointWorld = ToWorld( aPoint );
pointWorld.x = round( pointWorld.x / gridSize.x ) * gridSize.x;
pointWorld.y = round( pointWorld.y / gridSize.y ) * gridSize.y;
return ToScreen( pointWorld );
}
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file gpu_manager.cpp
* @brief Class to handle uploading vertices and indices to GPU in drawing purposes.
*/
#include <gal/opengl/gpu_manager.h>
#include <gal/opengl/cached_container.h>
#include <gal/opengl/noncached_container.h>
#include <gal/opengl/shader.h>
#include <typeinfo>
#include <wx/log.h>
#ifdef __WXDEBUG__
#include <profile.h>
#endif
using namespace KIGFX;
GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
{
if( typeid( *aContainer ) == typeid( CACHED_CONTAINER ) )
return new GPU_CACHED_MANAGER( aContainer );
else if( typeid( *aContainer ) == typeid( NONCACHED_CONTAINER ) )
return new GPU_NONCACHED_MANAGER( aContainer );
wxASSERT_MSG( false, "Not handled container type" );
return NULL;
}
GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) :
m_isDrawing( false ), m_container( aContainer ), m_shader( NULL )
{
}
GPU_MANAGER::~GPU_MANAGER()
{
}
void GPU_MANAGER::SetShader( SHADER& aShader )
{
m_shader = &aShader;
m_shaderAttrib = m_shader->GetAttribute( "attrShaderParams" );
if( m_shaderAttrib == -1 )
{
wxLogFatalError( wxT( "Could not get the shader attribute location" ) );
}
}
// Cached manager
GPU_CACHED_MANAGER::GPU_CACHED_MANAGER( VERTEX_CONTAINER* aContainer ) :
GPU_MANAGER( aContainer ), m_buffersInitialized( false ),
m_indicesSize( 0 )
{
// Allocate the biggest possible buffer for indices
m_indices.reset( new GLuint[aContainer->GetSize()] );
}
GPU_CACHED_MANAGER::~GPU_CACHED_MANAGER()
{
if( m_buffersInitialized )
{
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glDeleteBuffers( 1, &m_verticesBuffer );
}
}
void GPU_CACHED_MANAGER::Initialize()
{
wxASSERT( !m_buffersInitialized );
if( !m_buffersInitialized )
{
glGenBuffers( 1, &m_verticesBuffer );
m_buffersInitialized = true;
}
}
void GPU_CACHED_MANAGER::BeginDrawing()
{
wxASSERT( !m_isDrawing );
if( m_container->IsDirty() )
uploadToGpu();
// Number of vertices to be drawn in the EndDrawing()
m_indicesSize = 0;
// Set the indices pointer to the beginning of the indices-to-draw buffer
m_indicesPtr = m_indices.get();
m_isDrawing = true;
}
void GPU_CACHED_MANAGER::DrawIndices( unsigned int aOffset, unsigned int aSize )
{
wxASSERT( m_isDrawing );
// Copy indices of items that should be drawn to GPU memory
for( unsigned int i = aOffset; i < aOffset + aSize; *m_indicesPtr++ = i++ );
m_indicesSize += aSize;
}
void GPU_CACHED_MANAGER::DrawAll()
{
wxASSERT( m_isDrawing );
m_indicesSize = m_container->GetSize();
for( unsigned int i = 0; i < m_indicesSize; *m_indicesPtr++ = i++ );
}
void GPU_CACHED_MANAGER::EndDrawing()
{
wxASSERT( m_isDrawing );
// Prepare buffers
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
// Bind vertices data buffers
glBindBuffer( GL_ARRAY_BUFFER, m_verticesBuffer );
glVertexPointer( CoordStride, GL_FLOAT, VertexSize, 0 );
glColorPointer( ColorStride, GL_UNSIGNED_BYTE, VertexSize, (GLvoid*) ColorOffset );
if( m_shader != NULL ) // Use shader if applicable
{
m_shader->Use();
glEnableVertexAttribArray( m_shaderAttrib );
glVertexAttribPointer( m_shaderAttrib, ShaderStride, GL_FLOAT, GL_FALSE,
VertexSize, (GLvoid*) ShaderOffset );
}
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, (GLvoid*) m_indices.get() );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
// Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
if( m_shader != NULL )
{
glDisableVertexAttribArray( m_shaderAttrib );
m_shader->Deactivate();
}
m_isDrawing = false;
}
void GPU_CACHED_MANAGER::uploadToGpu()
{
#ifdef __WXDEBUG__
prof_counter totalTime;
prof_start( &totalTime, false );
#endif /* __WXDEBUG__ */
if( !m_buffersInitialized )
Initialize();
int bufferSize = m_container->GetSize();
GLfloat* vertices = (GLfloat*) m_container->GetAllVertices();
// Upload vertices coordinates and shader types to GPU memory
glBindBuffer( GL_ARRAY_BUFFER, m_verticesBuffer );
glBufferData( GL_ARRAY_BUFFER, bufferSize * VertexSize, vertices, GL_DYNAMIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
// Allocate the biggest possible buffer for indices
m_indices.reset( new GLuint[bufferSize] );
if( glGetError() != GL_NO_ERROR )
{
wxLogError( wxT( "Error during data upload to the GPU memory" ) );
}
#ifdef __WXDEBUG__
prof_end( &totalTime );
wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ),
bufferSize, (double) totalTime.value / 1000.0 );
#endif /* __WXDEBUG__ */
}
// Noncached manager
GPU_NONCACHED_MANAGER::GPU_NONCACHED_MANAGER( VERTEX_CONTAINER* aContainer ) :
GPU_MANAGER( aContainer )
{
}
void GPU_NONCACHED_MANAGER::Initialize()
{
// Nothing has to be intialized
}
void GPU_NONCACHED_MANAGER::BeginDrawing()
{
// Nothing has to be prepared
}
void GPU_NONCACHED_MANAGER::DrawIndices( unsigned int aOffset, unsigned int aSize )
{
wxASSERT_MSG( false, wxT( "Not implemented yet" ) );
}
void GPU_NONCACHED_MANAGER::DrawAll()
{
// This is the default use case, nothing has to be done
// The real rendering takes place in the EndDrawing() function
}
void GPU_NONCACHED_MANAGER::EndDrawing()
{
VERTEX* vertices = m_container->GetAllVertices();
GLfloat* coordinates = (GLfloat*) ( vertices );
GLubyte* colors = (GLubyte*) ( vertices ) + ColorOffset;
// Prepare buffers
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( CoordStride, GL_FLOAT, VertexSize, coordinates );
glColorPointer( ColorStride, GL_UNSIGNED_BYTE, VertexSize, colors );
if( m_shader != NULL ) // Use shader if applicable
{
GLfloat* shaders = (GLfloat*) ( vertices ) + ShaderOffset / sizeof(GLfloat);
m_shader->Use();
glEnableVertexAttribArray( m_shaderAttrib );
glVertexAttribPointer( m_shaderAttrib, ShaderStride, GL_FLOAT, GL_FALSE,
VertexSize, shaders );
}
glDrawArrays( GL_TRIANGLES, 0, m_container->GetSize() );
// Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
if( m_shader != NULL )
{
glDisableVertexAttribArray( m_shaderAttrib );
m_shader->Deactivate();
}
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file noncached_container.cpp
* @brief Class to store instances of VERTEX without caching. It allows a fast one-frame drawing
* and then clearing the buffer and starting from scratch.
*/
#include <gal/opengl/noncached_container.h>
#include <cstdlib>
using namespace KIGFX;
NONCACHED_CONTAINER::NONCACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER( aSize ), m_freePtr( 0 )
{
}
NONCACHED_CONTAINER::~NONCACHED_CONTAINER()
{
}
void NONCACHED_CONTAINER::SetItem( VERTEX_ITEM* aItem )
{
// Nothing has to be done, as the noncached container
// does not care about VERTEX_ITEMs ownership
}
VERTEX* NONCACHED_CONTAINER::Allocate( unsigned int aSize )
{
if( m_freeSpace < aSize )
{
// Double the space
VERTEX* newVertices = static_cast<VERTEX*>( realloc( m_vertices,
m_currentSize * 2 *
sizeof(VERTEX) ) );
if( newVertices != NULL )
{
m_vertices = newVertices;
m_freeSpace += m_currentSize;
m_currentSize *= 2;
}
else
{
return NULL;
}
}
VERTEX* freeVertex = &m_vertices[m_freePtr];
// Move to the next free chunk
m_freePtr += aSize;
m_freeSpace -= aSize;
return freeVertex;
}
void NONCACHED_CONTAINER::Clear()
{
m_freePtr = 0;
m_freeSpace = m_currentSize;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http:O//www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file opengl_compositor.cpp
* @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and
* later compositing into a single image (OpenGL flavour).
*/
#include <gal/opengl/opengl_compositor.h>
#include <wx/log.h>
using namespace KIGFX;
OPENGL_COMPOSITOR::OPENGL_COMPOSITOR() :
m_initialized( false ), m_current( 0 )
{
}
OPENGL_COMPOSITOR::~OPENGL_COMPOSITOR()
{
if( m_initialized )
clean();
}
void OPENGL_COMPOSITOR::Initialize()
{
if( m_initialized )
return;
// Get the maximum number of buffers
glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, (GLint*) &m_maxBuffers );
// We need framebuffer objects for drawing the screen contents
// Generate framebuffer and a depth buffer
glGenFramebuffersEXT( 1, &m_framebuffer );
glBindFramebufferEXT( GL_FRAMEBUFFER, m_framebuffer );
m_currentFbo = m_framebuffer;
// Allocate memory for the depth buffer
// Attach the depth buffer to the framebuffer
glGenRenderbuffersEXT( 1, &m_depthBuffer );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_depthBuffer );
// Use here a size of 24 bits for the depth buffer, 8 bits for the stencil buffer
// this is required later for anti-aliasing
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, m_width, m_height );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER_EXT, m_depthBuffer );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT,
GL_RENDERBUFFER_EXT, m_depthBuffer );
// Unbind the framebuffer, so by default all the rendering goes directly to the display
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
m_currentFbo = 0;
m_initialized = true;
}
void OPENGL_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
{
if( m_initialized )
clean();
m_width = aWidth;
m_height = aHeight;
}
unsigned int OPENGL_COMPOSITOR::CreateBuffer()
{
wxASSERT( m_initialized );
if( usedBuffers() >= m_maxBuffers )
{
wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at"
"least 3 framebuffers. You may try to update/change "
"your graphic drivers." ) );
return 0; // Unfortunately we have no more free buffers left
}
// GL_COLOR_ATTACHMENTn are consecutive integers
GLuint attachmentPoint = GL_COLOR_ATTACHMENT0 + usedBuffers();
GLuint textureTarget;
// Generate the texture for the pixel storage
glGenTextures( 1, &textureTarget );
glBindTexture( GL_TEXTURE_2D, textureTarget );
// Set texture parameters
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
// Bind the texture to the specific attachment point, clear and rebind the screen
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_framebuffer );
m_currentFbo = m_framebuffer;
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
// Check the status, exit if the framebuffer can't be created
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
if( status != GL_FRAMEBUFFER_COMPLETE_EXT )
{
switch( status )
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
wxLogFatalError( wxT( "The framebuffer does not have at least "
"one image attached to it." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) );
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
wxLogFatalError( wxT( "The combination of internal formats of the attached images "
"violates an implementation-dependent set of restrictions." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
"for all attached renderbuffers" ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) );
break;
default:
wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
break;
}
return 0;
}
ClearBuffer();
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
// Store the new buffer
OPENGL_BUFFER buffer = { textureTarget, attachmentPoint };
m_buffers.push_back( buffer );
return usedBuffers();
}
void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
{
if( aBufferHandle > usedBuffers() )
return;
// Change the rendering destination to the selected attachment point
if( aBufferHandle == DIRECT_RENDERING )
{
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
}
else if( m_currentFbo != m_framebuffer )
{
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_framebuffer );
m_currentFbo = m_framebuffer;
}
if( m_currentFbo != DIRECT_RENDERING )
{
m_current = aBufferHandle - 1;
glDrawBuffer( m_buffers[m_current].attachmentPoint );
}
}
void OPENGL_COMPOSITOR::ClearBuffer()
{
wxASSERT( m_initialized );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{
wxASSERT( m_initialized );
if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
{
wxLogError( wxT( "Wrong framebuffer handle" ) );
return;
}
// Switch to the main framebuffer and blit the scene
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
// Depth test has to be disabled to make transparency working
glDisable( GL_DEPTH_TEST );
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
// Enable texturing and bind the main texture
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, m_buffers[aBufferHandle - 1].textureTarget );
// Draw a full screen quad with the texture
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glBegin( GL_TRIANGLES );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( -1.0f, -1.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( 1.0f, -1.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( 1.0f, 1.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( -1.0f, -1.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( 1.0f, 1.0f );
glTexCoord2f( 0.0f, 0.0f );
glVertex2f( -1.0f, 1.0f );
glEnd();
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
}
void OPENGL_COMPOSITOR::clean()
{
wxASSERT( m_initialized );
glDeleteFramebuffersEXT( 1, &m_framebuffer );
glDeleteRenderbuffersEXT( 1, &m_depthBuffer );
OPENGL_BUFFERS::const_iterator it;
for( it = m_buffers.begin(); it != m_buffers.end(); ++it )
{
glDeleteTextures( 1, &it->textureTarget );
}
m_buffers.clear();
m_initialized = false;
}
GLuint OPENGL_COMPOSITOR::m_currentFbo = DIRECT_RENDERING;
This diff is collapsed.
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
*
* Graphics Abstraction Layer (GAL) for OpenGL
*
* Shader class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <fstream>
#include <wx/log.h>
#include <gal/opengl/shader.h>
#include "shader_src.h"
using namespace KIGFX;
SHADER::SHADER() :
isProgramCreated( false ),
isShaderLinked( false ),
active( false ),
maximumVertices( 4 ),
geomInputType( GL_LINES ),
geomOutputType( GL_LINES )
{
}
SHADER::~SHADER()
{
if( isProgramCreated )
{
// Delete the shaders and the program
for( std::deque<GLuint>::iterator it = shaderNumbers.begin(); it != shaderNumbers.end();
it++ )
{
glDeleteShader( *it );
}
glDeleteProgram( programNumber );
}
}
bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, SHADER_TYPE aShaderType )
{
if( aShaderNumber >= shaders_number )
return false;
return addSource( std::string( shaders_src[aShaderNumber] ), aShaderType );
}
bool SHADER::LoadShaderFromFile( const std::string& aShaderSourceName, SHADER_TYPE aShaderType )
{
// Load shader sources
const std::string shaderSource = readSource( aShaderSourceName );
return addSource( shaderSource, aShaderType );
}
void SHADER::ConfigureGeometryShader( GLuint maxVertices, GLuint geometryInputType,
GLuint geometryOutputType )
{
maximumVertices = maxVertices;
geomInputType = geometryInputType;
geomOutputType = geometryOutputType;
}
bool SHADER::Link()
{
// Shader linking
glLinkProgram( programNumber );
programInfo( programNumber );
// Check the Link state
glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB,
(GLint*) &isShaderLinked );
#ifdef __WXDEBUG__
if( !isShaderLinked )
{
int maxLength;
glGetProgramiv( programNumber, GL_INFO_LOG_LENGTH, &maxLength );
maxLength = maxLength + 1;
char* linkInfoLog = new char[maxLength];
glGetProgramInfoLog( programNumber, maxLength, &maxLength, linkInfoLog );
std::cerr << "Shader linking error:" << std::endl;
std::cerr << linkInfoLog;
delete[] linkInfoLog;
}
#endif /* __WXDEBUG__ */
return isShaderLinked;
}
int SHADER::AddParameter( const std::string& aParameterName )
{
GLint location = glGetUniformLocation( programNumber, aParameterName.c_str() );
if( location != -1 )
{
parameterLocation.push_back( location );
}
return location;
}
void SHADER::SetParameter( int parameterNumber, float value ) const
{
glUniform1f( parameterLocation[parameterNumber], value );
}
void SHADER::SetParameter( int parameterNumber, int value ) const
{
glUniform1i( parameterLocation[parameterNumber], value );
}
int SHADER::GetAttribute( std::string aAttributeName ) const
{
return glGetAttribLocation( programNumber, aAttributeName.c_str() );
}
void SHADER::programInfo( GLuint aProgram )
{
GLint glInfoLogLength = 0;
GLint writtenChars = 0;
// Get the length of the info string
glGetProgramiv( aProgram, GL_INFO_LOG_LENGTH, &glInfoLogLength );
// Print the information
if( glInfoLogLength > 2 )
{
GLchar* glInfoLog = new GLchar[glInfoLogLength];
glGetProgramInfoLog( aProgram, glInfoLogLength, &writtenChars, glInfoLog );
wxLogInfo( wxString::FromUTF8( (char*) glInfoLog ) );
delete[] glInfoLog;
}
}
void SHADER::shaderInfo( GLuint aShader )
{
GLint glInfoLogLength = 0;
GLint writtenChars = 0;
// Get the length of the info string
glGetShaderiv( aShader, GL_INFO_LOG_LENGTH, &glInfoLogLength );
// Print the information
if( glInfoLogLength > 2 )
{
GLchar* glInfoLog = new GLchar[glInfoLogLength];
glGetShaderInfoLog( aShader, glInfoLogLength, &writtenChars, glInfoLog );
wxLogInfo( wxString::FromUTF8( (char*) glInfoLog ) );
delete[] glInfoLog;
}
}
std::string SHADER::readSource( std::string aShaderSourceName )
{
// Open the shader source for reading
std::ifstream inputFile( aShaderSourceName.c_str(), std::ifstream::in );
std::string shaderSource;
if( !inputFile )
{
wxLogError( wxString::FromUTF8( "Can't read the shader source: " ) +
wxString( aShaderSourceName.c_str(), wxConvUTF8 ) );
exit( 1 );
}
std::string shaderSourceLine;
// Read all lines from the text file
while( getline( inputFile, shaderSourceLine ) )
{
shaderSource += shaderSourceLine;
shaderSource += "\n";
}
return shaderSource;
}
bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderType )
{
if( isShaderLinked )
{
wxLogError( wxString::FromUTF8( "Shader is already linked!" ) );
}
// Create the program
if( !isProgramCreated )
{
programNumber = glCreateProgram();
isProgramCreated = true;
}
// Create a shader
GLuint shaderNumber = glCreateShader( aShaderType );
shaderNumbers.push_back( shaderNumber );
// Get the program info
programInfo( programNumber );
// Copy to char array
char* source = new char[aShaderSource.size() + 1];
strcpy( source, aShaderSource.c_str() );
const char** source_ = (const char**) ( &source );
// Attach the source
glShaderSource( shaderNumber, 1, source_, NULL );
programInfo( programNumber );
// Delete the allocated char array
delete[] source;
// Compile and attach shader to the program
glCompileShader( shaderNumber );
GLint status;
glGetShaderiv( shaderNumber, GL_COMPILE_STATUS, &status );
if( status != GL_TRUE )
{
wxLogError( wxT( "Shader compilation error" ) );
shaderInfo( shaderNumber );
return false;
}
glAttachShader( programNumber, shaderNumber );
programInfo( programNumber );
// Special handling for the geometry shader
if( aShaderType == SHADER_TYPE_GEOMETRY )
{
glProgramParameteriEXT( programNumber, GL_GEOMETRY_VERTICES_OUT_EXT, maximumVertices );
glProgramParameteriEXT( programNumber, GL_GEOMETRY_INPUT_TYPE_EXT, geomInputType );
glProgramParameteriEXT( programNumber, GL_GEOMETRY_OUTPUT_TYPE_EXT, geomOutputType );
}
return true;
}
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* Fragment shader
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#version 120
// Shader types
const float SHADER_LINE = 1.0f;
const float SHADER_FILLED_CIRCLE = 2.0f;
const float SHADER_STROKED_CIRCLE = 3.0f;
varying vec4 shaderParams;
varying vec2 circleCoords;
void filledCircle( vec2 aCoord )
{
if( dot( aCoord, aCoord ) < 1.0f )
gl_FragColor = gl_Color;
else
discard;
}
void strokedCircle( vec2 aCoord, float aRadius, float aWidth )
{
float outerRadius = aRadius + ( aWidth / 2 );
float innerRadius = aRadius - ( aWidth / 2 );
float relWidth = innerRadius / outerRadius;
if( ( dot( aCoord, aCoord ) < 1.0f ) &&
( dot( aCoord, aCoord ) > relWidth * relWidth ) )
gl_FragColor = gl_Color;
else
discard;
}
void main()
{
if( shaderParams[0] == SHADER_FILLED_CIRCLE )
{
filledCircle( circleCoords );
}
else if( shaderParams[0] == SHADER_STROKED_CIRCLE )
{
strokedCircle( circleCoords, shaderParams[2], shaderParams[3] );
}
else
{
// Simple pass-through
gl_FragColor = gl_Color;
}
}
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* Vertex shader
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#version 120
// Shader types
const float SHADER_LINE = 1.0f;
const float SHADER_FILLED_CIRCLE = 2.0f;
const float SHADER_STROKED_CIRCLE = 3.0f;
// Minimum line width
const float MIN_WIDTH = 1.0f;
attribute vec4 attrShaderParams;
varying vec4 shaderParams;
varying vec2 circleCoords;
void main()
{
// Pass attributes to the fragment shader
shaderParams = attrShaderParams;
if( shaderParams[0] == SHADER_LINE )
{
float lineWidth = shaderParams[3];
float worldScale = gl_ModelViewMatrix[0][0];
float scale;
// Make lines appear to be at least 1 pixel wide
if( worldScale * lineWidth < MIN_WIDTH )
scale = MIN_WIDTH / ( worldScale * lineWidth );
else
scale = 1.0f;
gl_Position = gl_ModelViewProjectionMatrix *
( gl_Vertex + vec4( shaderParams.yz * scale, 0.0, 0.0 ) );
}
else if( ( shaderParams[0] == SHADER_STROKED_CIRCLE ) ||
( shaderParams[0] == SHADER_FILLED_CIRCLE ) )
{
// Compute relative circle coordinates basing on indices
// Circle
if( shaderParams[1] == 1.0f )
circleCoords = vec2( -sqrt( 3.0f ), -1.0f );
else if( shaderParams[1] == 2.0f )
circleCoords = vec2( sqrt( 3.0f ), -1.0f );
else if( shaderParams[1] == 3.0f )
circleCoords = vec2( 0.0f, 2.0f );
// Semicircle
else if( shaderParams[1] == 4.0f )
circleCoords = vec2( -3.0f / sqrt( 3.0f ), 0.0f );
else if( shaderParams[1] == 5.0f )
circleCoords = vec2( 3.0f / sqrt( 3.0f ), 0.0f );
else if( shaderParams[1] == 6.0f )
circleCoords = vec2( 0.0f, 2.0f );
// Make the line appear to be at least 1 pixel wide
float lineWidth = shaderParams[3];
float worldScale = gl_ModelViewMatrix[0][0];
// Make lines appear to be at least 1 pixel width
if( worldScale * lineWidth < MIN_WIDTH )
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
gl_Position = ftransform();
}
else
{
// Pass through the coordinates like in the fixed pipeline
gl_Position = ftransform();
}
gl_FrontColor = gl_Color;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file vertex_container.cpp
* @brief Class to store vertices and handle transfers between system memory and GPU memory.
*/
#include <gal/opengl/vertex_container.h>
#include <gal/opengl/cached_container.h>
#include <gal/opengl/noncached_container.h>
#include <gal/opengl/shader.h>
#include <wx/log.h>
using namespace KIGFX;
VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached )
{
if( aCached )
return new CACHED_CONTAINER;
else
return new NONCACHED_CONTAINER;
}
VERTEX_CONTAINER::VERTEX_CONTAINER( unsigned int aSize ) :
m_freeSpace( aSize ), m_currentSize( aSize ), m_initialSize( aSize ), m_failed( false )
{
m_vertices = static_cast<VERTEX*>( malloc( aSize * sizeof( VERTEX ) ) );
}
VERTEX_CONTAINER::~VERTEX_CONTAINER()
{
free( m_vertices );
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file vertex_item.cpp
* @brief Class to handle an item held in a container.
*/
#include <gal/opengl/vertex_item.h>
#include <gal/opengl/vertex_manager.h>
#include <cstring>
using namespace KIGFX;
VERTEX_ITEM::VERTEX_ITEM( const VERTEX_MANAGER& aManager ) :
m_manager( aManager ), m_offset( 0 ), m_size( 0 )
{
// As the item is created, we are going to modify it, so call to SetItem() is needed
m_manager.SetItem( *this );
}
VERTEX_ITEM::~VERTEX_ITEM()
{
m_manager.FreeItem( *this );
}
VERTEX* VERTEX_ITEM::GetVertices() const
{
return m_manager.GetVertices( *this );
}
This diff is collapsed.
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <geometry/seg.h>
template <typename T>
int sgn( T aVal )
{
return ( T( 0 ) < aVal ) - ( aVal < T( 0 ) );
}
bool SEG::PointCloserThan( const VECTOR2I& aP, int aDist ) const
{
VECTOR2I d = B - A;
ecoord dist_sq = (ecoord) aDist * aDist;
SEG::ecoord l_squared = d.Dot( d );
SEG::ecoord t = d.Dot( aP - A );
if( t <= 0 || !l_squared )
return ( aP - A ).SquaredEuclideanNorm() < dist_sq;
else if( t >= l_squared )
return ( aP - B ).SquaredEuclideanNorm() < dist_sq;
int dxdy = abs( d.x ) - abs( d.y );
if( ( dxdy >= -1 && dxdy <= 1 ) || abs( d.x ) <= 1 || abs( d.y ) <= 1 )
{
int ca = -sgn( d.y );
int cb = sgn( d.x );
int cc = -ca * A.x - cb * A.y;
ecoord num = ca * aP.x + cb * aP.y + cc;
num *= num;
if( ca && cb )
num >>= 1;
if( num > ( dist_sq + 100 ) )
return false;
else if( num < ( dist_sq - 100 ) )
return true;
}
VECTOR2I nearest;
nearest.x = A.x + rescale( t, (ecoord) d.x, l_squared );
nearest.y = A.y + rescale( t, (ecoord) d.y, l_squared );
return ( nearest - aP ).SquaredEuclideanNorm() <= dist_sq;
}
SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
{
// fixme: rather inefficient....
if( Intersect( aSeg ) )
return 0;
const VECTOR2I pts[4] =
{
aSeg.NearestPoint( A ) - A,
aSeg.NearestPoint( B ) - B,
NearestPoint( aSeg.A ) - aSeg.A,
NearestPoint( aSeg.B ) - aSeg.B
};
ecoord m = VECTOR2I::ECOORD_MAX;
for( int i = 0; i < 4; i++ )
m = std::min( m, pts[i].SquaredEuclideanNorm() );
return m;
}
OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines ) const
{
const VECTOR2I e( B - A );
const VECTOR2I f( aSeg.B - aSeg.A );
const VECTOR2I ac( aSeg.A - A );
ecoord d = f.Cross( e );
ecoord p = f.Cross( ac );
ecoord q = e.Cross( ac );
if( d == 0 )
return OPT_VECTOR2I();
if( !aLines && d > 0 && ( q < 0 || q > d || p < 0 || p > d ) )
return OPT_VECTOR2I();
if( !aLines && d < 0 && ( q < d || p < d || p > 0 || q > 0 ) )
return OPT_VECTOR2I();
if( !aLines && aIgnoreEndpoints && ( q == 0 || q == d ) && ( p == 0 || p == d ) )
return OPT_VECTOR2I();
VECTOR2I ip( aSeg.A.x + rescale( q, (ecoord) f.x, d ),
aSeg.A.y + rescale( q, (ecoord) f.y, d ) );
return ip;
}
bool SEG::ccw( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) const
{
return (ecoord) ( aC.y - aA.y ) * ( aB.x - aA.x ) > (ecoord) ( aB.y - aA.y ) * ( aC.x - aA.x );
}
bool SEG::Collide( const SEG& aSeg, int aClearance ) const
{
// check for intersection
// fixme: move to a method
if( ccw( A, aSeg.A, aSeg.B ) != ccw( B, aSeg.A, aSeg.B ) &&
ccw( A, B, aSeg.A ) != ccw( A, B, aSeg.B ) )
return true;
#define CHK( _seg, _pt ) \
if( (_seg).PointCloserThan( _pt, aClearance ) ) return true;
CHK( *this, aSeg.A );
CHK( *this, aSeg.B );
CHK( aSeg, A );
CHK( aSeg, B );
#undef CHK
return false;
}
bool SEG::Contains( const VECTOR2I& aP ) const
{
return PointCloserThan( aP, 1 );
}
This diff is collapsed.
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Jacobo Aragunde Pérez
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <geometry/shape_index.h>
template <>
const SHAPE* shapeFunctor( SHAPE* aItem )
{
return aItem;
}
This diff is collapsed.
This diff is collapsed.
...@@ -65,7 +65,7 @@ void GRID_TRICKS::getSelectedArea() ...@@ -65,7 +65,7 @@ void GRID_TRICKS::getSelectedArea()
wxArrayInt cols = m_grid->GetSelectedCols(); wxArrayInt cols = m_grid->GetSelectedCols();
wxArrayInt rows = m_grid->GetSelectedRows(); wxArrayInt rows = m_grid->GetSelectedRows();
D(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );) DBG(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );)
if( topLeft.Count() && botRight.Count() ) if( topLeft.Count() && botRight.Count() )
{ {
...@@ -97,7 +97,7 @@ void GRID_TRICKS::getSelectedArea() ...@@ -97,7 +97,7 @@ void GRID_TRICKS::getSelectedArea()
m_sel_col_count = 0; m_sel_col_count = 0;
} }
//D(printf("m_sel_row_start:%d m_sel_col_start:%d m_sel_row_count:%d m_sel_col_count:%d\n", m_sel_row_start, m_sel_col_start, m_sel_row_count, m_sel_col_count );) //DBG(printf("m_sel_row_start:%d m_sel_col_start:%d m_sel_row_count:%d m_sel_col_count:%d\n", m_sel_row_start, m_sel_col_start, m_sel_row_count, m_sel_col_count );)
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment