Resync with main branch r6482

This commit is contained in:
Cirilo Bernardo 2016-01-16 19:10:53 +11:00
commit e185b29baa
99 changed files with 2820 additions and 1180 deletions

View File

@ -0,0 +1,342 @@
#.rst:
# FindOpenSSL
# -----------
#
# Try to find the OpenSSL encryption library
#
# Once done this will define
#
# ::
#
# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL
#
#
#
# Read-Only variables:
#
# ::
#
# OPENSSL_FOUND - system has the OpenSSL library
# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s)
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright 2009-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if (UNIX)
find_package(PkgConfig QUIET)
pkg_check_modules(_OPENSSL QUIET openssl)
endif ()
if (WIN32)
# http://www.slproweb.com/products/Win32OpenSSL.html
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
ENV OPENSSL_ROOT_DIR
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"${_programfiles}/OpenSSL"
"${_programfiles}/OpenSSL-Win32"
"${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL/"
"C:/OpenSSL-Win32/"
"C:/OpenSSL-Win64/"
)
unset(_programfiles)
else ()
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
ENV OPENSSL_ROOT_DIR
)
endif ()
set(_OPENSSL_ROOT_HINTS_AND_PATHS
HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS}
)
find_path(OPENSSL_INCLUDE_DIR
NAMES
openssl/ssl.h
${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS
${_OPENSSL_INCLUDEDIR}
PATH_SUFFIXES
include
)
if(WIN32 AND NOT CYGWIN)
if(MSVC)
# /MD and /MDd are the standard values - if someone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
# TODO: handle /MT and static lib
# In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
# * MD for dynamic-release
# * MDd for dynamic-debug
# * MT for static-release
# * MTd for static-debug
# Implementation details:
# We are using the libraries located in the VC subdir instead of the parent directory eventhough :
# libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib
find_library(LIB_EAY_DEBUG
NAMES
libeay32MDd
libeay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
find_library(LIB_EAY_RELEASE
NAMES
libeay32MD
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
find_library(SSL_EAY_DEBUG
NAMES
ssleay32MDd
ssleay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
find_library(SSL_EAY_RELEASE
NAMES
ssleay32MD
ssleay32
ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
)
set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(LIB_EAY)
select_library_configurations(SSL_EAY)
mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} )
elseif(MINGW)
message( STATUS "Searching for OpenSSL in MinGW." )
# same player, for MinGW
set(LIB_EAY_NAMES libeay32)
set(SSL_EAY_NAMES ssleay32)
list(APPEND LIB_EAY_NAMES crypto)
list(APPEND SSL_EAY_NAMES ssl)
find_library(LIB_EAY
NAMES
${LIB_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
# Do not search system path. Otherwise the DLL will be found rather than the link library.
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)
find_library(SSL_EAY
NAMES
${SSL_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
# Do not search system path. Otherwise the DLL will be found rather than the link library.
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)
mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
unset(LIB_EAY_NAMES)
unset(SSL_EAY_NAMES)
else()
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
find_library(LIB_EAY
NAMES
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
find_library(SSL_EAY
NAMES
ssleay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
endif()
else()
find_library(OPENSSL_SSL_LIBRARY
NAMES
ssl
ssleay32
ssleay32MD
${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
find_library(OPENSSL_CRYPTO_LIBRARY
NAMES
crypto
${_OPENSSL_ROOT_HINTS_AND_PATHS}
HINTS
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
# compat defines
set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
endif()
function(from_hex HEX DEC)
string(TOUPPER "${HEX}" HEX)
set(_res 0)
string(LENGTH "${HEX}" _strlen)
while (_strlen GREATER 0)
math(EXPR _res "${_res} * 16")
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
string(SUBSTRING "${HEX}" 1 -1 HEX)
if (NIBBLE STREQUAL "A")
math(EXPR _res "${_res} + 10")
elseif (NIBBLE STREQUAL "B")
math(EXPR _res "${_res} + 11")
elseif (NIBBLE STREQUAL "C")
math(EXPR _res "${_res} + 12")
elseif (NIBBLE STREQUAL "D")
math(EXPR _res "${_res} + 13")
elseif (NIBBLE STREQUAL "E")
math(EXPR _res "${_res} + 14")
elseif (NIBBLE STREQUAL "F")
math(EXPR _res "${_res} + 15")
else()
math(EXPR _res "${_res} + ${NIBBLE}")
endif()
string(LENGTH "${HEX}" _strlen)
endwhile()
set(${DEC} ${_res} PARENT_SCOPE)
endfunction()
if (OPENSSL_INCLUDE_DIR)
if (_OPENSSL_VERSION)
set(OPENSSL_VERSION "${_OPENSSL_VERSION}")
elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
# The status gives if this is a developer or prerelease and is ignored here.
# Major, minor, and fix directly translate into the version numbers shown in
# the string. The patch field translates to the single character suffix that
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
# on.
message(STATUS "OPENSSL_VERSION_STR=${openssl_version_str}")
string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
# 96 is the ASCII code of 'a' minus 1
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
unset(_tmp)
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
# this should be updated to handle that, too. This has not happened yet
# so it is simply ignored here for now.
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
endif ()
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
endif ()
endif ()
include(FindPackageHandleStandardArgs)
if (OPENSSL_VERSION)
find_package_handle_standard_args(OpenSSL
REQUIRED_VARS
OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
)
else ()
find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR
)
endif ()
mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)

View File

@ -2,7 +2,6 @@
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
../potrace
../common
../polygon
${INC_AFTER}
)

View File

@ -30,19 +30,19 @@
#include <confirm.h>
#include <gestfich.h>
#include <wildcards_and_files_ext.h>
#include <bitmap2cmp_gui_base.h>
#include <bitmap2component.h>
#include <potracelib.h>
#include <bitmap_io.h>
#include <colors_selection.h>
#include <build_version.h>
#include <menus_helpers.h>
#include <kiway.h>
#include <kiface_i.h>
#include <potracelib.h>
#include "bitmap2component.h"
#include "bitmap2cmp_gui_base.h"
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )

View File

@ -21,28 +21,24 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cmath>
#include <algorithm> // std::max
// For some unknown reasons, polygon.hpp should be included first
#include <boost/polygon/polygon.hpp>
#include <wx/wx.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <cmath>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <layers_id_colors_and_visibility.h>
#include <common.h>
#include <bitmap2component.h>
#include <geometry/shape_poly_set.h>
#include <layers_id_colors_and_visibility.h>
// include this after shape_poly_set.h to avoid redefinition of min, max ...
#include <potracelib.h>
#include "bitmap2component.h"
/* free a potrace bitmap */
static void bm_free( potrace_bitmap_t* bm )
{
@ -60,14 +56,14 @@ static void bm_free( potrace_bitmap_t* bm )
class BITMAPCONV_INFO
{
public:
enum OUTPUT_FMT_ID m_Format; // File format
enum OUTPUT_FMT_ID m_Format; // File format
int m_PixmapWidth;
int m_PixmapHeight; // the bitmap size in pixels
double m_ScaleX;
double m_ScaleY; // the conversion scale
potrace_path_t* m_Paths; // the list of paths, from potrace (list of lines and bezier curves)
FILE* m_Outfile; // File to create
const char * m_CmpName; // The string used as cmp/footprint name
const char * m_CmpName; // The string used as cmp/footprint name
public:
BITMAPCONV_INFO();

View File

@ -1,6 +1,7 @@
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
./dialogs
./widgets
./dialog_about
${CAIRO_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
@ -12,6 +13,12 @@ include_directories(
${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(
@ -138,6 +145,9 @@ set( COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp
dialog_about/dialog_about.cpp
dialog_about/dialog_about_base.cpp
)
set( COMMON_DLG_SRCS
dialogs/dialog_display_info_HTML_base.cpp
dialogs/dialog_exit_base.cpp
dialogs/dialog_image_editor.cpp
@ -154,6 +164,10 @@ set( COMMON_ABOUT_DLG_SRCS
dialogs/wx_html_report_panel.cpp
)
set( COMMON_WIDGET_SRCS
widgets/widget_hotkey_list.cpp
)
set( COMMON_PAGE_LAYOUT_SRCS
page_layout/title_block_shapes.cpp
page_layout/class_worksheet_dataitem.cpp
@ -167,6 +181,8 @@ set( COMMON_PAGE_LAYOUT_SRCS
set( COMMON_SRCS
${LIB_KICAD_SRCS}
${COMMON_ABOUT_DLG_SRCS}
${COMMON_DLG_SRCS}
${COMMON_WIDGET_SRCS}
${COMMON_PAGE_LAYOUT_SRCS}
base_struct.cpp
basicframe.cpp
@ -285,7 +301,8 @@ add_dependencies( common lib-dependencies )
add_dependencies( common version_header )
target_link_libraries( common
${Boost_LIBRARIES}
# ${CURL_LIBRARIES} we dynamically link to this ON DEMAND, not at load time
${CURL_LIBRARIES}
${OPENSSL_LIBRARIES} # empty on Apple
)

View File

@ -28,7 +28,6 @@
* @brief EDA_BASE_FRAME class implementation.
*/
#include <kicad_curl/kicad_curl.h> /* Include before any wx file */
#include <wx/aboutdlg.h>
#include <wx/fontdlg.h>
#include <wx/clipbrd.h>
@ -40,7 +39,6 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <online_help.h>
#include <id.h>
#include <eda_doc.h>
#include <wxstruct.h>
@ -574,8 +572,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
<< ( BOOST_VERSION % 100 ) << wxT( "\n" );
msg_version << KICAD_CURL::GetSimpleVersion() << wxT( "\n" );
msg_version << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
#ifdef USE_WX_GRAPHICS_CONTEXT
msg_version << wxT( "ON\n" );

View File

@ -23,7 +23,6 @@
*/
#include <bin_mod.h>
#include <online_help.h>
#include <common.h>

View File

@ -21,320 +21,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <fctsys.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <dialog_hotkeys_editor.h>
class DIALOG_HOTKEY_CLIENT_DATA : public wxClientData
{
EDA_HOTKEY m_hotkey;
wxString m_section_tag;
public:
DIALOG_HOTKEY_CLIENT_DATA( const EDA_HOTKEY& aHotkey, const wxString& aSectionTag )
: m_hotkey( aHotkey ), m_section_tag( aSectionTag ) {}
EDA_HOTKEY& GetHotkey() { return m_hotkey; }
wxString GetSectionTag() const { return m_section_tag; }
};
HOTKEY_LIST_CTRL::HOTKEY_LIST_CTRL( wxWindow *aParent, const HOTKEYS_SECTIONS& aSections ) :
wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
m_sections( aSections )
{
AppendColumn( _( "Command" ) );
AppendColumn( _( "Hotkey" ) );
SetColumnWidth( 1, 100 );
Bind( wxEVT_CHAR, &HOTKEY_LIST_CTRL::OnChar, this );
}
void HOTKEY_LIST_CTRL::DeselectRow( int aRow )
{
wxASSERT( aRow >= 0 && aRow < (int)m_items.size() );
Unselect( m_items[aRow] );
}
void HOTKEY_LIST_CTRL::OnChar( wxKeyEvent& aEvent )
{
DIALOG_HOTKEY_CLIENT_DATA* data = GetSelHKClientData();
if( data )
{
long key = aEvent.GetKeyCode();
switch( key )
{
case WXK_ESCAPE:
UnselectAll();
break;
default:
if( key >= 'a' && key <= 'z' ) // convert to uppercase
key = key + ('A' - 'a');
// Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
// to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z'
if( aEvent.ControlDown() && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
key += 'A' - 1;
/* Disallow shift for keys that have two keycodes on them (e.g. number and
* punctuation keys) leaving only the "letter keys" of A-Z.
* Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
* and Ctrl-( and Ctrl-5 (FR layout).
* Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
*/
bool keyIsLetter = key >= 'A' && key <= 'Z';
if( aEvent.ShiftDown() && ( keyIsLetter || key > 256 ) )
key |= GR_KB_SHIFT;
if( aEvent.ControlDown() )
key |= GR_KB_CTRL;
if( aEvent.AltDown() )
key |= GR_KB_ALT;
// See if this key code is handled in hotkeys names list
bool exists;
KeyNameFromKeyCode( key, &exists );
if( exists && data->GetHotkey().m_KeyCode != key )
{
wxString tag = data->GetSectionTag();
bool canUpdate = ResolveKeyConflicts( key, tag );
if( canUpdate )
{
data->GetHotkey().m_KeyCode = key;
}
// Remove selection
UnselectAll();
}
}
}
UpdateFromClientData();
}
DIALOG_HOTKEY_CLIENT_DATA* HOTKEY_LIST_CTRL::GetSelHKClientData()
{
return GetHKClientData( GetSelection() );
}
DIALOG_HOTKEY_CLIENT_DATA* HOTKEY_LIST_CTRL::GetHKClientData( wxTreeListItem aItem )
{
if( aItem.IsOk() )
{
wxClientData* data = GetItemData( aItem );
if( !data )
return NULL;
DIALOG_HOTKEY_CLIENT_DATA* hkdata = static_cast<DIALOG_HOTKEY_CLIENT_DATA*>( data );
return hkdata;
}
else
{
return NULL;
}
}
void HOTKEY_LIST_CTRL::LoadSection( struct EDA_HOTKEY_CONFIG* aSection )
{
HOTKEY_LIST list;
EDA_HOTKEY** info_ptr;
for( info_ptr = aSection->m_HK_InfoList; *info_ptr; info_ptr++ )
{
EDA_HOTKEY info = **info_ptr;
list.push_back( info );
}
m_hotkeys.push_back( list );
}
void HOTKEY_LIST_CTRL::UpdateFromClientData()
{
for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
{
DIALOG_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( i );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
wxString name = wxGetTranslation( hk.m_InfoMsg );
wxString key = KeyNameFromKeyCode( hk.m_KeyCode );
SetItemText( i, 0, name );
SetItemText( i, 1, key );
}
}
bool HOTKEY_LIST_CTRL::TransferDataToControl()
{
Freeze();
DeleteAllItems();
m_items.clear();
m_hotkeys.clear();
HOTKEYS_SECTIONS::iterator sec_it;
size_t sec_index = 0;
for( sec_it = m_sections.begin(); sec_it != m_sections.end(); ++sec_it, ++sec_index )
{
LoadSection( sec_it->second );
wxString section_tag = *( sec_it->second->m_SectionTag );
// Create parent item
wxTreeListItem parent = AppendItem( GetRootItem(), sec_it->first );
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
HOTKEY_LIST::iterator hk_it;
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
{
wxTreeListItem item = AppendItem( parent, wxEmptyString );
SetItemData( item, new DIALOG_HOTKEY_CLIENT_DATA( &*hk_it, section_tag ) );
m_items.push_back( item );
}
Expand( parent );
}
UpdateFromClientData();
Thaw();
return true;
}
bool HOTKEY_LIST_CTRL::TransferDataFromControl()
{
for( size_t i_sec = 0; i_sec < m_sections.size(); ++i_sec )
{
struct EDA_HOTKEY_CONFIG* section = m_sections[i_sec].second;
for( EDA_HOTKEY** info_ptr = section->m_HK_InfoList; *info_ptr; ++info_ptr )
{
EDA_HOTKEY* info = *info_ptr;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
DIALOG_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
if( hk.m_Idcommand == info->m_Idcommand )
{
info->m_KeyCode = hk.m_KeyCode;
break;
}
}
}
}
return true;
}
bool HOTKEY_LIST_CTRL::ResolveKeyConflicts( long aKey, const wxString& aSectionTag )
{
EDA_HOTKEY* conflictingKey = NULL;
EDA_HOTKEY_CONFIG* conflictingSection = NULL;
CheckKeyConflicts( aKey, aSectionTag, &conflictingKey, &conflictingSection );
if( conflictingKey != NULL )
{
wxString info = wxGetTranslation( conflictingKey->m_InfoMsg );
wxString msg = wxString::Format(
_( "<%s> is already assigned to \"%s\" in section \"%s\". Are you sure you want "
"to change its assignment?" ),
KeyNameFromKeyCode( aKey ), GetChars( info ),
*(conflictingSection->m_Title) );
wxMessageDialog dlg( m_parent, msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
if( dlg.ShowModal() == wxID_YES )
{
conflictingKey->m_KeyCode = 0;
UpdateFromClientData();
return true;
}
else
{
return false;
}
}
return true;
}
bool HOTKEY_LIST_CTRL::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
{
EDA_HOTKEY* conflictingKey = NULL;
struct EDA_HOTKEY_CONFIG* conflictingSection = NULL;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
DIALOG_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
wxString tag = hkdata->GetSectionTag();
if( aSectionTag != g_CommonSectionTag
&& tag != g_CommonSectionTag
&& tag != aSectionTag )
continue;
if( aKey == hk.m_KeyCode )
{
conflictingKey = &hk;
// Find the section
HOTKEYS_SECTIONS::iterator it;
for( it = m_sections.begin(); it != m_sections.end(); ++it )
{
if( *it->second->m_SectionTag == tag )
{
conflictingSection = it->second;
break;
}
}
}
}
if( aConfKey )
*aConfKey = conflictingKey;
if( aConfSect )
*aConfSect = conflictingSection;
return conflictingKey == NULL;
}
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
{
HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );
int diag = dialog.ShowModal();
if( diag == wxID_OK )
{
aParent->ReCreateMenuBar();
@ -343,26 +37,18 @@ void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
}
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent,
EDA_HOTKEY_CONFIG* aHotkeys ) :
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent,
EDA_HOTKEY_CONFIG* aHotkeys ) :
HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
m_parent( aParent ),
m_hotkeys( aHotkeys )
{
EDA_HOTKEY_CONFIG* section;
HOTKEYS_SECTIONS sections;
for( section = m_hotkeys; section->m_HK_InfoList; section++ )
{
HOTKEYS_SECTION sec( wxGetTranslation( *section->m_Title ), section );
sections.push_back( sec );
}
m_hotkeyListCtrl = new HOTKEY_LIST_CTRL( this, sections );
m_mainSizer->Insert( 1, m_hotkeyListCtrl, wxSizerFlags( 1 ).Expand().Border( wxALL, 5 ) );
Layout();
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys,
WIDGET_HOTKEY_LIST::GenSections( aHotkeys ) );
m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys );
m_sdbSizerOK->SetDefault();
Layout();
Center();
}
@ -388,7 +74,7 @@ bool HOTKEYS_EDITOR_DIALOG::TransferDataFromWindow()
return false;
// save the hotkeys
m_parent->WriteHotkeyConfig( m_hotkeys );
GetParent()->WriteHotkeyConfig( m_hotkeys );
return true;
}
@ -398,4 +84,3 @@ void HOTKEYS_EDITOR_DIALOG::ResetClicked( wxCommandEvent& aEvent )
{
m_hotkeyListCtrl->TransferDataToControl();
}

View File

@ -15,10 +15,13 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind
m_mainSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Select a row and press a new key combination to alter the binding."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( 400 );
m_mainSizer->Add( m_staticText1, 0, wxALL|wxEXPAND, 5 );
m_panelHotkeys = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_mainSizer->Add( m_panelHotkeys, 1, wxEXPAND | wxALL, 5 );
wxBoxSizer* b_buttonsSizer;
b_buttonsSizer = new wxBoxSizer( wxHORIZONTAL );

View File

@ -125,7 +125,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Select a row and press a new key combination to alter the binding.</property>
<property name="label">Double-click to edit</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -176,6 +176,86 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelHotkeys</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxEXPAND</property>

View File

@ -20,6 +20,7 @@ class DIALOG_SHIM;
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/panel.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
@ -37,6 +38,7 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM
protected:
wxBoxSizer* m_mainSizer;
wxStaticText* m_staticText1;
wxPanel* m_panelHotkeys;
wxButton* m_resetButton;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;

View File

@ -147,6 +147,9 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_gal->BeginDrawing();
m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() );
KIGFX::COLOR4D gridColor = static_cast<KIGFX::PCB_RENDER_SETTINGS*> (m_painter->GetSettings())->GetLayerColor( ITEM_GAL_LAYER ( GRID_VISIBLE ) );
m_gal->SetGridColor ( gridColor );
if( m_view->IsDirty() )
{
m_view->ClearTargets();

View File

@ -302,6 +302,12 @@ void SHAPE_POLY_SET::BooleanIntersection( const SHAPE_POLY_SET& a, const SHAPE_P
void SHAPE_POLY_SET::Inflate( int aFactor, int aCircleSegmentsCount )
{
// A static table to avoid repetitive calculations of the coefficient
// 1.0 - cos( M_PI/aCircleSegmentsCount)
// aCircleSegmentsCount is most of time <= 64 and usually 8, 12, 16, 32
#define SEG_CNT_MAX 64
static double arc_tolerance_factor[SEG_CNT_MAX+1];
ClipperOffset c;
BOOST_FOREACH( const POLYGON& poly, m_polys )
@ -312,7 +318,27 @@ void SHAPE_POLY_SET::Inflate( int aFactor, int aCircleSegmentsCount )
PolyTree solution;
c.ArcTolerance = fabs( (double) aFactor ) / M_PI / aCircleSegmentsCount;
// Calculate the arc tolerance (arc error) from the seg count by circle.
// the seg count is nn = M_PI / acos(1.0 - c.ArcTolerance / abs(aFactor))
// see:
// www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/ClipperOffset/Properties/ArcTolerance.htm
if( aCircleSegmentsCount < 6 ) // avoid incorrect aCircleSegmentsCount values
aCircleSegmentsCount = 6;
double coeff;
if( aCircleSegmentsCount > SEG_CNT_MAX || arc_tolerance_factor[aCircleSegmentsCount] == 0 )
{
coeff = 1.0 - cos( M_PI/aCircleSegmentsCount);
if( aCircleSegmentsCount <= SEG_CNT_MAX )
arc_tolerance_factor[aCircleSegmentsCount] = coeff;
}
else
coeff = arc_tolerance_factor[aCircleSegmentsCount];
c.ArcTolerance = std::abs( aFactor ) * coeff;
c.Execute( solution, aFactor );

View File

@ -2,6 +2,7 @@
* 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
@ -26,56 +27,106 @@
#include <wx/dynlib.h>
#include <macros.h>
#include <fctsys.h>
#include <kicad_curl/kicad_curl.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;
static MUTEX s_lock; // for s_initialized
// Assume that on these platforms libcurl uses OpenSSL
#if defined(__linux__) || defined(_WIN32)
void (CURL_EXTERN * KICAD_CURL::easy_cleanup) ( CURL* curl );
CURL* (CURL_EXTERN * KICAD_CURL::easy_init) ( void );
CURLcode (CURL_EXTERN * KICAD_CURL::easy_perform) ( CURL* curl );
CURLcode (CURL_EXTERN * KICAD_CURL::easy_setopt) ( CURL* curl, CURLoption option, ... );
const char* (CURL_EXTERN * KICAD_CURL::easy_strerror) ( CURLcode );
CURLcode (CURL_EXTERN * KICAD_CURL::global_init) ( long flags );
void (CURL_EXTERN * KICAD_CURL::global_cleanup) ( void );
curl_slist* (CURL_EXTERN * KICAD_CURL::slist_append) ( curl_slist*, const char* );
void (CURL_EXTERN * KICAD_CURL::slist_free_all) ( curl_slist* );
char* (CURL_EXTERN * KICAD_CURL::version) ( void );
curl_version_info_data* (CURL_EXTERN * KICAD_CURL::version_info) (CURLversion);
#include <openssl/crypto.h>
static MUTEX* s_crypto_locks;
struct DYN_LOOKUP
static void lock_callback( int mode, int type, const char* file, int line )
{
const char* name;
void** address;
};
(void)file;
(void)line;
// May need to modify "name" for each platform according to how libcurl is built on
// that platform and the spelling or partial mangling of C function names. On linux
// there is no mangling.
#define DYN_PAIR( basename ) { "curl_" #basename, (void**) &KICAD_CURL::basename }
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();
}
}
const DYN_LOOKUP KICAD_CURL::dyn_funcs[] = {
DYN_PAIR( easy_cleanup ),
DYN_PAIR( easy_init ),
DYN_PAIR( easy_perform ),
DYN_PAIR( easy_setopt ),
DYN_PAIR( easy_strerror ),
DYN_PAIR( global_init ),
DYN_PAIR( global_cleanup ),
DYN_PAIR( slist_append ),
DYN_PAIR( slist_free_all ),
DYN_PAIR( version ),
DYN_PAIR( version_info ),
};
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()
@ -89,56 +140,14 @@ void KICAD_CURL::Init()
if( !s_initialized )
{
// dynamically load the library.
wxDynamicLibrary dso;
wxString canonicalName = dso.CanonicalizeName( wxT( "curl" ) );
// This is an ugly hack for MinGW builds. We should probably use something
// like objdump to get the actual library file name from the link file.
#if defined( __MINGW32__ )
canonicalName = dso.CanonicalizeName( wxT( "curl-4" ) );
canonicalName = wxT( "lib" ) + canonicalName;
#endif
if( !dso.Load( canonicalName, wxDL_NOW | wxDL_GLOBAL ) )
{
// Failure: error reporting UI was done via wxLogSysError().
std::string msg = StrPrintf( "%s not wxDynamicLibrary::Load()ed",
static_cast< const char *>( canonicalName.mb_str() ) );
THROW_IO_ERROR( msg );
}
// get addresses.
for( unsigned i=0; i < DIM(dyn_funcs); ++i )
{
*dyn_funcs[i].address = dso.GetSymbol( dyn_funcs[i].name );
if( *dyn_funcs[i].address == NULL )
{
// Failure: error reporting UI was done via wxLogSysError().
// No further reporting required here.
std::string msg = StrPrintf( "%s has no function %s",
static_cast<const char*>( canonicalName.mb_str() ),
dyn_funcs[i].name );
THROW_IO_ERROR( msg );
}
}
if( KICAD_CURL::global_init( CURL_GLOBAL_ALL ) != CURLE_OK )
if( curl_global_init( CURL_GLOBAL_ALL ) != CURLE_OK )
{
THROW_IO_ERROR( "curl_global_init() failed." );
}
wxLogDebug( "Using %s", GetVersion() );
init_locks();
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image,
// since everything is fine before this. In those cases where THROW_IO_ERROR
// is called, dso is destroyed and the DSO/DLL is unloaded before returning in
// those error cases.
(void) dso.Detach();
wxLogDebug( "Using %s", GetVersion() );
s_initialized = true;
}
@ -169,14 +178,11 @@ void KICAD_CURL::Cleanup()
if( s_initialized )
{
curl_global_cleanup();
KICAD_CURL::global_cleanup();
kill_locks();
// dyn_funcs are not good for anything now, assuming process is ending soon here.
for( unsigned i=0; i < DIM(dyn_funcs); ++i )
{
*dyn_funcs[i].address = 0;
}
atexit( &at_terminate );
s_initialized = false;
}
@ -189,7 +195,7 @@ std::string KICAD_CURL::GetSimpleVersion()
if( !s_initialized )
Init();
curl_version_info_data *info = KICAD_CURL::version_info( CURLVERSION_NOW );
curl_version_info_data* info = curl_version_info( CURLVERSION_NOW );
std::string res;

View File

@ -52,29 +52,24 @@ KICAD_CURL_EASY::KICAD_CURL_EASY() :
KICAD_CURL::Init();
// Do not catch exception from KICAD_CURL::Init() at this level.
// Instantiation of this instance will fail if Init() throws, thus ensuring
// that this instance cannot be subsequently used.
// Caller needs a try catch around KICAD_CURL_EASY instantiation.
m_CURL = KICAD_CURL::easy_init();
m_CURL = curl_easy_init();
if( !m_CURL )
{
THROW_IO_ERROR( "Unable to initialize CURL session" );
}
KICAD_CURL::easy_setopt( m_CURL, CURLOPT_WRITEFUNCTION, write_callback );
KICAD_CURL::easy_setopt( m_CURL, CURLOPT_WRITEDATA, (void*) &m_buffer );
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 )
KICAD_CURL::slist_free_all( m_headers );
curl_slist_free_all( m_headers );
KICAD_CURL::easy_cleanup( m_CURL );
curl_easy_cleanup( m_CURL );
}
@ -82,13 +77,13 @@ void KICAD_CURL_EASY::Perform()
{
if( m_headers )
{
KICAD_CURL::easy_setopt( m_CURL, CURLOPT_HTTPHEADER, 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 = KICAD_CURL::easy_perform( m_CURL );
CURLcode res = curl_easy_perform( m_CURL );
if( res != CURLE_OK )
{

View File

@ -30,7 +30,6 @@
* (locale handling)
*/
#include <kicad_curl/kicad_curl.h> /* Include before any wx file */
#include <fctsys.h>
#include <wx/html/htmlwin.h>
#include <wx/fs_zip.h>
@ -48,7 +47,6 @@
#include <id.h>
#include <build_version.h>
#include <hotkeys_basic.h>
#include <online_help.h>
#include <gestfich.h>
#include <menus_helpers.h>
#include <confirm.h>
@ -290,8 +288,6 @@ void PGM_BASE::destroy()
{
// unlike a normal destructor, this is designed to be called more than once safely:
KICAD_CURL::Cleanup();
delete m_common_settings;
m_common_settings = 0;

View File

@ -25,6 +25,7 @@
#include <cstdarg>
#include <config.h> // HAVE_FGETC_NOLOCK
#include <richio.h>

View File

@ -0,0 +1,674 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2016 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 <cctype>
#include <widgets/widget_hotkey_list.h>
#include <wx/dataview.h>
#include <wx/statline.h>
#include <draw_frame.h>
#include <dialog_shim.h>
/**
* Minimum width of the hotkey column
*/
static const int HOTKEY_MIN_WIDTH = 100;
/**
* Extra margin to compensate for vertical scrollbar
*/
static const int HORIZ_MARGIN = 30;
/**
* Menu IDs for the hotkey context menu
*/
enum ID_WHKL_MENU_IDS
{
ID_EDIT = 2001,
ID_RESET,
ID_RESET_ALL,
};
/**
* Class WIDGET_HOTKEY_CLIENT_DATA
* Stores the hotkey and section tag associated with each row. To change a
* hotkey, edit it in the row's client data, then call WIDGET_HOTKEY_LIST::UpdateFromClientData().
*/
class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData
{
EDA_HOTKEY m_hotkey;
wxString m_section_tag;
public:
WIDGET_HOTKEY_CLIENT_DATA( const EDA_HOTKEY& aHotkey, const wxString& aSectionTag )
: m_hotkey( aHotkey ), m_section_tag( aSectionTag )
{}
EDA_HOTKEY& GetHotkey() { return m_hotkey; }
const wxString& GetSectionTag() const { return m_section_tag; }
};
/**
* Class HK_PROMPT_DIALOG
* Dialog to prompt the user to enter a key.
*/
class HK_PROMPT_DIALOG : public DIALOG_SHIM
{
wxKeyEvent m_event;
public:
HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle,
const wxString& aName, const wxString& aCurrentKey )
: DIALOG_SHIM( aParent, aId, aTitle, wxDefaultPosition, wxDefaultSize )
{
wxPanel* panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize );
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
/* Dialog layout:
*
* inst_label........................
* ----------------------------------
*
* cmd_label_0 cmd_label_1 \
* | fgsizer
* key_label_0 key_label_1 /
*/
wxStaticText* inst_label = new wxStaticText( panel, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL );
inst_label->SetLabelText( _( "Press a new hotkey, or press Esc to cancel..." ) );
sizer->Add( inst_label, 0, wxALL, 5 );
sizer->Add( new wxStaticLine( panel ), 0, wxALL | wxEXPAND, 2 );
wxFlexGridSizer* fgsizer = new wxFlexGridSizer( 2 );
wxStaticText* cmd_label_0 = new wxStaticText( panel, wxID_ANY, _( "Command:" ) );
fgsizer->Add( cmd_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* cmd_label_1 = new wxStaticText( panel, wxID_ANY, wxEmptyString );
cmd_label_1->SetFont( cmd_label_1->GetFont().Bold() );
cmd_label_1->SetLabel( aName );
fgsizer->Add( cmd_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* key_label_0 = new wxStaticText( panel, wxID_ANY, _( "Current key:" ) );
fgsizer->Add( key_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* key_label_1 = new wxStaticText( panel, wxID_ANY, wxEmptyString );
key_label_1->SetFont( key_label_1->GetFont().Bold() );
key_label_1->SetLabel( aCurrentKey );
fgsizer->Add( key_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
sizer->Add( fgsizer, 1, wxEXPAND );
// Wrap the sizer in a second to give a larger border around the whole dialog
wxBoxSizer* outer_sizer = new wxBoxSizer( wxVERTICAL );
outer_sizer->Add( sizer, 0, wxALL | wxEXPAND, 10 );
panel->SetSizer( outer_sizer );
Layout();
outer_sizer->Fit( this );
Center();
SetMinClientSize( GetClientSize() );
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
// including specials like Tab and Return, are received, particularly
// on MSW.
panel->Bind( wxEVT_CHAR, &HK_PROMPT_DIALOG::OnChar, this );
panel->Bind( wxEVT_CHAR_HOOK, &HK_PROMPT_DIALOG::OnCharHook, this );
}
void OnCharHook( wxKeyEvent& aEvent )
{
// On certain platforms, EVT_CHAR_HOOK is the only handler that receives
// certain "special" keys. However, it doesn't always receive "normal"
// keys correctly. For example, with a US keyboard, it sees ? as shift+/.
//
// Untangling these incorrect keys would be too much trouble, so we bind
// both events, and simply skip the EVT_CHAR_HOOK if it receives a
// "normal" key.
const enum wxKeyCode skipped_keys[] =
{
WXK_NONE, WXK_SHIFT, WXK_ALT, WXK_CONTROL, WXK_CAPITAL,
WXK_NUMLOCK, WXK_SCROLL, WXK_RAW_CONTROL
};
int key = aEvent.GetKeyCode();
for( size_t i = 0; i < sizeof( skipped_keys ) / sizeof( skipped_keys[0] ); ++i )
{
if( key == skipped_keys[i] )
return;
}
if( key <= 255 && isprint( key ) && !isspace( key ) )
{
// Let EVT_CHAR handle this one
aEvent.DoAllowNextEvent();
// On Windows, wxEvent::Skip must NOT be called.
// On Linux and OSX, wxEvent::Skip MUST be called.
// No, I don't know why.
#ifndef __WXMSW__
aEvent.Skip();
#endif
}
else
{
OnChar( aEvent );
}
}
void OnChar( wxKeyEvent& aEvent )
{
m_event = aEvent;
EndFlexible( wxID_OK );
}
/**
* End the dialog whether modal or quasimodal
*/
void EndFlexible( int aRtnCode )
{
if( IsQuasiModal() )
EndQuasiModal( aRtnCode );
else
EndModal( aRtnCode );
}
static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName,
const wxString& aCurrentKey )
{
HK_PROMPT_DIALOG dialog( aParent, wxID_ANY, _( "Set Hotkey" ), aName, aCurrentKey );
if( dialog.ShowModal() == wxID_OK )
{
return dialog.m_event;
}
else
{
wxKeyEvent dummy;
return dummy;
}
}
};
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetHKClientData( wxTreeListItem aItem )
{
if( aItem.IsOk() )
{
wxClientData* data = GetItemData( aItem );
if( !data )
{
return NULL;
}
else
{
return static_cast<WIDGET_HOTKEY_CLIENT_DATA*>( data );
}
}
else
{
return NULL;
}
}
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::GetSelHKClientData()
{
return GetHKClientData( GetSelection() );
}
void WIDGET_HOTKEY_LIST::UpdateFromClientData()
{
for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( i );
if( hkdata )
{
EDA_HOTKEY& hk = hkdata->GetHotkey();
SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) );
SetItemText( i, 1, KeyNameFromKeyCode( hk.m_KeyCode ) );
}
}
}
void WIDGET_HOTKEY_LIST::LoadSection( EDA_HOTKEY_CONFIG* aSection )
{
HOTKEY_LIST list;
for( EDA_HOTKEY** info_ptr = aSection->m_HK_InfoList; *info_ptr; ++info_ptr )
{
list.push_back( **info_ptr );
}
m_hotkeys.push_back( list );
}
void WIDGET_HOTKEY_LIST::EditItem( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
if( !hkdata )
{
// Activated item was not a hotkey row
return;
}
wxString name = GetItemText( aItem, 0 );
wxString current_key = GetItemText( aItem, 1 );
wxKeyEvent key_event = HK_PROMPT_DIALOG::PromptForKey( GetParent(), name, current_key );
long key = MapKeypressToKeycode( key_event );
if( hkdata && key )
{
// See if this key code is handled in hotkeys names list
bool exists;
KeyNameFromKeyCode( key, &exists );
if( exists && hkdata->GetHotkey().m_KeyCode != key )
{
wxString tag = hkdata->GetSectionTag();
bool canUpdate = ResolveKeyConflicts( key, tag );
if( canUpdate )
{
hkdata->GetHotkey().m_KeyCode = key;
}
}
UpdateFromClientData();
}
}
void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
EDA_HOTKEY* hk = &hkdata->GetHotkey();
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
{
wxString& section_tag = *( m_sections[sec_index].m_section->m_SectionTag );
if( section_tag != hkdata->GetSectionTag() )
continue;
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
HOTKEY_LIST::iterator hk_it;
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
{
if( hk_it->m_Idcommand == hk->m_Idcommand )
{
hk->m_KeyCode = hk_it->m_KeyCode;
break;
}
}
}
UpdateFromClientData();
}
void WIDGET_HOTKEY_LIST::OnActivated( wxTreeListEvent& aEvent )
{
EditItem( aEvent.GetItem() );
}
void WIDGET_HOTKEY_LIST::OnContextMenu( wxTreeListEvent& aEvent )
{
// Save the active event for use in OnMenu
m_context_menu_item = aEvent.GetItem();
wxMenu menu;
menu.Append( ID_EDIT, _( "Edit..." ) );
menu.Append( ID_RESET, _( "Reset" ) );
menu.Append( wxID_SEPARATOR );
menu.Append( ID_RESET_ALL, _( "Reset all" ) );
PopupMenu( &menu );
}
void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
{
switch( aEvent.GetId() )
{
case ID_EDIT:
EditItem( m_context_menu_item );
break;
case ID_RESET:
ResetItem( m_context_menu_item );
break;
case ID_RESET_ALL:
TransferDataToControl();
break;
default:
wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
}
}
void WIDGET_HOTKEY_LIST::OnSize( wxSizeEvent& aEvent )
{
// Handle this manually - wxTreeListCtrl screws up the width of the first column
wxDataViewCtrl* view = GetDataView();
if( !view )
return;
wxRect rect = GetClientRect();
view->SetSize( rect );
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
{
wxWindow* view = GetView();
view->Refresh();
view->Update();
}
#endif
// Find the maximum width of the hotkey column
int hk_column_width = 0;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
const wxString& text = GetItemText( item, 1 );
int width = WidthFor( text );
if( width > hk_column_width )
hk_column_width = width;
}
if( hk_column_width < HOTKEY_MIN_WIDTH )
hk_column_width = HOTKEY_MIN_WIDTH;
SetColumnWidth( 1, hk_column_width );
SetColumnWidth( 0, rect.width - hk_column_width - HORIZ_MARGIN );
}
bool WIDGET_HOTKEY_LIST::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
{
EDA_HOTKEY* conflicting_key = NULL;
struct EDA_HOTKEY_CONFIG* conflicting_section = NULL;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
wxString tag = hkdata->GetSectionTag();
if( aSectionTag != g_CommonSectionTag
&& tag != g_CommonSectionTag
&& tag != aSectionTag )
{
// This key and its conflict candidate are in orthogonal sections, so skip.
continue;
}
if( aKey == hk.m_KeyCode )
{
conflicting_key = &hk;
// Find the section
HOTKEY_SECTIONS::iterator it;
for( it = m_sections.begin(); it != m_sections.end(); ++it )
{
if( *it->m_section->m_SectionTag == tag )
{
conflicting_section = it->m_section;
break;
}
}
}
}
// Write the outparams
if( aConfKey )
*aConfKey = conflicting_key;
if( aConfSect )
*aConfSect = conflicting_section;
return conflicting_key == NULL;
}
bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( long aKey, const wxString& aSectionTag )
{
EDA_HOTKEY* conflicting_key = NULL;
EDA_HOTKEY_CONFIG* conflicting_section = NULL;
CheckKeyConflicts( aKey, aSectionTag, &conflicting_key, &conflicting_section );
if( conflicting_key != NULL )
{
wxString info = wxGetTranslation( conflicting_key->m_InfoMsg );
wxString msg = wxString::Format(
_( "<%s> is already assigned to \"%s\" in section \"%s\". Are you sure you want "
"to change its assignment?" ),
KeyNameFromKeyCode( aKey ), GetChars( info ),
*(conflicting_section->m_Title) );
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
if( dlg.ShowModal() == wxID_YES )
{
conflicting_key->m_KeyCode = 0;
UpdateFromClientData();
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS& aSections )
: wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
m_sections( aSections )
{
AppendColumn( _( "Command" ) );
AppendColumn( _( "Hotkey" ) );
Bind( wxEVT_TREELIST_ITEM_ACTIVATED, &WIDGET_HOTKEY_LIST::OnActivated, this );
Bind( wxEVT_TREELIST_ITEM_CONTEXT_MENU, &WIDGET_HOTKEY_LIST::OnContextMenu, this );
Bind( wxEVT_MENU, &WIDGET_HOTKEY_LIST::OnMenu, this );
Bind( wxEVT_SIZE, &WIDGET_HOTKEY_LIST::OnSize, this );
}
HOTKEY_SECTIONS WIDGET_HOTKEY_LIST::GenSections( EDA_HOTKEY_CONFIG* aHotkeys )
{
HOTKEY_SECTIONS sections;
for( EDA_HOTKEY_CONFIG* section = aHotkeys; section->m_HK_InfoList; ++section )
{
HOTKEY_SECTION sec;
sec.m_name = wxGetTranslation( *section->m_Title );
sec.m_section = section;
sections.push_back( sec );
}
return sections;
}
void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
{
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
sizer->Add( this, 1, wxALL | wxEXPAND, 0 );
aPanel->SetSizer( sizer );
}
bool WIDGET_HOTKEY_LIST::TransferDataToControl()
{
Freeze();
DeleteAllItems();
m_hotkeys.clear();
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
{
// LoadSection pushes into m_hotkeys
LoadSection( m_sections[sec_index].m_section );
wxASSERT( m_hotkeys.size() == sec_index + 1 );
wxString section_tag = *( m_sections[sec_index].m_section->m_SectionTag );
// Create parent tree item
wxTreeListItem parent = AppendItem( GetRootItem(), m_sections[sec_index].m_name );
HOTKEY_LIST& each_list = m_hotkeys[sec_index];
HOTKEY_LIST::iterator hk_it;
for( hk_it = each_list.begin(); hk_it != each_list.end(); ++hk_it )
{
wxTreeListItem item = AppendItem( parent, wxEmptyString );
SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( &*hk_it, section_tag ) );
}
Expand( parent );
}
UpdateFromClientData();
Thaw();
return true;
}
bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
{
for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
{
EDA_HOTKEY_CONFIG* section = m_sections[sec_index].m_section;
for( EDA_HOTKEY** info_ptr = section->m_HK_InfoList; *info_ptr; ++info_ptr )
{
EDA_HOTKEY* info = *info_ptr;
for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
if( !hkdata )
continue;
EDA_HOTKEY& hk = hkdata->GetHotkey();
if( hk.m_Idcommand == info->m_Idcommand )
{
info->m_KeyCode = hk.m_KeyCode;
break;
}
}
}
}
return true;
}
long WIDGET_HOTKEY_LIST::MapKeypressToKeycode( const wxKeyEvent& aEvent )
{
long key = aEvent.GetKeyCode();
if( key == WXK_ESCAPE )
{
return 0;
}
else
{
if( key >= 'a' && key <= 'z' ) // convert to uppercase
key = key + ('A' - 'a');
// Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
// to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z'
if( aEvent.ControlDown() && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
key += 'A' - 1;
/* Disallow shift for keys that have two keycodes on them (e.g. number and
* punctuation keys) leaving only the "letter keys" of A-Z.
* Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
* and Ctrl-( and Ctrl-5 (FR layout).
* Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
*/
bool keyIsLetter = key >= 'A' && key <= 'Z';
if( aEvent.ShiftDown() && ( keyIsLetter || key > 256 ) )
key |= GR_KB_SHIFT;
if( aEvent.ControlDown() )
key |= GR_KB_CTRL;
if( aEvent.AltDown() )
key |= GR_KB_ALT;
return key;
}
}

View File

@ -132,6 +132,7 @@ set( EESCHEMA_SRCS
onrightclick.cpp
operations_on_items_lists.cpp
pinedit.cpp
pin_number.cpp
plot_schematic_DXF.cpp
plot_schematic_HPGL.cpp
plot_schematic_PS.cpp

View File

@ -33,9 +33,9 @@
#include <confirm.h>
#include <schframe.h>
#include <sch_reference_list.h>
#include <class_library.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
@ -111,11 +111,11 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
// Build component list
if( aAnnotateSchematic )
{
sheets.GetComponents( Prj().SchLibs(), references );
g_RootSheet->GetComponents( Prj().SchLibs(), references );
}
else
{
m_CurrentSheet->GetComponents( Prj().SchLibs(), references );
m_CurrentSheet->Last()->GetComponents( Prj().SchLibs(), references, true, false );
}
// Break full components reference in name (prefix) and number:
@ -186,14 +186,13 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
{
// build the screen list
SCH_SHEET_LIST SheetList;
SCH_REFERENCE_LIST ComponentsList;
// Build the list of components
if( !aOneSheetOnly )
SheetList.GetComponents( Prj().SchLibs(), ComponentsList );
g_RootSheet->GetComponents( Prj().SchLibs(), ComponentsList );
else
m_CurrentSheet->GetComponents( Prj().SchLibs(), ComponentsList );
m_CurrentSheet->Last()->GetComponents( Prj().SchLibs(), ComponentsList, true, false );
return ComponentsList.CheckAnnotation( aMessageList );
}

View File

@ -38,9 +38,10 @@
#include <wildcards_and_files_ext.h>
#include <general.h>
#include <sch_sheet_path.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_reference_list.h>
#include <sch_sheet_path.h>
#include <dsnlexer.h>
#include <ptree.h>
@ -53,10 +54,9 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
{
// Build a flat list of components in schematic:
SCH_REFERENCE_LIST refs;
SCH_SHEET_LIST sheets;
bool isChanged = false;
sheets.GetComponents( Prj().SchLibs(), refs, false );
g_RootSheet->GetComponents( Prj().SchLibs(), refs, false );
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
PTREE doc;
@ -135,9 +135,8 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
{
// Build a flat list of components in schematic:
SCH_REFERENCE_LIST referencesList;
SCH_SHEET_LIST sheetList;
sheetList.GetComponents( Prj().SchLibs(), referencesList, false );
g_RootSheet->GetComponents( Prj().SchLibs(), referencesList, false );
FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );

View File

@ -36,8 +36,9 @@
#include <fctsys.h>
#include <kicad_string.h>
#include <schframe.h>
#include <sch_reference_list.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_reference_list.h>
#include <boost/foreach.hpp>
@ -69,6 +70,7 @@ bool SCH_REFERENCE_LIST::sortByXPosition( const SCH_REFERENCE& item1,
return ii < 0;
}
bool SCH_REFERENCE_LIST::sortByYPosition( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
@ -132,7 +134,9 @@ bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1,
bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
const SCH_REFERENCE& item2 )
{
int ii = item1.m_SheetPath.Cmp( item2.m_SheetPath );
wxCHECK( item1.m_Sheet != NULL && item2.m_Sheet != NULL, false );
int ii = *item1.m_Sheet - *item2.m_Sheet;
if( ii == 0 )
ii = item1.m_TimeStamp - item2.m_TimeStamp;
@ -140,6 +144,7 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1,
return ii < 0;
}
int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit )
{
int NumRef;
@ -286,7 +291,7 @@ int SCH_REFERENCE_LIST::CreateFirstFreeRefId( std::vector<int>& aIdList, int aFi
void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap )
SCH_MULTI_UNIT_REFERENCE_MAP& aLockedUnitMap )
{
if ( componentFlatList.size() == 0 )
return;
@ -332,9 +337,11 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
// Check whether this component is in aLockedUnitMap.
SCH_REFERENCE_LIST* lockedList = NULL;
BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, aLockedUnitMap )
{
unsigned n_refs = pair.second.GetCount();
for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
{
SCH_REFERENCE &thisRef = pair.second[thisRefI];
@ -414,22 +421,29 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
if( lockedList != NULL )
{
unsigned n_refs = lockedList->GetCount();
for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
{
SCH_REFERENCE &thisRef = (*lockedList)[thisRefI];
if( thisRef.IsSameInstance( componentFlatList[ii] ) )
{
// This is the component we're currently annotating. Hold the unit!
componentFlatList[ii].m_Unit = thisRef.m_Unit;
}
if( thisRef.CompareValue( componentFlatList[ii] ) != 0 ) continue;
if( thisRef.CompareLibName( componentFlatList[ii] ) != 0 ) continue;
if( thisRef.CompareValue( componentFlatList[ii] ) != 0 )
continue;
if( thisRef.CompareLibName( componentFlatList[ii] ) != 0 )
continue;
// Find the matching component
for( unsigned jj = ii + 1; jj < componentFlatList.size(); jj++ )
{
if( ! thisRef.IsSameInstance( componentFlatList[jj] ) ) continue;
if( ! thisRef.IsSameInstance( componentFlatList[jj] ) )
continue;
componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef;
componentFlatList[jj].m_Unit = thisRef.m_Unit;
componentFlatList[jj].m_IsNew = false;
@ -438,13 +452,12 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
}
}
}
else
{
/* search for others units of this component.
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
for( Unit = 1; Unit <= NumberOfUnits; Unit++ )
{
if( componentFlatList[ii].m_Unit == Unit )
@ -498,7 +511,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
SortByRefAndValue();
// Spiit reference designators into name (prefix) and number: IC1 becomes IC, and 1.
// Split reference designators into name (prefix) and number: IC1 becomes IC, and 1.
SplitReferences();
// count not yet annotated items or annotation error.
@ -668,14 +681,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
for( int ii = 0; ( ii < imax ) && ( error < 4 ); ii++ )
{
if( ( componentFlatList[ii].m_TimeStamp != componentFlatList[ii + 1].m_TimeStamp )
|| ( componentFlatList[ii].GetSheetPath() != componentFlatList[ii + 1].GetSheetPath() ) )
|| ( componentFlatList[ii].GetSheet() != componentFlatList[ii + 1].GetSheet() ) )
continue;
// Same time stamp found.
wxString full_path;
full_path.Printf( wxT( "%s%8.8X" ),
GetChars( componentFlatList[ii].GetSheetPath().Path() ),
GetChars( componentFlatList[ii].GetSheet()->GetPath() ),
componentFlatList[ii].m_TimeStamp );
msg.Printf( _( "Duplicate time stamp (%s) for %s%d and %s%d" ),
@ -695,24 +708,24 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET_PATH& aSheetPath )
SCH_SHEET* aSheet )
{
wxASSERT( aComponent != NULL && aLibComponent != NULL );
m_RootCmp = aComponent;
m_Entry = aLibComponent;
m_Unit = aComponent->GetUnitSelection( aSheetPath.Last() );
m_SheetPath = aSheetPath;
m_Unit = aComponent->GetUnitSelection( aSheet );
m_Sheet = aSheet;
m_IsNew = false;
m_Flag = 0;
m_TimeStamp = aComponent->GetTimeStamp();
m_CmpPos = aComponent->GetPosition();
m_SheetNum = 0;
if( aComponent->GetRef( aSheetPath.Last() ).IsEmpty() )
aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) );
if( aComponent->GetRef( aSheet ).IsEmpty() )
aComponent->SetRef( aSheet, wxT( "DefRef?" ) );
SetRef( aComponent->GetRef( aSheetPath.Last() ) );
SetRef( aComponent->GetRef( aSheet ) );
m_NumRef = -1;
@ -730,9 +743,9 @@ void SCH_REFERENCE::Annotate()
else
m_Ref = TO_UTF8( GetRef() << m_NumRef );
m_RootCmp->SetRef( m_SheetPath.Last(), FROM_UTF8( m_Ref.c_str() ) );
m_RootCmp->SetRef( m_Sheet, FROM_UTF8( m_Ref.c_str() ) );
m_RootCmp->SetUnit( m_Unit );
m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit );
m_RootCmp->SetUnitSelection( m_Sheet, m_Unit );
}
@ -766,7 +779,7 @@ void SCH_REFERENCE::Split()
{
while( ll >= 0 )
{
if( (refText[ll] <= ' ' ) || isdigit( refText[ll] ) )
if( ( refText[ll] <= ' ' ) || isdigit( refText[ll] ) )
ll--;
else
{

View File

@ -340,7 +340,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{
int unit_selection = unitChoice->GetCurrentSelection() + 1;
m_cmp->SetUnitSelection( &m_parent->GetCurrentSheet(), unit_selection );
m_cmp->SetUnitSelection( m_parent->GetCurrentSheet().Last(), unit_selection );
m_cmp->SetUnit( unit_selection );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 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
@ -30,10 +30,14 @@
#include <class_base_screen.h>
#include <dialog_eeschema_options.h>
#include <widgets/widget_hotkey_list.h>
#include <schframe.h>
#include <hotkeys.h>
#include "wx/settings.h"
#include <wx/settings.h>
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
{
m_choiceUnits->SetFocus();
@ -50,9 +54,29 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
m_fieldGrid->AutoSizeColLabelSize( i );
}
// Embed the hotkeys list
HOTKEY_SECTIONS sections = WIDGET_HOTKEY_LIST::GenSections( g_Eeschema_Hokeys_Descr );
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, sections );
m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys );
// Make sure we select the first tab of the options tab page
m_notebook->SetSelection( 0 );
// Lay out all child pages
// No, I don't know why this->Layout() doesn't propagate through to these,
// but at least on MSW, it does not.
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
{
m_notebook->GetPage( i )->Layout();
}
Layout();
}
SCH_EDIT_FRAME* DIALOG_EESCHEMA_OPTIONS::GetParent()
{
return static_cast<SCH_EDIT_FRAME*>( DIALOG_EESCHEMA_OPTIONS_BASE::GetParent() );
}
@ -147,11 +171,13 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
{
bool this_row_selected = false;
for( int col = 0; col < m_fieldGrid->GetNumberCols(); ++col )
{
if( m_fieldGrid->IsInSelection( row, col ) )
this_row_selected = true;
}
if( this_row_selected )
{
selected_row = row;
@ -198,10 +224,12 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
TransferDataFromWindow();
int n_rows = m_fieldGrid->GetNumberRows();
for( int count = 0; count < n_rows; ++count )
{
// Iterate backwards, unsigned-friendly way for future
int row = n_rows - count - 1;
if( rows_to_delete[row] )
{
templateFields.erase( templateFields.begin() + row );
@ -217,9 +245,14 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() )
return false;
if( !m_hotkeyListCtrl->TransferDataToControl() )
return false;
m_fieldGrid->Freeze();
if( m_fieldGrid->GetNumberRows() )
m_fieldGrid->DeleteRows( 0, m_fieldGrid->GetNumberRows() );
m_fieldGrid->AppendRows( templateFields.size() );
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
@ -238,21 +271,34 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToWindow()
m_fieldGrid->SetCellRenderer( row, 2, new wxGridCellBoolRenderer() );
m_fieldGrid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
}
m_fieldGrid->AutoSizeRows();
m_fieldGrid->Thaw();
Layout();
return true;
}
bool DIALOG_EESCHEMA_OPTIONS::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
if( !m_hotkeyListCtrl->TransferDataFromControl() )
return false;
// Refresh hotkeys
GetParent()->ReCreateMenuBar();
GetParent()->Refresh();
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
{
templateFields[row].m_Name = m_fieldGrid->GetCellValue( row, 0 );
templateFields[row].m_Name = m_fieldGrid->GetCellValue( row, 0 );
templateFields[row].m_Value = m_fieldGrid->GetCellValue( row, 1 );
templateFields[row].m_Visible = ( m_fieldGrid->GetCellValue( row, 2 ) != wxEmptyString );
}
return true;
}
@ -271,4 +317,3 @@ TEMPLATE_FIELDNAMES DIALOG_EESCHEMA_OPTIONS::GetTemplateFields( void )
{
return templateFields;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 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
@ -34,9 +34,14 @@
#include <dialog_eeschema_options_base.h>
#include <template_fieldnames.h>
class WIDGET_HOTKEY_LIST;
class SCH_EDIT_FRAME;
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
{
protected:
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
/** @brief The template fieldnames for this dialog */
TEMPLATE_FIELDNAMES templateFields;
@ -80,7 +85,9 @@ public:
*
* @param parent The dialog's parent
*/
DIALOG_EESCHEMA_OPTIONS( wxWindow* parent );
DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent );
virtual SCH_EDIT_FRAME* GetParent();
/**
* Function GetUnitsSelection

View File

@ -233,7 +233,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_panel3->Layout();
bSizer8->Fit( m_panel3 );
m_notebook->AddPage( m_panel3, _("Editing"), false );
m_panel4 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_controlsPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer81;
bSizer81 = new wxBoxSizer( wxVERTICAL );
@ -248,35 +248,51 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
bSizer81->Add( fgSizer31, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer91;
bSizer91 = new wxBoxSizer( wxVERTICAL );
m_controlsSizer = new wxBoxSizer( wxVERTICAL );
m_checkEnableZoomCenter = new wxCheckBox( m_panel4, wxID_ANY, _("Cen&ter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 );
wxBoxSizer* bSizer13;
bSizer13 = new wxBoxSizer( wxHORIZONTAL );
m_staticText20 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Hotkeys:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
bSizer13->Add( m_staticText20, 1, wxALL, 5 );
m_staticText21 = new wxStaticText( m_controlsPanel, wxID_ANY, _("Double-click to edit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21->Wrap( -1 );
bSizer13->Add( m_staticText21, 0, wxALL, 5 );
m_controlsSizer->Add( bSizer13, 0, wxEXPAND, 5 );
m_panelHotkeys = new wxPanel( m_controlsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_controlsSizer->Add( m_panelHotkeys, 1, wxEXPAND | wxALL, 5 );
m_checkEnableZoomCenter = new wxCheckBox( m_controlsPanel, wxID_ANY, _("Cen&ter and warp cursor on zoom"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkEnableZoomCenter->SetToolTip( _("Keep the cursor at its current location when zooming") );
bSizer91->Add( m_checkEnableZoomCenter, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_controlsSizer->Add( m_checkEnableZoomCenter, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_checkEnableMiddleButtonPan = new wxCheckBox( m_panel4, xwID_ANY, _("&Use middle mouse button to pan"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkEnableMiddleButtonPan = new wxCheckBox( m_controlsPanel, xwID_ANY, _("&Use middle mouse button to pan"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkEnableMiddleButtonPan->SetToolTip( _("Use middle mouse button dragging to pan") );
bSizer91->Add( m_checkEnableMiddleButtonPan, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_controlsSizer->Add( m_checkEnableMiddleButtonPan, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_checkMiddleButtonPanLimited = new wxCheckBox( m_panel4, wxID_ANY, _("&Limit panning to scroll size"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkMiddleButtonPanLimited = new wxCheckBox( m_controlsPanel, wxID_ANY, _("&Limit panning to scroll size"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkMiddleButtonPanLimited->SetToolTip( _("Middle mouse button panning limited by current scrollbar size") );
bSizer91->Add( m_checkMiddleButtonPanLimited, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_controlsSizer->Add( m_checkMiddleButtonPanLimited, 0, wxTOP|wxRIGHT|wxLEFT, 3 );
m_checkAutoPan = new wxCheckBox( m_panel4, wxID_ANY, _("&Pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer91->Add( m_checkAutoPan, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 );
m_checkAutoPan = new wxCheckBox( m_controlsPanel, wxID_ANY, _("&Pan while moving object"), wxDefaultPosition, wxDefaultSize, 0 );
m_controlsSizer->Add( m_checkAutoPan, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 3 );
bSizer81->Add( bSizer91, 0, wxALL|wxEXPAND, 5 );
bSizer81->Add( m_controlsSizer, 1, wxALL|wxEXPAND, 5 );
m_panel4->SetSizer( bSizer81 );
m_panel4->Layout();
bSizer81->Fit( m_panel4 );
m_notebook->AddPage( m_panel4, _("Co&ntrols"), false );
m_controlsPanel->SetSizer( bSizer81 );
m_controlsPanel->Layout();
bSizer81->Fit( m_controlsPanel );
m_notebook->AddPage( m_controlsPanel, _("Controls"), false );
m_panel2 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_panel2->SetToolTip( _("User defined field names for schematic components. ") );
@ -342,10 +358,13 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_panel2->SetSizer( bSizer6 );
m_panel2->Layout();
bSizer6->Fit( m_panel2 );
m_notebook->AddPage( m_panel2, _("Default &Fields"), false );
m_notebook->AddPage( m_panel2, _("Default Fields"), false );
bOptionsSizer->Add( m_notebook, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer12;
bSizer12 = new wxBoxSizer( wxHORIZONTAL );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
@ -353,7 +372,10 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bOptionsSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 6 );
bSizer12->Add( m_sdbSizer, 1, wxALL|wxEXPAND, 5 );
bOptionsSizer->Add( bSizer12, 0, wxBOTTOM|wxEXPAND, 5 );
mainSizer->Add( bOptionsSizer, 1, wxEXPAND, 12 );

View File

@ -184,11 +184,11 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="notebookpage" expanded="1">
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Display</property>
<property name="select">1</property>
<object class="wxPanel" expanded="1">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -262,16 +262,16 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer82</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2</property>
@ -1675,11 +1675,11 @@
</object>
</object>
</object>
<object class="notebookpage" expanded="1">
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Editing</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -1753,16 +1753,16 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer8</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2</property>
@ -3069,11 +3069,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -3769,7 +3769,7 @@
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Co&amp;ntrols</property>
<property name="label">Controls</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
@ -3806,7 +3806,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panel4</property>
<property name="name">m_controlsPanel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -3850,11 +3850,11 @@
<property name="name">bSizer81</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="1">
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2</property>
@ -3868,15 +3868,272 @@
<property name="vgap">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer91</property>
<property name="name">m_controlsSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer13</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">1</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Hotkeys:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText20</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Double-click to edit</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText21</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelHotkeys</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">3</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
@ -4234,11 +4491,11 @@
</object>
</object>
</object>
<object class="notebookpage" expanded="1">
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Default &amp;Fields</property>
<property name="label">Default Fields</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -4312,25 +4569,25 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer11</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -4471,7 +4728,7 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
@ -4673,30 +4930,41 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">6</property>
<property name="flag">wxALL|wxEXPAND</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
<property name="name">bSizer12</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object>

View File

@ -103,7 +103,11 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM
wxCheckBox* m_checkAutoplaceFields;
wxCheckBox* m_checkAutoplaceJustify;
wxCheckBox* m_checkAutoplaceAlign;
wxPanel* m_panel4;
wxPanel* m_controlsPanel;
wxBoxSizer* m_controlsSizer;
wxStaticText* m_staticText20;
wxStaticText* m_staticText21;
wxPanel* m_panelHotkeys;
wxCheckBox* m_checkEnableZoomCenter;
wxCheckBox* m_checkEnableMiddleButtonPan;
wxCheckBox* m_checkMiddleButtonPanLimited;

View File

@ -2,6 +2,8 @@
#include "lib_pin.h"
#include "pin_number.h"
#include <boost/algorithm/string/join.hpp>
#include <queue>
@ -41,6 +43,8 @@ public:
void CalculateGrouping();
void Refresh();
PinNumbers GetAllPinNumbers();
#ifdef REASSOCIATE_HACK
void SetWidget( wxDataViewCtrl* aWidget ) { m_Widget = aWidget; }
#endif
@ -67,6 +71,9 @@ private:
mutable std::list<Pin> m_Pins;
mutable std::map<wxString, Group> m_Groups;
// like GetValue, but always returns a string
wxString GetString( const wxDataViewItem&, unsigned int ) const;
#ifdef REASSOCIATE_HACK
wxDataViewCtrl* m_Widget;
#endif
@ -76,6 +83,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Item
{
public:
virtual void GetValue( wxVariant& aValue, unsigned int aCol ) const = 0;
virtual wxString GetString( unsigned int aCol ) const = 0;
virtual wxDataViewItem GetParent() const = 0;
virtual bool IsContainer() const = 0;
virtual unsigned int GetChildren( wxDataViewItemArray& ) const = 0;
@ -88,7 +96,7 @@ public:
Group( unsigned int aGroupingColumn ) : m_GroupingColumn( aGroupingColumn ) {}
virtual void GetValue( wxVariant& aValue, unsigned int aCol ) const;
virtual wxString GetString( unsigned int aCol ) const;
virtual wxDataViewItem GetParent() const { return wxDataViewItem(); }
virtual bool IsContainer() const { return true; }
virtual unsigned int GetChildren( wxDataViewItemArray& aItems ) const
@ -116,7 +124,7 @@ public:
LIB_PIN* aBacking ) : m_Model( aModel ), m_Backing( aBacking ), m_Group( 0 ) {}
virtual void GetValue( wxVariant& aValue, unsigned int aCol ) const;
virtual wxString GetString( unsigned int aCol ) const;
virtual wxDataViewItem GetParent() const { return wxDataViewItem( m_Group ); }
virtual bool IsContainer() const { return false; }
virtual unsigned int GetChildren( wxDataViewItemArray& ) const { return 0; }
@ -174,6 +182,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
m_Pins->AppendColumn( col2 );
m_Pins->AppendColumn( col3 );
UpdateSummary();
GetSizer()->SetSizeHints(this);
Centre();
}
@ -184,6 +194,14 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
}
void DIALOG_LIB_EDIT_PIN_TABLE::UpdateSummary()
{
PinNumbers pins = m_Model->GetAllPinNumbers();
m_Summary->SetValue( pins.GetSummary() );
}
void DIALOG_LIB_EDIT_PIN_TABLE::OnColumnHeaderRightClicked( wxDataViewEvent& event )
{
m_Model->SetGroupingColumn( event.GetDataViewColumn()->GetModelColumn() );
@ -282,138 +300,14 @@ unsigned int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetChildren( const wxData
}
namespace {
wxString GetNextComponent( const wxString& str, wxString::size_type& cursor )
{
if( str.size() <= cursor )
return wxEmptyString;
wxString::size_type begin = cursor;
wxUniChar c = str[cursor];
if( isdigit( c ) || c == '+' || c == '-' )
{
// number, possibly with sign
while( ++cursor < str.size() )
{
c = str[cursor];
if( isdigit( c ) || c == 'v' || c == 'V' )
continue;
else
break;
}
}
else
{
while( ++cursor < str.size() )
{
c = str[cursor];
if( isdigit( c ) )
break;
else
continue;
}
}
return str.substr( begin, cursor - begin );
}
int ComparePinNames( const wxString& lhs, const wxString& rhs )
{
wxString::size_type cursor1 = 0;
wxString::size_type cursor2 = 0;
wxString comp1, comp2;
for( ; ; )
{
comp1 = GetNextComponent( lhs, cursor1 );
comp2 = GetNextComponent( rhs, cursor2 );
if( comp1.empty() && comp2.empty() )
return 0;
if( comp1.empty() )
return -1;
if( comp2.empty() )
return 1;
wxUniChar c1 = comp1[0];
wxUniChar c2 = comp2[0];
if( isdigit( c1 ) || c1 == '-' || c1 == '+' )
{
if( isdigit( c2 ) || c2 == '-' || c2 == '+' )
{
// numeric comparison
wxString::size_type v1 = comp1.find_first_of( "vV" );
if( v1 != wxString::npos )
comp1[v1] = '.';
wxString::size_type v2 = comp2.find_first_of( "vV" );
if( v2 != wxString::npos )
comp2[v2] = '.';
double val1, val2;
comp1.ToDouble( &val1 );
comp2.ToDouble( &val2 );
if( val1 < val2 )
return -1;
if( val1 > val2 )
return 1;
}
else
return -1;
}
else
{
if( isdigit( c2 ) || c2 == '-' || c2 == '+' )
return 1;
int res = comp1.Cmp( comp2 );
if( res != 0 )
return res;
}
}
}
class CompareLess
{
public:
bool operator()( const wxString& lhs, const wxString& rhs )
{
return ComparePinNames( lhs, rhs ) == -1;
}
};
}
int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Compare( const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
bool aAscending ) const
{
wxVariant var1;
GetValue( var1, aItem1, aCol );
wxString str1 = var1.GetString();
wxVariant var2;
GetValue( var2, aItem2, aCol );
wxString str2 = var2.GetString();
int res = ComparePinNames( str1, str2 );
wxString str1 = GetString( aItem1, aCol );
wxString str2 = GetString( aItem2, aCol );
int res = PinNumbers::Compare( str1, str2 );
if( res == 0 )
res = ( aItem1.GetID() < aItem2.GetID() ) ? -1 : 1;
@ -425,9 +319,9 @@ int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Compare( const wxDataViewItem& aIt
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::SetGroupingColumn( int aCol )
{
if( m_GroupingColumn == aCol )
return;
m_GroupingColumn = aCol;
m_GroupingColumn = NONE;
else
m_GroupingColumn = aCol;
Cleared();
CalculateGrouping();
@ -445,8 +339,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::CalculateGrouping()
for( std::list<Pin>::iterator i = m_Pins.begin(); i != m_Pins.end(); ++i )
{
i->GetValue( value, m_GroupingColumn );
wxString str = value.GetString();
wxString str = i->GetString( m_GroupingColumn );
std::map<wxString, Group>::iterator j = m_Groups.find( str );
if( j == m_Groups.end() )
@ -492,27 +385,50 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Refresh()
}
PinNumbers DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetAllPinNumbers()
{
PinNumbers ret;
for( std::list<Pin>::const_iterator i = m_Pins.begin(); i != m_Pins.end(); ++i )
ret.insert( i->GetString( PIN_NUMBER ) );
return ret;
}
wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetString( const wxDataViewItem& aItem, unsigned int aCol ) const
{
assert( aItem.IsOk() );
return reinterpret_cast<Item const*>( aItem.GetID() )->GetString( aCol );
}
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValue,
unsigned int aCol ) const
{
if( aCol == m_GroupingColumn )
{
// shortcut
m_Members.front()->GetValue( aValue, aCol );
}
else
{
std::set<wxString, CompareLess> values;
aValue = GetString( aCol );
}
for( std::list<Pin*>::const_iterator i = m_Members.begin(); i != m_Members.end(); ++i )
{
wxVariant value;
(*i)->GetValue( value, aCol );
values.insert( value.GetString() );
}
aValue = boost::algorithm::join( values, "," );
}
wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetString( unsigned int aCol ) const
{
if( aCol == m_GroupingColumn )
return m_Members.front()->GetString( aCol );
PinNumbers values;
for( std::list<Pin*>::const_iterator i = m_Members.begin(); i != m_Members.end(); ++i )
values.insert( (*i)->GetString( aCol ) );
if( values.size() > 1 )
return boost::algorithm::join( values, "," );
else
return m_Members.front()->GetString( aCol );
}
@ -538,15 +454,19 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::Add( Pin* aPin )
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue( wxVariant& aValue,
unsigned int aCol ) const
{
aValue = GetString( aCol );
}
wxString DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetString( unsigned int aCol ) const
{
switch( aCol )
{
case PIN_NUMBER:
aValue = m_Backing->GetNumberString();
break;
return m_Backing->GetNumberString();
case PIN_NAME:
{
if( m_Model.m_UnitCount > 1 )
{
wxString name;
@ -559,26 +479,24 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue( wxVariant& aValue,
name << ':';
name << m_Backing->GetName();
aValue = name;
return name;
}
else
{
aValue = m_Backing->GetName();
return m_Backing->GetName();
}
}
break;
case PIN_TYPE:
aValue = m_Backing->GetElectricalTypeName();
break;
return m_Backing->GetElectricalTypeName();
case PIN_POSITION:
{
wxPoint position = m_Backing->GetPosition();
wxString value;
value << "(" << position.x << "," << position.y << ")";
aValue = value;
return value;
}
break;
}
return wxEmptyString;
}

View File

@ -9,6 +9,8 @@ public:
DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART& aPart );
~DIALOG_LIB_EDIT_PIN_TABLE();
void UpdateSummary();
virtual void OnColumnHeaderRightClicked( wxDataViewEvent& aEvent );
private:

View File

@ -21,6 +21,9 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
top_sizer->Add( m_Pins, 1, wxALL|wxEXPAND, 5 );
m_Summary = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxNO_BORDER );
top_sizer->Add( m_Summary, 0, wxALL|wxEXPAND, 5 );
m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( this, wxID_OK );
m_Buttons->AddButton( m_ButtonsOK );

View File

@ -161,6 +161,97 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Summary</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxTE_READONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxNO_BORDER</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>

View File

@ -20,6 +20,7 @@ class DIALOG_SHIM;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -36,6 +37,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM
protected:
wxDataViewCtrl* m_Pins;
wxTextCtrl* m_Summary;
wxStdDialogButtonSizer* m_Buttons;
wxButton* m_ButtonsOK;

View File

@ -114,6 +114,12 @@ void DIALOG_SCH_FIND::OnUpdateReplaceUI( wxUpdateUIEvent& aEvent )
}
void DIALOG_SCH_FIND::OnUpdateReplaceAllUI( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( HasFlag( wxFR_REPLACEDIALOG ) && !m_comboFind->GetValue().empty() );
}
void DIALOG_SCH_FIND::OnUpdateWholeWordUI( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( !m_checkWildcardMatch->GetValue() );

View File

@ -157,6 +157,7 @@ protected:
void OnClose( wxCloseEvent& aEvent );
void OnUpdateFindUI( wxUpdateUIEvent& aEvent );
void OnUpdateReplaceUI( wxUpdateUIEvent& aEvent );
void OnUpdateReplaceAllUI( wxUpdateUIEvent& aEvent );
void OnUpdateWholeWordUI( wxUpdateUIEvent& aEvent );
void OnUpdateWildcardUI( wxUpdateUIEvent& aEvent );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 9 2015)
// C++ code generated with wxFormBuilder (version Dec 28 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -146,7 +146,7 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
m_buttonReplace->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );
m_buttonReplace->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceUI ), NULL, this );
m_buttonReplaceAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );
m_buttonReplaceAll->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceUI ), NULL, this );
m_buttonReplaceAll->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceAllUI ), NULL, this );
m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnCancel ), NULL, this );
}
@ -163,7 +163,7 @@ DIALOG_SCH_FIND_BASE::~DIALOG_SCH_FIND_BASE()
m_buttonReplace->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );
m_buttonReplace->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceUI ), NULL, this );
m_buttonReplaceAll->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnReplace ), NULL, this );
m_buttonReplaceAll->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceUI ), NULL, this );
m_buttonReplaceAll->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SCH_FIND_BASE::OnUpdateReplaceAllUI ), NULL, this );
m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_FIND_BASE::OnCancel ), NULL, this );
}

View File

@ -1802,7 +1802,7 @@
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI">OnUpdateReplaceUI</event>
<event name="OnUpdateUI">OnUpdateReplaceAllUI</event>
</object>
</object>
<object class="sizeritem" expanded="0">

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 9 2015)
// C++ code generated with wxFormBuilder (version Dec 28 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -68,6 +68,7 @@ class DIALOG_SCH_FIND_BASE : public DIALOG_SHIM
virtual void OnUpdateFindUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnReplace( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateReplaceUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnUpdateReplaceAllUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); }

View File

@ -248,8 +248,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
if( aMinConn < 0 )
{
if( (aNetItemRef->m_Type == NET_HIERLABEL)
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
if( aNetItemRef->m_Type == NET_HIERLABEL || aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER )
{
msg.Printf( _( "Hierarchical label %s is not connected to a sheet label." ),
GetChars( aNetItemRef->m_Label ) );
@ -258,7 +257,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
msg,
aNetItemRef->m_Start );
}
else if( (aNetItemRef->m_Type == NET_GLOBLABEL) )
else if( aNetItemRef->m_Type == NET_GLOBLABEL )
{
msg.Printf( _( "Global label %s is not connected to any other global label." ),
GetChars( aNetItemRef->m_Label ) );

View File

@ -41,6 +41,7 @@
#include <general.h>
#include <class_library.h>
#include <sch_component.h>
#include <sch_sheet_path.h>
#include <libeditframe.h>
#include <viewlib_frame.h>
#include <eeschema_id.h>
@ -325,7 +326,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
/* Update the unit number. */
component->SetUnitSelection( m_CurrentSheet, unit );
component->SetUnitSelection( m_CurrentSheet->Last(), unit );
component->SetUnit( unit );
component->ClearFlags();
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2014 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2014 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
@ -398,23 +398,38 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Language submenu
Pgm().AddMenuLanguageList( preferencesMenu );
// Hotkey submenu
AddHotkeyConfigMenu( preferencesMenu );
// Import/export
wxMenu* importExportSubmenu = new wxMenu();
// Separator
preferencesMenu->AppendSeparator();
AddMenuItem( preferencesMenu,
AddMenuItem( importExportSubmenu,
ID_CONFIG_SAVE,
_( "&Save Preferences" ),
_( "Save application preferences" ),
KiBitmap( save_setup_xpm ) );
wxNullBitmap );
AddMenuItem( preferencesMenu,
AddMenuItem( importExportSubmenu,
ID_CONFIG_READ,
_( "Load Prefe&rences" ),
_( "Load application preferences" ),
KiBitmap( read_setup_xpm ) );
wxNullBitmap );
AddMenuItem( importExportSubmenu,
ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
_( "E&xport Hotkeys" ),
_( "Create a hotkey configuration file to export the current hotkeys" ),
wxNullBitmap );
AddMenuItem( importExportSubmenu,
ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
_( "&Import Hotkeys" ),
_( "Load an existing hotkey configuration file" ),
wxNullBitmap );
AddMenuItem( preferencesMenu, importExportSubmenu,
wxID_ANY,
_( "&Import and export" ),
_( "Import and export settings" ),
KiBitmap( save_setup_xpm ) );
// Menu Tools:
wxMenu* toolsMenu = new wxMenu;

View File

@ -87,7 +87,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, uns
{
if( part->GetFootPrints().GetCount() != 0 ) // Put in list
{
cmpList.push_back( SCH_REFERENCE( comp, part, *path ) );
cmpList.push_back( SCH_REFERENCE( comp, part, path->Last() ) );
}
}

184
eeschema/pin_number.cpp Normal file
View File

@ -0,0 +1,184 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Simon Richter
* 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 "pin_number.h"
namespace {
wxString GetNextComponent( const wxString& str, wxString::size_type& cursor )
{
if( str.size() <= cursor )
return wxEmptyString;
wxString::size_type begin = cursor;
wxUniChar c = str[cursor];
if( isdigit( c ) || c == '+' || c == '-' )
{
// number, possibly with sign
while( ++cursor < str.size() )
{
c = str[cursor];
if( isdigit( c ) || c == 'v' || c == 'V' )
continue;
else
break;
}
}
else
{
while( ++cursor < str.size() )
{
c = str[cursor];
if( isdigit( c ) )
break;
else
continue;
}
}
return str.substr( begin, cursor - begin );
}
}
wxString PinNumbers::GetSummary() const
{
wxString ret;
const_iterator i = begin();
if( i == end() )
return ret;
const_iterator begin_of_range = i;
const_iterator last;
for( ;; )
{
last = i;
++i;
int rc = ( i != end() ) ? Compare( *last, *i ) : -2;
assert( rc == -1 || rc == -2 );
if( rc == -1 )
// adjacent elements
continue;
ret += *begin_of_range;
if( begin_of_range != last )
{
ret += '-';
ret += *last;
}
if( i == end() )
break;
begin_of_range = i;
ret += ',';
}
return ret;
}
int PinNumbers::Compare( const PinNumber& lhs, const PinNumber& rhs )
{
wxString::size_type cursor1 = 0;
wxString::size_type cursor2 = 0;
wxString comp1, comp2;
for( ; ; )
{
comp1 = GetNextComponent( lhs, cursor1 );
comp2 = GetNextComponent( rhs, cursor2 );
if( comp1.empty() && comp2.empty() )
return 0;
if( comp1.empty() )
return -2;
if( comp2.empty() )
return 2;
wxUniChar c1 = comp1[0];
wxUniChar c2 = comp2[0];
if( isdigit( c1 ) || c1 == '-' || c1 == '+' )
{
if( isdigit( c2 ) || c2 == '-' || c2 == '+' )
{
// numeric comparison
wxString::size_type v1 = comp1.find_first_of( "vV" );
if( v1 != wxString::npos )
comp1[v1] = '.';
wxString::size_type v2 = comp2.find_first_of( "vV" );
if( v2 != wxString::npos )
comp2[v2] = '.';
double val1, val2;
comp1.ToDouble( &val1 );
comp2.ToDouble( &val2 );
if( val1 < val2 )
{
if( val1 == val2 - 1 )
return -1;
else
return -2;
}
if( val1 > val2 )
{
if( val1 == val2 + 1 )
return 1;
else
return 2;
}
}
else
return -2;
}
else
{
if( isdigit( c2 ) || c2 == '-' || c2 == '+' )
return 2;
int res = comp1.Cmp( comp2 );
if( res != 0 )
return res;
}
}
}

69
eeschema/pin_number.h Normal file
View File

@ -0,0 +1,69 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Simon Richter
* 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 PIN_NUMBER_H_
#define PIN_NUMBER_H_ 1
#include <wx/string.h>
#include <set>
typedef wxString PinNumber;
class PinNumbers
{
public:
wxString GetSummary() const;
static int Compare( PinNumber const &lhs, PinNumber const &rhs );
private:
struct less
{
bool operator()( PinNumber const &lhs, PinNumber const &rhs ) const
{
return Compare( lhs, rhs ) < 0;
}
};
typedef std::set< PinNumber, less > container_type;
public:
typedef container_type::value_type value_type;
typedef container_type::iterator iterator;
typedef container_type::const_iterator const_iterator;
void insert( value_type const &v ) { pins.insert( v ); }
container_type::size_type size() const { return pins.size(); }
iterator begin() { return pins.begin(); }
iterator end() { return pins.end(); }
const_iterator begin() const { return pins.begin(); }
const_iterator end() const { return pins.end(); }
private:
container_type pins;
};
#endif

View File

@ -606,9 +606,9 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET* aSheet )
}
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection )
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET* aSheet, int aUnitSelection )
{
wxString path = GetPath( aSheet->Last() );
wxString path = GetPath( aSheet );
bool notInArray = true;

View File

@ -432,11 +432,11 @@ public:
const wxString& aRef,
int aMulti );
// returns the unit selection, for the given sheet path.
// returns the unit selection, for the given sheet.
int GetUnitSelection( SCH_SHEET* aSheet );
// Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection );
// Set the unit selection, for the given sheet.
void SetUnitSelection( SCH_SHEET* aSheet, int aUnitSelection );
// Geometric transforms (used in block operations):

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 1992-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see authors.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -35,15 +35,15 @@
#include <macros.h>
#include <class_libentry.h>
#include <sch_sheet_path.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_text.h>
#include <map>
class SCH_REFERENCE;
class SCH_REFERENCE_LIST;
/**
* Class SCH_REFERENCE
* is used as a helper to define a component's reference designator in a schematic. This
@ -62,11 +62,11 @@ class SCH_REFERENCE
///< used to annotate by X or Y position
int m_Unit; ///< The unit number for components with multiple parts
///< per package.
SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference.
SCH_SHEET* m_Sheet; ///< The sheet for this reference.
bool m_IsNew; ///< True if not yet annotated.
int m_SheetNum; ///< The sheet number for the reference.
time_t m_TimeStamp; ///< The time stamp for the reference.
EDA_TEXT* m_Value; ///< The component value of the refernce. It is the
EDA_TEXT* m_Value; ///< The component value of the reference. It is the
///< same for all instances.
int m_NumRef; ///< The numeric part of the reference designator.
int m_Flag;
@ -77,7 +77,7 @@ class SCH_REFERENCE
public:
SCH_REFERENCE() :
m_SheetPath()
m_Sheet()
{
m_RootCmp = NULL;
m_Entry = NULL;
@ -90,14 +90,14 @@ public:
m_SheetNum = 0;
}
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET_PATH& aSheetPath );
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET* aSheet );
SCH_COMPONENT* GetComp() const { return m_RootCmp; }
LIB_PART* GetLibComponent() const { return m_Entry; }
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
SCH_SHEET* GetSheet() const { return m_Sheet; }
int GetUnit() const { return m_Unit; }
@ -131,10 +131,12 @@ public:
{
return m_Ref;
}
void SetRefStr( const std::string& aReference )
{
m_Ref = aReference;
}
const char* GetRefStr() const
{
return m_Ref.c_str();
@ -162,7 +164,7 @@ public:
*/
bool IsSameInstance( const SCH_REFERENCE& other ) const
{
return GetComp() == other.GetComp() && GetSheetPath().Path() == other.GetSheetPath().Path();
return GetComp() == other.GetComp() && GetSheet()->GetPath() == other.GetSheet()->GetPath();
}
bool IsUnitsLocked()
@ -296,7 +298,8 @@ public:
* referenced U201 to U351, and items in sheet 3 start from U352
* </p>
*/
void Annotate( bool aUseSheetNum, int aSheetIntervalId, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap );
void Annotate( bool aUseSheetNum, int aSheetIntervalId,
std::map<wxString, SCH_REFERENCE_LIST>& aLockedUnitMap );
/**
* Function CheckAnnotation
@ -466,4 +469,12 @@ private:
int CreateFirstFreeRefId( std::vector<int>& aIdList, int aFirstValue );
};
/**
* Type SCH_MULTI_UNIT_REFERENCE_MAP
* is used to create a map of reference designators for multi-unit parts.
*/
typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
#endif // _SCH_REFERENCE_LIST_H_

View File

@ -42,6 +42,7 @@
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <class_netlist_object.h>
#include <sch_reference_list.h>
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
@ -182,6 +183,11 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
SCH_SHEET_PIN* sheetPin;
char* ptcar;
if( IsRootSheet() )
m_number = 1;
else
m_number = GetRootSheet()->CountSheets();
SetTimeStamp( GetNewTimeStamp() );
// sheets are added to the GetDrawItems() like other schematic components.
@ -221,8 +227,10 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( ((char*)aLine)[0] == 'U' )
{
sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp );
if( m_TimeStamp == 0 ) // zero is not unique!
SetTimeStamp( GetNewTimeStamp() );
continue;
}
@ -1350,6 +1358,39 @@ void SCH_SHEET::UpdateAllScreenReferences()
}
void SCH_SHEET::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols, bool aIncludeSubSheets )
{
for( SCH_ITEM* item = m_screen->GetDrawItems(); item; item = item->Next() )
{
if( item->Type() == SCH_SHEET_T && aIncludeSubSheets )
{
((SCH_SHEET*)item)->GetComponents( aLibs, aReferences, aIncludePowerSymbols,
aIncludeSubSheets );
}
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
// Skip pseudo components, which have a reference starting with #. This mainly
// affects power symbols.
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, this );
reference.SetSheetNumber( m_number );
aReferences.AddItem( reference );
}
}
}
}
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxLogDebug( wxT( "Sheet assignment operator." ) );
@ -1384,10 +1425,19 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
{
if( (*this - aRhs) < 0 )
return true;
return false;
}
int SCH_SHEET::operator-( const SCH_SHEET& aRhs ) const
{
// Don't waste time against comparing the same objects..
if( this == &aRhs )
return false;
return 0;
SCH_CONST_SHEETS lhsPath, rhsPath;
@ -1395,20 +1445,21 @@ bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
aRhs.GetPath( rhsPath );
// Shorter paths are less than longer paths.
if( lhsPath.size() < rhsPath.size() )
return true;
int retv = lhsPath.size() - rhsPath.size();
if( lhsPath.size() > rhsPath.size() )
return false;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
if( retv == 0 )
{
if( lhsPath[i]->GetTimeStamp() < rhsPath[i]->GetTimeStamp() )
return true;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
{
retv = lhsPath[i]->GetTimeStamp() - rhsPath[i]->GetTimeStamp();
if( retv != 0 )
break;
}
}
return false;
return retv;
}

View File

@ -44,6 +44,7 @@ class SCH_SHEET_PATH;
class DANGLING_END_ITEM;
class SCH_EDIT_FRAME;
class NETLIST_OBJECT_LIST;
class SCH_REFERENCE_LIST;
#define MIN_SHEET_WIDTH 500
@ -244,6 +245,11 @@ class SCH_SHEET : public SCH_ITEM
/// The size of the sheet.
wxSize m_size;
/// The sheet number ordered by file load.
// @todo: At some point this should really be a sheet number assigned by the user rather
// than assigned in the order the sheets were parsed and loaded.
int m_number;
public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -569,6 +575,8 @@ public:
*/
bool operator<( const SCH_SHEET& aRhs ) const;
int operator-( const SCH_SHEET& aRhs ) const;
wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition );
@ -679,6 +687,19 @@ public:
*/
void UpdateAllScreenReferences();
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
*
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols : false to only get normal components.
* @param aIncludeSubSheets true includes components of all sub-sheets and false includes
* only the components in this sheet.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true, bool aIncludeSubSheets = true );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override
#endif

