Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c6959b7de | |||
| e5307ca1fb | |||
| d1f8dbb9de | |||
| 99d7a35797 | |||
| 0145a03f79 | |||
| df191606ab | |||
| 556be7b431 | |||
| e15ba3bf32 | |||
| c23c52834c | |||
| 981fddc649 | |||
| 5127a6bd09 | |||
| 136ba26896 | |||
| 575b22d018 | |||
| 5f01ca8f88 | |||
| 5a3c944b2a | |||
| 50a4b5553a | |||
| 4cb084cd63 | |||
| a458342cfc | |||
| 8023c7a794 | |||
| 65fe561a4b | |||
| 18f77b894e | |||
| 94a3390544 | |||
| cec3e300a8 | |||
| a262445047 | |||
| 0fbdec4c08 | |||
| de52ae6c70 | |||
| 9ca6405bcb | |||
| 1dc747c0ae | |||
| 183835ee67 | |||
| 6dbe262b53 | |||
| e074c798bf | |||
| bd1aae9071 | |||
| 6382db4ebf | |||
| 8151ec387c | |||
| 6e1d45c79e | |||
| 1d05076761 | |||
| 89e7d89223 | |||
| 115d70e060 | |||
| 1a89a0601a | |||
| ca0aa6c971 | |||
| 5b4542231e |
+55
@@ -0,0 +1,55 @@
|
||||
boost_root
|
||||
.downloads-by-cmake
|
||||
Build*
|
||||
build*
|
||||
common/netlist_keywords.*
|
||||
common/netlist_lexer.h
|
||||
common/pcb_plot_params_lexer.h
|
||||
common/page_layout/page_layout_reader_keywords.cpp
|
||||
common/lib_table_keywords.*
|
||||
common/gal/opengl/shader_src.h
|
||||
include/lib_table_lexer.h
|
||||
include/netlist_lexer.h
|
||||
include/page_layout_reader_lexer.h
|
||||
eeschema/cmp_library_lexer.h
|
||||
eeschema/cmp_library_keywords.*
|
||||
eeschema/dialogs/dialog_bom_cfg_keywords.cpp
|
||||
eeschema/dialogs/dialog_bom_cfg_lexer.h
|
||||
eeschema/dialogs/dialog_bom_help_html.h
|
||||
eeschema/template_fieldnames_keywords.*
|
||||
eeschema/template_fieldnames_lexer.h
|
||||
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
|
||||
pcbnew/pcb_plot_params_keywords.cpp
|
||||
pcbnew/pcb_plot_params_lexer.h
|
||||
pcb_calculator/attenuators/bridget_tee_formula.h
|
||||
pcb_calculator/attenuators/pi_formula.h
|
||||
pcb_calculator/attenuators/splitter_formula.h
|
||||
pcb_calculator/attenuators/tee_formula.h
|
||||
Makefile
|
||||
CMakeCache.txt
|
||||
auto_renamed_to_cpp
|
||||
Testing
|
||||
version.h
|
||||
config.h
|
||||
install_manifest.txt
|
||||
Documentation/doxygen
|
||||
Documentation/development/doxygen
|
||||
*.bak
|
||||
*.pyc
|
||||
.*.swp
|
||||
*~
|
||||
common/pcb_plot_params_keywords.cpp
|
||||
include/pcb_plot_params_lexer.h
|
||||
pcbnew/specctra_keywords.cpp
|
||||
pcbnew/specctra_lexer.h
|
||||
pcb_calculator/pcb_calculator_datafile_keywords.cpp
|
||||
pcb_calculator/pcb_calculator_datafile_lexer.h
|
||||
new/html
|
||||
new/sch_lib_table_keywords.cpp
|
||||
new/sch_lib_table_lexer.h
|
||||
new/sweet_keywords.cpp
|
||||
new/sweet_lexer.h
|
||||
bitmaps_png/png*
|
||||
bitmaps_png/tmp
|
||||
common/pcb_keywords.cpp
|
||||
include/pcb_lexer.h
|
||||
+26
-3
@@ -1,3 +1,25 @@
|
||||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2007-2016 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# Default to CMAKE_BUILD_TYPE = Release unless overridden on command line
|
||||
# http://www.cmake.org/pipermail/cmake/2008-September/023808.html
|
||||
@@ -83,9 +105,6 @@ mark_as_advanced( KICAD_SKIP_BOOST ) # Normal builders should build Boost.
|
||||
option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
|
||||
|
||||
|
||||
# This can be set to a custom name to brag about a particular branch in the "About" dialog:
|
||||
set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this build came." )
|
||||
|
||||
|
||||
# All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they
|
||||
# would have to be downloaded over and over again. The default is to choose a directory that is
|
||||
@@ -550,6 +569,10 @@ if( NOT GLEW_FOUND )
|
||||
check_find_package_result( GLEW_FOUND "GLEW" )
|
||||
endif()
|
||||
|
||||
# Find CURL library
|
||||
find_package( CURL REQUIRED )
|
||||
|
||||
|
||||
######################
|
||||
# Find Cairo library #
|
||||
######################
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2010-2015 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2010-2016 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@@ -23,9 +23,9 @@
|
||||
#
|
||||
|
||||
macro( create_git_version_header _git_src_path )
|
||||
# If bzr is not found or an error occurs using the git commands to determine the repo
|
||||
# version, set the build version string to "no-git"
|
||||
set( KICAD_BUILD_VERSION "no-git" )
|
||||
# If an error occurs using the git commands to determine the repo
|
||||
# version, set the build version string to "git-error".
|
||||
set( KICAD_GIT_BUILD_VERSION "git-error" )
|
||||
|
||||
# Include Git support to automagically create version header file.
|
||||
find_package( Git )
|
||||
@@ -72,17 +72,17 @@ macro( create_git_version_header _git_src_path )
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_EXECUTABLE} rev-list HEAD --count
|
||||
--first-parent
|
||||
${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${_git_src_path}
|
||||
OUTPUT_VARIABLE _git_SERIAL
|
||||
OUTPUT_VARIABLE _git_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(STATUS "Git hash: ${_git_LONG_HASH}")
|
||||
message(STATUS "Git branch: ${_git_BRANCH}")
|
||||
|
||||
if( ${_git_log_result} EQUAL 0 )
|
||||
string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*"
|
||||
"\\2" Kicad_REPO_REVISION "BZR ${_git_SERIAL}, Git ${_git_SHORT_HASH}" )
|
||||
"\\2" Kicad_REPO_REVISION "revision ${_git_SHORT_HASH}" )
|
||||
string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*"
|
||||
"\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_git_LAST_COMITTER}")
|
||||
string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*"
|
||||
@@ -98,8 +98,8 @@ macro( create_git_version_header _git_src_path )
|
||||
if( Kicad_REPO_LAST_CHANGED_DATE )
|
||||
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3"
|
||||
_kicad_git_date ${Kicad_REPO_LAST_CHANGED_DATE} )
|
||||
set( KICAD_BUILD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
|
||||
set( KICAD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" )
|
||||
set( KICAD_BRANCH_NAME ${_git_BRANCH} )
|
||||
endif()
|
||||
|
||||
set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} )
|
||||
endmacro()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# Note: unless you are the person responsible for creating releases,
|
||||
# do *not* change these variables. This way the KiCad project
|
||||
# can maintain control over what is an official KiCad build and
|
||||
# what is not. Setting these variable that conflict with KiCad
|
||||
# releases is a shooting offense.
|
||||
#
|
||||
# This file gets included in the WriteVersionHeader.cmake file to set
|
||||
# the KiCad version when the source is provided in an archive file.
|
||||
# When KiCad is cloned using git, the git version is used. The only
|
||||
# time this should be set to a value other than "no-vcs-found" is when
|
||||
# a source archive is created. This eliminates the need to set
|
||||
# KICAD_VERSION during the build configuration step.
|
||||
set( KICAD_VERSION "4.0.6" )
|
||||
@@ -2,7 +2,7 @@
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
# Copyright (C) 2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
# Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@@ -22,49 +22,35 @@
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#
|
||||
|
||||
# Automagically create version header file if the version string was not defined during
|
||||
# the build configuration. If CreateBzrVersionHeader or CreateGitVersionHeader cannot
|
||||
# determine the current repo version, a version.h file is still created with
|
||||
# KICAD_BUILD_VERSION set to "no-vcs-found".
|
||||
if( NOT KICAD_BUILD_VERSION )
|
||||
set( _wvh_version_str "no-vcs-found" )
|
||||
# Automagically create version header file if the version string was
|
||||
# not defined during the build configuration. If
|
||||
# CreateGitVersionHeader cannot determine the current repo version, a
|
||||
# version.h file is still created with KICAD_VERSION set to "no-vcs-found".
|
||||
include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
|
||||
# Detect the appropiate VCS and set the version string.
|
||||
if( EXISTS "${SRC_PATH}/.bzr" )
|
||||
message( STATUS "Using Bazaar to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateBzrVersionHeader.cmake )
|
||||
create_bzr_version_header( ${SRC_PATH} )
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
elseif( EXISTS "${SRC_PATH}/.git" )
|
||||
message( STATUS "Using Git to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
|
||||
create_git_version_header( ${SRC_PATH} )
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
endif()
|
||||
else()
|
||||
set( _wvh_version_str ${KICAD_BUILD_VERSION} )
|
||||
# Attempt to detect if we have a git repo and set the version string if
|
||||
# the version wasn't set to something other than the default value in
|
||||
# KiCadVersion.cmake.
|
||||
if( KICAD_VERSION STREQUAL "no-vcs-found" AND EXISTS "${SRC_PATH}/.git" )
|
||||
message( STATUS "Using Git to determine build version string." )
|
||||
include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake )
|
||||
create_git_version_header( ${SRC_PATH} )
|
||||
endif()
|
||||
|
||||
set( _wvh_write_version_file ON )
|
||||
# $KICAD_VERSION_FULL will always be set to something. Even if it is "no-vcs-found".
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION}" )
|
||||
|
||||
# Compare the version argument against the version in the existing header file for a mismatch.
|
||||
if( EXISTS ${OUTPUT_FILE} )
|
||||
file( STRINGS ${OUTPUT_FILE} _current_version_str
|
||||
REGEX "^#define[\t ]+KICAD_BUILD_VERSION[\t ]+.*" )
|
||||
string( REGEX REPLACE "^#define KICAD_BUILD_VERSION \"([()a-zA-Z0-9 -.]+)\".*"
|
||||
"\\1" _wvh_last_version "${_current_version_str}" )
|
||||
|
||||
# No change, do not write version.h
|
||||
if( _wvh_version_str STREQUAL _wvh_last_version )
|
||||
message( STATUS "Not updating ${OUTPUT_FILE}" )
|
||||
set( _wvh_write_version_file OFF )
|
||||
endif()
|
||||
# Optional branch name detected by git or configuration defined option.
|
||||
if( KICAD_BRANCH_NAME )
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_BRANCH_NAME}" )
|
||||
endif()
|
||||
|
||||
if( _wvh_write_version_file )
|
||||
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${_wvh_version_str}" )
|
||||
# Optional user version information defined at configuration.
|
||||
if( KICAD_VERSION_EXTRA )
|
||||
set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_VERSION_EXTRA}" )
|
||||
endif()
|
||||
|
||||
file( WRITE ${OUTPUT_FILE}
|
||||
set( _wvh_new_version_text
|
||||
"/* Do not modify this file, it was automatically generated by CMake. */
|
||||
|
||||
/*
|
||||
@@ -73,11 +59,26 @@ if( _wvh_write_version_file )
|
||||
#ifndef __KICAD_VERSION_H__
|
||||
#define __KICAD_VERSION_H__
|
||||
|
||||
#define KICAD_BUILD_VERSION \"${_wvh_version_str}\"
|
||||
#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
|
||||
|
||||
#endif /* __KICAD_VERSION_H__ */
|
||||
"
|
||||
)
|
||||
" )
|
||||
|
||||
set( _wvh_write_version_file ON )
|
||||
|
||||
# Only write the header if it has changed, to avoid rebuilds
|
||||
if( EXISTS ${OUTPUT_FILE} )
|
||||
file( READ ${OUTPUT_FILE} _wvh_old_version_text )
|
||||
if( _wvh_old_version_text STREQUAL _wvh_new_version_text )
|
||||
message( STATUS "Not updating ${OUTPUT_FILE}" )
|
||||
set( _wvh_write_version_file OFF )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if( _wvh_write_version_file )
|
||||
message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_VERSION_FULL}" )
|
||||
|
||||
file( WRITE ${OUTPUT_FILE} ${_wvh_new_version_text} )
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -77,7 +77,4 @@
|
||||
#define KIFACE_SUFFIX wxT( "@KIFACE_SUFFIX@" )
|
||||
#define KIFACE_PREFIX wxT( "@KIFACE_PREFIX@" )
|
||||
|
||||
/// Name of repo from which this build came.
|
||||
#define KICAD_REPO_NAME "@KICAD_REPO_NAME@"
|
||||
|
||||
#endif // CONFIG_H_
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
||||
#
|
||||
# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
# Download av_http and install into ${PREFIX}, typically in our KiCad source tree.
|
||||
# Assumes include( ExternalProject ) was done inline previous to this file
|
||||
# and that set( DOWNLOAD_DIR ... ) was set in a higher context.
|
||||
|
||||
#-----<configure>-------------------------------------------------------------------------------------
|
||||
|
||||
# soon cmake will have https support, switch to a true download then:
|
||||
#set( AVHTTP_RELEASE ??? )
|
||||
#set( AVHTTP_MD5 ???? ) # re-calc this on every RELEASE change
|
||||
|
||||
#-----</configure>-----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Where the library is to be installed.
|
||||
set( PREFIX ${DOWNLOAD_DIR}/avhttp )
|
||||
|
||||
if( KICAD_SKIP_BOOST )
|
||||
set( AVHTTP_DEPEND "" )
|
||||
else()
|
||||
set( AVHTTP_DEPEND "boost" )
|
||||
endif()
|
||||
|
||||
|
||||
# Install the AVHTTP header only library ${PREFIX}
|
||||
ExternalProject_Add( avhttp
|
||||
PREFIX ${PREFIX}
|
||||
DOWNLOAD_DIR ${DOWNLOAD_DIR} # no true download yet
|
||||
|
||||
# grab it from a local zip file for now, cmake caller's source dir
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/avhttp-master.zip
|
||||
DEPENDS ${AVHTTP_DEPEND}
|
||||
|
||||
CONFIGURE_COMMAND ""
|
||||
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR> <INSTALL_DIR>
|
||||
)
|
||||
|
||||
|
||||
set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" )
|
||||
mark_as_advanced( AVHTTP_INCLUDE_DIR )
|
||||
@@ -78,14 +78,6 @@ specific patches required to build a working Boost library. These patches can b
|
||||
[patches folder][] in the KiCad source. These patches are named by the platform name they should
|
||||
be applied against.
|
||||
|
||||
## OpenSSL Secure Socket Layer Library ## {#openssl}
|
||||
|
||||
The [OpenSSL][] library is only required when the KiCad build is configured with the Github plugin
|
||||
enabled. See the [KiCad Build Configuration Options](#build_opts)` section for more information.
|
||||
Please note that KiCad will download and build version 1.0.1e of OpenSSL by default. You should
|
||||
probably use the version of OpenSSL installed on your system as it will most likely be more up to
|
||||
date and contain the latest security fixes.
|
||||
|
||||
## GLEW OpenGL Extension Wrangler Library ## {#glew}
|
||||
|
||||
The [OpenGL Extension Wrangler][GLEW] is an OpenGL helper library used by the KiCad graphics
|
||||
@@ -151,6 +143,11 @@ supplied by KiCad. This option is disabled by default.
|
||||
The KICAD_SCRIPTING_WXPYTHON option is used to enable building the wxPython interface into
|
||||
Pcbnew including the wxPython console. This option is disabled by default.
|
||||
|
||||
## Github Plugin ## {#github_opt}
|
||||
|
||||
The BUILD_GITHUB_PLUGIN option is used to control if the Github plugin is built. This option is
|
||||
enabled by default.
|
||||
|
||||
## Build with Static Libraries ## {#static_lib_opt}
|
||||
|
||||
The KICAD_BUILD_STATIC option is used to build KiCad with static libraries. This option is
|
||||
@@ -175,10 +172,30 @@ The USE_OSX_DEPS_BUILDER option forces the build configuration to download and b
|
||||
required dependencies to build KiCad on OSX. This option is not longer maintained and most
|
||||
likely is broken. Use it at your own peril.
|
||||
|
||||
## Github Plugin ## {#github_opt}
|
||||
## Setting the Build Version and Repository Name ## {#build_version_opt}
|
||||
|
||||
The BUILD_GITHUB_PLUGIN option is used to control if the Github plugin is built. This option is
|
||||
enabled by default.
|
||||
The KiCad version string is defined by the three CMake variables KICAD_VERSION, KICAD_BRANCH_NAME,
|
||||
and KICAD_VERSION_EXTRA. Variables KICAD_BRANCH_NAME and KICAD_VERSION_EXTRA are defined as empty
|
||||
strings and can be set at configuration. Unless the source branch is a stable release archive,
|
||||
KICAD_VERSION is set to "no-vcs-found". If an optional variable is not define, it is not appended
|
||||
to the full version string. If an optional variable is defined it is appended along with a leading
|
||||
'-' to the full version string as follows:
|
||||
|
||||
KICAD_VERSION[-KICAD_BRANCH_NAME][-KICAD_VERSION_EXTRA]
|
||||
|
||||
When the version string is set to "no-vcs-found", the build script automatically creates the
|
||||
version string information from the [git][] repository information as follows:
|
||||
|
||||
|
||||
(2016-08-26 revision 67230ac)-master
|
||||
| | |
|
||||
| | branch name, "HEAD" if not on a branch,
|
||||
| | or "unknown" if no .git present
|
||||
| |
|
||||
| abbreviated commit hash, or no-git if no .git
|
||||
| present
|
||||
|
|
||||
date of commit, or date of build if no .git present
|
||||
|
||||
# Getting the KiCad Source Code ## {#getting_src}
|
||||
|
||||
@@ -274,7 +291,7 @@ the following commands:
|
||||
mingw-w64-x86_64-boost \
|
||||
mingw-w64-x86_64-cairo \
|
||||
mingw-w64-x86_64-glew \
|
||||
mingw-w64-x86_64-openssl \
|
||||
mingw-w64-x86_64-curl \
|
||||
mingw-w64-x86_64-wxPython \
|
||||
mingw-w64-x86_64-wxWidgets
|
||||
cd kicad-source
|
||||
@@ -286,7 +303,6 @@ the following commands:
|
||||
-DCMAKE_PREFIX_PATH=/mingw64 \
|
||||
-DCMAKE_INSTALL_PREFIX=/mingw64 \
|
||||
-DDEFAULT_INSTALL_PATH=/mingw64 \
|
||||
-DOPENSSL_ROOT_DIR=/mingw64 \
|
||||
-DKICAD_SKIP_BOOST=ON \
|
||||
-DKICAD_SCRIPTING=ON \
|
||||
-DKICAD_SCRIPTING_MODULES=ON \
|
||||
@@ -383,7 +399,6 @@ Boost patches in the KiCad source [patch folder][].
|
||||
[wxWidgets]: http://wxwidgets.org/
|
||||
[patches folder]: http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/files/head:/patches/
|
||||
[Boost]: http://www.boost.org/
|
||||
[OpenSSL]: https://www.openssl.org/
|
||||
[GLEW]: http://glew.sourceforge.net/
|
||||
[GLUT]: https://www.opengl.org/resources/libraries/glut/
|
||||
[Cairo]: http://cairographics.org/
|
||||
|
||||
+24
-5
@@ -4,12 +4,19 @@ include_directories(
|
||||
./dialog_about
|
||||
${CAIRO_INCLUDE_DIR}
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
../3d-viewer
|
||||
../pcbnew
|
||||
../polygon
|
||||
${INC_AFTER}
|
||||
)
|
||||
|
||||
|
||||
if( NOT APPLE ) # windows and linux use openssl under curl
|
||||
find_package( OpenSSL REQUIRED )
|
||||
endif()
|
||||
|
||||
|
||||
# Generate header files containing shader programs
|
||||
# Order of input files is significant
|
||||
add_custom_command(
|
||||
@@ -115,15 +122,20 @@ install( TARGETS lib_kicad
|
||||
endif()
|
||||
|
||||
|
||||
# KiCad build version string defaults to undefined which forces the build version header
|
||||
# command to look for Bazaar to create the version string header.
|
||||
set( KICAD_BUILD_VERSION "" CACHE STRING "Version string defined at configuration time." )
|
||||
# KiCad build version string defaults to "no-vcs-found" which forces the build version header
|
||||
# command to look for git to create the version string header when the .git path is found in
|
||||
# the source path.
|
||||
set( KICAD_BRANCH_NAME "" CACHE STRING "KiCad repository name." )
|
||||
set( KICAD_VERSION_EXTRA "" CACHE STRING
|
||||
"User defined configuration string to append to KiCad version." )
|
||||
|
||||
# Generate version header file.
|
||||
add_custom_target(
|
||||
version_header ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DKICAD_BUILD_VERSION=${KICAD_BUILD_VERSION}
|
||||
-DKICAD_VERSION=${KICAD_VERSION}
|
||||
-DKICAD_BRANCH_NAME=${KICAD_BRANCH_NAME}
|
||||
-DKICAD_VERSION_EXTRA=${KICAD_VERSION_EXTRA}
|
||||
-DOUTPUT_FILE=${CMAKE_BINARY_DIR}/kicad_build_version.h
|
||||
-DSRC_PATH=${PROJECT_SOURCE_DIR}
|
||||
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
|
||||
@@ -252,6 +264,9 @@ endif()
|
||||
|
||||
set( COMMON_SRCS
|
||||
${COMMON_SRCS}
|
||||
kicad_curl/kicad_curl.cpp
|
||||
kicad_curl/kicad_curl_easy.cpp
|
||||
|
||||
view/view.cpp
|
||||
view/view_item.cpp
|
||||
view/view_group.cpp
|
||||
@@ -277,7 +292,11 @@ set( COMMON_SRCS
|
||||
add_library( common STATIC ${COMMON_SRCS} )
|
||||
add_dependencies( common lib-dependencies )
|
||||
add_dependencies( common version_header )
|
||||
target_link_libraries( common ${Boost_LIBRARIES} )
|
||||
target_link_libraries( common
|
||||
${Boost_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
${OPENSSL_LIBRARIES} # empty on Apple
|
||||
)
|
||||
|
||||
|
||||
set( PCB_COMMON_SRCS
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
* @file basicframe.cpp
|
||||
* @brief EDA_BASE_FRAME class implementation.
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
// kicad_curl.h must be included before wx headers, to avoid
|
||||
// conflicts for some defines, at least on Windows
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
#include <curl/curlver.h>
|
||||
#include <kicad_curl/kicad_curl.h>
|
||||
#endif
|
||||
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/fontdlg.h>
|
||||
@@ -580,6 +588,11 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
|
||||
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
|
||||
<< ( BOOST_VERSION % 100 ) << wxT( "\n" );
|
||||
|
||||
#ifdef BUILD_GITHUB_PLUGIN
|
||||
// Shows the Curl library version in use:
|
||||
msg_version << "Curl version: " << KICAD_CURL::GetVersion() << "\n";
|
||||
#endif
|
||||
|
||||
msg_version << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
|
||||
#ifdef USE_WX_GRAPHICS_CONTEXT
|
||||
msg_version << wxT( "ON\n" );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -37,9 +37,8 @@
|
||||
wxString GetBuildVersion()
|
||||
{
|
||||
wxString msg = wxString::Format(
|
||||
wxT( "%s-%s" ),
|
||||
wxT( KICAD_BUILD_VERSION ),
|
||||
wxT( KICAD_REPO_NAME )
|
||||
wxT( "%s" ),
|
||||
wxT( KICAD_VERSION_FULL )
|
||||
);
|
||||
|
||||
return msg;
|
||||
|
||||
@@ -107,9 +107,8 @@ bool BITMAP_BASE::SaveData( FILE* aFile ) const
|
||||
// Write binary data in hexadecimal form (ASCII)
|
||||
wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
|
||||
char* begin = (char*) buffer->GetBufferStart();
|
||||
int ii;
|
||||
|
||||
for( ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
|
||||
for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ )
|
||||
{
|
||||
if( ii >= 32 )
|
||||
{
|
||||
@@ -140,7 +139,7 @@ void BITMAP_BASE::SaveData( wxArrayString& aPngStrings ) const
|
||||
char* begin = (char*) buffer->GetBufferStart();
|
||||
wxString line;
|
||||
|
||||
for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
|
||||
for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ )
|
||||
{
|
||||
if( ii >= 32 )
|
||||
{
|
||||
|
||||
+12
-18
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2013-2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,7 +28,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#define USE_WORKER_THREADS 1 // 1:yes, 0:no. use worker thread to load libraries
|
||||
/**
|
||||
No. concurrent threads doing "http(s) GET". More than 6 is not significantly
|
||||
faster, less than 6 is likely slower. Main thread is in this count, so if
|
||||
set to 1 then no temp threads are created.
|
||||
*/
|
||||
#define READER_THREADS 6
|
||||
|
||||
/*
|
||||
* Functions to read footprint libraries and fill m_footprints by available footprints names
|
||||
@@ -120,13 +125,6 @@ void FOOTPRINT_INFO::load()
|
||||
}
|
||||
|
||||
|
||||
#define JOBZ 6 // no. libraries per worker thread. It takes about
|
||||
// a second to load a GITHUB library, so assigning
|
||||
// this no. libraries to each thread should give a little
|
||||
// over this no. seconds total time if the original delay
|
||||
// were caused by latencies alone.
|
||||
// (If https://github.com does not mind.)
|
||||
|
||||
void FOOTPRINT_LIST::loader_job( const wxString* aNicknameList, int aJobZ )
|
||||
{
|
||||
for( int i=0; i<aJobZ; ++i )
|
||||
@@ -204,8 +202,6 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* a
|
||||
// do all of them
|
||||
nicknames = aTable->GetLogicalLibs();
|
||||
|
||||
#if USE_WORKER_THREADS
|
||||
|
||||
// Even though the PLUGIN API implementation is the place for the
|
||||
// locale toggling, in order to keep LOCAL_IO::C_count at 1 or greater
|
||||
// for the duration of all helper threads, we increment by one here via instantiation.
|
||||
@@ -221,22 +217,23 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* a
|
||||
|
||||
MYTHREADS threads;
|
||||
|
||||
unsigned jobz = (nicknames.size() + READER_THREADS - 1) / READER_THREADS;
|
||||
|
||||
// Give each thread JOBZ nicknames to process. The last portion of, or if the entire
|
||||
// size() is small, I'll do myself.
|
||||
for( unsigned i=0; i<nicknames.size(); )
|
||||
{
|
||||
int jobz = JOBZ;
|
||||
|
||||
if( i + jobz >= nicknames.size() ) // on the last iteration of this for(;;)
|
||||
{
|
||||
jobz = nicknames.size() - i;
|
||||
|
||||
// Only a little bit to do, I'll do it myself, on current thread.
|
||||
// Only a little bit to do, I'll do it myself on current thread.
|
||||
// I am part of the READER_THREADS count.
|
||||
loader_job( &nicknames[i], jobz );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Delegate the job to a worker thread created here.
|
||||
// Delegate the job to a temporary thread created here.
|
||||
threads.push_back( new boost::thread( &FOOTPRINT_LIST::loader_job,
|
||||
this, &nicknames[i], jobz ) );
|
||||
}
|
||||
@@ -251,9 +248,6 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* a
|
||||
{
|
||||
threads[i].join();
|
||||
}
|
||||
#else
|
||||
loader_job( &nicknames[0], nicknames.size() );
|
||||
#endif
|
||||
|
||||
m_list.sort();
|
||||
}
|
||||
|
||||
+17
-2
@@ -323,7 +323,17 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR
|
||||
in->Duplicate( tok );
|
||||
sawUri = true;
|
||||
in->NeedSYMBOLorNUMBER();
|
||||
row.SetFullURI( in->FromUTF8() );
|
||||
// Saved path and file names use the Unix notation (separator = '/')
|
||||
// However old files, and files edited by hand can use the windows
|
||||
// separator. Force the unix notation.
|
||||
// (It works on windows, and moreover, wxFileName and wxDir takes care to that
|
||||
// on windows)
|
||||
// moreover, URLs use the '/' as separator
|
||||
{
|
||||
wxString uri = in->FromUTF8();
|
||||
uri.Replace( '\\', '/' );
|
||||
row.SetFullURI( uri );
|
||||
}
|
||||
break;
|
||||
|
||||
case T_type:
|
||||
@@ -393,10 +403,15 @@ void FP_LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
||||
void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
||||
throw( IO_ERROR, boost::interprocess::lock_exception )
|
||||
{
|
||||
// In Kicad, we save path and file names using the Unix notation (separator = '/')
|
||||
// So ensure separator is always '/' is saved URI string
|
||||
wxString uri = GetFullURI();
|
||||
uri.Replace( '\\', '/' );
|
||||
|
||||
out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n",
|
||||
out->Quotew( GetNickName() ).c_str(),
|
||||
out->Quotew( GetType() ).c_str(),
|
||||
out->Quotew( GetFullURI() ).c_str(),
|
||||
out->Quotew( uri ).c_str(),
|
||||
out->Quotew( GetOptions() ).c_str(),
|
||||
out->Quotew( GetDescr() ).c_str()
|
||||
);
|
||||
|
||||
@@ -450,7 +450,7 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn
|
||||
|
||||
void OPENGL_GAL::DrawPolyline( const std::deque<VECTOR2D>& aPointList )
|
||||
{
|
||||
if( aPointList.empty() )
|
||||
if( aPointList.size() < 2 )
|
||||
return;
|
||||
|
||||
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
|
||||
@@ -478,6 +478,9 @@ void OPENGL_GAL::DrawPolyline( const std::deque<VECTOR2D>& aPointList )
|
||||
|
||||
void OPENGL_GAL::DrawPolyline( const VECTOR2D aPointList[], int aListSize )
|
||||
{
|
||||
if( aListSize < 2 )
|
||||
return;
|
||||
|
||||
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
|
||||
|
||||
// Start from the second point
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
|
||||
* Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* 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 3
|
||||
* 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
|
||||
*/
|
||||
|
||||
// kicad_curl.h must be included before wx headers, to avoid
|
||||
// conflicts for some defines, at least on Windows
|
||||
#include <kicad_curl/kicad_curl.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
#include <wx/dynlib.h>
|
||||
|
||||
#include <macros.h>
|
||||
#include <fctsys.h>
|
||||
#include <ki_mutex.h> // MUTEX and MUTLOCK
|
||||
#include <richio.h>
|
||||
|
||||
|
||||
|
||||
// These are even more private than class members, and since there is only
|
||||
// one instance of KICAD_CURL ever, these statics are hidden here to simplify the
|
||||
// client (API) header file.
|
||||
static volatile bool s_initialized;
|
||||
|
||||
static MUTEX s_lock; // for s_initialized
|
||||
|
||||
// Assume that on these platforms libcurl uses OpenSSL
|
||||
#if defined(__linux__) || defined(__MINGW32__)
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
static MUTEX* s_crypto_locks;
|
||||
|
||||
static void lock_callback( int mode, int type, const char* file, int line )
|
||||
{
|
||||
(void)file;
|
||||
(void)line;
|
||||
|
||||
wxASSERT( s_crypto_locks && unsigned( type ) < unsigned( CRYPTO_num_locks() ) );
|
||||
|
||||
//DBG( printf( "%s: mode=0x%x type=%d file=%s line=%d\n", __func__, mode, type, file, line );)
|
||||
|
||||
if( mode & CRYPTO_LOCK )
|
||||
{
|
||||
s_crypto_locks[ type ].lock();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_crypto_locks[ type ].unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void init_locks()
|
||||
{
|
||||
s_crypto_locks = new MUTEX[ CRYPTO_num_locks() ];
|
||||
|
||||
// From http://linux.die.net/man/3/crypto_set_id_callback:
|
||||
|
||||
/*
|
||||
|
||||
OpenSSL can safely be used in multi-threaded applications provided that at
|
||||
least two callback functions are set, locking_function and threadid_func.
|
||||
|
||||
locking_function(int mode, int n, const char *file, int line) is needed to
|
||||
perform locking on shared data structures. (Note that OpenSSL uses a number
|
||||
of global data structures that will be implicitly shared whenever multiple
|
||||
threads use OpenSSL.) Multi-threaded applications will crash at random if it
|
||||
is not set.
|
||||
|
||||
threadid_func( CRYPTO_THREADID *id) is needed to record the
|
||||
currently-executing thread's identifier into id. The implementation of this
|
||||
callback should not fill in id directly, but should use
|
||||
CRYPTO_THREADID_set_numeric() if thread IDs are numeric, or
|
||||
CRYPTO_THREADID_set_pointer() if they are pointer-based. If the application
|
||||
does not register such a callback using CRYPTO_THREADID_set_callback(), then
|
||||
a default implementation is used - on Windows and BeOS this uses the
|
||||
system's default thread identifying APIs, and on all other platforms it uses
|
||||
the address of errno. The latter is satisfactory for thread-safety if and
|
||||
only if the platform has a thread-local error number facility.
|
||||
|
||||
Dick: "sounds like CRYPTO_THREADID_set_callback() is not mandatory on our
|
||||
2 OpenSSL platforms."
|
||||
|
||||
*/
|
||||
|
||||
CRYPTO_set_locking_callback( &lock_callback );
|
||||
}
|
||||
|
||||
|
||||
static void kill_locks()
|
||||
{
|
||||
CRYPTO_set_locking_callback( NULL );
|
||||
|
||||
delete[] s_crypto_locks;
|
||||
|
||||
s_crypto_locks = NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void init_locks() { /* dummy */ }
|
||||
inline void kill_locks() { /* dummy */ }
|
||||
|
||||
#endif
|
||||
|
||||
/// At process termination, using atexit() keeps the CURL stuff out of the
|
||||
/// singletops and PGM_BASE.
|
||||
static void at_terminate()
|
||||
{
|
||||
KICAD_CURL::Cleanup();
|
||||
}
|
||||
|
||||
|
||||
void KICAD_CURL::Init()
|
||||
{
|
||||
// We test s_initialized twice in an effort to avoid
|
||||
// unnecessarily locking s_lock. This understands that the common case
|
||||
// will not need to lock.
|
||||
if( !s_initialized )
|
||||
{
|
||||
MUTLOCK lock( s_lock );
|
||||
|
||||
if( !s_initialized )
|
||||
{
|
||||
if( curl_global_init( CURL_GLOBAL_ALL ) != CURLE_OK )
|
||||
{
|
||||
THROW_IO_ERROR( "curl_global_init() failed." );
|
||||
}
|
||||
|
||||
init_locks();
|
||||
|
||||
wxLogDebug( "Using %s", GetVersion() );
|
||||
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KICAD_CURL::Cleanup()
|
||||
{
|
||||
/*
|
||||
|
||||
Calling MUTLOCK() from a static destructor will typically be bad, since the
|
||||
s_lock may already have been statically destroyed itself leading to a boost
|
||||
exception. (Remember C++ does not provide certain sequencing of static
|
||||
destructor invocation.)
|
||||
|
||||
To prevent this we test s_initialized twice, which ensures that the MUTLOCK
|
||||
is only instantiated on the first call, which should be from
|
||||
PGM_BASE::destroy() which is first called earlier than static destruction.
|
||||
Then when called again from the actual PGM_BASE::~PGM_BASE() function,
|
||||
MUTLOCK will not be instantiated because s_initialized will be false.
|
||||
|
||||
*/
|
||||
|
||||
if( s_initialized )
|
||||
{
|
||||
MUTLOCK lock( s_lock );
|
||||
|
||||
if( s_initialized )
|
||||
{
|
||||
curl_global_cleanup();
|
||||
|
||||
kill_locks();
|
||||
|
||||
atexit( &at_terminate );
|
||||
|
||||
s_initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string KICAD_CURL::GetSimpleVersion()
|
||||
{
|
||||
if( !s_initialized )
|
||||
Init();
|
||||
|
||||
curl_version_info_data* info = curl_version_info( CURLVERSION_NOW );
|
||||
|
||||
std::string res;
|
||||
|
||||
if( info->version )
|
||||
{
|
||||
res += "libcurl version: " + std::string( info->version );
|
||||
}
|
||||
|
||||
res += " (";
|
||||
|
||||
if( info->features & CURL_VERSION_SSL )
|
||||
{
|
||||
res += "with SSL - ";
|
||||
res += std::string( info->ssl_version );
|
||||
}
|
||||
else
|
||||
{
|
||||
res += "without SSL";
|
||||
}
|
||||
res += ")";
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* 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 3
|
||||
* 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 <kicad_curl/kicad_curl_easy.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <exception>
|
||||
#include <stdarg.h>
|
||||
#include <sstream>
|
||||
#include <richio.h>
|
||||
|
||||
|
||||
static size_t write_callback( void* contents, size_t size, size_t nmemb, void* userp )
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
|
||||
std::string* p = (std::string*) userp;
|
||||
|
||||
p->append( (const char*) contents, realsize );
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
|
||||
KICAD_CURL_EASY::KICAD_CURL_EASY() :
|
||||
m_headers( NULL )
|
||||
{
|
||||
// Call KICAD_CURL::Init() from in here everytime, but only the first time
|
||||
// will incur any overhead. This strategy ensures that libcurl is never loaded
|
||||
// unless it is needed.
|
||||
|
||||
KICAD_CURL::Init();
|
||||
|
||||
m_CURL = curl_easy_init();
|
||||
|
||||
if( !m_CURL )
|
||||
{
|
||||
THROW_IO_ERROR( "Unable to initialize CURL session" );
|
||||
}
|
||||
|
||||
curl_easy_setopt( m_CURL, CURLOPT_WRITEFUNCTION, write_callback );
|
||||
curl_easy_setopt( m_CURL, CURLOPT_WRITEDATA, (void*) &m_buffer );
|
||||
}
|
||||
|
||||
|
||||
KICAD_CURL_EASY::~KICAD_CURL_EASY()
|
||||
{
|
||||
if( m_headers )
|
||||
curl_slist_free_all( m_headers );
|
||||
|
||||
curl_easy_cleanup( m_CURL );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_CURL_EASY::Perform()
|
||||
{
|
||||
if( m_headers )
|
||||
{
|
||||
curl_easy_setopt( m_CURL, CURLOPT_HTTPHEADER, m_headers );
|
||||
}
|
||||
|
||||
// bonus: retain worst case memory allocation, should re-use occur
|
||||
m_buffer.clear();
|
||||
|
||||
CURLcode res = curl_easy_perform( m_CURL );
|
||||
|
||||
if( res != CURLE_OK )
|
||||
{
|
||||
std::string msg = StrPrintf( "curl_easy_perform()=%d: %s",
|
||||
res, GetErrorText( res ).c_str() );
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
|
||||
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
|
||||
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
|
||||
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AutomaticFootprintMatching )
|
||||
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, CVPCB_MAINFRAME::DisplayDocFile )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
||||
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
|
||||
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
|
||||
@@ -500,12 +499,6 @@ void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
|
||||
{
|
||||
GetAssociatedDocument( this, m_DocModulesFileName, &Kiface().KifaceSearch() );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
|
||||
{
|
||||
if( m_skipComponentSelect )
|
||||
|
||||
@@ -164,8 +164,6 @@ public:
|
||||
*/
|
||||
void AutomaticFootprintMatching( wxCommandEvent& event );
|
||||
|
||||
void DisplayDocFile( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function OnSelectFilteringFootprint
|
||||
* is the command event handler for enabling and disabling footprint filtering.
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -91,9 +91,9 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
|
||||
KiBitmap( editor_xpm ) );
|
||||
|
||||
AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
|
||||
_( "Edit &Equ Files List" ),
|
||||
_( "Setup equ files list (.equ files)\n"
|
||||
"They are files which give the footprint name from the component value"),
|
||||
_( "&Edit Footprint Association File" ),
|
||||
_( "Modify footprint association file (.equ). This is the file which "
|
||||
"assigns the footprint name by the component value" ),
|
||||
KiBitmap( library_table_xpm ) );
|
||||
|
||||
// Language submenu
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2007-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2007-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -79,11 +79,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
|
||||
KiBitmap( delete_association_xpm ),
|
||||
_( "Delete all associations (links)" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
m_mainToolBar->AddTool( ID_PCB_DISPLAY_FOOTPRINT_DOC, wxEmptyString,
|
||||
KiBitmap( datasheet_xpm ),
|
||||
_( "Display footprint documentation" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
|
||||
KiBitmap( module_filtered_list_xpm ),
|
||||
|
||||
@@ -563,10 +563,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
||||
return;
|
||||
|
||||
if( WriteDiagnosticERC( dlg.GetPath() ) )
|
||||
{
|
||||
Close( true );
|
||||
ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-17
@@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2008-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -444,8 +444,7 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
case HK_ZOOM_REDRAW:
|
||||
case HK_ZOOM_CENTER:
|
||||
case HK_ZOOM_AUTO:
|
||||
case HK_LEAVE_SHEET:
|
||||
case HK_DELETE_NODE:
|
||||
// case HK_ZOOM_SELECTION:
|
||||
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
||||
case HK_SAVE_BLOCK: // Copy block to paste buffer.
|
||||
cmd.SetId( hotKey->m_IdMenuEvent );
|
||||
@@ -472,10 +471,12 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
}
|
||||
break;
|
||||
|
||||
case HK_UNDO:
|
||||
case HK_REDO:
|
||||
case HK_UNDO: // Hot keys that map to command IDs that cannot be called
|
||||
case HK_REDO: // while busy performing another command.
|
||||
case HK_FIND_ITEM:
|
||||
case HK_FIND_REPLACE:
|
||||
case HK_DELETE_NODE:
|
||||
case HK_LEAVE_SHEET:
|
||||
if( notBusy )
|
||||
{
|
||||
cmd.SetId( hotKey->m_IdMenuEvent );
|
||||
@@ -620,8 +621,6 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
|
||||
cmd.SetEventObject( this );
|
||||
|
||||
bool itemInEdit = m_drawItem && m_drawItem->InEditMode();
|
||||
|
||||
/* Convert lower to upper case (the usual toupper function has problem
|
||||
* with non ascii codes like function keys */
|
||||
if( (aHotKey >= 'a') && (aHotKey <= 'z') )
|
||||
@@ -635,6 +634,10 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
if( hotKey == NULL )
|
||||
return false;
|
||||
|
||||
bool itemInEdit = m_drawItem && m_drawItem->InEditMode();
|
||||
|
||||
bool blocInProgress = GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK;
|
||||
|
||||
switch( hotKey->m_Idcommand )
|
||||
{
|
||||
default:
|
||||
@@ -686,7 +689,7 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
break;
|
||||
|
||||
case HK_EDIT:
|
||||
if( ! itemInEdit )
|
||||
if( !itemInEdit )
|
||||
m_drawItem = LocateItemUsingCursor( aPosition );
|
||||
|
||||
if( m_drawItem )
|
||||
@@ -719,13 +722,21 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
break;
|
||||
|
||||
case HK_ROTATE:
|
||||
if( ! itemInEdit )
|
||||
m_drawItem = LocateItemUsingCursor( aPosition );
|
||||
|
||||
if( m_drawItem )
|
||||
if( blocInProgress )
|
||||
{
|
||||
cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
|
||||
HandleBlockPlace( aDC );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !itemInEdit )
|
||||
m_drawItem = LocateItemUsingCursor( aPosition );
|
||||
|
||||
if( m_drawItem )
|
||||
{
|
||||
cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -791,8 +802,7 @@ EDA_HOTKEY* LIB_VIEW_FRAME::GetHotKeyDescription( int aCommand ) const
|
||||
}
|
||||
|
||||
|
||||
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||
EDA_ITEM* aItem )
|
||||
bool LIB_VIEW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
|
||||
{
|
||||
if( aHotKey == 0 )
|
||||
return false;
|
||||
|
||||
@@ -55,10 +55,11 @@
|
||||
|
||||
<!-- the table entries -->
|
||||
<xsl:template match="components/comp">
|
||||
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
|
||||
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
|
||||
<xsl:value-of select="footprint"/><xsl:text>,</xsl:text>
|
||||
<xsl:value-of select="datasheet"/>
|
||||
<xsl:text>"</xsl:text>
|
||||
<xsl:value-of select="@ref"/><xsl:text>","</xsl:text>
|
||||
<xsl:value-of select="value"/><xsl:text>","</xsl:text>
|
||||
<xsl:value-of select="footprint"/><xsl:text>","</xsl:text>
|
||||
<xsl:value-of select="datasheet"/><xsl:text>"</xsl:text>
|
||||
<xsl:apply-templates select="fields"/>
|
||||
<xsl:text>&nl;</xsl:text>
|
||||
</xsl:template>
|
||||
@@ -72,7 +73,7 @@
|
||||
<!-- for all existing head entries -->
|
||||
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||
<xsl:variable name="allnames" select="@name"/>
|
||||
<xsl:text>,</xsl:text>
|
||||
<xsl:text>,"</xsl:text>
|
||||
|
||||
<!-- for all field entries in the remembered fields section -->
|
||||
<xsl:for-each select="$fieldvar">
|
||||
@@ -87,6 +88,8 @@
|
||||
Every non-blank entry is assigned to its proper column.
|
||||
-->
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
+10
-9
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -74,6 +74,8 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
|
||||
_( "Print schematic" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_GEN_PLOT_SCHEMATIC, wxEmptyString, KiBitmap( plot_xpm ),
|
||||
_( "Plot schematic" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
|
||||
@@ -138,6 +140,10 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||
m_mainToolBar->AddTool( ID_TO_LIBVIEW, wxEmptyString, KiBitmap( library_browse_xpm ),
|
||||
HELP_RUN_LIB_VIEWER );
|
||||
|
||||
// modedit is with libedit in a "library section" because the user must have footprints before
|
||||
// they can be assigned.
|
||||
m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString, KiBitmap( module_editor_xpm ),
|
||||
_( "Footprint Editor" ) );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
|
||||
@@ -147,6 +153,9 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||
m_mainToolBar->AddTool( ID_GET_ERC, wxEmptyString, KiBitmap( erc_xpm ),
|
||||
_( "Perform electrical rules check" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
|
||||
_( "Run CvPcb to associate components and footprints" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
|
||||
_( "Generate netlist" ) );
|
||||
|
||||
@@ -156,14 +165,6 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
|
||||
// The user must have footprints before he can assign them. So put this before CvPcb.
|
||||
|
||||
m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString, KiBitmap( module_editor_xpm ),
|
||||
_( "Footprint Editor" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
|
||||
_( "Run CvPcb to associate components and footprints" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiBitmap( pcbnew_xpm ),
|
||||
_( "Run Pcbnew to layout printed circuit board" ) );
|
||||
|
||||
|
||||
@@ -162,17 +162,17 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
||||
{
|
||||
msg = _( "Layer" );
|
||||
msg << wxT( " " ) << ii + 1;
|
||||
m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg );
|
||||
|
||||
if( g_GERBER_List.GetGbrImage( ii ) == NULL ) // Nothing loaded on this draw layer
|
||||
wxStaticBoxSizer* boxSizer = ( ii < 16 ) ? m_leftLayersBoxSizer
|
||||
: m_rightLayersBoxSizer;
|
||||
|
||||
m_BoxSelectLayer[ii] = new wxCheckBox( boxSizer->GetStaticBox(),
|
||||
wxID_ANY, msg );
|
||||
boxSizer->Add( m_BoxSelectLayer[ii], wxGROW | wxLEFT | wxRIGHT | wxTOP );
|
||||
|
||||
if( g_GERBER_List.GetGbrImage( ii ) == NULL )
|
||||
// Nothing loaded on this draw layer
|
||||
m_BoxSelectLayer[ii]->Enable( false );
|
||||
|
||||
if( ii < 16 )
|
||||
m_leftLayersBoxSizer->Add( m_BoxSelectLayer[ii],
|
||||
wxGROW | wxLEFT | wxRIGHT | wxTOP );
|
||||
else
|
||||
m_rightLayersBoxSizer->Add( m_BoxSelectLayer[ii],
|
||||
wxGROW | wxLEFT | wxRIGHT | wxTOP );
|
||||
}
|
||||
|
||||
// Read the scale adjust option
|
||||
|
||||
+2
-5
@@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2009-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -255,9 +255,6 @@ enum main_id
|
||||
ID_EDA_SOCKET_EVENT_SERV,
|
||||
ID_EDA_SOCKET_EVENT,
|
||||
|
||||
// Command IDs common to Pcbnew and CvPcb.
|
||||
ID_PCB_DISPLAY_FOOTPRINT_DOC,
|
||||
|
||||
// Common to all
|
||||
ID_TB_OPTIONS_SELECT_UNIT_MM,
|
||||
ID_TB_OPTIONS_SELECT_UNIT_INCH,
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* 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 3
|
||||
* 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
|
||||
*/
|
||||
#ifndef KICAD_CURL_H_
|
||||
#define KICAD_CURL_H_
|
||||
|
||||
/*
|
||||
* KICAD_CURL.h must be included before wxWidgets because on Windows,
|
||||
* wxWidgets ends up including windows.h before winsocks2.h inside curl
|
||||
* this causes build warnings
|
||||
* Because we are before wx, we must explicitly define we are building with unicode.
|
||||
* wxWidgets defaults to supporting unicode now, so this should be safe.
|
||||
*/
|
||||
#if defined(WIN32)
|
||||
#ifndef UNICODE
|
||||
# define UNICODE
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
# define _UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <string>
|
||||
|
||||
// CURL_EXTERN expands to dllimport on MinGW which causes gcc warnings. This really should
|
||||
// expand to nothing on MinGW.
|
||||
#if defined( __MINGW32__)
|
||||
# if defined( CURL_EXTERN )
|
||||
# undef CURL_EXTERN
|
||||
# define CURL_EXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
struct DYN_LOOKUP;
|
||||
|
||||
|
||||
/**
|
||||
* Class KICAD_CURL
|
||||
* simple wrapper class to call curl_global_init and curl_global_cleanup for KiCad.
|
||||
*/
|
||||
class KICAD_CURL
|
||||
{
|
||||
friend class KICAD_CURL_EASY;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Function Init
|
||||
* calls curl_global_init for the application. It must be used only once
|
||||
* and before any curl functions that perform requests.
|
||||
*
|
||||
* @return bool - True if successful, false if CURL returned an error
|
||||
* @throw IO_ERROR on failure, hopefully with helpful text in it.
|
||||
*/
|
||||
static void Init();
|
||||
|
||||
/**
|
||||
* Function Cleanup
|
||||
* calls curl_global_cleanup for the application. It must be used only after
|
||||
* curl_global_init was called.
|
||||
*/
|
||||
static void Cleanup();
|
||||
|
||||
/**
|
||||
* Function GetVersion
|
||||
* wrapper for curl_version(). Reports back a short string of loaded libraries.
|
||||
*
|
||||
* @return const char* - String reported by libcurl and owned by it.
|
||||
* @throw IO_ERROR on failure, hopefully with helpful text in it.
|
||||
*/
|
||||
static const char* GetVersion()
|
||||
{
|
||||
return curl_version();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function GetSimpleVersion
|
||||
* Reports back curl version only and SSL library support
|
||||
*
|
||||
* @return std::string - Generated version string
|
||||
*/
|
||||
static std::string GetSimpleVersion();
|
||||
};
|
||||
|
||||
#endif // KICAD_CURL_H_
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* 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 3
|
||||
* 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
|
||||
*/
|
||||
#ifndef KICAD_CURL_EASY_H_
|
||||
#define KICAD_CURL_EASY_H_
|
||||
|
||||
/*
|
||||
* KICAD_CURL_EASY.h must included before wxWidgets because on Windows,
|
||||
* wxWidgets ends up including windows.h before winsocks2.h inside curl
|
||||
* this causes build warnings
|
||||
* Because we are before wx, we must explicitly define we are building with unicode
|
||||
* wxWidgets defaults to supporting unicode now, so this should be safe.
|
||||
*/
|
||||
#if defined(WIN32)
|
||||
#ifndef UNICODE
|
||||
# define UNICODE
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
# define _UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <curl/curl.h>
|
||||
#include <kicad_curl/kicad_curl.h>
|
||||
|
||||
|
||||
/**
|
||||
* Class KICAD_CURL_EASY
|
||||
* wrapper interface around the curl_easy API
|
||||
*
|
||||
* Handling of using the curl_easy API to make a request and save the response to
|
||||
* a memory buffer
|
||||
*
|
||||
* Here is a small example usage:
|
||||
* @code
|
||||
* KICAD_CURL_EASY curl;
|
||||
*
|
||||
* curl.SetURL( "http://github.com" );
|
||||
* curl.SetUserAgent( <http-client-indentifier> );
|
||||
* curl.SetHeader( "Accept", "application/json" );
|
||||
* curl.Perform();
|
||||
* @endcode
|
||||
*/
|
||||
class KICAD_CURL_EASY
|
||||
{
|
||||
public:
|
||||
KICAD_CURL_EASY();
|
||||
~KICAD_CURL_EASY();
|
||||
|
||||
/**
|
||||
* Function perform
|
||||
* equivalent to curl_easy_perform. Executes the request
|
||||
* that was previously setup.
|
||||
*
|
||||
* @throw IO_ERROR, if there is a CURL request error
|
||||
*/
|
||||
void Perform();
|
||||
|
||||
/**
|
||||
* Function SetHeader
|
||||
* sets an arbitrary header for the HTTP(s) request.
|
||||
*
|
||||
* @param aName is the left hand side of the header, i.e. Accept without the colon
|
||||
* @param aValue is the right hand side of the header, i.e. application/json
|
||||
*/
|
||||
void SetHeader( const std::string& aName, const std::string& aValue )
|
||||
{
|
||||
std::string header = aName + ':' + aValue;
|
||||
m_headers = curl_slist_append( m_headers, header.c_str() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetUserAgent
|
||||
* sets the request user agent
|
||||
*
|
||||
* @param aAgent is the string to set for the user agent
|
||||
* @return bool - True if successful, false if not
|
||||
*/
|
||||
bool SetUserAgent( const std::string& aAgent )
|
||||
{
|
||||
if( SetOption<const char*>( CURLOPT_USERAGENT, aAgent.c_str() ) == CURLE_OK )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetURL
|
||||
* sets the request URL
|
||||
*
|
||||
* @param aURL is the URL
|
||||
* @return bool - True if successful, false if not
|
||||
*/
|
||||
bool SetURL( const std::string& aURL )
|
||||
{
|
||||
if( SetOption<const char *>( CURLOPT_URL, aURL.c_str() ) == CURLE_OK )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetFollowRedirects
|
||||
* enables the following of HTTP(s) and other redirects, by default curl
|
||||
* does not follow redirects.
|
||||
*
|
||||
* @param aFollow is a boolean where true will enable following redirects
|
||||
* @return bool - True if successful, false if not
|
||||
*/
|
||||
bool SetFollowRedirects( bool aFollow )
|
||||
{
|
||||
if( SetOption<long>( CURLOPT_FOLLOWLOCATION , (aFollow ? 1 : 0) ) == CURLE_OK )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetErrorText
|
||||
* fetches CURL's "friendly" error string for a given error code
|
||||
*
|
||||
* @param aCode is CURL error code
|
||||
* @return const std::string - the corresponding error string for the given code
|
||||
*/
|
||||
const std::string GetErrorText( CURLcode aCode )
|
||||
{
|
||||
return curl_easy_strerror( aCode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetOption
|
||||
* sets a curl option, only supports single parameter curl options
|
||||
*
|
||||
* @param aOption is CURL option, see CURL manual for options
|
||||
* @param aArg is the argument being passed to CURL, ensure it is the right type per manual
|
||||
* @return CURLcode - CURL error code, will return CURLE_OK unless a problem was encountered
|
||||
*/
|
||||
template <typename T> CURLcode SetOption( CURLoption aOption, T aArg )
|
||||
{
|
||||
return curl_easy_setopt( m_CURL, aOption, aArg );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetBuffer
|
||||
* returns a const reference to the recevied data buffer
|
||||
*/
|
||||
const std::string& GetBuffer()
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
private:
|
||||
CURL* m_CURL;
|
||||
curl_slist* m_headers;
|
||||
std::string m_buffer;
|
||||
};
|
||||
|
||||
#endif // KICAD_CURL_EASY_H_
|
||||
@@ -75,6 +75,7 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
|
||||
*/
|
||||
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" )
|
||||
|
||||
|
||||
class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
||||
{
|
||||
friend struct PCB::IFACE;
|
||||
@@ -227,6 +228,13 @@ public:
|
||||
|
||||
void OnQuit( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function GetAutoSaveFilePrefix
|
||||
*
|
||||
* @return the string to prepend to a file name for automatic save.
|
||||
*/
|
||||
static wxString GetAutoSaveFilePrefix();
|
||||
|
||||
/**
|
||||
* Execute a remote command send by Eeschema via a socket,
|
||||
* port KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242)
|
||||
|
||||
@@ -424,11 +424,11 @@ if( KICAD_SCRIPTING_MODULES )
|
||||
pcad2kicadpcb
|
||||
lib_dxf
|
||||
idf3
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
polygon
|
||||
bitmaps
|
||||
gal
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
${PYTHON_LIBRARIES}
|
||||
${PCBNEW_EXTRA_LIBS}
|
||||
@@ -594,8 +594,8 @@ target_link_libraries( pcbnew_kiface
|
||||
gal
|
||||
lib_dxf
|
||||
idf3
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GITHUB_PLUGIN_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
${PYTHON_LIBRARIES}
|
||||
${Boost_LIBRARIES} # must follow GITHUB
|
||||
|
||||
@@ -612,7 +612,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
|
||||
tmpz.x = -tmpz.x;
|
||||
pad->SetDelta( tmpz );
|
||||
|
||||
pad->SetOrientation( 1800 - pad->GetOrientation() );
|
||||
pad->SetOrientation( - pad->GetOrientation() );
|
||||
}
|
||||
|
||||
for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
||||
|
||||
@@ -230,14 +230,15 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
|
||||
|
||||
if( outline->GetLayer() != aLayer )
|
||||
break;
|
||||
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
|
||||
0,
|
||||
aCircleToSegmentsCount,
|
||||
aCorrectionFactor );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
|
||||
0,
|
||||
aCircleToSegmentsCount,
|
||||
aCorrectionFactor );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
|
||||
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
}
|
||||
|
||||
if( TOOL_MANAGER* toolMgr = GetToolManager() )
|
||||
toolMgr->DeactivateTool();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2012 Jean_Pierre Charras <jp.charras at wanadoo.fr>
|
||||
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -772,10 +772,9 @@ const wxString EXCELLON_WRITER::drillFileName( LAYER_PAIR aPair, bool aNPTH ) co
|
||||
wxFileName fn = m_pcb->GetFileName();
|
||||
|
||||
fn.SetName( fn.GetName() + extend );
|
||||
fn.SetPath( "" );
|
||||
fn.SetExt( DrillFileExtension );
|
||||
|
||||
wxString ret = fn.GetFullPath(); // show me in debugger
|
||||
wxString ret = fn.GetFullName(); // show me in debugger
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+38
-11
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -64,6 +64,12 @@ static const wxChar backupSuffix[] = wxT( "-bak" );
|
||||
static const wxChar autosavePrefix[] = wxT( "_autosave-" );
|
||||
|
||||
|
||||
wxString PCB_EDIT_FRAME::GetAutoSaveFilePrefix()
|
||||
{
|
||||
return wxString( autosavePrefix );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function AskLoadBoardFileName
|
||||
* puts up a wxFileDialog asking for a BOARD filename to open.
|
||||
@@ -807,7 +813,7 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName )
|
||||
}
|
||||
|
||||
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n'%s'" ),
|
||||
GetChars( pcbFileName.GetFullPath() ) ) );
|
||||
GetChars( pcbFileName.GetFullPath() ) ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -815,19 +821,40 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName )
|
||||
|
||||
bool PCB_EDIT_FRAME::doAutoSave()
|
||||
{
|
||||
wxFileName tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||
wxFileName fn = tmpFileName;
|
||||
wxFileName tmpFileName;
|
||||
|
||||
// Auto save file name is the normal file name prepended with
|
||||
// autosaveFilePrefix string.
|
||||
fn.SetName( wxString( autosavePrefix ) + fn.GetName() );
|
||||
if( GetBoard()->GetFileName().IsEmpty() )
|
||||
{
|
||||
tmpFileName = wxFileName( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ),
|
||||
KiCadPcbFileExtension );
|
||||
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
||||
}
|
||||
|
||||
wxLogTrace( traceAutoSave,
|
||||
wxT( "Creating auto save file <" + fn.GetFullPath() ) + wxT( ">" ) );
|
||||
wxFileName autoSaveFileName = tmpFileName;
|
||||
|
||||
if( !fn.IsOk() )
|
||||
// Auto save file name is the board file name prepended with autosaveFilePrefix string.
|
||||
autoSaveFileName.SetName( wxString( autosavePrefix ) + autoSaveFileName.GetName() );
|
||||
|
||||
if( !autoSaveFileName.IsOk() )
|
||||
return false;
|
||||
else if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) )
|
||||
|
||||
// If the board file path is not writable, try writing to a platform specific temp file
|
||||
// path. If that path isn't writabe, give up.
|
||||
if( !autoSaveFileName.IsDirWritable() )
|
||||
{
|
||||
autoSaveFileName.SetPath( wxFileName::GetTempDir() );
|
||||
|
||||
if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
|
||||
return false;
|
||||
}
|
||||
|
||||
wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" );
|
||||
|
||||
if( SavePcbFile( autoSaveFileName.GetFullPath(), NO_BACKUP_FILE ) )
|
||||
{
|
||||
GetScreen()->SetModify();
|
||||
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
||||
|
||||
@@ -22,44 +22,21 @@
|
||||
|
||||
|
||||
|
||||
# Download avhttp and install the headers, not actually compiled
|
||||
#################################################
|
||||
include( download_avhttp )
|
||||
|
||||
if( MINGW AND NOT OPENSSL_ROOT_DIR )
|
||||
# download, compile and install to scratch dir a recent OPENSSL library and headers
|
||||
include( download_openssl )
|
||||
else()
|
||||
find_package( OpenSSL REQUIRED )
|
||||
#message( STATUS "OPENSSL_FOUND:${OPENSSL_FOUND} OPENSSL_LIBRARIES:${OPENSSL_LIBRARIES}" )
|
||||
|
||||
# FindOpenSSL.cmake does not set this var into cache, so is not globally visible,
|
||||
# do it here incase some other link image needs these libraries
|
||||
set( OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES}" CACHE FILEPATH "OpenSSL link libraries" )
|
||||
set( OPENSSL_INCLUDE_DIR "${OPENSSL_INCLUDE_DIR}" CACHE FILEPATH "OpenSSL include dir" )
|
||||
endif()
|
||||
|
||||
|
||||
# These are additions to any inherited from pcbnew dir:
|
||||
include_directories( . ${OPENSSL_INCLUDE_DIR} ${AVHTTP_INCLUDE_DIR} )
|
||||
include_directories( . )
|
||||
|
||||
# Tell AVHTTP we have SSL.
|
||||
add_definitions( -DAVHTTP_ENABLE_OPENSSL )
|
||||
|
||||
# tone down the compiler warnings for avhttp header library:
|
||||
set( CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} -Wno-sign-compare -Wno-reorder -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing" )
|
||||
include_directories( ${CURL_INCLUDE_DIRS} )
|
||||
|
||||
set( GITHUB_PLUGIN_SRCS
|
||||
github_plugin.cpp github_getliblist.cpp html_link_parser.cpp
|
||||
github_plugin.cpp
|
||||
github_getliblist.cpp
|
||||
html_link_parser.cpp
|
||||
)
|
||||
|
||||
add_library( github_plugin STATIC ${GITHUB_PLUGIN_SRCS} )
|
||||
|
||||
# No, you don't get github without boost and openssl. Boost_LIBRARIES now moved up
|
||||
# into CMakeLists.txt for pcbnew and cvpcb:
|
||||
target_link_libraries( github_plugin
|
||||
${OPENSSL_LIBRARIES}
|
||||
common
|
||||
)
|
||||
|
||||
if( MINGW )
|
||||
@@ -70,9 +47,4 @@ if( MINGW )
|
||||
endif()
|
||||
|
||||
add_dependencies( github_plugin boost )
|
||||
add_dependencies( github_plugin avhttp )
|
||||
|
||||
if( MINGW AND NOT OPENSSL_ROOT_DIR )
|
||||
add_dependencies( github_plugin openssl )
|
||||
endif()
|
||||
|
||||
|
||||
@@ -35,41 +35,10 @@
|
||||
*
|
||||
* This gets just information on the repo in JSON format.
|
||||
*
|
||||
* I used avhttp, already used in the pcbnew Github plugin to download
|
||||
* the json file.
|
||||
*
|
||||
* JP Charras.
|
||||
*/
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* FIX ME
|
||||
* I do not include avhttp.hpp here, because it is already included in
|
||||
* github_plugin.cpp
|
||||
* and if it is also included in this file, the link fails (double definiton of modules)
|
||||
* therefore, the GITHUB_GETLIBLIST method which uses avhttp to download dats from gitub
|
||||
* is in github_plugin.cpp
|
||||
*/
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
// when WIN32_LEAN_AND_MEAN is defined, some useless includes in <window.h>
|
||||
// are skipped, and this avoid some compil issues
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
// defines needed by avhttp
|
||||
// Minimal Windows version is XP: Google for _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define WINVER 0x0501
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <avhttp.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#include <kicad_curl/kicad_curl_easy.h> // Include before any wx file
|
||||
#include <wx/uri.h>
|
||||
|
||||
#include <github_getliblist.h>
|
||||
@@ -90,6 +59,7 @@ bool GITHUB_GETLIBLIST::Get3DshapesLibsList( wxArrayString* aList,
|
||||
bool (*aFilter)( const wxString& aData ) )
|
||||
{
|
||||
std::string fullURLCommand;
|
||||
|
||||
strcpy( m_option_string, "text/html" );
|
||||
|
||||
wxString repoURL = m_repoURL;
|
||||
@@ -97,7 +67,7 @@ bool GITHUB_GETLIBLIST::Get3DshapesLibsList( wxArrayString* aList,
|
||||
wxString errorMsg;
|
||||
|
||||
fullURLCommand = repoURL.utf8_str();
|
||||
bool success = remote_get_json( &fullURLCommand, &errorMsg );
|
||||
bool success = remoteGetJSON( fullURLCommand, &errorMsg );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
@@ -123,6 +93,7 @@ bool GITHUB_GETLIBLIST::GetFootprintLibraryList( wxArrayString& aList )
|
||||
std::string fullURLCommand;
|
||||
int page = 1;
|
||||
int itemCountMax = 99; // Do not use a valu > 100, it does not work
|
||||
|
||||
strcpy( m_option_string, "application/json" );
|
||||
|
||||
// Github max items returned is 100 per page
|
||||
@@ -147,7 +118,7 @@ bool GITHUB_GETLIBLIST::GetFootprintLibraryList( wxArrayString& aList )
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
bool success = remote_get_json( &fullURLCommand, &errorMsg );
|
||||
bool success = remoteGetJSON( fullURLCommand, &errorMsg );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
@@ -235,3 +206,37 @@ bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError )
|
||||
{
|
||||
KICAD_CURL_EASY kcurl;
|
||||
|
||||
wxLogDebug( wxT( "Attempting to download: " ) + aFullURLCommand );
|
||||
|
||||
kcurl.SetURL( aFullURLCommand );
|
||||
kcurl.SetUserAgent( "http://kicad-pcb.org" );
|
||||
kcurl.SetHeader( "Accept", m_option_string );
|
||||
kcurl.SetFollowRedirects( true );
|
||||
|
||||
try
|
||||
{
|
||||
kcurl.Perform();
|
||||
m_image = kcurl.GetBuffer();
|
||||
return true;
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
if( aMsgError )
|
||||
{
|
||||
UTF8 fmt( _( "Error fetching JSON data from URL '%s'.\nReason: '%s'" ) );
|
||||
|
||||
std::string msg = StrPrintf( fmt.c_str(),
|
||||
aFullURLCommand.c_str(),
|
||||
TO_UTF8( ioe.errorText ) );
|
||||
|
||||
*aMsgError = FROM_UTF8( msg.c_str() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
int aItemCountMax, int aPage = 1 );
|
||||
|
||||
/**
|
||||
* Function remote_get_json
|
||||
* Function remoteGetJSON
|
||||
* Download a json text from a github repo. The text image
|
||||
* is received into the m_input_stream.
|
||||
* @param aFullURLCommand the full command, i.e. the url with options like
|
||||
@@ -111,7 +111,7 @@ protected:
|
||||
* @param aMsgError a pointer to a wxString which can store an error message
|
||||
* @return true if OK, false if error (which an error message in *aMsgError
|
||||
*/
|
||||
bool remote_get_json( std::string* aFullURLCommand, wxString* aMsgError );
|
||||
bool remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError );
|
||||
|
||||
wxString m_github_path; ///< Something like https://api.github.com/orgs/KiCad
|
||||
std::string m_image; ///< image of the downloaded data in its entirety.
|
||||
|
||||
+53
-133
@@ -38,8 +38,7 @@ I have lost my enthusiasm for local caching until a faster time stamp retrieval
|
||||
mechanism can be found, or github gets more servers. But note that the occasionally
|
||||
slow response is the exception rather than the norm. Normally the response is
|
||||
down around a 1/3 of a second. The information we would use is in the header
|
||||
named "Last-Modified" as seen below. This would need parsing, but avhttp may
|
||||
offer some help there, if not, then boost async probably does.
|
||||
named "Last-Modified" as seen below.
|
||||
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
@@ -62,23 +61,9 @@ Access-Control-Expose-Headers: ETag, Link, X-RateLimit-Limit, X-RateLimit-Remain
|
||||
Access-Control-Allow-Origin: *
|
||||
X-GitHub-Request-Id: 411087C2:659E:50FD6E6:52E67F66
|
||||
Vary: Accept-Encoding
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
// when WIN32_LEAN_AND_MEAN is defined, some useless includes in <window.h>
|
||||
// are skipped, and this avoid some compil issues
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
// defines needed by avhttp
|
||||
// Minimal Windows version is XP: Google for _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#define WINVER 0x0501
|
||||
#endif
|
||||
|
||||
#include <kicad_curl/kicad_curl_easy.h> // Include before any wx file
|
||||
#include <sstream>
|
||||
#include <boost/ptr_container/ptr_map.hpp>
|
||||
#include <set>
|
||||
@@ -88,10 +73,6 @@ Vary: Accept-Encoding
|
||||
#include <wx/uri.h>
|
||||
|
||||
#include <fctsys.h>
|
||||
// Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h
|
||||
// in fact after wx/wx.h, included by fctsys.h,
|
||||
// to avoid issues (perhaps due to incompatible defines)
|
||||
#include <avhttp.hpp> // chinese SSL magic
|
||||
|
||||
#include <io_mgr.h>
|
||||
#include <richio.h>
|
||||
@@ -103,6 +84,7 @@ Vary: Accept-Encoding
|
||||
#include <fp_lib_table.h> // ExpandSubstitutions()
|
||||
#include <github_getliblist.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -139,7 +121,7 @@ GITHUB_PLUGIN::~GITHUB_PLUGIN()
|
||||
|
||||
const wxString GITHUB_PLUGIN::PluginName() const
|
||||
{
|
||||
return wxT( "Github" );
|
||||
return "Github";
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +194,8 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
|
||||
|
||||
if( it != m_gh_cache->end() ) // fp_name is present
|
||||
{
|
||||
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
|
||||
//std::string::data() ensures that the referenced data block is contiguous.
|
||||
wxMemoryInputStream mis( m_zip_image.data(), m_zip_image.size() );
|
||||
|
||||
// This decoder should always be UTF8, since it was saved that way by git.
|
||||
// That is, since pretty footprints are UTF8, and they were pushed to the
|
||||
@@ -223,21 +206,17 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
|
||||
if( zis.OpenEntry( *entry ) )
|
||||
{
|
||||
INPUTSTREAM_LINE_READER reader( &zis, aLibraryPath );
|
||||
#if 1
|
||||
|
||||
// I am a PCB_IO derivative with my own PCB_PARSER
|
||||
m_parser->SetLineReader( &reader ); // ownership not passed
|
||||
|
||||
MODULE* ret = (MODULE*) m_parser->Parse();
|
||||
#else
|
||||
PCB_PARSER parser( &reader );
|
||||
|
||||
MODULE* ret = (MODULE*) parser.Parse();
|
||||
#endif
|
||||
|
||||
// Dude, the footprint name comes from the file name in
|
||||
// a github library. Zero out the library name, we don't know it here.
|
||||
// Some caller may set the library nickname, one such instance is
|
||||
// FP_LIB_TABLE::FootprintLoad().
|
||||
// In a github library, (as well as in a "KiCad" library) the name of
|
||||
// the pretty file defines the footprint name. That filename trumps
|
||||
// any name found in the pretty file; any name in the pretty file
|
||||
// must be ignored here. Also, the library nickname is unknown in
|
||||
// this context so clear it just in case.
|
||||
ret->SetFPID( fp_name );
|
||||
|
||||
return ret;
|
||||
@@ -408,7 +387,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP
|
||||
|
||||
if( !wx_pretty_fn.IsOk() ||
|
||||
!wx_pretty_fn.IsDirWritable() ||
|
||||
wx_pretty_fn.GetExt() != wxT( "pretty" )
|
||||
wx_pretty_fn.GetExt() != "pretty"
|
||||
)
|
||||
{
|
||||
wxString msg = wxString::Format(
|
||||
@@ -425,13 +404,13 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP
|
||||
}
|
||||
|
||||
// operator==( wxString, wxChar* ) does not exist, construct wxString once here.
|
||||
const wxString kicad_mod( wxT( "kicad_mod" ) );
|
||||
const wxString kicad_mod( "kicad_mod" );
|
||||
|
||||
//D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n", __func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );)
|
||||
m_gh_cache = new GH_CACHE();
|
||||
|
||||
// INIT_LOGGER( "/tmp", "test.log" );
|
||||
remote_get_zip( aLibraryPath );
|
||||
remoteGetZip( aLibraryPath );
|
||||
// UNINIT_LOGGER();
|
||||
|
||||
m_lib_path = aLibraryPath;
|
||||
@@ -460,7 +439,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP
|
||||
}
|
||||
|
||||
|
||||
bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||
bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL )
|
||||
{
|
||||
// e.g. "https://github.com/liftoff-sr/pretty_footprints"
|
||||
//D(printf("aRepoURL:%s\n", TO_UTF8( aRepoURL ) );)
|
||||
@@ -470,12 +449,12 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||
if( repo.HasServer() && repo.HasPath() )
|
||||
{
|
||||
// scheme might be "http" or if truly github.com then "https".
|
||||
wxString zip_url = repo.GetScheme();
|
||||
|
||||
zip_url += "://";
|
||||
wxString zip_url;
|
||||
|
||||
if( repo.GetServer() == "github.com" )
|
||||
{
|
||||
//codeload.github.com only supports https
|
||||
zip_url = "https://";
|
||||
#if 0 // A proper code path would be this one, but it is not the fastest.
|
||||
zip_url += repo.GetServer();
|
||||
zip_url += repo.GetPath(); // path comes with a leading '/'
|
||||
@@ -488,8 +467,6 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||
|
||||
// In order to bypass this redirect, saving time, we use the
|
||||
// redirected URL on first attempt to save one HTTP GET hit.
|
||||
// avhttp would do the redirect behind the scenes normally, but that would
|
||||
// be slower than doing this bypass.
|
||||
zip_url += "codeload.github.com";
|
||||
zip_url += repo.GetPath(); // path comes with a leading '/'
|
||||
zip_url += "/zip/master";
|
||||
@@ -498,9 +475,11 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||
|
||||
else
|
||||
{
|
||||
zip_url = repo.GetScheme();
|
||||
zip_url += "://";
|
||||
|
||||
// This is the generic code path for any server which can serve
|
||||
// up zip files. The schemes tested include: http and https.
|
||||
// (I don't know what the avhttp library supports beyond that.)
|
||||
|
||||
// zip_url goal: "<scheme>://<server>[:<port>]/<path>"
|
||||
|
||||
@@ -533,9 +512,9 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL )
|
||||
}
|
||||
|
||||
|
||||
void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||
void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||
{
|
||||
string zip_url;
|
||||
std::string zip_url;
|
||||
|
||||
if( !repoURL_zipURL( aRepoURL, &zip_url ) )
|
||||
{
|
||||
@@ -543,107 +522,48 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
|
||||
boost::asio::io_service io;
|
||||
avhttp::http_stream h( io );
|
||||
avhttp::request_opts options;
|
||||
wxLogDebug( wxT( "Attempting to download: " ) + zip_url );
|
||||
|
||||
options.insert( "Accept", "application/zip" );
|
||||
options.insert( "User-Agent", "http://kicad-pcb.org" ); // THAT WOULD BE ME.
|
||||
h.request_options( options );
|
||||
KICAD_CURL_EASY kcurl; // this can THROW_IO_ERROR
|
||||
|
||||
kcurl.SetURL( zip_url.c_str() );
|
||||
kcurl.SetUserAgent( "http://kicad-pcb.org" );
|
||||
kcurl.SetHeader( "Accept", "application/zip" );
|
||||
kcurl.SetFollowRedirects( true );
|
||||
|
||||
try
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
h.open( zip_url ); // only one file, therefore do it synchronously.
|
||||
os << &h;
|
||||
|
||||
// Keep zip file byte image in RAM. That plus the MODULE_MAP will constitute
|
||||
// the cache. We don't cache the MODULEs per se, we parse those as needed from
|
||||
// this zip file image.
|
||||
m_zip_image = os.str();
|
||||
|
||||
// 4 lines, using SSL, top that.
|
||||
kcurl.Perform();
|
||||
m_zip_image = kcurl.GetBuffer();
|
||||
}
|
||||
catch( const boost::system::system_error& e )
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
// https "GET" has faild, report this to API caller.
|
||||
// https "GET" has failed, report this to API caller.
|
||||
// Note: kcurl.Perform() does not return an error if the file to download is not found
|
||||
static const char errorcmd[] = "http GET command failed"; // Do not translate this message
|
||||
|
||||
UTF8 fmt( _( "%s\nCannot get/download Zip archive: '%s'\nfor library path: '%s'.\nReason: '%s'" ) );
|
||||
|
||||
string msg = StrPrintf( fmt.c_str(),
|
||||
errorcmd,
|
||||
// Report both secret zip_url and Lib Path, to user. The secret
|
||||
// zip_url may go bad at some point in future if github changes
|
||||
// their server architecture. Then fix repoURL_zipURL() to reflect
|
||||
// new architecture.
|
||||
zip_url.c_str(), TO_UTF8( aRepoURL ),
|
||||
e.what() );
|
||||
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
catch( const exception& exc )
|
||||
{
|
||||
UTF8 error( _( "Exception '%s' in avhttp while open()-ing URI:'%s'" ) );
|
||||
|
||||
string msg = StrPrintf( error.c_str(), exc.what(), zip_url.c_str() );
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This GITHUB_GETLIBLIST method should not be here, but in github_getliblist.cpp !
|
||||
// However it is here just because we need to include <avhttp.hpp> to compile it.
|
||||
// and when we include avhttp in two .cpp files, the link fails because it detects duplicate
|
||||
// avhttp functions.
|
||||
// So until it is fixed, this code is here.
|
||||
bool GITHUB_GETLIBLIST::remote_get_json( std::string* aFullURLCommand, wxString* aMsgError )
|
||||
{
|
||||
boost::asio::io_service io;
|
||||
avhttp::http_stream h( io );
|
||||
avhttp::request_opts options;
|
||||
|
||||
|
||||
options.insert( "Accept", m_option_string );
|
||||
options.insert( "User-Agent", "http://kicad-pcb.org" ); // THAT WOULD BE ME.
|
||||
h.request_options( options );
|
||||
|
||||
try
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
h.open( *aFullURLCommand ); // only one file, therefore do it synchronously.
|
||||
os << &h;
|
||||
|
||||
// Keep downloaded text file image in RAM.
|
||||
m_image = os.str();
|
||||
|
||||
// 4 lines, using SSL, top that.
|
||||
}
|
||||
catch( boost::system::system_error& e )
|
||||
{
|
||||
// https "GET" has faild, report this to API caller.
|
||||
static const char errorcmd[] = "https GET command failed"; // Do not translate this message
|
||||
|
||||
UTF8 fmt( _( "%s\nCannot get/download data from: '%s'\nReason: '%s'" ) );
|
||||
|
||||
std::string msg = StrPrintf( fmt.c_str(),
|
||||
errorcmd,
|
||||
// Report secret list_url to user. The secret
|
||||
// list_url may go bad at some point in future if github changes
|
||||
// their server architecture. Then fix repoURL_zipURL() to reflect
|
||||
// new architecture.
|
||||
aFullURLCommand->c_str(), e.what() );
|
||||
errorcmd,
|
||||
zip_url.c_str(),
|
||||
TO_UTF8( aRepoURL ),
|
||||
TO_UTF8( ioe.errorText )
|
||||
);
|
||||
|
||||
if( aMsgError )
|
||||
{
|
||||
*aMsgError = FROM_UTF8( msg.c_str() );
|
||||
return false;
|
||||
}
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
|
||||
return true;
|
||||
// If the zip archive is not existing, the received data is "Not Found" or "404: Not Found",
|
||||
// and no error is returned by kcurl.Perform().
|
||||
if( ( m_zip_image.compare( 0, 9, "Not Found", 9 ) == 0 ) ||
|
||||
( m_zip_image.compare( 0, 14, "404: Not Found", 14 ) == 0 ) )
|
||||
{
|
||||
UTF8 fmt( _( "Cannot download library '%s'.\nThe library does not exist on the server" ) );
|
||||
std::string msg = StrPrintf( fmt.c_str(), TO_UTF8( aRepoURL ) );
|
||||
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 && defined(STANDALONE)
|
||||
@@ -657,7 +577,7 @@ int main( int argc, char** argv )
|
||||
try
|
||||
{
|
||||
wxArrayString fps = gh.FootprintEnumerate(
|
||||
wxT( "https://github.com/liftoff-sr/pretty_footprints" ),
|
||||
"https://github.com/liftoff-sr/pretty_footprints",
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -213,11 +213,11 @@ protected:
|
||||
static bool repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL );
|
||||
|
||||
/**
|
||||
* Function remote_get_zip
|
||||
* Function remoteGetZip
|
||||
* fetches a zip file image from a github repo synchronously. The byte image
|
||||
* is received into the m_input_stream.
|
||||
*/
|
||||
void remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR );
|
||||
void remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR );
|
||||
|
||||
wxString m_lib_path; ///< from aLibraryPath, something like https://github.com/liftoff-sr/pretty_footprints
|
||||
std::string m_zip_image; ///< byte image of the zip file in its entirety.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -39,12 +39,12 @@
|
||||
#include <class_pcb_text.h>
|
||||
|
||||
// Keys to store setup in config
|
||||
#define DXF_IMPORT_LAYER_OPTION_KEY wxT("DxfImportBrdLayer")
|
||||
#define DXF_IMPORT_COORD_ORIGIN_KEY wxT("DxfImportCoordOrigin")
|
||||
#define DXF_IMPORT_LAST_FILE_KEY wxT("DxfImportLastFile")
|
||||
#define DXF_IMPORT_GRID_UNITS_KEY wxT("DxfImportGridUnits")
|
||||
#define DXF_IMPORT_GRID_OFFSET_X_KEY wxT("DxfImportGridOffsetX")
|
||||
#define DXF_IMPORT_GRID_OFFSET_Y_KEY wxT("DxfImportGridOffsetY")
|
||||
#define DXF_IMPORT_LAYER_OPTION_KEY "DxfImportBrdLayer"
|
||||
#define DXF_IMPORT_COORD_ORIGIN_KEY "DxfImportCoordOrigin"
|
||||
#define DXF_IMPORT_LAST_FILE_KEY "DxfImportLastFile"
|
||||
#define DXF_IMPORT_GRID_UNITS_KEY "DxfImportGridUnits"
|
||||
#define DXF_IMPORT_GRID_OFFSET_X_KEY "DxfImportGridOffsetX"
|
||||
#define DXF_IMPORT_GRID_OFFSET_Y_KEY "DxfImportGridOffsetY"
|
||||
|
||||
|
||||
// Static members of DIALOG_DXF_IMPORT, to remember
|
||||
@@ -54,10 +54,11 @@ int DIALOG_DXF_IMPORT::m_offsetSelection = 0;
|
||||
LAYER_NUM DIALOG_DXF_IMPORT::m_layer = Dwgs_User;
|
||||
|
||||
|
||||
DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent )
|
||||
DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aUseModuleItems )
|
||||
: DIALOG_DXF_IMPORT_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_dxfImporter.UseModuleItems( aUseModuleItems );
|
||||
m_config = Kiface().KifaceSettings();
|
||||
m_PCBGridUnits = 0;
|
||||
m_PCBGridOffsetX = 0.0;
|
||||
@@ -77,7 +78,7 @@ DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent )
|
||||
wxString tmpStr;
|
||||
tmpStr << m_PCBGridOffsetX;
|
||||
m_DXFPCBXCoord->SetValue( tmpStr );
|
||||
tmpStr = wxT( "" );
|
||||
tmpStr = "";
|
||||
tmpStr << m_PCBGridOffsetY;
|
||||
m_DXFPCBYCoord->SetValue( tmpStr );
|
||||
|
||||
@@ -136,7 +137,7 @@ void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event )
|
||||
wxFileDialog dlg( m_parent,
|
||||
_( "Open File" ),
|
||||
path, filename,
|
||||
wxT( "DXF Files (*.dxf)|*.dxf" ),
|
||||
"DXF Files (*.dxf)|*.dxf",
|
||||
wxFD_OPEN|wxFD_FILE_MUST_EXIST );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
@@ -238,7 +239,7 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
||||
{
|
||||
wxASSERT( aModule );
|
||||
|
||||
DIALOG_DXF_IMPORT dlg( aCaller );
|
||||
DIALOG_DXF_IMPORT dlg( aCaller, true );
|
||||
bool success = ( dlg.ShowModal() == wxID_OK );
|
||||
|
||||
if( success )
|
||||
@@ -252,37 +253,7 @@ bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
|
||||
|
||||
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
|
||||
{
|
||||
BOARD_ITEM* item = *it;
|
||||
BOARD_ITEM* converted = NULL;
|
||||
|
||||
// Modules use different types for the same things,
|
||||
// so we need to convert imported items to appropriate classes.
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_LINE_T:
|
||||
{
|
||||
converted = new EDGE_MODULE( aModule );
|
||||
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
|
||||
aModule->Add( converted );
|
||||
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
|
||||
delete item;
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_TEXT_T:
|
||||
{
|
||||
converted = new TEXTE_MODULE( aModule );
|
||||
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
|
||||
aModule->Add( converted );
|
||||
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
|
||||
delete item;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
wxLogDebug( wxT( "type %d currently not handled" ), item->Type() );
|
||||
break;
|
||||
}
|
||||
aModule->Add( *it );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,6 +276,7 @@ int DIALOG_DXF_IMPORT::GetPCBGridUnits( void )
|
||||
return m_DXFPCBGridUnits->GetSelection();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_DXF_IMPORT::GetPCBGridOffsets( double &aXOffset, double &aYOffset )
|
||||
{
|
||||
aXOffset = DoubleValueFromString( UNSCALED_UNITS, m_DXFPCBXCoord->GetValue() );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -29,7 +29,7 @@
|
||||
class DIALOG_DXF_IMPORT : public DIALOG_DXF_IMPORT_BASE
|
||||
{
|
||||
public:
|
||||
DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent );
|
||||
DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent, bool aUseModuleItems = false );
|
||||
~DIALOG_DXF_IMPORT();
|
||||
|
||||
/**
|
||||
|
||||
+166
-148
@@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -44,8 +44,10 @@
|
||||
#include <macros.h>
|
||||
#include <class_board.h>
|
||||
#include <class_drawsegment.h>
|
||||
#include <class_edge_mod.h>
|
||||
#include <class_pcb_text.h>
|
||||
#include <convert_from_iu.h>
|
||||
#include <class_text_mod.h>
|
||||
#include <drw_base.h>
|
||||
|
||||
// minimum bulge value before resorting to a line segment;
|
||||
@@ -98,9 +100,6 @@ bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of the method which handles layers.
|
||||
*/
|
||||
void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& aData )
|
||||
{
|
||||
// Not yet useful in Pcbnew.
|
||||
@@ -111,12 +110,10 @@ void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& aData )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Import line entities.
|
||||
*/
|
||||
void DXF2BRD_CONVERTER::addLine( const DRW_Line& aData )
|
||||
{
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT;
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
|
||||
|
||||
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
wxPoint start( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
|
||||
@@ -148,7 +145,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData )
|
||||
continue;
|
||||
}
|
||||
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT( NULL );
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
|
||||
new DRAWSEGMENT;
|
||||
|
||||
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
segm->SetStart( segment_startpoint );
|
||||
@@ -163,7 +162,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData )
|
||||
// Polyline flags bit 0 indicates closed (1) or open (0) polyline
|
||||
if( aData.flags & 1 )
|
||||
{
|
||||
DRAWSEGMENT* closing_segm = new DRAWSEGMENT( NULL );
|
||||
DRAWSEGMENT* closing_segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) :
|
||||
new DRAWSEGMENT;
|
||||
|
||||
closing_segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
closing_segm->SetStart( segment_startpoint );
|
||||
@@ -174,6 +175,7 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& aData )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& aData )
|
||||
{
|
||||
// Currently, Pcbnew does not know polylines, for boards.
|
||||
@@ -221,12 +223,11 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& aData )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Import Circle entities.
|
||||
*/
|
||||
|
||||
void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& aData )
|
||||
{
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT;
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
|
||||
|
||||
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
segm->SetShape( S_CIRCLE );
|
||||
@@ -244,7 +245,8 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& aData )
|
||||
*/
|
||||
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
|
||||
{
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT;
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
|
||||
|
||||
segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
segm->SetShape( S_ARC );
|
||||
@@ -276,13 +278,26 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
|
||||
m_newItemsList.push_back( segm );
|
||||
}
|
||||
|
||||
/**
|
||||
* Import texts (TEXT).
|
||||
*/
|
||||
|
||||
void DXF2BRD_CONVERTER::addText( const DRW_Text& aData )
|
||||
{
|
||||
TEXTE_PCB* pcb_text = new TEXTE_PCB( NULL );
|
||||
pcb_text->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
BOARD_ITEM* brdItem;
|
||||
EDA_TEXT* textItem;
|
||||
|
||||
if( m_useModuleItems )
|
||||
{
|
||||
TEXTE_MODULE* modText = new TEXTE_MODULE( NULL );
|
||||
brdItem = static_cast< BOARD_ITEM* >( modText );
|
||||
textItem = static_cast< EDA_TEXT* >( modText );
|
||||
}
|
||||
else
|
||||
{
|
||||
TEXTE_PCB* pcbText = new TEXTE_PCB( NULL );
|
||||
brdItem = static_cast< BOARD_ITEM* >( pcbText );
|
||||
textItem = static_cast< EDA_TEXT* >( pcbText );
|
||||
}
|
||||
|
||||
brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
|
||||
wxPoint refPoint( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
|
||||
wxPoint secPoint( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) );
|
||||
@@ -299,63 +314,63 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData )
|
||||
|
||||
switch( aData.alignV )
|
||||
{
|
||||
case DRW_Text::VBaseLine:
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
break;
|
||||
case DRW_Text::VBaseLine:
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
break;
|
||||
|
||||
case DRW_Text::VBottom:
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
break;
|
||||
case DRW_Text::VBottom:
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
break;
|
||||
|
||||
case DRW_Text::VMiddle:
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
break;
|
||||
case DRW_Text::VMiddle:
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
break;
|
||||
|
||||
case DRW_Text::VTop:
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
break;
|
||||
case DRW_Text::VTop:
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
break;
|
||||
}
|
||||
|
||||
switch( aData.alignH )
|
||||
{
|
||||
case DRW_Text::HLeft:
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
case DRW_Text::HLeft:
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
|
||||
case DRW_Text::HCenter:
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
break;
|
||||
case DRW_Text::HCenter:
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
break;
|
||||
|
||||
case DRW_Text::HRight:
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
break;
|
||||
case DRW_Text::HRight:
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
break;
|
||||
|
||||
case DRW_Text::HAligned:
|
||||
// no equivalent options in text pcb.
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
case DRW_Text::HAligned:
|
||||
// no equivalent options in text pcb.
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
|
||||
case DRW_Text::HMiddle:
|
||||
// no equivalent options in text pcb.
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
break;
|
||||
case DRW_Text::HMiddle:
|
||||
// no equivalent options in text pcb.
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
break;
|
||||
|
||||
case DRW_Text::HFit:
|
||||
// no equivalent options in text pcb.
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
case DRW_Text::HFit:
|
||||
// no equivalent options in text pcb.
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
wxString sty = wxString::FromUTF8(aData.style.c_str());
|
||||
sty=sty.ToLower();
|
||||
wxString sty = wxString::FromUTF8( aData.style.c_str() );
|
||||
sty = sty.ToLower();
|
||||
|
||||
if (aData.textgen==2)
|
||||
if( aData.textgen == 2 )
|
||||
{
|
||||
// Text dir = left to right;
|
||||
} else if (aData.textgen==4)
|
||||
} else if( aData.textgen == 4 )
|
||||
{
|
||||
/ Text dir = top to bottom;
|
||||
// Text dir = top to bottom;
|
||||
} else
|
||||
{
|
||||
}
|
||||
@@ -363,21 +378,19 @@ void DXF2BRD_CONVERTER::addText( const DRW_Text& aData )
|
||||
|
||||
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
|
||||
|
||||
pcb_text->SetTextPosition( refPoint );
|
||||
pcb_text->SetOrientation( aData.angle * 10 );
|
||||
// The 0.8 factor gives a better height/width ratio with our font
|
||||
pcb_text->SetWidth( mapDim( aData.height * 0.8 ) );
|
||||
pcb_text->SetHeight( mapDim( aData.height ) );
|
||||
pcb_text->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
|
||||
pcb_text->SetText( text );
|
||||
textItem->SetTextPosition( refPoint );
|
||||
textItem->SetOrientation( aData.angle * 10 );
|
||||
|
||||
m_newItemsList.push_back( pcb_text );
|
||||
// The 0.8 factor gives a better height/width ratio with our font
|
||||
textItem->SetWidth( mapDim( aData.height * 0.8 ) );
|
||||
textItem->SetHeight( mapDim( aData.height ) );
|
||||
textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
|
||||
textItem->SetText( text );
|
||||
|
||||
m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Import multi line texts (MTEXT).
|
||||
*/
|
||||
void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
|
||||
{
|
||||
wxString text = toNativeString( wxString::FromUTF8( aData.text.c_str() ) );
|
||||
@@ -408,46 +421,63 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
|
||||
text = tmp;
|
||||
}
|
||||
|
||||
TEXTE_PCB* pcb_text = new TEXTE_PCB( NULL );
|
||||
pcb_text->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
BOARD_ITEM* brdItem;
|
||||
EDA_TEXT* textItem;
|
||||
|
||||
if( m_useModuleItems )
|
||||
{
|
||||
TEXTE_MODULE* modText = new TEXTE_MODULE( NULL );
|
||||
brdItem = static_cast< BOARD_ITEM* >( modText );
|
||||
textItem = static_cast< EDA_TEXT* >( modText );
|
||||
}
|
||||
else
|
||||
{
|
||||
TEXTE_PCB* pcbText = new TEXTE_PCB( NULL );
|
||||
brdItem = static_cast< BOARD_ITEM* >( pcbText );
|
||||
textItem = static_cast< EDA_TEXT* >( pcbText );
|
||||
}
|
||||
|
||||
brdItem->SetLayer( ToLAYER_ID( m_brdLayer ) );
|
||||
wxPoint textpos( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
|
||||
pcb_text->SetTextPosition( textpos );
|
||||
pcb_text->SetOrientation( aData.angle * 10 );
|
||||
|
||||
textItem->SetTextPosition( textpos );
|
||||
textItem->SetOrientation( aData.angle * 10 );
|
||||
|
||||
// The 0.8 factor gives a better height/width ratio with our font
|
||||
pcb_text->SetWidth( mapDim( aData.height * 0.8 ) );
|
||||
pcb_text->SetHeight( mapDim( aData.height ) );
|
||||
pcb_text->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
|
||||
pcb_text->SetText( text );
|
||||
textItem->SetWidth( mapDim( aData.height * 0.8 ) );
|
||||
textItem->SetHeight( mapDim( aData.height ) );
|
||||
textItem->SetThickness( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
|
||||
textItem->SetText( text );
|
||||
|
||||
// Initialize text justifications:
|
||||
if( aData.textgen <= 3 )
|
||||
{
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
|
||||
}
|
||||
else if( aData.textgen <= 6 )
|
||||
{
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
|
||||
}
|
||||
else
|
||||
{
|
||||
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
textItem->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||
}
|
||||
|
||||
if( aData.textgen % 3 == 1 )
|
||||
{
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||
}
|
||||
else if( aData.textgen % 3 == 2 )
|
||||
{
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
|
||||
}
|
||||
else
|
||||
{
|
||||
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
textItem->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
}
|
||||
|
||||
#if 0 // These setting have no mening in Pcbnew
|
||||
if( data.alignH==1 )
|
||||
if( data.alignH == 1 )
|
||||
{
|
||||
// Text is left to right;
|
||||
}
|
||||
@@ -460,7 +490,7 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
|
||||
// use ByStyle;
|
||||
}
|
||||
|
||||
if( aData.alignV==1 )
|
||||
if( aData.alignV == 1 )
|
||||
{
|
||||
// use AtLeast;
|
||||
}
|
||||
@@ -470,13 +500,10 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& aData )
|
||||
}
|
||||
#endif
|
||||
|
||||
m_newItemsList.push_back( pcb_text );
|
||||
m_newItemsList.push_back( static_cast< BOARD_ITEM* >( brdItem ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the header variables from the DXF file.
|
||||
*/
|
||||
void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
|
||||
{
|
||||
std::map<std::string, DRW_Variant*>::const_iterator it;
|
||||
@@ -497,77 +524,69 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
|
||||
|
||||
switch( var->content.i )
|
||||
{
|
||||
case 1: // inches
|
||||
m_DXF2mm = 25.4;
|
||||
break;
|
||||
case 1: // inches
|
||||
m_DXF2mm = 25.4;
|
||||
break;
|
||||
|
||||
case 2: // feet
|
||||
m_DXF2mm = 304.8;
|
||||
break;
|
||||
case 2: // feet
|
||||
m_DXF2mm = 304.8;
|
||||
break;
|
||||
|
||||
case 5: // centimeters
|
||||
m_DXF2mm = 10.0;
|
||||
break;
|
||||
case 5: // centimeters
|
||||
m_DXF2mm = 10.0;
|
||||
break;
|
||||
|
||||
case 6: // meters
|
||||
m_DXF2mm = 1000.0;
|
||||
break;
|
||||
case 6: // meters
|
||||
m_DXF2mm = 1000.0;
|
||||
break;
|
||||
|
||||
case 8: // microinches
|
||||
m_DXF2mm = 2.54e-5;
|
||||
break;
|
||||
case 8: // microinches
|
||||
m_DXF2mm = 2.54e-5;
|
||||
break;
|
||||
|
||||
case 9: // mils
|
||||
m_DXF2mm = 0.0254;
|
||||
break;
|
||||
case 9: // mils
|
||||
m_DXF2mm = 0.0254;
|
||||
break;
|
||||
|
||||
case 10: // yards
|
||||
m_DXF2mm = 914.4;
|
||||
break;
|
||||
case 10: // yards
|
||||
m_DXF2mm = 914.4;
|
||||
break;
|
||||
|
||||
case 11: // Angstroms
|
||||
m_DXF2mm = 1.0e-7;
|
||||
break;
|
||||
case 11: // Angstroms
|
||||
m_DXF2mm = 1.0e-7;
|
||||
break;
|
||||
|
||||
case 12: // nanometers
|
||||
m_DXF2mm = 1.0e-6;
|
||||
break;
|
||||
case 12: // nanometers
|
||||
m_DXF2mm = 1.0e-6;
|
||||
break;
|
||||
|
||||
case 13: // micrometers
|
||||
m_DXF2mm = 1.0e-3;
|
||||
break;
|
||||
case 13: // micrometers
|
||||
m_DXF2mm = 1.0e-3;
|
||||
break;
|
||||
|
||||
case 14: // decimeters
|
||||
m_DXF2mm = 100.0;
|
||||
break;
|
||||
case 14: // decimeters
|
||||
m_DXF2mm = 100.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use the default of 1.0 for:
|
||||
// 0: Unspecified Units
|
||||
// 4: mm
|
||||
// 3: miles
|
||||
// 7: kilometers
|
||||
// 15: decameters
|
||||
// 16: hectometers
|
||||
// 17: gigameters
|
||||
// 18: AU
|
||||
// 19: lightyears
|
||||
// 20: parsecs
|
||||
break;
|
||||
default:
|
||||
// use the default of 1.0 for:
|
||||
// 0: Unspecified Units
|
||||
// 4: mm
|
||||
// 3: miles
|
||||
// 7: kilometers
|
||||
// 15: decameters
|
||||
// 16: hectometers
|
||||
// 17: gigameters
|
||||
// 18: AU
|
||||
// 19: lightyears
|
||||
// 20: parsecs
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a native unicode string into a DXF encoded string.
|
||||
*
|
||||
* DXF endoding includes the following special sequences:
|
||||
* - %%%c for a diameter sign
|
||||
* - %%%d for a degree sign
|
||||
* - %%%p for a plus/minus sign
|
||||
*/
|
||||
wxString DXF2BRD_CONVERTER::toDxfString( const wxString& aStr )
|
||||
{
|
||||
wxString res;
|
||||
@@ -622,9 +641,6 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& aStr )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a DXF encoded string into a native Unicode string.
|
||||
*/
|
||||
wxString DXF2BRD_CONVERTER::toNativeString( const wxString& aData )
|
||||
{
|
||||
wxString res;
|
||||
@@ -708,7 +724,8 @@ void DXF2BRD_CONVERTER::addTextStyle( const DRW_Textstyle& aData )
|
||||
void DXF2BRD_CONVERTER::insertLine( const wxRealPoint& aSegStart,
|
||||
const wxRealPoint& aSegEnd, int aWidth )
|
||||
{
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT( NULL );
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
|
||||
wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
|
||||
wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
|
||||
|
||||
@@ -725,7 +742,8 @@ void DXF2BRD_CONVERTER::insertLine( const wxRealPoint& aSegStart,
|
||||
void DXF2BRD_CONVERTER::insertArc( const wxRealPoint& aSegStart, const wxRealPoint& aSegEnd,
|
||||
double aBulge, int aWidth )
|
||||
{
|
||||
DRAWSEGMENT* segm = new DRAWSEGMENT( NULL );
|
||||
DRAWSEGMENT* segm = ( m_useModuleItems ) ?
|
||||
static_cast< DRAWSEGMENT* >( new EDGE_MODULE( NULL ) ) : new DRAWSEGMENT;
|
||||
|
||||
wxPoint segment_startpoint( Millimeter2iu( aSegStart.x ), Millimeter2iu( aSegStart.y ) );
|
||||
wxPoint segment_endpoint( Millimeter2iu( aSegEnd.x ), Millimeter2iu( aSegEnd.y ) );
|
||||
|
||||
@@ -50,11 +50,15 @@ private:
|
||||
int m_brdLayer; // The board layer to place imported DXF items
|
||||
int m_version; // the dxf version, not used here
|
||||
std::string m_codePage; // The code page, not used here
|
||||
bool m_useModuleItems; // Use module items instead of board items when true.
|
||||
|
||||
public:
|
||||
DXF2BRD_CONVERTER();
|
||||
~DXF2BRD_CONVERTER();
|
||||
|
||||
bool IsUsingModuleItems() const { return m_useModuleItems; }
|
||||
void UseModuleItems( bool aUseModuleItems = true ) { m_useModuleItems = aUseModuleItems; }
|
||||
|
||||
/**
|
||||
* Set the coordinate offset between the importede dxf items
|
||||
* and Pcbnew.
|
||||
@@ -151,7 +155,19 @@ private:
|
||||
|
||||
virtual void setBlock( const int aHandle ) {}
|
||||
|
||||
/**
|
||||
* Converts a native unicode string into a DXF encoded string.
|
||||
*
|
||||
* DXF endoding includes the following special sequences:
|
||||
* - %%%c for a diameter sign
|
||||
* - %%%d for a degree sign
|
||||
* - %%%p for a plus/minus sign
|
||||
*/
|
||||
static wxString toDxfString( const wxString& aStr );
|
||||
|
||||
/**
|
||||
* Converts a DXF encoded string into a native Unicode string.
|
||||
*/
|
||||
static wxString toNativeString( const wxString& aData );
|
||||
|
||||
// These functions are not used in Kicad.
|
||||
|
||||
@@ -151,7 +151,7 @@ protected:
|
||||
///> otherwise returns unchanged net code
|
||||
inline int getNetCode( int aNetCode )
|
||||
{
|
||||
if( aNetCode < (int) m_netCodes.size() )
|
||||
if( (unsigned int) aNetCode < m_netCodes.size() )
|
||||
return m_netCodes[aNetCode];
|
||||
|
||||
return aNetCode;
|
||||
|
||||
+3
-2
@@ -993,12 +993,13 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer )
|
||||
{
|
||||
PCB_BASE_FRAME::SetActiveLayer( aLayer );
|
||||
|
||||
GetGalCanvas()->SetHighContrastLayer( aLayer );
|
||||
|
||||
m_Layers->SelectLayer( GetActiveLayer() );
|
||||
m_Layers->OnLayerSelected();
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
GetGalCanvas()->SetHighContrastLayer( aLayer );
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,11 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
// (it depends on the actual board)
|
||||
// So we do not show the default clearance, by setting it to 0
|
||||
// The footprint or pad specific clearance will be shown
|
||||
GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
|
||||
GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
|
||||
|
||||
// Don't show the default board solder mask clearance in the footprint editor. Only the
|
||||
// footprint or pad clearance setting should be shown if it is not 0.
|
||||
GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0;
|
||||
|
||||
// restore the last footprint from the project, if any
|
||||
restoreLastFootprint();
|
||||
@@ -551,6 +555,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
|
||||
aEvent.Check( GetToolId() == aEvent.GetId() );
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
|
||||
+27
-12
@@ -248,10 +248,8 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) throw( PARSE_ERROR, IO_ERROR )
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
if( token != T_LEFT )
|
||||
Expecting( T_LEFT );
|
||||
|
||||
token = NextTok();
|
||||
if( token == T_LEFT )
|
||||
token = NextTok();
|
||||
|
||||
switch( token )
|
||||
{
|
||||
@@ -264,14 +262,14 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText ) throw( PARSE_ERROR, IO_ERROR )
|
||||
switch( token )
|
||||
{
|
||||
case T_size:
|
||||
{
|
||||
wxSize sz;
|
||||
sz.SetHeight( parseBoardUnits( "text height" ) );
|
||||
sz.SetWidth( parseBoardUnits( "text width" ) );
|
||||
aText->SetSize( sz );
|
||||
NeedRIGHT();
|
||||
{
|
||||
wxSize sz;
|
||||
sz.SetHeight( parseBoardUnits( "text height" ) );
|
||||
sz.SetWidth( parseBoardUnits( "text width" ) );
|
||||
aText->SetSize( sz );
|
||||
NeedRIGHT();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case T_thickness:
|
||||
aText->SetThickness( parseBoardUnits( "text thickness" ) );
|
||||
@@ -1960,7 +1958,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments )
|
||||
|
||||
RotatePoint( &pt, module->GetOrientation() );
|
||||
pad->SetPosition( pt + module->GetPosition() );
|
||||
module->Add( pad );
|
||||
module->Add( pad, ADD_APPEND );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2058,6 +2056,23 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR )
|
||||
|
||||
case T_effects:
|
||||
parseEDA_TEXT( (EDA_TEXT*) text.get() );
|
||||
// Due to a double definition (a bug) of SetVisible (one in EDA_TEXT and
|
||||
// one in TEXTE_MODULE), verify if the EDA_TEXT is set to invisible
|
||||
// This allows compatibility with files which could be created
|
||||
// by pcbnew version janv 25, 2017, which fix a old bug (this one)
|
||||
// This compatibility is especially important for footprint files.
|
||||
if( !text->EDA_TEXT::IsVisible() )
|
||||
{
|
||||
// Only if the EDA_TEXT visibility is false, set the
|
||||
// TEXTE_MODULE visibility to false.
|
||||
// in files created by 4.05 version and older, the EDA_TEXT
|
||||
// visibility is always true (the default), due to this bug
|
||||
text->SetVisible( false );
|
||||
// If we want a full compatibiliy with previous stable version,
|
||||
// this ugly workaround avoids writing "hide" token
|
||||
// in "effects" section, when the file comes from some recent pcbnew version
|
||||
text->EDA_TEXT::SetVisible( true );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+10
-4
@@ -609,8 +609,15 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||
// Delete the auto save file if it exists.
|
||||
wxFileName fn = GetBoard()->GetFileName();
|
||||
|
||||
// Auto save file name is the normal file name prefixed with a '$'.
|
||||
fn.SetName( wxT( "$" ) + fn.GetName() );
|
||||
// Auto save file name is the normal file name prefixed with '_autosave'.
|
||||
fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
|
||||
|
||||
// When the auto save feature does not have write access to the board file path, it falls
|
||||
// back to a platform specific user temporary file path.
|
||||
if( !fn.IsOk() || !fn.IsDirWritable() )
|
||||
fn.SetPath( wxFileName::GetTempDir() );
|
||||
|
||||
wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
|
||||
|
||||
// Remove the auto save file on a normal close of Pcbnew.
|
||||
if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
|
||||
@@ -838,14 +845,13 @@ void PCB_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer )
|
||||
{
|
||||
PCB_BASE_FRAME::SetActiveLayer( aLayer );
|
||||
|
||||
GetGalCanvas()->SetHighContrastLayer( aLayer );
|
||||
|
||||
syncLayerWidgetLayer();
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
m_toolManager->RunAction( COMMON_ACTIONS::layerChanged ); // notify other tools
|
||||
GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
|
||||
GetGalCanvas()->SetHighContrastLayer( aLayer );
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
+15
-26
@@ -205,40 +205,29 @@ static bool scriptingSetup()
|
||||
{
|
||||
wxString path_frag;
|
||||
|
||||
#if defined( __MINGW32__ )
|
||||
// force python environment under Windows:
|
||||
const wxString python_us( wxT( "python27_us" ) );
|
||||
#if defined( __WINDOWS__ )
|
||||
// If our python.exe (in kicad/bin) exists, force our kicad python environment
|
||||
wxString kipython = FindKicadFile( "python.exe" );
|
||||
|
||||
// Build our python path inside kicad
|
||||
wxString kipython = FindKicadFile( python_us + wxT( "/python.exe" ) );
|
||||
|
||||
//we need only the path:
|
||||
wxFileName fn( kipython );
|
||||
// we need only the path:
|
||||
wxFileName fn( kipython );
|
||||
kipython = fn.GetPath();
|
||||
|
||||
// If our python install is existing inside kicad, use it
|
||||
// Note: this is usefull only when an other python version is installed
|
||||
if( wxDirExists( kipython ) )
|
||||
{
|
||||
// clear any PYTHONPATH and PYTHONHOME env var definition: the default
|
||||
// values work fine inside Kicad:
|
||||
wxSetEnv( wxT( "PYTHONPATH" ), wxEmptyString );
|
||||
wxSetEnv( wxT( "PYTHONHOME" ), wxEmptyString );
|
||||
|
||||
// Add our python executable path in first position:
|
||||
wxString ppath;
|
||||
wxGetEnv( wxT( "PATH" ), &ppath );
|
||||
|
||||
if( !wxGetEnv( wxT( "PYTHONPATH" ), &ppath ) || !ppath.Contains( python_us ) )
|
||||
{
|
||||
ppath << kipython << wxT( "/pylib;" );
|
||||
ppath << kipython << wxT( "/lib;" );
|
||||
ppath << kipython << wxT( "/dll" );
|
||||
wxSetEnv( wxT( "PYTHONPATH" ), ppath );
|
||||
// DBG( std::cout << "set PYTHONPATH to " << TO_UTF8( ppath ) << "\n"; )
|
||||
|
||||
// Add python executable path:
|
||||
wxGetEnv( wxT( "PATH" ), &ppath );
|
||||
|
||||
if( !ppath.Contains( python_us ) )
|
||||
{
|
||||
kipython << wxT( ";" ) << ppath;
|
||||
wxSetEnv( wxT( "PATH" ), kipython );
|
||||
// DBG( std::cout << "set PATH to " << TO_UTF8( kipython ) << "\n"; )
|
||||
}
|
||||
}
|
||||
kipython << wxT( ";" ) << ppath;
|
||||
wxSetEnv( wxT( "PATH" ), kipython );
|
||||
}
|
||||
|
||||
// TODO: make this path definable by the user, and set more than one path
|
||||
|
||||
@@ -486,6 +486,13 @@ bool ROUTER_TOOL::onViaCommand( TOOL_EVENT& aEvent, VIATYPE_T aType )
|
||||
bool ROUTER_TOOL::prepareInteractive()
|
||||
{
|
||||
int routingLayer = getStartLayer( m_startItem );
|
||||
|
||||
if( !IsCopperLayer( routingLayer ) )
|
||||
{
|
||||
DisplayError( m_frame, _( "Tracks on Copper layers only " ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_frame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
|
||||
|
||||
// fixme: switch on invisible layer
|
||||
|
||||
@@ -447,7 +447,10 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList_NG( BOARD* aPcb )
|
||||
if (g_DumpZonesWhenFilling)
|
||||
dumper->Write( &holes, "feature-holes-postsimplify" );
|
||||
|
||||
solidAreas.BooleanSubtract( holes, true );
|
||||
// Generate the filled areas (currently, without thermal shapes, which will
|
||||
// be created later).
|
||||
// Generate strictly simple polygons needed by Gerber files and Fracture()
|
||||
solidAreas.BooleanSubtract( holes, false );
|
||||
|
||||
if (g_DumpZonesWhenFilling)
|
||||
dumper->Write( &solidAreas, "solid-areas-minus-holes" );
|
||||
@@ -476,8 +479,9 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList_NG( BOARD* aPcb )
|
||||
if( !thermalHoles.IsEmpty() )
|
||||
{
|
||||
thermalHoles.Simplify();
|
||||
// Remove unconnected stubs
|
||||
solidAreas.BooleanSubtract( thermalHoles );
|
||||
// Remove unconnected stubs.
|
||||
// Generate strictly simple polygons needed by Gerber files and Fracture()
|
||||
solidAreas.BooleanSubtract( thermalHoles, false );
|
||||
|
||||
if( g_DumpZonesWhenFilling )
|
||||
dumper->Write( &thermalHoles, "thermal-holes" );
|
||||
|
||||
Reference in New Issue
Block a user