View File

@ -227,43 +227,9 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const
}
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
{
// Search to sheet path number:
int sheetnumber = 1; // 1 = root
SCH_SHEET_LIST sheetList;
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext(), sheetnumber++ )
{
if( Cmp( *path ) == 0 )
break;
}
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
{
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
// Skip pseudo components, which have a reference starting with #. This mainly
// affects power symbols.
if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
reference.SetSheetNumber( sheetnumber );
aReferences.AddItem( reference );
}
}
}
}
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
bool aIncludePowerSymbols )
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs,
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols )
{
// Find sheet path number
int sheetnumber = 1; // 1 = root
@ -289,7 +255,7 @@ void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_RE
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
if( part && part->GetUnitCount() > 1 )
{
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
SCH_REFERENCE reference = SCH_REFERENCE( component, part, Last() );
reference.SetSheetNumber( sheetnumber );
wxString reference_str = reference.GetRef();
@ -629,24 +595,20 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
}
void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols )
{
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
path->GetComponents( aLibs, aReferences, aIncludePowerSymbols );
}
void SCH_SHEET_LIST::GetMultiUnitComponents( PART_LIBS* aLibs,
SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols )
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols )
{
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
{
SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
path->GetMultiUnitComponents( aLibs, tempMap );
BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, tempMap )
{
// Merge this list into the main one
unsigned n_refs = pair.second.GetCount();
for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
{
aRefList[pair.first].AddItem( pair.second[thisRef] );

View File

@ -1,9 +1,10 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 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
@ -32,6 +33,7 @@
#define CLASS_DRAWSHEET_PATH_H
#include <base_struct.h>
#include <sch_reference_list.h>
/** Info about complex hierarchies handling:
@ -82,18 +84,12 @@ class SCH_SCREEN;
class SCH_MARKER;
class SCH_SHEET;
class SCH_ITEM;
class SCH_REFERENCE_LIST;
class PART_LIBS;
#define SHEET_NOT_FOUND -1
/**
* Type SCH_MULTI_UNIT_REFERENCE_MAP
* is used to create a map of reference designators for multi-unit parts.
*/
typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
/**
* Class SCH_SHEET_PATH
* handles access to a sheet by way of a path.
@ -215,16 +211,6 @@ public:
*/
bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false );
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols : false to only get normal components.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true );
/**
* Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -234,7 +220,7 @@ public:
* @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols : false to only get normal components.
*/
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols = true );
/**
@ -414,17 +400,6 @@ public:
*/
SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
/**
* Function GetComponents
* adds a SCH_REFERENCE() object to \a aReferences for each component in the list
* of sheets.
* @param aLibs the library list to use
* @param aReferences List of references to populate.
* @param aIncludePowerSymbols Set to false to only get normal components.
*/
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
bool aIncludePowerSymbols = true );
/**
* Function GetMultiUnitComponents
* adds a SCH_REFERENCE_LIST object to \a aRefList for each same-reference set of
@ -434,8 +409,8 @@ public:
* @param aRefList Map of reference designators to reference lists
* @param aIncludePowerSymbols Set to false to only get normal components.
*/
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
bool aIncludePowerSymbols = true );
void GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
bool aIncludePowerSymbols = true );
/**
* Function FindNextItem

View File

@ -1,6 +1,3 @@
#ifndef BIN_MOD_H_
#define BIN_MOD_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +21,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef BIN_MOD_H_
#define BIN_MOD_H_
#if 0
#include <wx/filehistory.h> // wx 3.0:
#else

View File

@ -1,8 +1,3 @@
/**
* @file class_bitmap_base.h
*
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -30,6 +25,10 @@
#ifndef _BITMAP_BASE_H_
#define _BITMAP_BASE_H_
/**
* @file class_bitmap_base.h
*
*/
class PLOTTER;

View File

@ -1,5 +1,3 @@
#ifndef TITLE_BLOCK_H_
#define TITLE_BLOCK_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -23,6 +21,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CLASS_TITLE_BLOCK_H_
#define CLASS_TITLE_BLOCK_H_
#include <wx/string.h>
@ -162,4 +163,4 @@ private:
}
};
#endif // TITLE_BLOCK_H_
#endif // CLASS_TITLE_BLOCK_H_

View File

@ -1,5 +1,3 @@
#ifndef CONFIG_PARAMS_H_
#define CONFIG_PARAMS_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +23,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CONFIG_PARAMS_H_
#define CONFIG_PARAMS_H_
/**
* The common library
* @file config_params.h

View File

@ -1,6 +1,3 @@
/**
* @file convert_basic_shapes_to_polygon.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -28,6 +25,10 @@
#ifndef CONVERT_BASIC_SHAPES_TO_POLYGON_H
#define CONVERT_BASIC_SHAPES_TO_POLYGON_H
/**
* @file convert_basic_shapes_to_polygon.h
*/
#include <vector>
#include <fctsys.h>

View File

@ -5,7 +5,7 @@
*
* 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
* 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,
@ -28,151 +28,9 @@
#ifndef __dialog_hotkeys_editor__
#define __dialog_hotkeys_editor__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/choice.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/treelist.h>
#include <wx/dialog.h>
#include <wx/grid.h>
#include <vector>
#include <utility>
#include <hotkeys_basic.h>
#include <draw_frame.h>
#include <../common/dialogs/dialog_hotkeys_editor_base.h>
typedef std::pair<wxString, struct EDA_HOTKEY_CONFIG*> HOTKEYS_SECTION;
typedef std::vector<HOTKEYS_SECTION> HOTKEYS_SECTIONS;
typedef std::vector<EDA_HOTKEY> HOTKEY_LIST;
class HOTKEYS_EDITOR_DIALOG;
class DIALOG_HOTKEY_CLIENT_DATA;
/**
* Class HOTKEY_LIST_CTRL
* is a class to contain the contents of a hotkey editor tab page.
*/
class HOTKEY_LIST_CTRL : public wxTreeListCtrl
{
public:
HOTKEY_LIST_CTRL( wxWindow* aParent, const HOTKEYS_SECTIONS& aSections );
~HOTKEY_LIST_CTRL() {};
/**
* Function DeselectRow
* Deselect the given row
*
* @param aRow is the row to deselect
*/
void DeselectRow( int aRow );
/**
* Function TransferDataToControl
* Load the hotkey data into the control.
* @return true iff the operation was successful
*/
bool TransferDataToControl();
/**
* Function TransferDataFromControl
* Save the hotkey data from the control.
* @return true iff the operation was successful
*/
bool TransferDataFromControl();
/**
* Function ResolveKeyConflicts
* Check if we can set a hotkey, this will prompt the user if there
* is a conflict between keys. The key code should have already been
* checked that it's not for the same entry as its currently in or else
* it'll prompt the change on itself.
* The function will do conflict detection depending on aSectionTag.
* g_CommonSectionTag means the key code must be checked with all sections.
* While other tags means the key code only must be checked with the aSectionTag
* section and g_CommonSectionTag section.
*
* @param aKey is the key code that wants to be set
* @param aSectionTag is the section tag that the key code came from
*
* @return True if the user accepted the overwrite or no conflict existed
*/
bool ResolveKeyConflicts( long aKey, const wxString& aSectionTag );
/**
* Function CheckKeyConflicts
* Check whether the given key conflicts with anything in this HOTKEY_LIST_CTRL.
*
* @param aKey - key to check
* @param aSectionTag - section tag of the key
* @param aConfKey - if not NULL, outparam holding the key this one conflicts with
* @param aConfSect - if not NULL, outparam holding the section this one conflicts with
*/
bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
/**
* Function UpdateFromClientData
* Update all visible items from the data stored in their client data objects.
*/
void UpdateFromClientData();
private:
HOTKEYS_SECTIONS m_sections;
std::vector< HOTKEY_LIST > m_hotkeys;
std::vector< wxTreeListItem > m_items;
/**
* Function GetSelHKClientData
* Return the DIALOG_HOTKEY_CLIENT_DATA for the item being edited, or NULL if none is selected.
*/
DIALOG_HOTKEY_CLIENT_DATA* GetSelHKClientData();
/**
* Function GetHKClientData
* Return the DIALOG_HOTKEY_CLIENT_DATA for the given item, or NULL if invalid.
*/
DIALOG_HOTKEY_CLIENT_DATA* GetHKClientData( wxTreeListItem aItem );
protected:
/**
* Function LoadSection
* Generates a HOTKEY_LIST from the given hotkey configuration array and
* pushes it to m_hotkeys.
*
* @param aSection is a pointer to the hotkey configuration array
*/
void LoadSection( struct EDA_HOTKEY_CONFIG* aSection );
/**
* Function OnGetItemText
* Returns the requested row, column data to the list control.
*
* @param aRow is the row of the data which matches our hotkeys vector as a index
* @param aColumn is the column of the data which is either Command(0) or KeyCode(1)
*
* @return String containing the text for the specified row, column combination
*/
wxString OnGetItemText( long aRow, long aColumn ) const;
/**
* Function OnChar
* Decoded key press handler which is used to set key codes in the list control
*
* @param aEvent is the key press event, the keycode is retrieved from it
*/
void OnChar( wxKeyEvent& aEvent );
};
#include <widgets/widget_hotkey_list.h>
/**
* Class HOTKEYS_EDITOR_DIALOG
@ -182,14 +40,18 @@ protected:
class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
{
protected:
EDA_BASE_FRAME* m_parent;
struct EDA_HOTKEY_CONFIG* m_hotkeys;
HOTKEY_LIST_CTRL* m_hotkeyListCtrl;
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
bool TransferDataToWindow();
bool TransferDataFromWindow();
virtual EDA_BASE_FRAME* GetParent()
{
return static_cast<EDA_BASE_FRAME*>( HOTKEYS_EDITOR_DIALOG_BASE::GetParent() );
}
public:
HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );

View File

@ -1,6 +1,3 @@
#ifndef DIALOG_SHIM_
#define DIALOG_SHIM_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_SHIM_
#define DIALOG_SHIM_
#include <wx/dialog.h>
#include <hashtables.h>
#include <kiway_player.h>

View File

@ -1,5 +1,3 @@
#ifndef EDA_DRAW_FRAME_H_
#define EDA_DRAW_FRAME_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +23,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DRAW_FRAME_H_
#define DRAW_FRAME_H_
#include <wxstruct.h>
#include <kiway_player.h>
#include <climits>
@ -809,4 +810,4 @@ public:
DECLARE_EVENT_TABLE()
};
#endif // EDA_DRAW_FRAME_H_
#endif // DRAW_FRAME_H_

View File

@ -1,4 +1,4 @@
/* -*- c++ -*-
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Chris Pavlina <pavlina.chris@gmail.com>

View File

@ -1,4 +1,3 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*

View File

@ -635,8 +635,11 @@ public:
{
gridOrigin = aGridOrigin;
gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
(long) gridOrigin.y % (long) gridSize.y );
if( gridSize.x == 0.0 || gridSize.y == 0.0 )
gridOffset = VECTOR2D(0.0, 0.0);
else
gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
(long) gridOrigin.y % (long) gridSize.y );
}
/**

View File

@ -1,5 +1,3 @@
#ifndef HASHTABLES_H_
#define HASHTABLES_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HASHTABLES_H_
#define HASHTABLES_H_
#include <base_struct.h>
#include <wx/string.h>

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
@ -29,6 +29,8 @@
#ifndef HOTKEYS_BASIC_H
#define HOTKEYS_BASIC_H
#include <common.h>
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" )
// A define to allow translation of Hot Key message Info in hotkey help menu

View File

@ -1,5 +1,3 @@
#ifndef IMPORT_EXPORT_H_
#define IMPORT_EXPORT_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef IMPORT_EXPORT_H_
#define IMPORT_EXPORT_H_
/// Macros which export functions from a DLL/DSO.
/// See: http://gcc.gnu.org/wiki/Visibility

View File

@ -92,7 +92,7 @@ public:
*/
static const char* GetVersion()
{
return KICAD_CURL::version();
return curl_version();
}
@ -103,26 +103,6 @@ public:
* @return std::string - Generated version string
*/
static std::string GetSimpleVersion();
private:
// Alphabetically:
// dynamically looked up libcurl function pointers whose prototypes were
// taken from the system's libcurl headers.
static void (CURL_EXTERN * easy_cleanup) ( CURL* curl );
static CURL* (CURL_EXTERN * easy_init) ( void );
static CURLcode (CURL_EXTERN * easy_perform) ( CURL* curl );
static CURLcode (CURL_EXTERN * easy_setopt) ( CURL* curl, CURLoption option, ... );
static const char* (CURL_EXTERN * easy_strerror) ( CURLcode );
static CURLcode (CURL_EXTERN * global_init) ( long flags );
static void (CURL_EXTERN * global_cleanup) ( void );
static curl_slist* (CURL_EXTERN * slist_append) ( curl_slist*, const char* );
static void (CURL_EXTERN * slist_free_all) ( curl_slist* );
static char* (CURL_EXTERN * version) ( void );
static curl_version_info_data* (CURL_EXTERN * version_info) (CURLversion);
/// A tuple of ASCII function names and pointers to pointers to functions
static const DYN_LOOKUP dyn_funcs[];
};
#endif // KICAD_CURL_H_

View File

@ -89,7 +89,7 @@ public:
void SetHeader( const std::string& aName, const std::string& aValue )
{
std::string header = aName + ':' + aValue;
m_headers = KICAD_CURL::slist_append( m_headers, header.c_str() );
m_headers = curl_slist_append( m_headers, header.c_str() );
}
/**
@ -150,7 +150,7 @@ public:
*/
const std::string GetErrorText( CURLcode aCode )
{
return KICAD_CURL::easy_strerror( aCode );
return curl_easy_strerror( aCode );
}
/**
@ -163,7 +163,7 @@ public:
*/
template <typename T> CURLcode SetOption( CURLoption aOption, T aArg )
{
return KICAD_CURL::easy_setopt( m_CURL, aOption, aArg );
return curl_easy_setopt( m_CURL, aOption, aArg );
}
/**

View File

@ -1,4 +1,3 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*

View File

@ -1,6 +1,3 @@
#ifndef KIFACE_I_H_
#define KIFACE_I_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +21,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KIFACE_I_H_
#define KIFACE_I_H_
#include <kiway.h>
#include <bin_mod.h>

View File

@ -1,5 +1,3 @@
#ifndef KIWAY_H_
#define KIWAY_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KIWAY_H_
#define KIWAY_H_
/*

View File

@ -1,5 +1,3 @@
#ifndef KIWAY_EXPRESS_H_
#define KIWAY_EXPRESS_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KIWAY_EXPRESS_H_
#define KIWAY_EXPRESS_H_
// @see http://wiki.wxwidgets.org/Custom_Events_Tutorial
#include <wx/wx.h>
@ -102,4 +103,3 @@ typedef void ( wxEvtHandler::*kiwayExpressFunction )( KIWAY_EXPRESS& );
#endif // KIWAY_EXPRESS_H_

View File

@ -1,7 +1,3 @@
#ifndef KIWAY_MGR_H_
#define KIWAY_MGR_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -26,6 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KIWAY_MGR_H_
#define KIWAY_MGR_H_
#include <kiway.h>
#include <boost/ptr_container/ptr_vector.hpp>

View File

@ -1,6 +1,3 @@
#ifndef KIWAY_PLAYER_H_
#define KIWAY_PLAYER_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef KIWAY_PLAYER_H_
#define KIWAY_PLAYER_H_
#include <wx/frame.h>
#include <vector>
#include <wxstruct.h>

View File

@ -1,8 +1,3 @@
/**
* @file menus_helpers.h
* @brief Usefull macros and inline functions to create menus items
* in menubars or popup menus
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -26,6 +21,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef MENUS_HELPERS_H_
#define MENUS_HELPERS_H_
/**
* @file menus_helpers.h
* @brief Usefull macros and inline functions to create menus items
* in menubars or popup menus
*/
#include <bitmaps.h>
@ -203,3 +206,5 @@ static inline wxMenuItem* AddMenuItem( wxMenu* aMenu,
return item;
};
#endif // MENUS_HELPERS_H_

View File

@ -1,13 +0,0 @@
/**
* @file online_help.h
* @brief Definitions for online help for KiCad.
*/
#ifndef ONLINE_HELP_H
#define ONLINE_HELP_H
/*
* KiCad uses HTML or PDF file format in the online help (help command)
*/
#endif /* #ifndef ONLINE_HELP_H */

View File

@ -1,6 +1,25 @@
/******************/
/* pad_shapes.h */
/******************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 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 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
*/
#ifndef PAD_SHAPES_H_
#define PAD_SHAPES_H_

View File

@ -1,5 +1,3 @@
#ifndef PROJECT_H_
#define PROJECT_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -23,6 +21,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PROJECT_H_
#define PROJECT_H_
#include <vector>
#include <wx/string.h>
#include <wx/filename.h>

View File

@ -1,6 +1,3 @@
#ifndef PTREE_H_
#define PTREE_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PTREE_H_
#define PTREE_H_
/*

View File

@ -1,13 +1,3 @@
#ifndef _REPORTER_H_
#define _REPORTER_H_
/**
* @file reporter.h
* @author Wayne Stambaugh
* @note A special thanks to Dick Hollenbeck who came up with the idea that inspired
* me to write this.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -32,6 +22,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _REPORTER_H_
#define _REPORTER_H_
/**
* @file reporter.h
* @author Wayne Stambaugh
* @note A special thanks to Dick Hollenbeck who came up with the idea that inspired
* me to write this.
*/
class wxString;
class wxTextCtrl;

View File

@ -1,5 +1,3 @@
#ifndef RICHIO_H_
#define RICHIO_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef RICHIO_H_
#define RICHIO_H_
// This file defines 3 classes useful for working with DSN text files and is named
// "richio" after its author, Richard Hollenbeck, aka Dick Hollenbeck.

View File

@ -1,7 +1,3 @@
/**
* @file trigo.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,9 +21,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef TRIGO_H
#define TRIGO_H
/**
* @file trigo.h
*/
#include <math.h>
#include <wx/gdicmn.h> // For wxPoint

View File

@ -1,5 +1,3 @@
#ifndef UTF8_H_
#define UTF8_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -24,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef UTF8_H_
#define UTF8_H_
#include <string>
#include <wx/string.h>

View File

@ -0,0 +1,202 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2016 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
*/
/**
* @file widget_hotkey_list
*/
#ifndef __widget_hotkey_list__
#define __widget_hotkey_list__
#include <utility>
#include <vector>
#include <wx/treelist.h>
#include <hotkeys_basic.h>
/**
* struct HOTKEY_SECTION
* Associates a hotkey configuration with a name.
*/
struct HOTKEY_SECTION
{
wxString m_name;
EDA_HOTKEY_CONFIG* m_section;
};
typedef std::vector<HOTKEY_SECTION> HOTKEY_SECTIONS;
typedef std::vector<EDA_HOTKEY> HOTKEY_LIST;
class WIDGET_HOTKEY_CLIENT_DATA;
class WIDGET_HOTKEY_LIST : public wxTreeListCtrl
{
HOTKEY_SECTIONS m_sections;
std::vector<HOTKEY_LIST> m_hotkeys;
wxTreeListItem m_context_menu_item;
/**
* Method GetHKClientData
* Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the
* item is invalid.
*/
WIDGET_HOTKEY_CLIENT_DATA* GetHKClientData( wxTreeListItem aItem );
/**
* Method GetSelHKClientData
* Return the WIDGET_HOTKEY_CLIENT_DATA for the item being edited, or NULL if
* none is selected.
*/
WIDGET_HOTKEY_CLIENT_DATA* GetSelHKClientData();
/**
* Method UpdateFromClientData
* Refresh the visible text on the widget from the rows' client data objects.
*/
void UpdateFromClientData();
protected:
/**
* Method LoadSection
* Generates a HOTKEY_LIST from the given hotkey configuration array and pushes
* it to m_hotkeys.
*/
void LoadSection( EDA_HOTKEY_CONFIG* aSection );
/**
* Method EditItem
* Prompt the user for a new hotkey given a list item.
*/
void EditItem( wxTreeListItem aItem );
/**
* Method ResetItem
* Reset the item to the original from the dialog was created.
*/
void ResetItem( wxTreeListItem aItem );
/**
* Method OnActivated
* Handle activation of a row.
*/
void OnActivated( wxTreeListEvent& aEvent );
/**
* Method OnContextMenu
* Handle right-click on a row.
*/
void OnContextMenu( wxTreeListEvent& aEvent );
/**
* Method OnMenu
* Handle activation of a context menu item.
*/
void OnMenu( wxCommandEvent& aEvent );
/**
* Function OnSize
* Handle resizing of the control. Overrides the buggy wxTreeListCtrl::OnSize.
*/
void OnSize( wxSizeEvent& aEvent );
/**
* Method CheckKeyConflicts
* Check whether the given key conflicts with anything in this WIDGET_HOTKEY_LIST.
*
* @param aKey - key to check
* @param aSectionTag - section tag into which the key is proposed to be installed
* @param aConfKey - if not NULL, outparam getting the key this one conflicts with
* @param aConfSect - if not NULL, outparam getting the section this one conflicts with
*/
bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
/**
* Method ResolveKeyConflicts
* Check if we can set a hotkey, and prompt the user if there is a conflict between
* keys. The key code should already have been checked that it's not for the same
* entry as it's current in, or else this method will prompt for the self-change.
*
* The method will do conflict resolution depending on aSectionTag.
* g_CommonSectionTag means the key code must only be checkd with the aSectionTag
* section and g_CommonSectionTag section.
*
* @param aKey - key to check
* @param aSectionTag - section tag into which the key is proposed to be installed
*
* @return true iff the user accepted the overwrite or no conflict existed
*/
bool ResolveKeyConflicts( long aKey, const wxString& aSectionTag );
public:
/**
* Constructor WIDGET_HOTKEY_LIST
* Create a WIDGET_HOTKEY_LIST.
*
* @param aParent - parent widget
* @param aSections - list of the hotkey sections to display and their names.
* See WIDGET_HOTKEY_LIST::GenSections for a way to generate these easily
* from an EDA_HOTKEY_CONFIG*.
*/
WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS& aSections );
/**
* Static method GenSections
* Generate a list of sections and names from an EDA_HOTKEY_CONFIG*. Titles
* will be looked up from translations.
*/
static HOTKEY_SECTIONS GenSections( EDA_HOTKEY_CONFIG* aHotkeys );
/**
* Method InstallOnPanel
* Install this WIDGET_HOTKEY_LIST onto an empty panel. This is useful
* when combining with wxFormBuilder, as an empty panel can be left as a
* placeholder in the layout.
*/
void InstallOnPanel( wxPanel* aPanel );
/**
* Method TransferDataToControl
* Load the hotkey data into the control. It is safe to call this multiple times,
* for example to reset the control.
* @return true iff the operation was successful
*/
bool TransferDataToControl();
/**
* Method TransferDataFromControl
* Save the hotkey data from the control.
* @return true iff the operation was successful
*/
bool TransferDataFromControl();
/**
* Static method MapKeypressToKeycode
* Map a keypress event to the correct key code for use as a hotkey.
*/
static long MapKeypressToKeycode( const wxKeyEvent& aEvent );
};
#endif // __widget_hotkey_list__

View File

@ -1,6 +1,25 @@
/***************/
/* worksheet.h */
/***************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 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 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
*/
// For page and paper size, values are in 1/1000 inch

View File

@ -495,6 +495,16 @@ public:
*/
bool OnHotkeyRotateItem( int aIdCommand );
/**
* Function OnHotkeyFlipItem
* Flip the item (text or footprint) found under the mouse cursor
* @note This command can be used with an item currently in edit.
* Only some items can be rotated (footprints and texts).
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool OnHotkeyFlipItem( int aIdCommand );
/**
* Function OnHotkeyBeginRoute
* If the current active layer is a copper layer,

View File

@ -1,6 +1,3 @@
#ifndef XATTR_H_
#define XATTR_H_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -25,6 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef XNODE_H_
#define XNODE_H_
#include <richio.h>
// quiet the deprecated warnings with 3 lines:
@ -97,4 +97,4 @@ public:
};
#endif // XATTR_H_
#endif // XNODE_H_

View File

@ -35,7 +35,6 @@
#include <kiway.h>
#include <pgm_kicad.h>
#include <tree_project_frame.h>
#include <online_help.h>
#include <wildcards_and_files_ext.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <hotkeys_basic.h>

View File

@ -73,7 +73,7 @@ extern int MaxNodes; /* maximum number of nodes opened at one time */
/* Structures useful to the generation of board as bitmap. */
typedef char MATRIX_CELL;
typedef unsigned char MATRIX_CELL;
typedef int DIST_CELL;
typedef char DIR_CELL;

View File

@ -180,7 +180,6 @@ bool CRectPlacement::AddAtEmptySpot( TRect& r )
return bFound;
}
#include <stdio.h>
// --------------------------------------------------------------------------------
// Name : AddAtEmptySpotAutoGrow
// Description : Add a rectangle of the given size, growing our area if needed

View File

@ -480,6 +480,13 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
if( myframe->GetGalCanvas() )
{
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() );
}
myframe->GetCanvas()->Refresh();
}

View File

@ -56,8 +56,8 @@
#include <wx/stdpaths.h>
//#define USE_INSTRUMENTATION true
#define USE_INSTRUMENTATION false
//#define USE_INSTRUMENTATION 1
#define USE_INSTRUMENTATION 0
static const wxChar backupSuffix[] = wxT( "-bak" );
@ -378,7 +378,7 @@ IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl )
{
pluginType = IO_MGR::LEGACY;
}
else if( fn.GetExt() == IO_MGR::GetFileExtension( IO_MGR::IO_MGR::PCAD ) )
else if( fn.GetExt() == IO_MGR::GetFileExtension( IO_MGR::PCAD ) )
{
pluginType = IO_MGR::PCAD;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2016 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
@ -542,8 +542,6 @@ void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR )
catch( const IO_ERROR& ioe )
{
// https "GET" has faild, report this to API caller.
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'" ) );
std::string msg = StrPrintf( fmt.c_str(),

View File

@ -54,11 +54,7 @@
*/
static const wxString traceFootprintLibrary( wxT( "GedaPcbFootprintLib" ) );
static const char delims[] = " \t\r\n";
static bool inline isSpace( int c ) { return strchr( delims, c ) != 0; }
#ifdef DEBUG
static void inline traceParams( wxArrayString& aParams )
{
wxString tmp;
@ -73,7 +69,7 @@ static void inline traceParams( wxArrayString& aParams )
wxLogTrace( traceFootprintLibrary, tmp );
}
#endif
static inline long parseInt( const wxString& aValue, double aScalar )
{

View File

@ -563,7 +563,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break;
case HK_FLIP_ITEM:
OnHotkeyRotateItem( HK_FLIP_ITEM );
OnHotkeyFlipItem( HK_FLIP_ITEM );
break;
case HK_MOVE_ITEM_EXACT:
@ -1026,12 +1026,67 @@ TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC )
return track;
}
bool PCB_EDIT_FRAME::OnHotkeyFlipItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->GetFlags();
int evt_type = 0; // Used to post a wxCommandEvent on demand
wxASSERT( aIdCommand == HK_FLIP_ITEM );
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
evt_type = ID_POPUP_FLIP_BLOCK;
}
else
{
if( !itemCurrentlyEdited )
item = PcbGeneralLocateAndDisplay();
if( item == NULL )
return false;
SetCurItem( item );
switch( item->Type() )
{
case PCB_MODULE_T:
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
break;
case PCB_TEXT_T:
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
break;
default:
break;
}
}
if( evt_type != 0 )
{
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
evt.SetEventObject( this );
evt.SetId( evt_type );
GetEventHandler()->ProcessEvent( evt );
return true;
}
else
{
return false;
}
}
bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->GetFlags();
int evt_type = 0; // Used to post a wxCommandEvent on demand
wxASSERT( aIdCommand == HK_ROTATE_ITEM );
// Allows block rotate operation on hot key.
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
@ -1050,25 +1105,15 @@ bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
switch( item->Type() )
{
case PCB_MODULE_T:
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
if( aIdCommand == HK_FLIP_ITEM ) // move to other side
evt_type = ID_POPUP_PCB_CHANGE_SIDE_MODULE;
evt_type = ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE;
break;
case PCB_TEXT_T:
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
else if( aIdCommand == HK_FLIP_ITEM )
evt_type = ID_POPUP_PCB_FLIP_TEXTEPCB;
evt_type = ID_POPUP_PCB_ROTATE_TEXTEPCB;
break;
case PCB_MODULE_TEXT_T:
if( aIdCommand == HK_ROTATE_ITEM ) // Rotation
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
evt_type = ID_POPUP_PCB_ROTATE_TEXTMODULE;
break;
default:
@ -1148,8 +1193,8 @@ bool PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem( int aIdCommand )
break;
default:
wxASSERT_MSG( false, "Unhandled move, duplicate or array for "
"object type " + item->Type() );
wxASSERT_MSG( false, wxString::Format( "Unhandled move, duplicate or array for "
"object type %d", item->Type() ) );
break;
}

View File

@ -241,32 +241,6 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller )
using namespace std; // auto_ptr
static inline const char* ShowVertJustify( EDA_TEXT_VJUSTIFY_T vertical )
{
const char* rs;
switch( vertical )
{
case GR_TEXT_VJUSTIFY_TOP: rs = "T"; break;
case GR_TEXT_VJUSTIFY_CENTER: rs = "C"; break;
case GR_TEXT_VJUSTIFY_BOTTOM: rs = "B"; break;
default: rs = "?"; break;
}
return rs;
}
static inline const char* ShowHorizJustify( EDA_TEXT_HJUSTIFY_T horizontal )
{
const char* rs;
switch( horizontal )
{
case GR_TEXT_HJUSTIFY_LEFT: rs = "L"; break;
case GR_TEXT_HJUSTIFY_CENTER: rs = "C"; break;
case GR_TEXT_HJUSTIFY_RIGHT: rs = "R"; break;
default: rs = "?"; break;
}
return rs;
}
static EDA_TEXT_HJUSTIFY_T horizJustify( const char* horizontal )
{
if( !strcmp( "L", horizontal ) )
@ -3161,6 +3135,35 @@ void LEGACY_PLUGIN::SaveModule3D( const MODULE* me ) const
//-----<BOARD Save Functions>---------------------------------------------------
static inline const char* ShowVertJustify( EDA_TEXT_VJUSTIFY_T vertical )
{
const char* rs;
switch( vertical )
{
case GR_TEXT_VJUSTIFY_TOP: rs = "T"; break;
case GR_TEXT_VJUSTIFY_CENTER: rs = "C"; break;
case GR_TEXT_VJUSTIFY_BOTTOM: rs = "B"; break;
default: rs = "?"; break;
}
return rs;
}
static inline const char* ShowHorizJustify( EDA_TEXT_HJUSTIFY_T horizontal )
{
const char* rs;
switch( horizontal )
{
case GR_TEXT_HJUSTIFY_LEFT: rs = "L"; break;
case GR_TEXT_HJUSTIFY_CENTER: rs = "C"; break;
case GR_TEXT_HJUSTIFY_RIGHT: rs = "R"; break;
default: rs = "?"; break;
}
return rs;
}
#define SPBUFZ 50 // wire all usages of this together.
int LEGACY_PLUGIN::biuSprintf( char* buf, BIU aValue ) const

View File

@ -25,6 +25,7 @@
#include <pcb_base_edit_frame.h>
#include <tool/tool_manager.h>
#include <pcb_draw_panel_gal.h>
#include <gal/graphics_abstraction_layer.h>
#include <class_board.h>
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
@ -73,6 +74,8 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
PCB_BASE_FRAME::SetBoard( aBoard );
GetGalCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) );
// update the tool manager with the new board and its view.
if( m_toolManager )
{
@ -86,4 +89,3 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
}
}

View File

@ -786,7 +786,19 @@ EDA_COLOR_T PCB_EDIT_FRAME::GetGridColor() const
void PCB_EDIT_FRAME::SetGridColor( EDA_COLOR_T aColor )
{
GetBoard()->SetVisibleElementColor( GRID_VISIBLE, aColor );
if( IsGalCanvasActive() )
{
StructColors c = g_ColorRefs[ aColor ];
KIGFX::COLOR4D color( (double) c.m_Red / 255.0,
(double) c.m_Green / 255.0,
(double) c.m_Blue / 255.0,
0.7 );
GetGalCanvas()->GetGAL()->SetGridColor( color );
}
}

View File

@ -1,4 +1,5 @@
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/v1
${CMAKE_CURRENT_SOURCE_DIR}/v2

View File

@ -3320,7 +3320,7 @@ void IDF3_COMP_OUTLINE::readData( std::ifstream& aLibFile, const std::string& aH
// check RECORD 4
while( aLibFile.good() && !FetchIDFLine( aLibFile, iline, comment, pos ) );
if( ( !aLibFile.good() && aLibFile.eof() ) || iline.empty() )
if( ( !aLibFile.good() && aLibFile.eof() ) && iline.empty() )
{
ostringstream ostr;