* KIWAY Milestone A): Make major modules into DLL/DSOs.

!   The initial testing of this commit should be done using a Debug build so that
    all the wxASSERT()s are enabled.  Also, be sure and keep enabled the
    USE_KIWAY_DLLs option.  The tree won't likely build without it.  Turning it
    off is senseless anyways.  If you want stable code, go back to a prior version,
    the one tagged with "stable".

*   Relocate all functionality out of the wxApp derivative into more finely
    targeted purposes:
    a) DLL/DSO specific
    b) PROJECT specific
    c) EXE or process specific
    d) configuration file specific data
    e) configuration file manipulations functions.

    All of this functionality was blended into an extremely large wxApp derivative
    and that was incompatible with the desire to support multiple concurrently
    loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
    An amazing amount of organization come from simply sorting each bit of
    functionality into the proper box.

*   Switch to wxConfigBase from wxConfig everywhere except instantiation.
*   Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
    PGM_SINGLE_TOP,
*   Remove "Return" prefix on many function names.
*   Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
*   Fix building boost for use in a DSO on linux.
*   Remove some of the assumptions in the CMakeLists.txt files that windows had
    to be the host platform when building windows binaries.
*   Reduce the number of wxStrings being constructed at program load time via
    static construction.
*   Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
    these functions are useful even when the wxConfigBase comes from another
    source, as is the case in the KICAD_MANAGER_FRAME.
*   Move the setting of the KIPRJMOD environment variable into class PROJECT,
    so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
*   Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
    its child wxFrames and wxDialogs now have a Kiway() member function which
    returns a KIWAY& that that window tree branch is in support of.  This is like
    wxWindows DNA in that child windows get this member with proper value at time
    of construction.
*   Anticipate some of the needs for milestones B) and C) and make code
    adjustments now in an effort to reduce work in those milestones.
*   No testing has been done for python scripting, since milestone C) has that
    being largely reworked and re-thought-out.
This commit is contained in:
Dick Hollenbeck 2014-03-19 19:42:08 -05:00
parent ec9c949c9b
commit 2c67c3ff80
335 changed files with 9281 additions and 6943 deletions

View File

@ -77,7 +77,7 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad,
{
if( aPad->GetShape() == PAD_CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aCornerBuffer, aPad->ReturnShapePos(),
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
return;
}
@ -809,7 +809,7 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
int inner_radius = aVia->GetDrillValue() / 2;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
aVia->ReturnLayerPair( &top_layer, &bottom_layer );
aVia->LayerPair( &top_layer, &bottom_layer );
// Drawing via hole:
if( g_Parm_3D_Visu.IsRealisticMode() )

View File

@ -26,7 +26,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
@ -38,23 +39,23 @@
#include <wxBasePcbFrame.h>
INFO3D_VISU g_Parm_3D_Visu;
// Key to store 3D Viewer config:
static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) );
static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) );
static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) );
static const wxString keyShowRealisticMode( wxT( "ShowRealisticMode" ) );
static const wxString keyShowAxis( wxT( "ShowAxis" ) );
static const wxString keyShowZones( wxT( "ShowZones" ) );
static const wxString keyShowFootprints( wxT( "ShowFootprints" ) );
static const wxString keyShowCopperThickness( wxT( "ShowCopperThickness" ) );
static const wxString keyShowAdhesiveLayers( wxT( "ShowAdhesiveLayers" ) );
static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) );
static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) );
static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) );
static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) );
static const wxString keyShowBoardBody( wxT( "ShowBoardBody" ) );
static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) );
static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowZones[] = wxT( "ShowZones" );
static const wxChar keyShowFootprints[] = wxT( "ShowFootprints" );
static const wxChar keyShowCopperThickness[] = wxT( "ShowCopperThickness" );
static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
static const wxChar keyShowSolderPasteLayers[] =wxT( "ShowSolderPasteLayers" );
static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, EDA_BASE_FRAME )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
@ -72,11 +73,13 @@ EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent,
const wxString& title,
long style ) :
EDA_BASE_FRAME( parent, DISPLAY3D_FRAME_TYPE, title,
wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) )
END_EVENT_TABLE()
EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
const wxString& aTitle, long style ) :
KIWAY_PLAYER( aKiway, aParent, DISPLAY3D_FRAME_TYPE, aTitle,
wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) )
{
m_canvas = NULL;
m_reloadRequest = false;
@ -87,7 +90,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent,
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
SetIcon( icon );
GetSettings();
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line
@ -139,84 +142,76 @@ void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
void EDA_3D_FRAME::GetSettings()
void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg )
{
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
class INFO3D_VISU& prms = g_Parm_3D_Visu;
EDA_BASE_FRAME::LoadSettings( aCfg );
if( config )
{
EDA_BASE_FRAME::LoadSettings();
INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
config->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
aCfg->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
aCfg->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
aCfg->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
bool tmp;
config->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
config->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
aCfg->Read( keyShowAxis, &tmp, true );
prms.SetFlag( FL_AXIS, tmp );
config->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
aCfg->Read( keyShowFootprints, &tmp, true );
prms.SetFlag( FL_MODULE, tmp );
config->Read( keyShowCopperThickness, &tmp, false );
prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
aCfg->Read( keyShowCopperThickness, &tmp, false );
prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
config->Read( keyShowZones, &tmp, true );
prms.SetFlag( FL_ZONE, tmp );
aCfg->Read( keyShowZones, &tmp, true );
prms.SetFlag( FL_ZONE, tmp );
config->Read( keyShowAdhesiveLayers, &tmp, true );
prms.SetFlag( FL_ADHESIVE, tmp );
aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
prms.SetFlag( FL_ADHESIVE, tmp );
config->Read( keyShowSilkScreenLayers, &tmp, true );
prms.SetFlag( FL_SILKSCREEN, tmp );
aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
prms.SetFlag( FL_SILKSCREEN, tmp );
config->Read( keyShowSolderMaskLayers, &tmp, true );
prms.SetFlag( FL_SOLDERMASK, tmp );
aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
prms.SetFlag( FL_SOLDERMASK, tmp );
config->Read( keyShowSolderPasteLayers, &tmp, true );
prms.SetFlag( FL_SOLDERPASTE, tmp );
aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
prms.SetFlag( FL_SOLDERPASTE, tmp );
config->Read( keyShowCommentsLayer, &tmp, true );
prms.SetFlag( FL_COMMENTS, tmp );
aCfg->Read( keyShowCommentsLayer, &tmp, true );
prms.SetFlag( FL_COMMENTS, tmp );
config->Read( keyShowEcoLayers, &tmp, true );
prms.SetFlag( FL_ECO, tmp );
aCfg->Read( keyShowEcoLayers, &tmp, true );
prms.SetFlag( FL_ECO, tmp );
config->Read( keyShowBoardBody, &tmp, true );
prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
aCfg->Read( keyShowBoardBody, &tmp, true );
prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
void EDA_3D_FRAME::SaveSettings()
void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg )
{
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
EDA_BASE_FRAME::SaveSettings( aCfg );
if( !config )
return;
INFO3D_VISU& prms = g_Parm_3D_Visu;
EDA_BASE_FRAME::SaveSettings();
config->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
class INFO3D_VISU& prms = g_Parm_3D_Visu;
config->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
config->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
config->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
config->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
config->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
config->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
config->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
config->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
config->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
config->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
config->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
config->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
aCfg->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
aCfg->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyShowAxis, prms.GetFlag( FL_AXIS ) );
aCfg->Write( keyShowFootprints, prms.GetFlag( FL_MODULE ) );
aCfg->Write( keyShowCopperThickness, prms.GetFlag( FL_USE_COPPER_THICKNESS ) );
aCfg->Write( keyShowZones, prms.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, prms.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, prms.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, prms.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, prms.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, prms.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, prms.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, prms.GetFlag( FL_SHOW_BOARD_BODY ) );
}

View File

@ -31,7 +31,7 @@
#include <common.h>
#include <macros.h>
#include <kicad_string.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <3d_viewer.h>
#include <info3d_visu.h>

View File

@ -30,7 +30,7 @@
#ifndef __3D_VIEWER_H__
#define __3D_VIEWER_H__
#include <wxstruct.h> // for EDA_BASE_FRAME.
#include <draw_frame.h>
#if !wxUSE_GLCANVAS
#error Please build wxWidgets with Opengl support (./configure --with-opengl)
@ -50,24 +50,29 @@
#include <3d_struct.h>
#define KISYS3DMOD "KISYS3DMOD"
class EDA_3D_CANVAS;
class PCB_BASE_FRAME;
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#define LIB3D_PATH wxT( "packages3d" )
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
#define LIB3D_PATH wxT( "packages3d" )
class EDA_3D_FRAME : public EDA_BASE_FRAME
class EDA_3D_FRAME : public KIWAY_PLAYER
{
private:
EDA_3D_CANVAS* m_canvas;
bool m_reloadRequest;
wxString m_defaultFileName; /// Filename to propose for screenshot
/// Tracks whether to use Orthographic or Perspective projection
bool m_ortho;
public:
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
~EDA_3D_FRAME()
{
m_auimgr.UnInit();
@ -118,8 +123,9 @@ private:
// to the current display options
void ReCreateMainToolbar();
void SetToolbars();
void GetSettings();
void SaveSettings();
void LoadSettings( wxConfigBase* aCfg ); // overload virtual
void SaveSettings( wxConfigBase* aCfg ); // overload virtual
// Other functions
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );

View File

@ -24,7 +24,7 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
#
option( USE_KIWAY_DLLS
"Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." OFF )
"Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." ON )
# The desire is to migrate designs *away from* case independence, and to create designs which use
# literally (case specific) interpreted component names. But for backwards compatibility,
@ -110,6 +110,12 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
OUTPUT_VARIABLE GCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( TO_LINKER -XLinker )
else()
set( TO_LINKER -Wl )
endif()
# Establish -Wall early, so specialized relaxations of this may come
# subsequently on the command line, such as in pcbnew/github/CMakeLists.txt
set( CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}" )
@ -177,12 +183,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( TO_LINKER -XLinker )
else()
set( TO_LINKER -Wl )
endif()
# Thou shalt not link vaporware and tell us it's a valid DSO:
set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
@ -206,11 +206,11 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif()
if( NOT CMAKE_CXX_COMPILER )
EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
endif( NOT CMAKE_CXX_COMPILER )
endif()
endif()
@ -326,7 +326,7 @@ include( ExternalProject )
include( CheckFindPackageResult )
# Turn on wxWidgets compatibility mode for some classes
add_definitions(-DWX_COMPATIBILITY)
add_definitions( -DWX_COMPATIBILITY )
#######################
# Find OpenGL library #
@ -334,6 +334,11 @@ add_definitions(-DWX_COMPATIBILITY)
find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" )
# Dick 5-Feb-2014:
# Marco: This is broken. You cannot use both ExternalProject_Add() add and find_package()
# in the same CMake tree and have them both reference the same package:
# http://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add
# https://www.mail-archive.com/cmake@cmake.org/msg47501.html
if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib;.dll")
@ -351,9 +356,16 @@ if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
# TODO - Library packaging/relocation
endif()
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig
)
if( MINGW )
include( download_bzip2 )
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig bzip2
)
else()
add_custom_target( lib-dependencies
DEPENDS boost cairo glew libpng pixman pkgconfig
)
endif()
include( download_libpng )
@ -385,14 +397,18 @@ endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
#####################
# Find GLEW library #
#####################
find_package(GLEW)
check_find_package_result(GLEW_FOUND "GLEW")
if( NOT GLEW_FOUND )
find_package( GLEW )
check_find_package_result( GLEW_FOUND "GLEW" )
endif()
######################
# Find Cairo library #
######################
find_package(Cairo 1.8.1 QUIET)
check_find_package_result(CAIRO_FOUND "Cairo")
if( NOT CAIRO_FOUND )
find_package( Cairo 1.8.1 QUIET )
check_find_package_result( CAIRO_FOUND "Cairo" )
endif()
# Download boost and possibly build parts of it
#################################################
@ -428,8 +444,8 @@ else()
endif()
if( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
endif( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
endif()
# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )

View File

@ -59,7 +59,9 @@ set( BOOST_LIBS_BUILT
)
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" )
set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )
@ -99,7 +101,7 @@ else()
endif()
if( MINGW )
if( MINGW AND NOT CMAKE_HOST_UNIX ) # building for MINGW on windows not UNIX
if( MSYS )
# The Boost system does not build properly on MSYS using bootstrap.sh. Running
# bootstrap.bat with cmd.exe does. It's ugly but it works. At least for Boost
@ -113,14 +115,16 @@ if( MINGW )
set( b2_libs ${b2_libs} --with-${lib} )
endforeach()
unset( BOOST_CFLAGS )
else()
string( REGEX REPLACE "\\;" "," libs_csv "${boost_libs_list}" )
#message( STATUS "libs_csv:${libs_csv}" )
set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} )
# pass to *both* C and C++ compilers
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
set( BOOST_CXXFLAGS "cxxflags=${PIC_FLAG}" )
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
unset( b2_libs )
endif()

View File

@ -33,7 +33,9 @@ set( CAIRO_ROOT "${PROJECT_SOURCE_DIR}/cairo_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/cairo )
@ -42,7 +44,7 @@ if ( KICAD_BUILD_STATIC )
endif( KICAD_BUILD_STATIC )
if (APPLE)
if (APPLE)
set( CAIRO_CFLAGS "CFLAGS=" )
set( CAIRO_LDFLAGS "LDFLAGS=-framework CoreServices -framework Cocoa" )
@ -94,8 +96,13 @@ ExternalProject_Add( cairo
#BINARY_DIR "${PREFIX}"
BUILD_COMMAND $(MAKE)
BUILD_COMMAND $(MAKE)
INSTALL_DIR "${CAIRO_ROOT}"
INSTALL_COMMAND $(MAKE) install
)
# match these with whatever FindCairo.cmake sets
set( CAIRO_FOUND true )
set( CAIRO_INCLUDE_DIR ${PREFIX}/include )
set( CAIRO_CAIRO_LIBRARIES ${PREFIX}/lib )

View File

@ -33,11 +33,13 @@ set( GLEW_ROOT "${PROJECT_SOURCE_DIR}/glew_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/glew )
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
set( GLEW_CFLAGS "CFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" )
set( GLEW_LDFLAGS "LDFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" )

View File

@ -33,13 +33,15 @@ set( PIXMAN_ROOT "${PROJECT_SOURCE_DIR}/pixman_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/pixman )
set(PIXMAN_CPPFLAGS "CFLAGS=")
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
set(PIXMAN_CPPFLAGS "${PIXMAN_CPPFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES} -fno-common -mmacosx-version-min=10.5")
else()

View File

@ -33,7 +33,9 @@ set( PKGCONFIG_ROOT "${PROJECT_SOURCE_DIR}/pkgconfig_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/pkgconfig )

View File

@ -33,11 +33,13 @@ set( LIBWX_ROOT "${PROJECT_SOURCE_DIR}/libwx_root" )
#-----</configure>---------------------------------------------------------------
find_package( BZip2 REQUIRED )
if( NOT BZIP2_FOUND )
find_package( BZip2 REQUIRED )
endif()
set( PREFIX ${DOWNLOAD_DIR}/libwx )
if (APPLE)
if (APPLE)
if( CMAKE_OSX_ARCHITECTURES )
STRING(REGEX REPLACE " -arch " "," LIBWX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
SET( LIBWX_ARCHITECTURES --enable-universal_binary=${LIBWX_ARCHITECTURES})
@ -80,7 +82,7 @@ ExternalProject_Add( libwx
#SET directories
set(wxWidgets_BIN_DIR ${LIBWX_ROOT}/bin)
set(wxWidgets_CONFIG_EXECUTABLE ${LIBWX_ROOT}/bin/wx-config)
set(wxWidgets_INCLUDE_DIRS ${LIBWX_ROOT}/include)
set(wxWidgets_INCLUDE_DIRS ${LIBWX_ROOT}/include)
set(wxWidgets_LIBRARY_DIRS ${LIBWX_ROOT}/lib)
@ -110,7 +112,7 @@ ExternalProject_Add_Step( libwx bzr_init_libwx
######
ExternalProject_Add_Step( libwx libwx_recursive_message
COMMAND cmake .
COMMAND cmake .
COMMENT "*** RERUN CMAKE - wxWidgets built, now reissue a cmake to build Kicad"
DEPENDEES install
)

View File

@ -0,0 +1,29 @@
KIWAY Build Symbols, Definitions and Intentions
COMPILING_DLL:
This is a signal to import_export.h, and when present, toggles the
interpretation of the #defines in that file. Its purpose should not be
extended beyond this.
USE_KIWAY_DLLS:
Comes from CMake as a user configuration variable, settable in the Cmake
user interface. It decides if KiCad will be built with the *.kiface program
modules.
BUILD_KIWAY_DLL:
Comes from CMake, but at the 2nd tier, not the top tier. By 2nd tier,
something like pcbnew/CMakeLists.txt, not /CMakeLists.txt is meant. It is
not a user configuration variable. Instead, the 2nd tier CMakeLists.txt file
looks at the top level USE_KIWAY_DLLS and decides how the object files under
the 2nd tier's control will be built. If it decides it wants to march in
lockstep with USE_KIWAY_DLLS, then this local CMakeLists.txt file may pass a
defined BUILD_KIWAY_DLL (singular) on the compiler command line to the
pertinent set of compilation steps under its control.

View File

@ -62,7 +62,11 @@ PCBNew
Dick's Final TODO List:
======================
*) Get licensing cleaned up.
*) DLL-ization of pcbnew & eeschema
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
*) Get licensing cleaned up.
*) DLL-ization of pcbnew & eeschema
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
Issues as a result of minimal testing:
Kicad project manager will crash when requesting help file.

View File

@ -1,5 +1,5 @@
include_directories(BEFORE ${INC_BEFORE})
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
../potrace
../polygon/kbool/include
@ -7,48 +7,63 @@ include_directories(
${INC_AFTER}
)
set(BITMAP2COMPONENT_SRCS
set( BITMAP2COMPONENT_SRCS
../common/single_top.cpp
bitmap2component.cpp
bitmap2cmp_gui_base
bitmap2cmp_gui
)
if(WIN32)
if(MINGW)
# BITMAP2COMPONENT_RESOURCES variable is set by the macro.
mingw_resource_compiler(bitmap2component)
else(MINGW)
set(BITMAP2COMPONENT_RESOURCES bitmap2component.rc)
endif(MINGW)
endif(WIN32)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=0"
)
set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
COMPILE_DEFINITIONS "COMPILING_DLL"
)
add_executable( bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES}
)
target_link_libraries( bitmap2component
common
polygon
bitmaps
${wxWidgets_LIBRARIES}
potrace
)
install( TARGETS bitmap2component
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
if(APPLE)
set(BITMAP2COMPONENT_RESOURCES bitmap2component.icns)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(MACOSX_BUNDLE_ICON_FILE bitmap2component.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.bitmap2component)
endif(APPLE)
if( false ) # linker map with cross reference
set_target_properties( bitmap2component PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=bitmap2component.map"
)
endif()
add_executable(bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES})
if( MINGW )
# BITMAP2COMPONENT_RESOURCES variable is set by the macro.
mingw_resource_compiler( bitmap2component )
else()
set( BITMAP2COMPONENT_RESOURCES bitmap2component.rc )
endif()
if(APPLE)
set_target_properties(bitmap2component PROPERTIES MACOSX_BUNDLE_INFO_PLIST
${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE)
target_link_libraries( bitmap2component common polygon bitmaps
${wxWidgets_LIBRARIES}
potrace
)
install(TARGETS bitmap2component
DESTINATION ${KICAD_BIN}
COMPONENT binary)
if( APPLE )
set( BITMAP2COMPONENT_RESOURCES bitmap2component.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/bitmap2component.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE bitmap2component.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.bitmap2component )
set_target_properties( bitmap2component PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
endif()

View File

@ -21,8 +21,11 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <macros.h>
#include <pgm_base.h>
#include <wxstruct.h>
#include <confirm.h>
#include <gestfich.h>
@ -39,47 +42,53 @@
#include <colors_selection.h>
#include <build_version.h>
#include <menus_helpers.h>
#include <kiway.h>
#include <kiface_i.h>
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" )
#define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" )
#define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" )
#define KEYWORD_LAST_FORMAT wxT( "Last_format" )
#define KEYWORD_BINARY_THRESHOLD wxT( "Threshold" )
#define KEYWORD_BW_NEGATIVE wxT( "Negative_choice" )
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" )
#define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" )
#define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" )
#define KEYWORD_LAST_FORMAT wxT( "Last_format" )
#define KEYWORD_BINARY_THRESHOLD wxT( "Threshold" )
#define KEYWORD_BW_NEGATIVE wxT( "Negative_choice" )
extern int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, int aFormat );
/* Class BM2CMP_FRAME_BASE
This is the main frame for this application
*/
/**
* Class BM2CMP_FRAME_BASE
* is the main frame for this application
*/
class BM2CMP_FRAME : public BM2CMP_FRAME_BASE
{
private:
wxImage m_Pict_Image;
wxBitmap m_Pict_Bitmap;
wxImage m_Greyscale_Image;
wxBitmap m_Greyscale_Bitmap;
wxImage m_NB_Image;
wxBitmap m_BN_Bitmap;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
wxSize m_FrameSize;
wxPoint m_FramePos;
wxConfig * m_Config;
wxImage m_Pict_Image;
wxBitmap m_Pict_Bitmap;
wxImage m_Greyscale_Image;
wxBitmap m_Greyscale_Bitmap;
wxImage m_NB_Image;
wxBitmap m_BN_Bitmap;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
wxSize m_FrameSize;
wxPoint m_FramePos;
wxConfig* m_Config;
public:
BM2CMP_FRAME();
BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
~BM2CMP_FRAME();
// overload KIWAY_PLAYER virtual
bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl=0 );
private:
// Event handlers
void OnPaint( wxPaintEvent& event );
void OnLoadFile( wxCommandEvent& event );
bool LoadFile( wxString& aFullFileName );
void OnExport( wxCommandEvent& event );
/**
@ -114,8 +123,11 @@ private:
};
BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
BM2CMP_FRAME_BASE( aParent )
{
SetKiway( this, aKiway );
int tmp;
m_Config = new wxConfig();
m_Config->Read( KEYWORD_FRAME_POSX, & m_FramePos.x, -1 );
@ -124,15 +136,16 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
m_Config->Read( KEYWORD_FRAME_SIZEY, & m_FrameSize.y, -1 );
m_Config->Read( KEYWORD_LAST_INPUT_FILE, &m_BitmapFileName );
m_Config->Read( KEYWORD_LAST_OUTPUT_FILE, &m_ConvertedFileName );
if( m_Config->Read( KEYWORD_BINARY_THRESHOLD, &tmp ) )
m_sliderThreshold->SetValue( tmp );
if( m_Config->Read( KEYWORD_BW_NEGATIVE, &tmp ) )
m_rbOptions->SetSelection( tmp ? 1 : 0 );
m_Config->Read( KEYWORD_LAST_FORMAT, &tmp );
m_radioBoxFormat->SetSelection( tmp );
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_bitmap2component_xpm ) );
@ -144,14 +157,14 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
m_buttonExport->Enable( false );
if ( m_FramePos == wxDefaultPosition )
if( m_FramePos == wxDefaultPosition )
Centre();
}
BM2CMP_FRAME::~BM2CMP_FRAME()
{
if( ( m_Config == NULL ) || IsIconized() )
if( !m_Config || IsIconized() )
return;
m_FrameSize = GetSize();
@ -207,23 +220,24 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event )
*/
void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )
{
wxFileName fn(m_BitmapFileName);
wxString path = fn.GetPath();
wxFileName fn(m_BitmapFileName);
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = wxGetCwd();
wxFileDialog FileDlg( this, _( "Choose Image" ), path, wxEmptyString,
wxFileDialog fileDlg( this, _( "Choose Image" ), path, wxEmptyString,
_( "Image Files " ) + wxImage::GetImageExtWildcard(),
wxFD_OPEN );
int diag = FileDlg.ShowModal();
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
wxString fullFilename = FileDlg.GetPath();
wxString fullFilename = fileDlg.GetPath();
if( ! LoadFile( fullFilename ) )
if( !OpenProjectFiles( std::vector<wxString>( 1, fullFilename ) ) )
return;
m_buttonExport->Enable( true );
@ -232,13 +246,22 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )
}
bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName )
bool BM2CMP_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
m_BitmapFileName = aFullFileName;
// Prj().MaybeLoadProjectSettings();
m_BitmapFileName = aFileSet[0];
if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
{
wxMessageBox( _( "Couldn't load image from <%s>" ), m_BitmapFileName.c_str() );
/* LoadFile has its own UI, no need for further failure notification here
wxString msg = wxString::Format(
_( "Could not load image '%s'" ),
GetChars( aFilename )
);
wxMessageBox( msg );
*/
return false;
}
@ -249,6 +272,7 @@ bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName )
int nb = m_Pict_Bitmap.GetDepth();
wxString msg;
msg.Printf( wxT( "%d" ), w );
m_SizeXValue->SetLabel(msg);
msg.Printf( wxT( "%d" ), h );
@ -262,12 +286,14 @@ bool BM2CMP_FRAME::LoadFile( wxString& aFullFileName )
m_Greyscale_Image.Destroy();
m_Greyscale_Image = m_Pict_Image.ConvertToGreyscale( );
if( m_rbOptions->GetSelection() > 0 )
NegateGreyscaleImage( );
m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image );
m_NB_Image = m_Greyscale_Image;
Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
Binarize( (double) m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
return true;
}
@ -297,9 +323,10 @@ void BM2CMP_FRAME::Binarize( double aThreshold )
m_BN_Bitmap = wxBitmap( m_NB_Image );
}
void BM2CMP_FRAME::NegateGreyscaleImage( )
{
unsigned char pix;
unsigned char pix;
int h = m_Greyscale_Image.GetHeight();
int w = m_Greyscale_Image.GetWidth();
@ -321,58 +348,61 @@ void BM2CMP_FRAME::OnOptionsSelection( wxCommandEvent& event )
Refresh();
}
void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event )
{
Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
Refresh();
}
void BM2CMP_FRAME::OnExport( wxCommandEvent& event )
{
int sel = m_radioBoxFormat->GetSelection();
switch( sel )
{
case 0:
OnExportEeschema();
break;
case 0:
OnExportEeschema();
break;
case 1:
OnExportPcbnew( true );
break;
case 1:
OnExportPcbnew( true );
break;
case 2:
OnExportPcbnew( false );
break;
case 2:
OnExportPcbnew( false );
break;
case 3:
OnExportPostScript();
break;
case 3:
OnExportPostScript();
break;
case 4:
OnExportLogo();
break;
case 4:
OnExportLogo();
break;
}
}
void BM2CMP_FRAME::OnExportLogo()
{
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd();
wxString msg = _( "Logo file (*.kicad_wks)|*.kicad_wks" );
wxFileDialog FileDlg( this, _( "Create a logo file" ), path, wxEmptyString,
wxFileDialog fileDlg( this, _( "Create a logo file" ), path, wxEmptyString,
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = FileDlg.ShowModal();
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
m_ConvertedFileName = FileDlg.GetPath();
m_ConvertedFileName = fileDlg.GetPath();
FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
@ -389,24 +419,26 @@ void BM2CMP_FRAME::OnExportLogo()
fclose( outfile );
}
void BM2CMP_FRAME::OnExportPostScript()
{
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
wxFileName fn( m_ConvertedFileName );
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
if( path.IsEmpty() || !wxDirExists( path ) )
path = ::wxGetCwd();
wxString msg = _( "Postscript file (*.ps)|*.ps" );
wxFileDialog FileDlg( this, _( "Create a Postscript file" ), path, wxEmptyString,
wxFileDialog fileDlg( this, _( "Create a Postscript file" ), path, wxEmptyString,
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = FileDlg.ShowModal();
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
m_ConvertedFileName = FileDlg.GetPath();
m_ConvertedFileName = fileDlg.GetPath();
FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
@ -423,27 +455,29 @@ void BM2CMP_FRAME::OnExportPostScript()
fclose( outfile );
}
void BM2CMP_FRAME::OnExportEeschema()
{
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
wxFileName fn( m_ConvertedFileName );
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd();
wxString msg = _( "Schematic lib file (*.lib)|*.lib" );
wxFileDialog FileDlg( this, _( "Create a lib file for Eeschema" ), path, wxEmptyString,
wxFileDialog fileDlg( this, _( "Create a lib file for Eeschema" ), path, wxEmptyString,
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = FileDlg.ShowModal();
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
m_ConvertedFileName = FileDlg.GetPath();
m_ConvertedFileName = fileDlg.GetPath();
FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL )
{
@ -460,29 +494,29 @@ void BM2CMP_FRAME::OnExportEeschema()
void BM2CMP_FRAME::OnExportPcbnew( bool aLegacyFormat )
{
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
wxFileName fn( m_ConvertedFileName );
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
if( path.IsEmpty() || !wxDirExists( path ) )
path = ::wxGetCwd();
wxString msg = aLegacyFormat ?
_( "Footprint file (*.emp)|*.emp" ) :
_( "Footprint file (*.kicad_mod)|*.kicad_mod" );
wxFileDialog FileDlg( this, _( "Create a footprint file for PcbNew" ),
wxFileDialog fileDlg( this, _( "Create a footprint file for PcbNew" ),
path, wxEmptyString,
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = FileDlg.ShowModal();
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
m_ConvertedFileName = FileDlg.GetPath();
m_ConvertedFileName = fileDlg.GetPath();
FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL )
{
@ -496,6 +530,7 @@ void BM2CMP_FRAME::OnExportPcbnew( bool aLegacyFormat )
fclose( outfile );
}
void BM2CMP_FRAME::ExportFile( FILE* aOutfile, int aFormat )
{
// Create a potrace bitmap
@ -525,29 +560,82 @@ void BM2CMP_FRAME::ExportFile( FILE* aOutfile, int aFormat )
}
// EDA_APP
IMPLEMENT_APP( EDA_APP )
//-----<KIFACE>-----------------------------------------------------------------
///-----------------------------------------------------------------------------
// EDA_APP
// main program
//-----------------------------------------------------------------------------
namespace BMP2CMP {
bool EDA_APP::OnInit()
static struct IFACE : public KIFACE_I
{
wxInitAllImageHandlers();
bool OnKifaceStart( PGM_BASE* aProgram );
InitEDA_Appl( wxT( "BMP2CMP" ) );
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
{
switch( aClassId )
{
wxFrame* frame = new BM2CMP_FRAME();
SetTopWindow( frame );
frame->Show( true );
default:
{
KIWAY_PLAYER* frame = new BM2CMP_FRAME( aKiway, aParent );
return frame;
}
}
}
return true;
/**
* Function IfaceOrAddress
* return a pointer to the requested object. The safest way to use this
* is to retrieve a pointer to a static instance of an interface, similar to
* how the KIFACE interface is exported. But if you know what you are doing
* use it to retrieve anything you want.
*
* @param aDataId identifies which object you want the address of.
*
* @return void* - and must be cast into the know type.
*/
void* IfaceOrAddress( int aDataId )
{
return NULL;
}
IFACE( const char* aDSOname, KIWAY::FACE_T aType ) :
KIFACE_I( aDSOname, aType )
{}
} kiface( "BMP2CMP", KIWAY::FACE_BMP2CMP );
} // namespace BMP2CMP
using namespace BMP2CMP;
static PGM_BASE* process;
KIFACE_I& Kiface()
{
return kiface;
}
void EDA_APP::MacOpenFile( const wxString& aFileName )
// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
#if defined(BUILD_KIWAY_DLLS)
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
#endif
bool IFACE::OnKifaceStart( PGM_BASE* aProgram )
{
return start_common();
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : KIWAY_PLAYER( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

View File

@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
@ -44,7 +46,7 @@
<property name="pos"></property>
<property name="size">527,470</property>
<property name="style">wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="subclass">KIWAY_PLAYER; kiway_player.h</property>
<property name="title">Bitmap to Component Converter</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class KIWAY_PLAYER;
#include "kiway_player.h"
#include <wx/scrolwin.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
@ -37,7 +40,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class BM2CMP_FRAME_BASE
///////////////////////////////////////////////////////////////////////////////
class BM2CMP_FRAME_BASE : public wxFrame
class BM2CMP_FRAME_BASE : public KIWAY_PLAYER
{
private:

View File

@ -62,6 +62,48 @@ if( WIN32 AND MSYS )
add_definitions( -DGLEW_STATIC )
endif()
# A shared library subsetted from common which restricts what can go into
# a single_top link image. By not linking to common, we control what does
# statically go into single_top link images. My current thinking is that only
# wxWidgets should be a shared link from single top, everything else should be
# statically bound into it. Otherwise you will have DSO loading problems. After it
# sets the LIB PATHS however, we want the *.kiface modules to use shared linking.
add_library( singletop STATIC EXCLUDE_FROM_ALL
confirm.cpp
eda_doc.cpp
kiway.cpp
kiway_holder.cpp
)
# A shared library used by multiple *.kiface files and one or two program
# launchers. Object files can migrate into here over time, but only if they are
# surely needed and certainly used from more than one place without recompilation.
# Functions and data all need to use the #include <import_export.h> and be declared
# as APIEXPORT
set( LIB_KICAD_SRCS
colors.cpp
dlist.cpp
string.cpp
)
if( future )
add_library( lib_kicad SHARED
)
target_link_libraries( lib_kicad
${wxWidgets_LIBRARIES}
)
set_target_properties( lib_kicad PROPERTIES
OUTPUT_NAME ki
)
install( TARGETS lib_kicad
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
set( COMMON_ABOUT_DLG_SRCS
dialog_about/AboutDialog_main.cpp
dialog_about/dialog_about.cpp
@ -89,11 +131,13 @@ set( COMMON_PAGE_LAYOUT_SRCS
)
set( COMMON_SRCS
${LIB_KICAD_SRCS}
${COMMON_ABOUT_DLG_SRCS}
${COMMON_PAGE_LAYOUT_SRCS}
base_struct.cpp
basicframe.cpp
bezier_curves.cpp
bin_mod.cpp
bitmap.cpp
block_commande.cpp
build_version.cpp
@ -103,6 +147,7 @@ set( COMMON_SRCS
class_marker_base.cpp
class_plotter.cpp
class_undoredo_container.cpp
colors.cpp
common.cpp
common_plot_functions.cpp
common_plotHPGL_functions.cpp
@ -111,13 +156,13 @@ set( COMMON_SRCS
common_plotGERBER_functions.cpp
common_plotDXF_functions.cpp
common_plotSVG_functions.cpp
config_params.cpp
confirm.cpp
copy_to_clipboard.cpp
dialog_shim.cpp
displlst.cpp
dlist.cpp
drawframe.cpp
drawpanel.cpp
draw_frame.cpp
draw_panel.cpp
drawtxt.cpp
dsnlexer.cpp
eda_dde.cpp
@ -130,16 +175,19 @@ set( COMMON_SRCS
hotkeys_basic.cpp
hotkey_grid_table.cpp
html_messagebox.cpp
kiface_i.cpp
kiway.cpp
kiway_holder.cpp
msgpanel.cpp
netlist_keywords.cpp
newstroke_font.cpp
projet_config.cpp
project.cpp
ptree.cpp
reporter.cpp
richio.cpp
search_stack.cpp
selcolor.cpp
string.cpp
systemdirsappend.cpp
trigo.cpp
utf8.cpp
wildcards_and_files_ext.cpp
@ -149,9 +197,11 @@ set( COMMON_SRCS
zoom.cpp
)
# We will not want edaappl.cpp linked into the KIFACE, only into the KIWAY.
if( TRUE OR NOT USE_KIWAY_DLLS )
list( APPEND COMMON_SRCS edaappl.cpp )
#if( NOT USE_KIWAY_DLLS )
# We DO NOT want pgm_base.cpp linked into the KIFACE, only into the KIWAY.
# Check the map files to verify eda_pgm.o not being linked in.
list( APPEND COMMON_SRCS pgm_base.cpp )
endif()
if( NOT HAVE_STRTOKR )
@ -180,10 +230,9 @@ set( COMMON_SRCS
geometry/shape_collisions.cpp
geometry/shape_index.cpp
)
add_library( common STATIC ${COMMON_SRCS} )
set( PCB_COMMON_SRCS
base_screen.cpp
eda_text.cpp

View File

@ -197,7 +197,7 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
* otherwise the actual value is rounded when read from dialog and converted
* in internal units, and therefore modified.
*/
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol )
wxString StringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol )
{
double value_to_print = To_User_Unit( aUnit, aValue );
@ -257,7 +257,7 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue )
{
wxString msg = ReturnStringFromValue( g_UserUnit, aValue );
wxString msg = StringFromValue( g_UserUnit, aValue );
aTextCtr.SetValue( msg );
}
@ -286,7 +286,7 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue )
}
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
double value;
double dtmp = 0;
@ -348,21 +348,21 @@ int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
}
int ReturnValueFromString( const wxString& aTextValue )
int ValueFromString( const wxString& aTextValue )
{
int value;
value = ReturnValueFromString( g_UserUnit, aTextValue);
value = ValueFromString( g_UserUnit, aTextValue);
return value;
}
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
int value;
wxString msg = aTextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg );
value = ValueFromString( g_UserUnit, msg );
return value;
}

View File

@ -36,7 +36,8 @@
#include <build_version.h>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <online_help.h>
#include <id.h>
#include <eda_doc.h>
@ -61,11 +62,9 @@ static const wxChar entryPerspective[] = wxT( "Perspective" );
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString& aFrameName ) :
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName )
{
wxSize minsize;
@ -108,7 +107,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent,
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
{
SaveSettings(); // virtual, wxFrame specific
SaveSettings( config() ); // virtual, wxFrame specific
event.Skip(); // we did not "handle" the event, only eavesdropped on it.
}
@ -116,9 +115,6 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
EDA_BASE_FRAME::~EDA_BASE_FRAME()
{
if( wxGetApp().GetHtmlHelpController() )
wxGetApp().SetHtmlHelpController( NULL );
delete m_autoSaveTimer;
// This is needed for OSX: avoids further OnDraw processing after this
@ -174,54 +170,45 @@ void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
{
int id = event.GetId();
wxGetApp().SetLanguageIdentifier( id );
wxGetApp().SetLanguage();
Pgm().SetLanguageIdentifier( id );
Pgm().SetLanguage();
ReCreateMenuBar();
GetMenuBar()->Refresh();
}
void EDA_BASE_FRAME::LoadSettings()
void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
{
wxString text;
int Ypos_min;
wxConfig* config;
config = wxGetApp().GetSettings();
int maximized = 0;
if( config )
wxString text = m_FrameName + wxT( "Pos_x" );
aCfg->Read( text, &m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
aCfg->Read( text, &m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
aCfg->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" );
aCfg->Read( text, &m_FrameSize.y, 400 );
text = m_FrameName + wxT( "Maximized" );
aCfg->Read( text, &maximized, 0 );
if( m_hasAutoSave )
{
text = m_FrameName + wxT( "Pos_x" );
config->Read( text, &m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
config->Read( text, &m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
config->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" );
config->Read( text, &m_FrameSize.y, 400 );
text = m_FrameName + wxT( "Maximized" );
config->Read( text, &maximized, 0 );
if( m_hasAutoSave )
{
text = m_FrameName + entryAutoSaveInterval;
config->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
}
text = m_FrameName + entryAutoSaveInterval;
aCfg->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
}
// Ensure Window title bar is visible
#if defined( __WXMAC__ )
// for macOSX, the window must be below system (macOSX) toolbar
// Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
Ypos_min = 20;
// Ypos_min = GetMBarHeight(); seems no more exist in new API (subject to change)
int Ypos_min = 20;
#else
Ypos_min = 0;
int Ypos_min = 0;
#endif
if( m_FramePos.y < Ypos_min )
m_FramePos.y = Ypos_min;
@ -229,44 +216,39 @@ void EDA_BASE_FRAME::LoadSettings()
if( maximized )
Maximize();
// Once this is fully implemented, wxAuiManager will be used to maintain the persistance of
// the main frame and all it's managed windows and all of the legacy frame persistence
// position code can be removed.
if( config )
config->Read( m_FrameName + entryPerspective, &m_perspective );
aCfg->Read( m_FrameName + entryPerspective, &m_perspective );
}
void EDA_BASE_FRAME::SaveSettings()
void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
{
wxString text;
wxConfig* config = wxGetApp().GetSettings();
wxString text;
if( !config || IsIconized() )
if( IsIconized() )
return;
m_FrameSize = GetSize();
m_FramePos = GetPosition();
text = m_FrameName + wxT( "Pos_x" );
config->Write( text, (long) m_FramePos.x );
aCfg->Write( text, (long) m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
config->Write( text, (long) m_FramePos.y );
aCfg->Write( text, (long) m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
config->Write( text, (long) m_FrameSize.x );
aCfg->Write( text, (long) m_FrameSize.x );
text = m_FrameName + wxT( "Size_y" );
config->Write( text, (long) m_FrameSize.y );
aCfg->Write( text, (long) m_FrameSize.y );
text = m_FrameName + wxT( "Maximized" );
config->Write( text, IsMaximized() );
aCfg->Write( text, IsMaximized() );
if( m_hasAutoSave )
{
text = m_FrameName + entryAutoSaveInterval;
config->Write( text, m_autoSaveInterval );
aCfg->Write( text, m_autoSaveInterval );
}
// Once this is fully implemented, wxAuiManager will be used to maintain
@ -276,8 +258,16 @@ void EDA_BASE_FRAME::SaveSettings()
// printf( "perspective(%s): %s\n",
// TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) );
aCfg->Write( m_FrameName + entryPerspective, perspective );
}
config->Write( m_FrameName + entryPerspective, perspective );
wxConfigBase* EDA_BASE_FRAME::config()
{
// KICAD_MANAGER_FRAME overrides this
wxConfigBase* ret = Kiface().KifaceSettings();
wxASSERT( ret );
return ret;
}
@ -288,12 +278,12 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text )
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxFileHistory * aFileHistory )
wxFileHistory* aFileHistory )
{
wxFileHistory* fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().GetFileHistory();
if( !fileHistory )
fileHistory = &Kiface().GetFileHistory();
fileHistory->AddFileToHistory( FullFileName );
}
@ -302,33 +292,36 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
wxFileHistory* aFileHistory )
{
wxString fn, msg;
size_t i;
wxFileHistory* fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().GetFileHistory();
if( !fileHistory )
fileHistory = &Kiface().GetFileHistory();
int baseId = fileHistory->GetBaseId();
wxASSERT( cmdId >= baseId && cmdId < baseId + ( int )fileHistory->GetCount() );
wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
i = ( size_t )( cmdId - baseId );
unsigned i = cmdId - baseId;
if( i < fileHistory->GetCount() )
{
fn = fileHistory->GetHistoryFile( i );
wxString fn = fileHistory->GetHistoryFile( i );
if( !wxFileName::FileExists( fn ) )
if( wxFileName::FileExists( fn ) )
return fn;
else
{
msg.Printf( wxT( "file <%s> was not found." ), GetChars( fn ) );
wxString msg = wxString::Format(
wxT( "file '%s' was not found." ),
GetChars( fn ) );
wxMessageBox( msg );
fileHistory->RemoveFileFromHistory( i );
fn = wxEmptyString;
}
}
return fn;
return wxEmptyString;
}
@ -339,28 +332,28 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
/* We have to get document for beginners,
* or the the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in wxGetApp().GetHelpFileName())
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
if( event.GetId() == wxID_INDEX )
{
// Temporary change the help filename
wxString tmp = wxGetApp().GetHelpFileName();
// Temporarily change the help filename
wxString tmp = Kiface().GetHelpFileName();
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
wxGetApp().SetHelpFileName( wxT( "getting_started_in_kicad.pdf" ) );
wxString helpFile = wxGetApp().GetHelpFile();
Kiface().SetHelpFileName( wxT( "getting_started_in_kicad.pdf" ) );
wxString helpFile = Kiface().GetHelpFile();
if( !helpFile )
{ // Try to find "Getting_Started_in_KiCad.pdf"
wxGetApp().SetHelpFileName( wxT( "Getting_Started_in_KiCad.pdf" ) );
helpFile = wxGetApp().GetHelpFile();
Kiface().SetHelpFileName( wxT( "Getting_Started_in_KiCad.pdf" ) );
helpFile = Kiface().GetHelpFile();
}
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( wxGetApp().GetHelpFileName() ) );
GetChars( Kiface().GetHelpFileName() ) );
wxMessageBox( msg );
}
else
@ -368,36 +361,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument( this, helpFile );
}
wxGetApp().SetHelpFileName( tmp );
Kiface().SetHelpFileName( tmp );
return;
}
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if( wxGetApp().GetHtmlHelpController() == NULL )
if( Kiface().GetHtmlHelpController() == NULL )
{
wxGetApp().InitOnLineHelp();
Kiface().InitOnLineHelp();
}
if( wxGetApp().GetHtmlHelpController() )
if( Kiface().GetHtmlHelpController() )
{
wxGetApp().GetHtmlHelpController()->DisplayContents();
wxGetApp().GetHtmlHelpController()->Display( wxGetApp().GetHelpFileName() );
Kiface().GetHtmlHelpController()->DisplayContents();
Kiface().GetHtmlHelpController()->Display( Kiface().GetHelpFileName() );
}
else
{
msg.Printf( _( "Help file %s could not be found." ), GetChars( wxGetApp().GetHelpFileName() ) );
msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) );
wxMessageBox( msg );
}
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString helpFile = wxGetApp().GetHelpFile();
wxString helpFile = Kiface().GetHelpFile();
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( wxGetApp().GetHelpFileName() ) );
GetChars( Kiface().GetHelpFileName() ) );
wxMessageBox( msg );
}
else
@ -413,8 +406,8 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
{
wxFileName fn = wxGetApp().GetEditorName();
wxString wildcard( wxT( "*" ) );
wxFileName fn = Pgm().GetEditorName();
wxString wildcard( wxT( "*" ) );
#ifdef __WINDOWS__
wildcard += wxT( ".exe" );
@ -430,18 +423,16 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxASSERT( wxGetApp().GetCommonSettings() );
wxString editor = dlg.GetPath();
wxConfig* cfg = wxGetApp().GetCommonSettings();
wxGetApp().SetEditorName( dlg.GetPath() );
cfg->Write( wxT( "Editor" ), wxGetApp().GetEditorName() );
Pgm().SetEditorName( editor );
}
void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
{
bool ShowAboutDialog(wxWindow * parent);
ShowAboutDialog(this);
ShowAboutDialog( this );
}
@ -535,7 +526,7 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
wxString tmp;
wxPlatformInfo info;
tmp = wxT( "Application: " ) + wxGetApp().GetTitle() + wxT( "\n" );
tmp = wxT( "Application: " ) + Pgm().App().GetAppName() + wxT( "\n" );
tmp << wxT( "Version: " ) << GetBuildVersion()
#ifdef DEBUG
<< wxT( " Debug" )
@ -666,14 +657,14 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
if( !autoSaveFileName.FileExists() )
return;
wxString msg;
wxString msg = wxString::Format( _(
"Well this is potentially embarrassing! It appears that the last time "
"you were editing the file '%s' it was not saved properly. Do you wish to restore the last "
"edits you made?" ),
GetChars( aFileName.GetFullName() )
);
msg.Printf( _( "Well this is potentially embarrassing! It appears that the last time \
you were editing the file <%s> it was not saved properly. Do you wish to restore the last \
edits you made?" ),
GetChars( aFileName.GetFullName() ) );
int response = wxMessageBox( msg, wxGetApp().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
// Make a backup of the current file, delete the file, and rename the auto save file to
// the file name.
@ -703,7 +694,7 @@ edits you made?" ),
if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
{
wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
wxGetApp().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
}
}
else
@ -716,29 +707,21 @@ edits you made?" ),
}
}
/**
* Function SetModalMode
* Disable or enable all other windows, to emulate a dialog behavior
* Useful when the frame is used to show and selec items
* (see FOOTPRINT_VIEWER_FRAME and LIB_VIEW_FRAME)
*
* @param aModal = true to disable all other opened windows (i.e.
* this windows is in dialog mode
* = false to enable other windows
* This function is analog to MakeModal( aModal ), deprecated since wxWidgets 2.9.4
*/
void EDA_BASE_FRAME::SetModalMode( bool aModal )
{
// Disable all other windows
#if wxCHECK_VERSION(2, 9, 4)
if ( IsTopLevel() )
if( IsTopLevel() )
{
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while (node)
while( node )
{
wxWindow *win = node->GetData();
if (win != this)
win->Enable(!aModal);
wxWindow* win = node->GetData();
if( win != this )
win->Enable( !aModal );
node = node->GetNext();
}

52
common/bin_mod.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <wx/config.h>
#include <bin_mod.h>
#include <online_help.h>
BIN_MOD::BIN_MOD( const char* aName ) :
m_name( aName ),
m_config( 0 )
{
}
void BIN_MOD::Init()
{
// do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
m_config = new wxConfig( wxString::FromUTF8( m_name ) );
m_history.Load( *m_config );
// Prepare On Line Help. Use only lower case for help file names, in order to
// avoid problems with upper/lower case file names under windows and unix.
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_help_file = wxString::FromUTF8( m_name ) + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_help_file = wxString::FromUTF8( m_name ) + wxT( ".pdf" );
#else
#error Help files format not defined
#endif
}
void BIN_MOD::End()
{
if( m_config )
{
m_history.Save( *m_config );
// Deleting a wxConfigBase writes its contents to disk if changed.
// Might be NULL if called twice, in which case nothing happens.
delete m_config;
m_config = 0;
}
}
BIN_MOD::~BIN_MOD()
{
End();
}

View File

@ -29,7 +29,7 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <common.h>
#include <macros.h>
#include <base_struct.h>

156
common/colors.cpp Normal file
View File

@ -0,0 +1,156 @@
#include <colors.h>
/**
* The predefined colors used in KiCad.
* Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
* This list must have exactly NBCOLORS items
*/
const StructColors g_ColorRefs[NBCOLORS] =
{
{ 0, 0, 0, BLACK, wxT( "Black" ), DARKDARKGRAY },
{ 72, 72, 72, DARKDARKGRAY, wxT( "Gray 1" ), DARKGRAY },
{ 132, 132, 132, DARKGRAY, wxT( "Gray 2" ), LIGHTGRAY },
{ 194, 194, 194, LIGHTGRAY, wxT( "Gray 3" ), WHITE },
{ 255, 255, 255, WHITE, wxT( "White" ), WHITE },
{ 194, 255, 255, LIGHTYELLOW, wxT( "L.Yellow" ), WHITE },
{ 72, 0, 0, DARKBLUE, wxT( "Blue 1" ), BLUE },
{ 0, 72, 0, DARKGREEN, wxT( "Green 1" ), GREEN },
{ 72, 72, 0, DARKCYAN, wxT( "Cyan 1" ), CYAN },
{ 0, 0, 72, DARKRED, wxT( "Red 1" ), RED },
{ 72, 0, 72, DARKMAGENTA, wxT( "Magenta 1" ), MAGENTA },
{ 0, 72, 72, DARKBROWN, wxT( "Brown 1" ), BROWN },
{ 132, 0, 0, BLUE, wxT( "Blue 2" ), LIGHTBLUE },
{ 0, 132, 0, GREEN, wxT( "Green 2" ), LIGHTGREEN },
{ 132, 132, 0, CYAN, wxT( "Cyan 2" ), LIGHTCYAN },
{ 0, 0, 132, RED, wxT( "Red 2" ), LIGHTRED },
{ 132, 0, 132, MAGENTA, wxT( "Magenta 2" ), LIGHTMAGENTA },
{ 0, 132, 132, BROWN, wxT( "Brown 2" ), YELLOW },
{ 194, 0, 0, LIGHTBLUE, wxT( "Blue 3" ), PUREBLUE, },
{ 0, 194, 0, LIGHTGREEN, wxT( "Green 3" ), PUREGREEN },
{ 194, 194, 0, LIGHTCYAN, wxT( "Cyan 3" ), PURECYAN },
{ 0, 0, 194, LIGHTRED, wxT( "Red 3" ), PURERED },
{ 194, 0, 194, LIGHTMAGENTA, wxT( "Magenta 3" ), PUREMAGENTA },
{ 0, 194, 194, YELLOW, wxT( "Yellow 3" ), PUREYELLOW },
{ 255, 0, 0, PUREBLUE, wxT( "Blue 4" ), WHITE },
{ 0, 255, 0, PUREGREEN, wxT( "Green 4" ), WHITE },
{ 255, 255, 0, PURECYAN, wxT( "Cyan 4" ), WHITE },
{ 0, 0, 255, PURERED, wxT( "Red 4" ), WHITE },
{ 255, 0, 255, PUREMAGENTA, wxT( "Magenta 4" ), WHITE },
{ 0, 255, 255, PUREYELLOW, wxT( "Yellow 4" ), WHITE },
};
EDA_COLOR_T ColorByName( const wxString& aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
bool ColorIsLight( EDA_COLOR_T aColor )
{
const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
int r = c.m_Red;
int g = c.m_Green;
int b = c.m_Blue;
return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
return ColorFindNearest( aColor.Red(), aColor.Green(), aColor.Blue() );
}
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB )
{
EDA_COLOR_T candidate = BLACK;
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (aR - c.m_Red) * (aR - c.m_Red) +
(aG - c.m_Green) * (aG - c.m_Green) +
(aB - c.m_Blue) * (aB - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= aR &&
c.m_Green >= aG && c.m_Blue >= aB )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( mixed );
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}

View File

@ -65,48 +65,6 @@ EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor;
/**
* The predefined colors used in KiCad.
* Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
* This list must have exactly NBCOLORS items
*/
const StructColors g_ColorRefs[NBCOLORS] =
{
{ 0, 0, 0, BLACK, wxT( "Black" ), DARKDARKGRAY },
{ 72, 72, 72, DARKDARKGRAY, wxT( "Gray 1" ), DARKGRAY },
{ 132, 132, 132, DARKGRAY, wxT( "Gray 2" ), LIGHTGRAY },
{ 194, 194, 194, LIGHTGRAY, wxT( "Gray 3" ), WHITE },
{ 255, 255, 255, WHITE, wxT( "White" ), WHITE },
{ 194, 255, 255, LIGHTYELLOW, wxT( "L.Yellow" ), WHITE },
{ 72, 0, 0, DARKBLUE, wxT( "Blue 1" ), BLUE },
{ 0, 72, 0, DARKGREEN, wxT( "Green 1" ), GREEN },
{ 72, 72, 0, DARKCYAN, wxT( "Cyan 1" ), CYAN },
{ 0, 0, 72, DARKRED, wxT( "Red 1" ), RED },
{ 72, 0, 72, DARKMAGENTA, wxT( "Magenta 1" ), MAGENTA },
{ 0, 72, 72, DARKBROWN, wxT( "Brown 1" ), BROWN },
{ 132, 0, 0, BLUE, wxT( "Blue 2" ), LIGHTBLUE },
{ 0, 132, 0, GREEN, wxT( "Green 2" ), LIGHTGREEN },
{ 132, 132, 0, CYAN, wxT( "Cyan 2" ), LIGHTCYAN },
{ 0, 0, 132, RED, wxT( "Red 2" ), LIGHTRED },
{ 132, 0, 132, MAGENTA, wxT( "Magenta 2" ), LIGHTMAGENTA },
{ 0, 132, 132, BROWN, wxT( "Brown 2" ), YELLOW },
{ 194, 0, 0, LIGHTBLUE, wxT( "Blue 3" ), PUREBLUE, },
{ 0, 194, 0, LIGHTGREEN, wxT( "Green 3" ), PUREGREEN },
{ 194, 194, 0, LIGHTCYAN, wxT( "Cyan 3" ), PURECYAN },
{ 0, 0, 194, LIGHTRED, wxT( "Red 3" ), PURERED },
{ 194, 0, 194, LIGHTMAGENTA, wxT( "Magenta 3" ), PUREMAGENTA },
{ 0, 194, 194, YELLOW, wxT( "Yellow 3" ), PUREYELLOW },
{ 255, 0, 0, PUREBLUE, wxT( "Blue 4" ), WHITE },
{ 0, 255, 0, PUREGREEN, wxT( "Green 4" ), WHITE },
{ 255, 255, 0, PURECYAN, wxT( "Cyan 4" ), WHITE },
{ 0, 0, 255, PURERED, wxT( "Red 4" ), WHITE },
{ 255, 0, 255, PUREMAGENTA, wxT( "Magenta 4" ), WHITE },
{ 0, 255, 255, PUREYELLOW, wxT( "Yellow 4" ), WHITE },
};
/**
* Function to use local notation or C standard notation for floating point numbers
* some countries use 1,5 and others (and C) 1.5

View File

@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <trigo.h>
#include <wxstruct.h>
#include <base_struct.h>

View File

@ -211,34 +211,34 @@ void PSLIKE_PLOTTER::fputsPostscriptString(FILE *fout, const wxString& txt)
putc( '(', fout );
for( unsigned i = 0; i < txt.length(); i++ )
{
// Lazyness made me use stdio buffering yet another time...
wchar_t ch = txt[i];
if( ch < 256 )
{
switch (ch)
{
// The ~ shouldn't reach the outside
case '~':
break;
// These characters must be escaped
case '(':
case ')':
case '\\':
putc( '\\', fout );
// Lazyness made me use stdio buffering yet another time...
wchar_t ch = txt[i];
if( ch < 256 )
{
switch (ch)
{
// The ~ shouldn't reach the outside
case '~':
break;
// These characters must be escaped
case '(':
case ')':
case '\\':
putc( '\\', fout );
// FALLTHRU
default:
putc( ch, fout );
break;
}
}
// FALLTHRU
default:
putc( ch, fout );
break;
}
}
}
putc( ')', fout );
}
/**
* Sister function for the ReturnGraphicTextWidth in drawtxt.cpp
* Sister function for the GraphicTextWidth in drawtxt.cpp
* Does the same processing (i.e. calculates a text string width) but
* using postscript metrics for the Helvetica font (optionally used for
* PS and PDF plotting
@ -303,7 +303,7 @@ void PSLIKE_PLOTTER::postscriptOverlinePositions( const wxString& aText, int aXS
}
void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror )
double aScale, bool aMirror )
{
wxASSERT( !outputFile );
m_plotMirror = aMirror;
@ -354,31 +354,31 @@ void PSLIKE_PLOTTER::computeTextParameters( const wxPoint& aPos,
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
dx = -tw / 2;
break;
dx = -tw / 2;
break;
case GR_TEXT_HJUSTIFY_RIGHT:
dx = -tw;
break;
dx = -tw;
break;
case GR_TEXT_HJUSTIFY_LEFT:
dx = 0;
break;
dx = 0;
break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
dy = th / 2;
break;
dy = th / 2;
break;
case GR_TEXT_VJUSTIFY_TOP:
dy = th;
break;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
dy = 0;
break;
dy = 0;
break;
}
RotatePoint( &dx, &dy, aOrient );
@ -620,7 +620,7 @@ void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
}
if( penState != plume || pos != penLastpos )
{
DPOINT pos_dev = userToDeviceCoordinates( pos );
DPOINT pos_dev = userToDeviceCoordinates( pos );
fprintf( outputFile, "%g %g %sto\n",
pos_dev.x, pos_dev.y,
( plume=='D' ) ? "line" : "move" );
@ -650,39 +650,39 @@ bool PS_PLOTTER::StartPlot()
static const char* PSMacro[] =
{
"%%BeginProlog\n"
"/line { newpath moveto lineto stroke } bind def\n",
"/cir0 { newpath 0 360 arc stroke } bind def\n",
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/arc0 { newpath arc stroke } bind def\n",
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [200] 100 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n",
"%%BeginProlog\n"
"/line { newpath moveto lineto stroke } bind def\n",
"/cir0 { newpath 0 360 arc stroke } bind def\n",
"/cir1 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/cir2 { newpath 0 360 arc gsave fill grestore stroke } bind def\n",
"/arc0 { newpath arc stroke } bind def\n",
"/arc1 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/arc2 { newpath 4 index 4 index moveto arc closepath gsave fill\n",
" grestore stroke } bind def\n",
"/poly0 { stroke } bind def\n",
"/poly1 { closepath gsave fill grestore stroke } bind def\n",
"/poly2 { closepath gsave fill grestore stroke } bind def\n",
"/rect0 { rectstroke } bind def\n",
"/rect1 { rectfill } bind def\n",
"/rect2 { rectfill } bind def\n",
"/linemode0 { 0 setlinecap 0 setlinejoin 0 setlinewidth } bind def\n",
"/linemode1 { 1 setlinecap 1 setlinejoin } bind def\n",
"/dashedline { [200] 100 setdash } bind def\n",
"/solidline { [] 0 setdash } bind def\n",
// This is for 'hidden' text (search anchors for PDF)
// This is for 'hidden' text (search anchors for PDF)
"/phantomshow { moveto\n",
" /KicadFont findfont 0.000001 scalefont setfont\n",
" show } bind def\n",
" show } bind def\n",
// This is for regular postscript text
"/textshow { gsave\n",
" findfont exch scalefont setfont concat 1 scale 0 0 moveto show\n",
" } bind def\n",
// Utility for getting Latin1 encoded fonts
"/reencodefont {\n",
// Utility for getting Latin1 encoded fonts
"/reencodefont {\n",
" findfont dup length dict begin\n",
" { 1 index /FID ne\n",
" { def }\n",
@ -692,13 +692,13 @@ bool PS_PLOTTER::StartPlot()
" currentdict\n",
" end } bind def\n"
// Remap AdobeStandard fonts to Latin1
"/KicadFont /Helvetica reencodefont definefont pop\n",
"/KicadFont-Bold /Helvetica-Bold reencodefont definefont pop\n",
"/KicadFont-Oblique /Helvetica-Oblique reencodefont definefont pop\n",
"/KicadFont-BoldOblique /Helvetica-BoldOblique reencodefont definefont pop\n",
"%%EndProlog\n",
NULL
// Remap AdobeStandard fonts to Latin1
"/KicadFont /Helvetica reencodefont definefont pop\n",
"/KicadFont-Bold /Helvetica-Bold reencodefont definefont pop\n",
"/KicadFont-Oblique /Helvetica-Oblique reencodefont definefont pop\n",
"/KicadFont-BoldOblique /Helvetica-BoldOblique reencodefont definefont pop\n",
"%%EndProlog\n",
NULL
};
time_t time1970 = time( NULL );
@ -726,8 +726,8 @@ bool PS_PLOTTER::StartPlot()
psPaperSize.Set( pageInfo.GetHeightMils(), pageInfo.GetWidthMils() );
fprintf( outputFile, "%%%%BoundingBox: 0 0 %d %d\n",
(int) ceil( psPaperSize.x * BIGPTsPERMIL ),
(int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
(int) ceil( psPaperSize.x * BIGPTsPERMIL ),
(int) ceil( psPaperSize.y * BIGPTsPERMIL ) );
// Specify the size of the sheet and the name associated with that size.
// (If the "User size" option has been selected for the sheet size,
@ -775,9 +775,9 @@ bool PS_PLOTTER::StartPlot()
// within the Document Structuring Convention.
fputs( "%%Page: 1 1\n"
"%%BeginPageSetup\n"
"gsave\n"
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
"linemode1\n", outputFile );
"gsave\n"
"0.0072 0.0072 scale\n" // Configure postscript for decimils coordinates
"linemode1\n", outputFile );
// Rototranslate the coordinate to achieve the landscape layout
@ -803,7 +803,7 @@ bool PS_PLOTTER::EndPlot()
wxASSERT( outputFile );
fputs( "showpage\n"
"grestore\n"
"%%EOF\n", outputFile );
"%%EOF\n", outputFile );
fclose( outputFile );
outputFile = NULL;
@ -813,15 +813,15 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth,
bool aItalic,
bool aBold )
enum EDA_COLOR_T aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth,
bool aItalic,
bool aBold )
{
SetCurrentLineWidth( aWidth );
SetColor( aColor );
@ -874,7 +874,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
if( m_textMode == PLOTTEXTMODE_PHANTOM )
{
fputsPostscriptString( outputFile, aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
fprintf( outputFile, " %g %g phantomshow\n",
pos_dev.x, pos_dev.y );
}

View File

@ -1,15 +1,36 @@
/*********************/
/* projet_config.cpp */
/*********************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <wxstruct.h>
#include <param_config.h>
#include <config_params.h>
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
@ -19,8 +40,89 @@
#include <boost/foreach.hpp>
#define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true
void wxConfigSaveParams( wxConfigBase* aCfg,
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
{
wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
if( param.m_Setup )
continue;
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( aCfg );
}
}
}
void wxConfigLoadParams( wxConfigBase* aCfg,
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
{
wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
if( param.m_Setup )
continue;
param.ReadParam( aCfg );
}
}
void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
{
wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( !param.m_Setup )
continue;
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( aCfg );
}
}
}
void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
{
wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( !param.m_Setup )
continue;
param.ReadParam( aCfg );
}
}
void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue )
@ -35,220 +137,6 @@ void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double
}
bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
const wxString& GroupName,
bool ForceUseLocalConfig )
{
wxFileName fn = fileName;
// Free old config file.
if( m_projectSettings )
{
delete m_projectSettings;
m_projectSettings = NULL;
}
/* Force the file extension.
* This allows the user to enter a filename without extension
* or use an existing name to create the project file
*/
if( fn.GetExt() != ProjectFileExtension )
{
fn.SetExt( ProjectFileExtension );
}
/* Update the library search path list if a new project file is loaded. */
if( m_projectFileName != fn )
{
RemoveLibraryPath( m_projectFileName.GetPath() );
InsertLibraryPath( fn.GetPath(), 0 );
m_projectFileName = fn;
}
// Init local config filename
if( ForceUseLocalConfig || fn.FileExists() )
{
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
m_CurrentOptionFile, wxEmptyString );
m_projectSettings->DontCreateOnDemand();
if( ForceUseLocalConfig )
return true;
/* Check the application version against the version saved in the
* project file.
*
* TODO: Push the version test up the stack so that when one of the
* KiCad application version changes, the other applications
* settings do not get updated. Practically, this can go away.
* It isn't used anywhere as far as I know (WLS).
*/
int version = -1;
int def_version = 0;
m_projectSettings->SetPath( GroupName );
version = m_projectSettings->Read( wxT( "version" ), def_version );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
if( version > 0 )
{
return true;
}
else
{
delete m_projectSettings; // Version incorrect
}
}
wxString defaultFileName;
defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) );
if( defaultFileName.IsEmpty() )
{
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
}
else
{
fn = defaultFileName;
}
// Create new project file using the default name.
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
wxEmptyString, fn.GetFullPath() );
m_projectSettings->DontCreateOnDemand();
return false;
}
void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params )
{
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write date ( surtout pour eviter bug de wxFileConfig
* qui se trompe de rubrique si declaration [xx] en premiere ligne
* (en fait si groupe vide) */
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
m_projectSettings->Write( wxT( "update" ), DateAndTime() );
m_projectSettings->Write( wxT( "last_client" ), GetAppName() );
/* Save parameters */
m_projectSettings->DeleteGroup( GroupName ); // Erase all data
m_projectSettings->Flush();
m_projectSettings->SetPath( GroupName );
m_projectSettings->Write( wxT( "version" ), CONFIG_VERSION );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{
if( param.m_Group )
m_projectSettings->SetPath( param.m_Group );
else
m_projectSettings->SetPath( GroupName );
if( param.m_Setup )
continue;
if ( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
m_projectSettings->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( m_projectSettings );
}
}
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
delete m_projectSettings;
m_projectSettings = NULL;
}
void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{
if( m_settings == NULL )
return;
unsigned count = List.size();
for( unsigned i=0; i<count; ++i )
{
const PARAM_CFG_BASE& param = List[i];
if( param.m_Setup == false )
continue;
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
m_settings->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( m_settings );
}
}
}
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New )
{
ReCreatePrjConfig( local_config_filename, GroupName, false );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
wxString timestamp = m_projectSettings->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) )
{
return false;
}
m_CurrentOptionFileDateAndTime = timestamp;
BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{
if( param.m_Group )
m_projectSettings->SetPath( param.m_Group );
else
m_projectSettings->SetPath( GroupName );
if( param.m_Setup )
continue;
param.ReadParam( m_projectSettings );
}
delete m_projectSettings;
m_projectSettings = NULL;
return true;
}
void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{
BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
{
if( param.m_Setup == false )
continue;
param.ReadParam( m_settings );
}
}
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
const wxChar* group )
{
@ -286,7 +174,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
int itmp = aConfig->Read( m_Ident, m_Default );
@ -300,7 +188,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
aConfig->Write( m_Ident, *m_Pt_param );
@ -330,7 +218,7 @@ PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( bool Insetup,
void PARAM_CFG_INT_WITH_SCALE::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
double dtmp = (double) m_Default * m_BIU_to_cfgunit;
@ -347,7 +235,7 @@ void PARAM_CFG_INT_WITH_SCALE::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
// We cannot use aConfig->Write for a double, because
@ -383,8 +271,9 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
if( itmp == UNSPECIFIED_COLOR )
@ -395,7 +284,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
@ -433,7 +322,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
double dtmp = m_Default;
@ -448,7 +337,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
// We cannot use aConfig->Write for a double, because
@ -483,7 +372,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
int itmp = aConfig->Read( m_Ident, (int) m_Default );
@ -494,7 +383,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
aConfig->Write( m_Ident, *m_Pt_param );
@ -524,22 +413,22 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
*m_Pt_param = aConfig->Read( m_Ident, m_default );
}
void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
aConfig->Write( m_Ident, *m_Pt_param );
}
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
wxString* ptparam,
const wxChar* group ) :
@ -551,7 +440,7 @@ PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
wxString prm = aConfig->Read( m_Ident );
@ -567,7 +456,7 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
wxString prm = *m_Pt_param;
@ -588,7 +477,7 @@ PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
int indexlib = 1; // We start indexlib to 1 because first
@ -617,15 +506,15 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) const
{
if( m_Pt_param == NULL || aConfig == NULL )
if( !m_Pt_param || !aConfig )
return;
wxArrayString* libname_list = m_Pt_param;
unsigned indexlib = 0;
wxString configkey;
wxString libname;
for( ; indexlib < libname_list->GetCount(); indexlib++ )
for( unsigned indexlib = 0; indexlib < libname_list->GetCount(); indexlib++ )
{
configkey = m_Ident;

View File

@ -34,7 +34,7 @@
#include <class_drawpanel.h>
#include <class_base_screen.h>
#include <confirm.h>
#include <wxstruct.h>
#include <draw_frame.h>
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );

View File

@ -21,7 +21,7 @@
#include <bitmaps.h>
#include <wxstruct.h>
#include <common.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <build_version.h>
@ -41,7 +41,7 @@ static wxString HtmlNewline( const unsigned int amount = 1 );
static void InitKiCadAboutNew( AboutAppInfo& info )
{
// Set application specific icon
const wxTopLevelWindow * const tlw = wxDynamicCast(::wxGetApp().GetTopWindow(), wxTopLevelWindow);
const wxTopLevelWindow* const tlw = wxDynamicCast( Pgm().App().GetTopWindow(), wxTopLevelWindow);
if( tlw )
info.SetIcon( tlw->GetIcon() );
@ -56,10 +56,10 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
}
/* Set title */
info.SetAppName( wxT( ".: " ) + wxGetApp().GetTitle() + wxT( " :." ) );
info.SetAppName( wxT( ".: " ) + Pgm().App().GetAppName() + wxT( " :." ) );
/* Copyright information */
info.SetCopyright( wxT( "(C) 1992-2013 KiCad Developers Team" ) );
info.SetCopyright( wxT( "(C) 1992-2014 KiCad Developers Team" ) );
/* KiCad build version */
wxString version;

View File

@ -24,12 +24,22 @@
*/
#include <dialog_shim.h>
#include <kiway_player.h>
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name ) :
wxDialog( aParent, id, title, pos, size, style, name )
wxDialog( aParent, id, title, pos, size, style, name ),
KIWAY_HOLDER( 0 )
{
// pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation.
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
wxASSERT_MSG( h,
wxT( "DIALOG_SHIM's parent not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
if( h )
SetKiway( this, &h->Kiway() );
#if DLGSHIM_USE_SETFOCUS
Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SHIM::onInit ) );
#endif

View File

@ -5,7 +5,7 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <dialog_get_component.h>

View File

@ -28,7 +28,7 @@
#include <algorithm>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <dialog_hotkeys_editor.h>
@ -202,7 +202,7 @@ void HOTKEYS_EDITOR_DIALOG::OnRightClickOnCell( wxGridEvent& event )
wxString keyname = wxGetSingleChoice( _( "Special keys only. For others keys, use keyboard" ),
_( "Select a key" ), C_COUNT, choices, this );
int key = ReturnKeyCodeFromKeyName( keyname );
int key = KeyCodeFromKeyName( keyname );
if( key == 0 )
return;
@ -251,7 +251,7 @@ void HOTKEYS_EDITOR_DIALOG::OnKeyPressed( wxKeyEvent& event )
#endif
// See if this key code is handled in hotkeys names list
bool exists;
ReturnKeyNameFromKeyCode( key, &exists );
KeyNameFromKeyCode( key, &exists );
if( !exists ) // not handled, see hotkeys_basic.cpp
{

View File

@ -33,7 +33,7 @@
#include <base_struct.h>
#include <class_drawpanel.h>
#include <class_title_block.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <worksheet_shape_builder.h>
#include <class_base_screen.h>
#include <wildcards_and_files_ext.h>

View File

@ -29,7 +29,7 @@
#include <fctsys.h>
#include <macros.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_string.h>
#include <dialog_helpers.h>

View File

@ -28,7 +28,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <gr_basic.h>
#include <common.h>
#include <bitmaps.h>
@ -38,7 +39,7 @@
#include <class_drawpanel_gal.h>
#include <class_base_screen.h>
#include <msgpanel.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
@ -88,12 +89,12 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME )
END_EVENT_TABLE()
EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_drawToolBar = NULL;
m_optionsToolBar = NULL;
@ -531,7 +532,7 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
}
int EDA_DRAW_FRAME::ReturnBlockCommand( int key )
int EDA_DRAW_FRAME::BlockCommand( int key )
{
return 0;
}
@ -582,25 +583,21 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
}
void EDA_DRAW_FRAME::LoadSettings()
void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
{
wxASSERT( wxGetApp().GetSettings() != NULL );
EDA_BASE_FRAME::LoadSettings( aCfg );
wxConfig* cfg = wxGetApp().GetSettings();
aCfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
EDA_BASE_FRAME::LoadSettings();
cfg->Read( m_FrameName + CursorShapeEntryKeyword, &m_cursorShape, ( long )0 );
bool btmp;
if ( cfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
if( aCfg->Read( m_FrameName + ShowGridEntryKeyword, &btmp ) )
SetGridVisibility( btmp );
int itmp;
if( cfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
if( aCfg->Read( m_FrameName + GridColorEntryKeyword, &itmp ) )
SetGridColor( ColorFromInt( itmp ) );
cfg->Read( m_FrameName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
aCfg->Read( m_FrameName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
// m_LastGridSizeId is an offset, expected to be >= 0
if( m_LastGridSizeId < 0 )
@ -608,17 +605,14 @@ void EDA_DRAW_FRAME::LoadSettings()
}
void EDA_DRAW_FRAME::SaveSettings()
void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
{
wxASSERT( wxGetApp().GetSettings() != NULL );
EDA_BASE_FRAME::SaveSettings( aCfg );
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings();
cfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
cfg->Write( m_FrameName + ShowGridEntryKeyword, IsGridVisible() );
cfg->Write( m_FrameName + GridColorEntryKeyword, ( long ) GetGridColor() );
cfg->Write( m_FrameName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
aCfg->Write( m_FrameName + CursorShapeEntryKeyword, m_cursorShape );
aCfg->Write( m_FrameName + ShowGridEntryKeyword, IsGridVisible() );
aCfg->Write( m_FrameName + GridColorEntryKeyword, ( long ) GetGridColor() );
aCfg->Write( m_FrameName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
}
@ -682,7 +676,7 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosi
if( ( Block->GetCommand() != BLOCK_IDLE ) || ( Block->GetState() != STATE_NO_BLOCK ) )
return false;
Block->SetCommand( (BLOCK_COMMAND_T) ReturnBlockCommand( aKey ) );
Block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
if( Block->GetCommand() == 0 )
return false;

View File

@ -28,7 +28,8 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <gr_basic.h>
#include <common.h>
#include <macros.h>
@ -36,7 +37,7 @@
#include <class_drawpanel.h>
#include <class_drawpanel_gal.h>
#include <class_base_screen.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_device_context.h>
@ -45,16 +46,17 @@ static const int CURSOR_SIZE = 12; ///< Cursor size in pixels
#define CLIP_BOX_PADDING 2
// keys to store options in config:
#define ENBL_ZOOM_NO_CENTER_KEY wxT( "ZoomNoCenter" )
#define ENBL_MIDDLE_BUTT_PAN_KEY wxT( "MiddleButtonPAN" )
#define MIDDLE_BUTT_PAN_LIMITED_KEY wxT( "MiddleBtnPANLimited" )
#define ENBL_AUTO_PAN_KEY wxT( "AutoPAN" )
#define ENBL_ZOOM_NO_CENTER_KEY wxT( "ZoomNoCenter" )
#define ENBL_MIDDLE_BUTT_PAN_KEY wxT( "MiddleButtonPAN" )
#define MIDDLE_BUTT_PAN_LIMITED_KEY wxT( "MiddleBtnPANLimited" )
#define ENBL_AUTO_PAN_KEY wxT( "AutoPAN" )
/* Definitions for enabling and disabling debugging features in drawpanel.cpp.
* Please don't forget to turn these off before making any commits to Launchpad.
*/
// Definitions for enabling and disabling debugging features in drawpanel.cpp.
// Please don't forget to turn these off before making any commits to Launchpad.
#define DEBUG_SHOW_CLIP_RECT 0 // Set to 1 to draw clipping rectangle.
/**
* Trace mask used to enable or disable the trace output of coordinates during drawing
* functions. The coordinate dumping can be turned on by setting the WXTRACE environment
@ -122,12 +124,14 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL;
if( wxGetApp().GetSettings() )
wxConfigBase* cfg = Kiface().KifaceSettings();
if( cfg )
{
wxGetApp().GetSettings()->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, false );
wxGetApp().GetSettings()->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
wxGetApp().GetSettings()->Read( MIDDLE_BUTT_PAN_LIMITED_KEY, &m_panScrollbarLimits, false );
wxGetApp().GetSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
cfg->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, false );
cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
cfg->Read( MIDDLE_BUTT_PAN_LIMITED_KEY, &m_panScrollbarLimits, false );
cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
}
m_requestAutoPan = false;
@ -149,10 +153,15 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
EDA_DRAW_PANEL::~EDA_DRAW_PANEL()
{
wxGetApp().GetSettings()->Write( ENBL_MIDDLE_BUTT_PAN_KEY, m_enableMiddleButtonPan );
wxGetApp().GetSettings()->Write( ENBL_ZOOM_NO_CENTER_KEY, m_enableZoomNoCenter );
wxGetApp().GetSettings()->Write( MIDDLE_BUTT_PAN_LIMITED_KEY, m_panScrollbarLimits );
wxGetApp().GetSettings()->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
wxConfigBase* cfg = Kiface().KifaceSettings();
if( cfg )
{
cfg->Write( ENBL_MIDDLE_BUTT_PAN_KEY, m_enableMiddleButtonPan );
cfg->Write( ENBL_ZOOM_NO_CENTER_KEY, m_enableZoomNoCenter );
cfg->Write( MIDDLE_BUTT_PAN_LIMITED_KEY, m_panScrollbarLimits );
cfg->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
}
}

View File

@ -161,7 +161,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode )
}
int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aWidth )
int GraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aWidth )
{
int tally = 0;
int char_count = aText.length();
@ -315,7 +315,7 @@ void DrawGraphicText( EDA_RECT* aClipBox,
current_char_pos = aPos;
dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aWidth );
dx = GraphicTextWidth( aText, size_h, aItalic, aWidth );
dy = size_v;
/* Do not draw the text if out of draw area! */

View File

@ -4,7 +4,7 @@
#include <fctsys.h>
#include <eda_dde.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <id.h>
#include <common.h>
#include <macros.h>

View File

@ -3,7 +3,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
@ -14,19 +14,20 @@
#include <macros.h>
void EDA_APP::ReadPdfBrowserInfos()
void PGM_BASE::ReadPdfBrowserInfos()
{
wxASSERT( m_commonSettings != NULL );
wxASSERT( m_common_settings );
m_PdfBrowser = m_commonSettings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
wxString browser = m_common_settings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
SetPdfBrowserName( browser );
}
void EDA_APP::WritePdfBrowserInfos()
void PGM_BASE::WritePdfBrowserInfos()
{
wxASSERT( m_commonSettings != NULL );
wxASSERT( m_common_settings );
m_commonSettings->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
m_common_settings->Write( wxT( "PdfBrowserName" ), GetPdfBrowserName() );
}
@ -122,7 +123,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( !wxFileExists( fullfilename ) )
{
msg.Printf( _( "Doc File <%s> not found" ), GetChars( aDocName ) );
msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) );
DisplayError( aFrame, msg );
return false;
}

View File

@ -94,7 +94,7 @@ EDA_TEXT::~EDA_TEXT()
int EDA_TEXT::LenSize( const wxString& aLine ) const
{
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
return GraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <wildcards_and_files_ext.h>
#include <footprint_info.h>
#include <io_mgr.h>

View File

@ -30,7 +30,9 @@
#include <set>
#include <appl_wxstruct.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <search_stack.h>
#include <pcb_netlist.h>
#include <reporter.h>
#include <footprint_info.h>
@ -52,11 +54,11 @@ static const wxString traceFpLibTable( wxT( "KicadFpLibTable" ) );
/// The footprint library table name used when no project file is passed to Pcbnew or CvPcb.
/// This is used temporarily to store the project specific library table until the project
/// file being edited is save. It is then moved to the file fp-lib-table in the folder where
/// file being edited is saved. It is then moved to the file fp-lib-table in the folder where
/// the project file is saved.
static wxString defaultProjectFileName( wxT( "prj-fp-lib-table" ) );
static const wxChar templateProjectFileName[] = wxT( "prj-fp-lib-table" );
static wxString defaultFileName( wxT( "fp-lib-table" ) );
static const wxChar global_tbl_name[] = wxT( "fp-lib-table" );
void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
@ -409,7 +411,7 @@ void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR )
{
wxFileName fn = GetProjectFileName( aPath );
wxFileName fn = GetProjectTableFileName( aPath.GetFullPath() );
wxLogTrace( traceFpLibTable, wxT( "Saving footprint libary table <%s>." ),
GetChars( fn.GetFullPath() ) );
@ -680,33 +682,8 @@ bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
}
bool FP_LIB_TABLE::MissingLegacyLibs( const wxArrayString& aLibNames, wxString* aErrorMsg )
{
bool retv = false;
for( unsigned i = 0; i < aLibNames.GetCount(); i++ )
{
wxFileName fn = wxFileName( wxEmptyString, aLibNames[i], LegacyFootprintLibPathExtension );
wxString legacyLibPath = wxGetApp().FindLibraryPath( fn );
if( legacyLibPath.IsEmpty() )
continue;
if( FindRowByURI( legacyLibPath ) == 0 )
{
retv = true;
if( aErrorMsg )
*aErrorMsg += wxT( "\"" ) + legacyLibPath + wxT( "\"\n" );
}
}
return retv;
}
bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aLibNames,
REPORTER* aReporter ) throw( IO_ERROR )
bool FP_LIB_TABLE::ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
const wxArrayString& aLibNames, REPORTER* aReporter ) throw( IO_ERROR )
{
wxString msg;
FPID lastFPID;
@ -720,7 +697,6 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
aNetList.SortByFPID();
wxString libPath;
wxFileName fn;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
@ -738,9 +714,9 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
{
fn = wxFileName( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
libPath = wxGetApp().FindLibraryPath( fn );
libPath = aSStack.FindValidPath( fn );
if( !libPath )
{
@ -766,7 +742,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
}
if( module == NULL )
if( !module )
{
if( aReporter )
{
@ -780,6 +756,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
// Clear the footprint assignment since the old library lookup method is no
// longer valid.
FPID emptyFPID;
component->SetFPID( emptyFPID );
retv = false;
continue;
@ -800,7 +777,9 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 )
{
uri.Replace( wxT( "/"), wxT( "\\" ) );
}
if( uri == libPath )
{
@ -815,7 +794,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
{
if( aReporter )
{
msg.Printf( _( "Component `%s` footprint '%s' legacy library path <%s > "
msg.Printf( _( "Component '%s' footprint '%s' legacy library path '%s' "
"was not found in the footprint library table.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
@ -834,7 +813,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
{
if( aReporter )
{
msg.Printf( _( "Component `%s` FPID '%s' is not valid.\n" ),
msg.Printf( _( "Component '%s' FPID '%s' is not valid.\n" ),
GetChars( component->GetReference() ),
GetChars( newFPID.Format() ) );
aReporter->Report( msg );
@ -855,55 +834,34 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
void FP_LIB_TABLE::SetProjectPathEnvVariable( const wxFileName& aPath )
{
wxString path;
if( !aPath.IsOk() || !aPath.DirExists() )
path = wxEmptyString;
else
path = aPath.GetPath();
wxLogTrace( traceFpLibTable, wxT( "Setting env %s to '%s'." ),
GetChars( ProjectPathEnvVariableName() ), GetChars( path ) );
wxSetEnv( ProjectPathEnvVariableName(), path );
}
const wxString FP_LIB_TABLE::ProjectPathEnvVariableName()
{
return wxT( "KIPRJMOD" );
}
const wxString FP_LIB_TABLE::GlobalPathEnvVariableName()
{
return wxT( KISYSMOD );
return wxT( "KISYSMOD" );
}
wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath )
wxString FP_LIB_TABLE::GetProjectTableFileName( const wxString& aProjectFullName )
{
wxFileName fn = aPath;
wxFileName fn = aProjectFullName;
wxString path = fn.GetPath();
// Set $KICAD_PRJ_PATH to user's configuration path if aPath is not set or does not exist.
if( !aPath.IsOk() || !aPath.DirExists() )
if( !fn.IsOk() || !wxFileName::IsDirReadable( path ) )
{
fn.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#if defined( __WINDOWS__ )
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.SetName( defaultProjectFileName );
fn.SetName( templateProjectFileName );
}
else
{
fn.AssignDir( aPath.GetPath() );
fn.SetName( defaultFileName );
fn.SetName( global_tbl_name );
}
wxLogTrace( traceFpLibTable, wxT( "Project specific footprint library table file '%s'." ),
wxLogTrace( traceFpLibTable, wxT( "Project footprint lib table file '%s'." ),
GetChars( fn.GetFullPath() ) );
return fn.GetFullPath();
@ -912,8 +870,8 @@ wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath )
bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
{
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
if( !fn.FileExists() )
{
@ -925,21 +883,22 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
GetChars( fn.GetPath() ) ) );
}
// Attempt to copy the default global file table from the KiCad template folder to
// the users home configuration path.
wxString fileName = wxGetApp().FindLibraryPath( defaultFileName );
// Attempt to copy the default global file table from the KiCad
// template folder to the user's home configuration path.
wxString fileName = Kiface().KifaceSearch().FindValidPath( global_tbl_name );
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
emptyTable.Format( &sf, 0 );
}
}
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
aTable.Parse( &lexer );
return tableExists;
@ -965,9 +924,9 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
}
const wxString& FP_LIB_TABLE::GetFileName()
const wxString FP_LIB_TABLE::GetFileName()
{
return defaultFileName;
return global_tbl_name;
}
@ -979,8 +938,9 @@ void FP_LIB_TABLE::Load( const wxFileName& aFileName, FP_LIB_TABLE* aFallBackTab
// Empty footprint library tables are valid.
if( aFileName.IsOk() && aFileName.FileExists() )
{
FILE_LINE_READER reader( aFileName.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
FILE_LINE_READER reader( aFileName.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
Parse( &lexer );
}
}

View File

@ -30,7 +30,7 @@
// For compilers that support precompilation, includes "wx.h".
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <confirm.h>
#include <common.h>
@ -299,14 +299,14 @@ wxString FindKicadHelpPath()
bool PathFound = false;
/* find kicad/help/ */
tmp = wxGetApp().GetExecutablePath();
tmp = Pgm().GetExecutablePath();
if( tmp.Last() == '/' )
tmp.RemoveLast();
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/doc/help/" );
LocaleString = wxGetApp().GetLocale()->GetCanonicalName();
LocaleString = Pgm().GetLocale()->GetCanonicalName();
wxString path_tmp = FullPath;
#ifdef __WINDOWS__
@ -319,9 +319,9 @@ wxString FindKicadHelpPath()
}
/* find kicad/help/ from environment variable KICAD */
if( !PathFound && wxGetApp().IsKicadEnvVariableDefined() )
if( !PathFound && Pgm().IsKicadEnvVariableDefined() )
{
FullPath = wxGetApp().GetKicadEnvVariable() + wxT( "/doc/help/" );
FullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" );
if( wxDirExists( FullPath ) )
PathFound = true;
@ -379,7 +379,7 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname of
* the KiCad binary path.
*/
FullFileName = wxGetApp().GetExecutablePath() + shortname;
FullFileName = Pgm().GetExecutablePath() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
@ -387,9 +387,9 @@ wxString FindKicadFile( const wxString& shortname )
/* Test the presence of the file in the directory shortname
* defined by the environment variable KiCad.
*/
if( wxGetApp().IsKicadEnvVariableDefined() )
if( Pgm().IsKicadEnvVariableDefined() )
{
FullFileName = wxGetApp().GetKicadEnvVariable() + shortname;
FullFileName = Pgm().GetKicadEnvVariable() + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
@ -426,7 +426,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
#ifdef __WXMAC__
if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) )
{
return ProcessExecute( wxGetApp().GetExecutablePath() + wxT( "/" )
return ProcessExecute( Pgm().GetExecutablePath() + wxT( "/" )
+ ExecFile + wxT( " " )
+ param, wxEXEC_ASYNC, callback );
}
@ -450,26 +450,26 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
}
wxString ReturnKicadDatasPath()
wxString KicadDatasPath()
{
bool PathFound = false;
wxString data_path;
if( wxGetApp().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
if( Pgm().IsKicadEnvVariableDefined() ) // Path defined by the KICAD environment variable.
{
data_path = wxGetApp().GetKicadEnvVariable();
data_path = Pgm().GetKicadEnvVariable();
PathFound = true;
}
else // Path of executables.
{
wxString tmp = wxGetApp().GetExecutablePath();
wxString tmp = Pgm().GetExecutablePath();
#ifdef __WINDOWS__
tmp.MakeLower();
#endif
if( tmp.Contains( wxT( "kicad" ) ) )
{
#ifdef __WINDOWS__
tmp = wxGetApp().GetExecutablePath();
tmp = Pgm().GetExecutablePath();
#endif
if( tmp.Last() == '/' )
tmp.RemoveLast();
@ -527,47 +527,6 @@ wxString ReturnKicadDatasPath()
}
wxString& EDA_APP::GetEditorName()
{
wxString editorname = m_EditorName;
// We get the preferred editor name from environment variable first.
if( editorname.IsEmpty() )
{
// If there is no EDITOR variable set, try the desktop default
if(!wxGetEnv( wxT( "EDITOR" ), &editorname ))
{
#ifdef __WXMAC__
editorname = "/usr/bin/open";
#elif __WXX11__
editorname = "/usr/bin/xdg-open";
#endif
}
}
if( editorname.IsEmpty() ) // We must get a preferred editor name
{
DisplayInfoMessage( NULL,
_( "No default editor found, you must choose it" ) );
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT( ".exe" );
#endif
editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString,
wxEmptyString, wxEmptyString, mask,
NULL, wxFD_OPEN, true );
}
if( !editorname.IsEmpty() )
{
m_EditorName = editorname;
m_commonSettings->Write( wxT( "Editor" ), m_EditorName );
}
return m_EditorName;
}
bool OpenPDF( const wxString& file )
{
wxString command;
@ -575,12 +534,12 @@ bool OpenPDF( const wxString& file )
wxString type;
bool success = false;
wxGetApp().ReadPdfBrowserInfos();
Pgm().ReadPdfBrowserInfos();
if( !wxGetApp().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
if( !Pgm().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
{
AddDelimiterString( filename );
command = wxGetApp().GetPdfBrowserFileName() + wxT( " " ) + filename;
command = Pgm().GetPdfBrowserName() + wxT( " " ) + filename;
}
else
{

View File

@ -1405,113 +1405,6 @@ void GRBezier( EDA_RECT* ClipBox,
}
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( mixed );
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}
EDA_COLOR_T ColorByName( const wxString& aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
bool ColorIsLight( EDA_COLOR_T aColor )
{
const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
int r = c.m_Red;
int g = c.m_Green;
int b = c.m_Blue;
return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
return ColorFindNearest( aColor.Red(), aColor.Green(), aColor.Blue() );
}
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB )
{
EDA_COLOR_T candidate = BLACK;
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (aR - c.m_Red) * (aR - c.m_Red) +
(aG - c.m_Green) * (aG - c.m_Green) +
(aB - c.m_Blue) * (aB - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= aR &&
c.m_Green >= aG && c.m_Blue >= aB )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
int aSize, EDA_COLOR_T aColor )
{

View File

@ -78,7 +78,7 @@ wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col )
}
else
{
return ReturnKeyNameFromKeyCode( hotkey_descr->m_KeyCode );
return KeyNameFromKeyCode( hotkey_descr->m_KeyCode );
}
}
}

View File

@ -29,7 +29,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <hotkeys_basic.h>
#include <id.h>
#include <confirm.h>
@ -61,9 +61,11 @@ wxString g_ModuleEditSectionTag( wxT( "[footprinteditor]" ) );
EDA_HOTKEY::EDA_HOTKEY( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent )
{
m_KeyCode = keycode; // Key code (ascii value for ascii keys
// or wxWidgets code for function key
m_InfoMsg = infomsg; // info message.
m_Idcommand = idcommand; // internal id for the corresponding
// command (see hotkey_id_commnand list)
m_IdMenuEvent = idmenuevent; // id to call the corresponding event
// (if any) (see id.h)
@ -137,13 +139,13 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
{ wxT( "" ), 0 }
};
#define MODIFIER_CTRL wxT( "Ctrl+" )
#define MODIFIER_ALT wxT( "Alt+" )
#define MODIFIER_CTRL wxT( "Ctrl+" )
#define MODIFIER_ALT wxT( "Alt+" )
#define MODIFIER_SHIFT wxT( "Shift+" )
/**
* Function ReturnKeyNameFromKeyCode
* Function KeyNameFromKeyCode
* return the key name from the key code
* Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] )
@ -151,7 +153,7 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
* @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
* @return the key name in a wxString
*/
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
{
wxString keyname, modifier, fullkeyname;
int ii;
@ -237,7 +239,7 @@ wxString AddHotkeyName( const wxString& aText, EDA_HOTKEY** aList,
wxString keyname;
if( aList )
keyname = ReturnKeyNameFromCommandId( aList, aCommandId );
keyname = KeyNameFromCommandId( aList, aCommandId );
if( !keyname.IsEmpty() )
{
@ -278,14 +280,14 @@ wxString AddHotkeyName( const wxString& aText,
{
wxString msg = aText;
wxString keyname;
EDA_HOTKEY** List;
EDA_HOTKEY** list;
if( aDescList )
{
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
{
List = aDescList->m_HK_InfoList;
keyname = ReturnKeyNameFromCommandId( List, aCommandId );
list = aDescList->m_HK_InfoList;
keyname = KeyNameFromCommandId( list, aCommandId );
if( !keyname.IsEmpty() )
{
@ -313,13 +315,13 @@ wxString AddHotkeyName( const wxString& aText,
/**
* Function ReturnKeyNameFromCommandId
* Function KeyNameFromCommandId
* return the key name from the Command id value ( m_Idcommand member value)
* @param aList = pointer to a EDA_HOTKEY list of commands
* @param aCommandId = Command Id value
* @return the key name in a wxString
*/
wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
wxString KeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
{
wxString keyname;
@ -329,7 +331,7 @@ wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
if( hk_decr->m_Idcommand == aCommandId )
{
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
break;
}
}
@ -339,14 +341,14 @@ wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId )
/**
* Function ReturnKeyCodeFromKeyName
* Function KeyCodeFromKeyName
* return the key code from its key name
* Only some wxWidgets key values are handled for function key
* @param keyname = wxString key name to find in s_Hotkey_Name_List[],
* like F2 or space or an usual (ascii) char.
* @return the key code
*/
int ReturnKeyCodeFromKeyName( const wxString& keyname )
int KeyCodeFromKeyName( const wxString& keyname )
{
int ii, keycode = 0;
@ -406,7 +408,7 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname )
void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList )
{
wxString keyname;
EDA_HOTKEY** List;
EDA_HOTKEY** list;
wxString msg = wxT( "<html><body bgcolor=\"#E2E2E2\">" );
@ -416,15 +418,16 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
{
List = aDescList->m_HK_InfoList;
list = aDescList->m_HK_InfoList;
for( ; *List != NULL; List++ )
for( ; *list != NULL; list++ )
{
EDA_HOTKEY* hk_decr = *List;
EDA_HOTKEY* hk_decr = *list;
if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) )
{
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
// Some chars should be modified, using html encoding, to be
// displayed by DisplayHtmlInfoMessage()
keyname.Replace( wxT("<"), wxT("&lt;") );
@ -480,8 +483,8 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
msg = wxT( "$hotkey list\n" );
/* Print the current hotkey list */
EDA_HOTKEY** List;
// Print the current hotkey list
EDA_HOTKEY** list;
for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
{
@ -495,13 +498,13 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
msg += *aDescList->m_SectionTag;
msg += wxT( "\n" );
List = aDescList->m_HK_InfoList;
list = aDescList->m_HK_InfoList;
for( ; *List != NULL; List++ )
for( ; *list != NULL; list++ )
{
EDA_HOTKEY* hk_decr = *List;
EDA_HOTKEY* hk_decr = *list;
msg += wxT( "shortcut " );
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
AddDelimiterString( keyname );
infokey = hk_decr->m_InfoMsg;
AddDelimiterString( infokey );
@ -548,21 +551,21 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename,
{
wxFile cfgfile( aFilename );
/* get length */
// get length
cfgfile.SeekEnd();
wxFileOffset size = cfgfile.Tell();
cfgfile.Seek( 0 );
/* read data */
// read data
char* buffer = new char[size];
cfgfile.Read( buffer, size );
wxString data( buffer, wxConvUTF8 );
/* parse */
// parse
ParseHotkeyConfig( data, aDescList );
/* cleanup */
// cleanup
delete[] buffer;
cfgfile.Close();
return 1;
@ -603,7 +606,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList )
void ParseHotkeyConfig( const wxString& data,
struct EDA_HOTKEY_CONFIG* aDescList )
{
/* Read the config */
// Read the config
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
EDA_HOTKEY** CurrentHotkeyList = 0;
@ -643,23 +646,23 @@ void ParseHotkeyConfig( const wxString& data,
if( CurrentHotkeyList == NULL )
continue;
/* Get the key name */
// Get the key name
lineTokenizer.SetString( lineTokenizer.GetString(), L"\"\r\n\t ", wxTOKEN_STRTOK );
wxString keyname = lineTokenizer.GetNextToken();
wxString remainder = lineTokenizer.GetString();
/* Get the command name */
// Get the command name
wxString fctname = remainder.AfterFirst( '\"' ).BeforeFirst( '\"' );
/* search the hotkey in current hotkey list */
for( EDA_HOTKEY** List = CurrentHotkeyList; *List != NULL; List++ )
// search the hotkey in current hotkey list
for( EDA_HOTKEY** list = CurrentHotkeyList; *list != NULL; list++ )
{
EDA_HOTKEY* hk_decr = *List;
EDA_HOTKEY* hk_decr = *list;
if( hk_decr->m_InfoMsg == fctname )
{
int code = ReturnKeyCodeFromKeyName( keyname );
int code = KeyCodeFromKeyName( keyname );
if( code )
hk_decr->m_KeyCode = code;
@ -681,7 +684,7 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext;
wxString path = wxGetCwd();
wxString filename = wxGetApp().GetAppName() + wxT( "." ) + ext;
wxString filename = Kiface().Name() + wxT( '.' ) + ext;
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
path,
@ -709,7 +712,7 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescLi
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext;
wxString path = wxGetCwd();
wxString filename = wxGetApp().GetAppName() + wxT( "." ) + ext;
wxString filename = Kiface().Name() + wxT( "." ) + ext;
filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
path,
@ -736,14 +739,14 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
wxMenu* HotkeySubmenu = new wxMenu();
/* List existing hotkey menu*/
// List existing hotkey menu
AddMenuItem( HotkeySubmenu,
ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
_( "&List Current Keys" ),
_( "Displays the current hotkeys list and corresponding commands" ),
KiBitmap( info_xpm ) );
/* Call hotkeys editor*/
// Call hotkeys editor
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
_( "&Edit Hotkeys" ),
_( "Call the hotkeys editor" ),
@ -751,19 +754,19 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
HotkeySubmenu->AppendSeparator();
/* create hotkey file to export current hotkeys config */
// create hotkey file to export current hotkeys config
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
_( "E&xport Hotkeys" ),
_( "Create a hotkey configuration file to export the current hotkeys" ),
KiBitmap( save_setup_xpm ) );
/* Reload hotkey file */
// Reload hotkey file
AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
_( "&Import Hotkeys" ),
_( "Load an existing hotkey configuration file" ),
KiBitmap( reload_xpm ) );
/* Append HotkeySubmenu to menu */
// Append HotkeySubmenu to menu
AddMenuItem( aMenu, HotkeySubmenu,
ID_PREFERENCES_HOTKEY_SUBMENU, _( "&Hotkeys" ),
_( "Hotkeys configuration and preferences" ),

206
common/kiface_i.cpp Normal file
View File

@ -0,0 +1,206 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <macros.h> // FROM_UTF8()
#include <wx/config.h>
#include <wx/stdpaths.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <common.h>
#include <gr_basic.h>
static const wxChar showPageLimitsKey[] = wxT( "ShowPageLimits" );
static const wxChar backgroundColorKey[] = wxT( "BackgroundColor" );
/// Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
/// A non-member function so it an be moved easily, plus it's nobody's business.
static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
{
SEARCH_STACK bases;
SystemDirsAppend( &bases );
aDst->Clear();
for( unsigned i = 0; i < bases.GetCount(); ++i )
{
wxFileName fn( bases[i], wxEmptyString );
// Add schematic library file path to search path list.
// we must add <kicad path>/library and <kicad path>/library/doc
if( aId == KIWAY::FACE_SCH )
{
fn.AppendDir( wxT( "library" ) );
aDst->AddPaths( fn.GetPath() );
// Add schematic doc file path (library/doc)to search path list.
fn.AppendDir( wxT( "doc" ) );
aDst->AddPaths( fn.GetPath() );
fn.RemoveLastDir();
fn.RemoveLastDir(); // "../../" up twice, removing library/doc/
}
// Add PCB library file path to search path list.
if( aId == KIWAY::FACE_PCB || aId == KIWAY::FACE_CVPCB )
{
fn.AppendDir( wxT( "modules" ) );
aDst->AddPaths( fn.GetPath() );
// Add 3D module library file path to search path list.
fn.AppendDir( wxT( "packages3d" ) );
aDst->AddPaths( fn.GetPath() );
fn.RemoveLastDir();
fn.RemoveLastDir(); // "../../" up twice, remove modules/packages3d
}
// Add KiCad template file path to search path list.
fn.AppendDir( wxT( "template" ) );
aDst->AddPaths( fn.GetPath() );
}
#if 1 && defined(DEBUG)
aDst->Show( "kiway" );
#endif
}
bool KIFACE_I::start_common()
{
m_bm.Init();
m_bm.m_config->Read( showPageLimitsKey, &g_ShowPageLimits );
// FIXME OSX Mountain Lion (10.8)
// Seems that Read doesn't found anything and ColorFromInt
// Asserts - I'm unable to reproduce on 10.7
int draw_bg_color = BLACK; // Default for all apps but Eeschema
if( m_id == KIWAY::FACE_SCH )
draw_bg_color = WHITE; // Default for Eeschema
m_bm.m_config->Read( backgroundColorKey, &draw_bg_color );
g_DrawBgColor = ColorFromInt( draw_bg_color );
setSearchPaths( &m_bm.m_search, m_id );
return true;
}
void KIFACE_I::end_common()
{
m_bm.End();
}
wxString KIFACE_I::GetHelpFile()
{
wxString fn;
wxArrayString subdirs;
wxArrayString altsubdirs;
// FIXME: This is not the ideal way to handle this. Unfortunately, the
// CMake install paths seem to be a moving target so this crude
// hack solves the problem of install path differences between
// Windows and non-Windows platforms.
// Partially fixed, but must be enhanced
// Create subdir tree for "standard" linux distributions, when KiCad comes
// from a distribution files are in /usr/share/doc/kicad/help and binaries
// in /usr/bin or /usr/local/bin
subdirs.Add( wxT( "share" ) );
subdirs.Add( wxT( "doc" ) );
subdirs.Add( wxT( "kicad" ) );
subdirs.Add( wxT( "help" ) );
// Create subdir tree for linux and Windows KiCad pack.
// Note the pack form under linux is also useful if a user wants to
// install KiCad to a server because there is only one path to mount
// or export (something like /usr/local/kicad).
// files are in <install dir>/kicad/doc/help
// (often /usr/local/kicad/kicad/doc/help)
// <install dir>/kicad/ is retrieved from m_BinDir
altsubdirs.Add( wxT( "doc" ) );
altsubdirs.Add( wxT( "help" ) );
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale* i18n = Pgm().GetLocale();
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( i18n->GetCanonicalName() );
altsubdirs.Add( i18n->GetCanonicalName() );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
// Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
// wxLocale::GetName() does not return always the short name
subdirs.Add( i18n->GetName().BeforeLast( '_' ) );
altsubdirs.Add( i18n->GetName().BeforeLast( '_' ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( wxT( "en" ) );
altsubdirs.Add( wxT( "en" ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
return fn;
}

View File

@ -53,9 +53,9 @@ const wxString KIWAY::dso_name( FACE_T aFaceId )
}
PROJECT& KIWAY::Project()
PROJECT& KIWAY::Prj() const
{
return m_project;
return *(PROJECT*) &m_project; // strip const-ness, function really is const.
}

29
common/kiway_holder.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <kiway.h>
#include <kiway_player.h>
PROJECT& KIWAY_HOLDER::Prj() const
{
return Kiway().Prj();
}
// this is not speed critical, hide it out of line.
void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
{
#if defined(DEBUG)
// offer a trap point for debugging most any window
wxASSERT( aDest );
if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
{
int breakhere=1;
(void) breakhere;
}
#endif
(void) aDest;
m_kiway = aKiway;
}

View File

@ -50,13 +50,14 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <drawtxt.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <worksheet_shape_builder.h>
#include <class_worksheet_dataitem.h>
// The layout shape used in the application
// It is accessible by WORKSHEET_LAYOUT::GetTheInstance()
WORKSHEET_LAYOUT wksTheInstance;
@ -70,21 +71,25 @@ WORKSHEET_LAYOUT::WORKSHEET_LAYOUT()
m_bottomMargin = 10.0; // the bottom page margin in mm
}
void WORKSHEET_LAYOUT::SetLeftMargin( double aMargin )
{
m_leftMargin = aMargin; // the left page margin in mm
}
void WORKSHEET_LAYOUT::SetRightMargin( double aMargin )
{
m_rightMargin = aMargin; // the right page margin in mm
}
void WORKSHEET_LAYOUT::SetTopMargin( double aMargin )
{
m_topMargin = aMargin; // the top page margin in mm
}
void WORKSHEET_LAYOUT::SetBottomMargin( double aMargin )
{
m_bottomMargin = aMargin; // the bottom page margin in mm
@ -98,8 +103,7 @@ void WORKSHEET_LAYOUT::ClearList()
m_list.clear();
}
/* Insert an item to the list of items at position aIdx
*/
void WORKSHEET_LAYOUT::Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx )
{
if ( aIdx >= GetCount() )
@ -108,8 +112,7 @@ void WORKSHEET_LAYOUT::Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx )
m_list.insert( m_list.begin() + aIdx, aItem );
}
/* Remove the item to the list of items at position aIdx
*/
bool WORKSHEET_LAYOUT::Remove( unsigned aIdx )
{
if ( aIdx >= GetCount() )
@ -118,8 +121,7 @@ bool WORKSHEET_LAYOUT::Remove( unsigned aIdx )
return true;
}
/* Remove the item to the list of items at position aIdx
*/
bool WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
{
unsigned idx = 0;
@ -135,8 +137,7 @@ bool WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
return Remove( idx );
}
/* return the index of aItem, or -1 if does not exist
*/
int WORKSHEET_LAYOUT::GetItemIndex( WORKSHEET_DATAITEM* aItem ) const
{
unsigned idx = 0;
@ -161,17 +162,13 @@ WORKSHEET_DATAITEM* WORKSHEET_LAYOUT::GetItem( unsigned aIdx ) const
return NULL;
}
/* return a short filename from a full filename:
* if the path is the current path,or if the path is the same
* as kicad.pro (in template), returns a shortname
* else do nothing and returns the full filename
*/
const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileName )
{
wxFileName fn = aFullFileName;
wxString shortFileName = aFullFileName;
wxFileName fn = aFullFileName;
wxString shortFileName = aFullFileName;
wxString fileName = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
wxString fileName = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
if( !fileName.IsEmpty() )
{
fn = fileName;
@ -182,19 +179,15 @@ const wxString WORKSHEET_LAYOUT::MakeShortFileName( const wxString& aFullFileNam
return shortFileName;
}
/**
* @return a full filename from a short filename,
* if the short filename path is void
* In this case the path is the same as kicad.pro (in template)
* else return the short filename (which have an absolute os relative path
*/
const wxString WORKSHEET_LAYOUT::MakeFullFileName( const wxString& aShortFileName )
{
wxFileName fn = aShortFileName;
wxString fullFileName = aShortFileName;
wxFileName fn = aShortFileName;
wxString fullFileName = aShortFileName;
if( fn.GetPath().IsEmpty() && !fn.GetFullName().IsEmpty() )
{
wxString name = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
wxString name = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
if( !name.IsEmpty() )
fullFileName = name;
}

742
common/pgm_base.cpp Normal file
View File

@ -0,0 +1,742 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eda_pgm.cpp
*
* @brief For the main application: init functions, and language selection
* (locale handling)
*/
#include <fctsys.h>
#include <wx/html/htmlwin.h>
#include <wx/fs_zip.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/snglinst.h>
#include <wx/stdpaths.h>
#include <pgm_base.h>
#include <wxstruct.h>
#include <macros.h>
#include <config_params.h>
#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>
#define KICAD_COMMON wxT( "kicad_common" )
// some key strings used to store parameters in KICAD_COMMON
const wxChar PGM_BASE::workingDirKey[] = wxT( "WorkingDir" ); // public
static const wxChar languageCfgKey[] = wxT( "LanguageID" );
static const wxChar kicadFpLibPath[] = wxT( "KicadFootprintLibraryPath" );
/**
* A small class to handle the list of existing translations.
* The locale translation is automatic.
* The selection of languages is mainly for maintainer's convenience
* To add a support to a new translation:
* create a new icon (flag of the country) (see Lang_Fr.xpm as an example)
* add a new item to s_Languages[].
*/
struct LANGUAGE_DESCR
{
/// wxWidgets locale identifier (See wxWidgets doc)
int m_WX_Lang_Identifier;
/// KiCad identifier used in menu selection (See id.h)
int m_KI_Lang_Identifier;
/// The menu language icons
BITMAP_DEF m_Lang_Icon;
/// Labels used in menus
wxString m_Lang_Label;
/// Set to true if the m_Lang_Label must not be translated
bool m_DoNotTranslate;
};
/**
* Variable s_Languages
* Note: because this list is not created on the fly, wxTranslation
* must be called when a language name must be displayed after translation.
* Do not change this behavior, because m_Lang_Label is also used as key in config
*/
static LANGUAGE_DESCR s_Languages[] =
{
// Default language
{
wxLANGUAGE_DEFAULT,
ID_LANGUAGE_DEFAULT,
lang_def_xpm,
_( "Default" )
},
// English language
{
wxLANGUAGE_ENGLISH,
ID_LANGUAGE_ENGLISH,
lang_en_xpm,
wxT( "English" ),
true
},
// French language
{
wxLANGUAGE_FRENCH,
ID_LANGUAGE_FRENCH,
lang_fr_xpm,
_( "French" )
},
// Finnish language
{
wxLANGUAGE_FINNISH,
ID_LANGUAGE_FINNISH,
lang_fi_xpm,
_( "Finnish" )
},
// Spanish language
{
wxLANGUAGE_SPANISH,
ID_LANGUAGE_SPANISH,
lang_es_xpm,
_( "Spanish" )
},
// Portuguese language
{
wxLANGUAGE_PORTUGUESE,
ID_LANGUAGE_PORTUGUESE,
lang_pt_xpm,
_( "Portuguese" )
},
// Italian language
{
wxLANGUAGE_ITALIAN,
ID_LANGUAGE_ITALIAN,
lang_it_xpm,
_( "Italian" )
},
// German language
{
wxLANGUAGE_GERMAN,
ID_LANGUAGE_GERMAN,
lang_de_xpm,
_( "German" )
},
// Greek language
{
wxLANGUAGE_GREEK,
ID_LANGUAGE_GREEK,
lang_gr_xpm,
_( "Greek" )
},
// Slovenian language
{
wxLANGUAGE_SLOVENIAN,
ID_LANGUAGE_SLOVENIAN,
lang_sl_xpm,
_( "Slovenian" )
},
// Hungarian language
{
wxLANGUAGE_HUNGARIAN,
ID_LANGUAGE_HUNGARIAN,
lang_hu_xpm,
_( "Hungarian" )
},
// Polish language
{
wxLANGUAGE_POLISH,
ID_LANGUAGE_POLISH,
lang_pl_xpm,
_( "Polish" )
},
// Czech language
{
wxLANGUAGE_CZECH,
ID_LANGUAGE_CZECH,
lang_cs_xpm,
_( "Czech" )
},
// Russian language
{
wxLANGUAGE_RUSSIAN,
ID_LANGUAGE_RUSSIAN,
lang_ru_xpm,
_( "Russian" )
},
// Korean language
{
wxLANGUAGE_KOREAN,
ID_LANGUAGE_KOREAN,
lang_ko_xpm,
_( "Korean" )
},
// Chinese simplified
{
wxLANGUAGE_CHINESE_SIMPLIFIED,
ID_LANGUAGE_CHINESE_SIMPLIFIED,
lang_chinese_xpm,
_( "Chinese simplified" )
},
// Catalan language
{
wxLANGUAGE_CATALAN,
ID_LANGUAGE_CATALAN,
lang_catalan_xpm,
_( "Catalan" )
},
// Dutch language
{
wxLANGUAGE_DUTCH,
ID_LANGUAGE_DUTCH,
lang_nl_xpm,
_( "Dutch" )
},
// Japanese language
{
wxLANGUAGE_JAPANESE,
ID_LANGUAGE_JAPANESE,
lang_jp_xpm,
_( "Japanese" )
},
// Bulgarian language
{
wxLANGUAGE_BULGARIAN,
ID_LANGUAGE_BULGARIAN,
lang_bg_xpm,
_( "Bulgarian" )
}
};
PGM_BASE::PGM_BASE()
{
m_pgm_checker = NULL;
m_file_checker = NULL;
m_html_ctrl = NULL;
m_locale = NULL;
m_common_settings = NULL;
m_wx_app = NULL;
setLanguageId( wxLANGUAGE_DEFAULT );
}
PGM_BASE::~PGM_BASE()
{
destroy();
}
void PGM_BASE::destroy()
{
// unlike a normal destructor, this is designed to be called more than once safely:
delete m_common_settings;
m_common_settings = 0;
delete m_pgm_checker;
m_pgm_checker = 0;
delete m_file_checker;
m_file_checker = 0;
delete m_locale;
m_locale = 0;
delete m_html_ctrl;
m_html_ctrl = 0;
}
void PGM_BASE::SetEditorName( const wxString& aFileName )
{
m_editor_name = aFileName;
wxASSERT( m_common_settings );
m_common_settings->Write( wxT( "Editor" ), aFileName );
}
const wxString& PGM_BASE::GetEditorName()
{
wxString editorname = m_editor_name;
if( !editorname )
{
// Get the preferred editor name from environment variable first.
if(!wxGetEnv( wxT( "EDITOR" ), &editorname ))
{
// If there is no EDITOR variable set, try the desktop default
#ifdef __WXMAC__
editorname = "/usr/bin/open";
#elif __WXX11__
editorname = "/usr/bin/xdg-open";
#endif
}
}
if( !editorname ) // We must get a preferred editor name
{
DisplayInfoMessage( NULL,
_( "No default editor found, you must choose it" ) );
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT( ".exe" );
#endif
editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString,
wxEmptyString, wxEmptyString, mask,
NULL, wxFD_OPEN, true );
}
if( !editorname.IsEmpty() )
{
m_editor_name = editorname;
m_common_settings->Write( wxT( "Editor" ), m_editor_name );
}
return m_editor_name;
}
bool PGM_BASE::initPgm()
{
wxFileName pgm_name( App().argv[0] );
wxInitAllImageHandlers();
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() );
if( m_pgm_checker->IsAnotherRunning() )
{
wxString quiz = wxString::Format(
_( "%s is already running, Continue?" ),
GetChars( pgm_name.GetName() )
);
if( !IsOK( NULL, quiz ) )
return false;
}
// Init KiCad environment
// the environment variable KICAD (if exists) gives the kicad path:
// something like set KICAD=d:\kicad
bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );
if( isDefined ) // ensure m_kicad_env ends by "/"
{
m_kicad_env.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
m_kicad_env += UNIX_STRING_DIR_SEP;
}
// Init parameters for configuration
App().SetVendorName( wxT( "KiCad" ) );
App().SetAppName( pgm_name.GetName().Lower() );
// Install some image handlers, mainly for help
wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxJPEGHandler );
wxFileSystem::AddHandler( new wxZipFSHandler );
// Analyze the command line & initialize the binary path
setExecutablePath();
SetLanguagePath();
// OS specific instantiation of wxConfigBase derivative:
m_common_settings = new wxConfig( KICAD_COMMON );
ReadPdfBrowserInfos(); // needs m_common_settings
loadCommonSettings();
bool succes = SetLanguage( true );
if( !succes )
{
}
// Set locale option for separator used in float numbers
SetLocaleTo_Default();
return true;
}
void PGM_BASE::SetHtmlHelpController( wxHtmlHelpController* aController )
{
delete m_html_ctrl;
m_html_ctrl = aController;
}
void PGM_BASE::InitOnLineHelp()
{
wxString fullfilename = FindKicadHelpPath();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName = fullfilename + wxT( ".html" );
fullfilename += wxT( "kicad.hhp" );
if( wxFileExists( fullfilename ) )
{
m_html_ctrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS |
wxHF_PRINT | wxHF_OPEN_FILES
/*| wxHF_SEARCH */ );
m_html_ctrl->UseConfig( m_common_settings );
m_html_ctrl->SetTitleFormat( wxT( "KiCad Help" ) );
m_html_ctrl->AddBook( fullfilename );
}
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_html_ctrl = NULL;
#else
#error Help files format not defined
#endif
}
bool PGM_BASE::setExecutablePath()
{
// Apple MacOSx
#ifdef __APPLE__
// Derive path from location of the app bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
if( mainBundle == NULL )
return false;
CFURLRef urlref = CFBundleCopyBundleURL( mainBundle );
if( urlref == NULL )
return false;
CFStringRef str = CFURLCopyFileSystemPath( urlref, kCFURLPOSIXPathStyle );
if( str == NULL )
return false;
char* native_str = NULL;
int len = CFStringGetMaximumSizeForEncoding( CFStringGetLength( str ),
kCFStringEncodingUTF8 ) + 1;
native_str = new char[len];
CFStringGetCString( str, native_str, len, kCFStringEncodingUTF8 );
m_bin_dir = FROM_UTF8( native_str );
delete[] native_str;
#else
m_bin_dir = wxStandardPaths::Get().GetExecutablePath();
#endif
// Use unix notation for paths. I am not sure this is a good idea,
// but it simplifies compatibility between Windows and Unices.
// However it is a potential problem in path handling under Windows.
m_bin_dir.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
// Remove file name form command line:
while( m_bin_dir.Last() != '/' && !m_bin_dir.IsEmpty() )
m_bin_dir.RemoveLast();
return true;
}
void PGM_BASE::loadCommonSettings()
{
wxASSERT( m_common_settings );
m_help_size.x = 500;
m_help_size.y = 400;
wxString languageSel;
m_common_settings->Read( languageCfgKey, &languageSel );
setLanguageId( wxLANGUAGE_DEFAULT );
// Search for the current selection
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( s_Languages[ii].m_Lang_Label == languageSel )
{
setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
break;
}
}
m_editor_name = m_common_settings->Read( wxT( "Editor" ) );
}
void PGM_BASE::saveCommonSettings()
{
// m_common_settings is not initialized until fairly late in the
// process startup: initPgm(), so test before using:
if( m_common_settings )
{
m_common_settings->Write( workingDirKey, wxGetCwd() );
}
}
bool PGM_BASE::SetLanguage( bool first_time )
{
bool retv = true;
// dictionary file name without extend (full name is kicad.mo)
wxString dictionaryName( wxT( "kicad" ) );
delete m_locale;
m_locale = new wxLocale;
#if wxCHECK_VERSION( 2, 9, 0 )
if( !m_locale->Init( m_language_id ) )
#else
if( !m_locale->Init( m_language_id, wxLOCALE_CONV_ENCODING ) )
#endif
{
wxLogDebug( wxT( "This language is not supported by the system." ) );
setLanguageId( wxLANGUAGE_DEFAULT );
delete m_locale;
m_locale = new wxLocale;
m_locale->Init();
retv = false;
}
else if( !first_time )
{
wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ),
GetChars( dictionaryName ), GetChars( m_locale->GetName() ) );
}
// how about a meaningful comment here.
if( !first_time )
{
wxString languageSel;
// Search for the current selection
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( s_Languages[ii].m_WX_Lang_Identifier == m_language_id )
{
languageSel = s_Languages[ii].m_Lang_Label;
break;
}
}
m_common_settings->Write( languageCfgKey, languageSel );
}
// Test if floating point notation is working (bug in cross compilation, using wine)
// Make a conversion double <=> string
double dtst = 0.5;
wxString msg;
extern bool g_DisableFloatingPointLocalNotation; // See common.cpp
g_DisableFloatingPointLocalNotation = false;
msg << dtst;
double result;
msg.ToDouble( &result );
if( result != dtst ) // string to double encode/decode does not work! Bug detected
{
// Disable floating point localization:
g_DisableFloatingPointLocalNotation = true;
SetLocaleTo_C_standard( );
}
if( !m_locale->IsLoaded( dictionaryName ) )
m_locale->AddCatalog( dictionaryName );
if( !retv )
return retv;
return m_locale->IsOk();
}
void PGM_BASE::SetLanguageIdentifier( int menu_id )
{
wxLogDebug( wxT( "Select language ID %d from %zd possible languages." ),
menu_id, DIM( s_Languages ) );
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( menu_id == s_Languages[ii].m_KI_Lang_Identifier )
{
setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
break;
}
}
}
void PGM_BASE::SetLanguagePath()
{
SEARCH_STACK guesses;
SystemDirsAppend( &guesses );
// Add our internat dir to the wxLocale catalog of paths
for( unsigned i = 0; i < guesses.GetCount(); i++ )
{
wxFileName fn( guesses[i], wxEmptyString );
// Append path for Windows and unix KiCad package install
fn.AppendDir( wxT( "share" ) );
fn.AppendDir( wxT( "internat" ) );
if( fn.IsDirReadable() )
{
wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
// Append path for unix standard install
fn.RemoveLastDir();
fn.AppendDir( wxT( "kicad" ) );
fn.AppendDir( wxT( "internat" ) );
if( fn.IsDirReadable() )
{
wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
}
}
void PGM_BASE::AddMenuLanguageList( wxMenu* MasterMenu )
{
wxMenu* menu = NULL;
wxMenuItem* item = MasterMenu->FindItem( ID_LANGUAGE_CHOICE );
if( item ) // This menu exists, do nothing
return;
menu = new wxMenu;
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
wxString label;
if( s_Languages[ii].m_DoNotTranslate )
label = s_Languages[ii].m_Lang_Label;
else
label = wxGetTranslation( s_Languages[ii].m_Lang_Label );
AddMenuItem( menu, s_Languages[ii].m_KI_Lang_Identifier,
label, KiBitmap(s_Languages[ii].m_Lang_Icon ),
wxITEM_CHECK );
}
AddMenuItem( MasterMenu, menu,
ID_LANGUAGE_CHOICE,
_( "Language" ),
_( "Select application language (only for testing!)" ),
KiBitmap( language_xpm ) );
// Set Check mark on current selected language
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( m_language_id == s_Languages[ii].m_WX_Lang_Identifier )
menu->Check( s_Languages[ii].m_KI_Lang_Identifier, true );
else
menu->Check( s_Languages[ii].m_KI_Lang_Identifier, false );
}
}
bool PGM_BASE::LockFile( const wxString& aFileName )
{
// first make absolute and normalize, to avoid that different lock files
// for the same file can be created
wxFileName fn( aFileName );
fn.MakeAbsolute();
// semaphore to protect the edition of the file by more than one instance
if( m_file_checker != NULL )
{
// it means that we had an open file and we are opening a different one
delete m_file_checker;
}
wxString lockFileName = fn.GetFullPath() + wxT( ".lock" );
lockFileName.Replace( wxT( "/" ), wxT( "_" ) );
// We can have filenames coming from Windows, so also convert Windows separator
lockFileName.Replace( wxT( "\\" ), wxT( "_" ) );
m_file_checker = new wxSingleInstanceChecker( lockFileName );
if( m_file_checker &&
m_file_checker->IsAnotherRunning() )
{
return false;
}
return true;
}

302
common/project.cpp Normal file
View File

@ -0,0 +1,302 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
*/
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <pgm_base.h>
#include <project.h>
#include <wx/stdpaths.h>
#include <kicad_string.h>
#include <config_params.h>
#include <wildcards_and_files_ext.h>
PROJECT::PROJECT()
{
memset( m_elems, 0, sizeof(m_elems) );
}
PROJECT::~PROJECT()
{
/* @todo
careful here, this may work, but the virtual destructor may not
be in the same link image as PROJECT. Won't enable this until
we're more stable and destructor is assuredly in same image, i.e.
libki.so
for( unsigned i = 0; i<DIM(m_elems); ++i )
delete m_elems[i];
*/
}
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
{
m_project_name = aFullPathAndName;
wxASSERT( m_project_name.IsAbsolute() );
#if 0
wxASSERT( m_project_name.GetExt() == wxT( ".pro" ) )
#else
m_project_name.SetExt( wxT( ".pro" ) );
#endif
// until multiple projects are in play, set an environment variable for the
// the project pointer.
{
wxString path = m_project_name.GetPath();
// wxLogDebug( wxT( "Setting env %s to '%s'." ), PROJECT_VAR_NAME, GetChars( path ) );
wxSetEnv( PROJECT_VAR_NAME, path );
}
}
const wxString PROJECT::GetProjectFullName() const
{
return m_project_name.GetFullPath();
}
RETAINED_PATH& PROJECT::RPath( RETPATH_T aIndex )
{
unsigned ndx = unsigned( aIndex );
if( ndx < DIM( m_rpaths ) )
{
return m_rpaths[ndx];
}
else
{
static RETAINED_PATH no_cookie_for_you;
wxASSERT( 0 ); // bad index
return no_cookie_for_you;
}
}
PROJECT::_ELEM* PROJECT::Elem( ELEM_T aIndex, _ELEM* aElem )
{
unsigned ndx = unsigned( aIndex );
if( ndx < DIM( m_elems ) )
{
if( aElem )
m_elems[ndx] = aElem;
return m_elems[ndx];
}
return NULL;
}
// non-member so it can be moved easily, and kept REALLY private.
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
{
for( int i=1; true; ++i )
{
wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
wxString upath = aCfg->Read( key, wxEmptyString );
if( !upath )
break;
aDst->AddPaths( upath, aIndex );
}
}
// non-member so it can be moved easily, and kept REALLY private.
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
{
for( unsigned i=0; i<aSrc.GetCount(); ++i )
aDst->AddPaths( aSrc[i], aIndex );
}
/*
bool PROJECT::MaybeLoadProjectSettings( const std::vector<wxString>& aFileSet )
{
// @todo
return true;
}
*/
wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, bool aForceUseLocalConfig )
{
wxConfigBase* cfg = 0;
wxFileName fn = aFileName;
fn.SetExt( ProjectFileExtension );
// is there an edge transition, a change in m_project_filename?
if( m_project_name != fn )
{
m_sch_search.Clear();
SetProjectFullName( fn.GetFullPath() );
// to the empty list, add project dir as first
m_sch_search.AddPaths( fn.GetPath() );
// append all paths from aSList
add_search_paths( &m_sch_search, aSList, -1 );
// addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
// This is undocumented, but somebody wanted to store !schematic!
// library search paths in the .kicad_common file?
add_search_paths( &m_sch_search, Pgm().CommonSettings(), -1 );
#if 1 && defined(DEBUG)
m_sch_search.Show( __func__ );
#endif
}
// Init local config filename
if( aForceUseLocalConfig || fn.FileExists() )
{
wxString cur_pro_fn = fn.GetFullPath();
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
if( aForceUseLocalConfig )
{
SetProjectFullName( cur_pro_fn );
return cfg;
}
/* Check the application version against the version saved in the
* project file.
*
* TODO: Push the version test up the stack so that when one of the
* KiCad application version changes, the other applications
* settings do not get updated. Practically, this can go away.
* It isn't used anywhere as far as I know (WLS).
*/
cfg->SetPath( aGroupName );
int def_version = 0;
int version = cfg->Read( wxT( "version" ), def_version );
if( version > 0 )
{
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
SetProjectFullName( cur_pro_fn );
return cfg;
}
else // Version incorrect
{
delete cfg;
cfg = 0;
}
}
// Search for the template kicad.pro file by using caller's SEARCH_STACK.
wxString kicad_pro_template = aSList.FindValidPath( wxT( "kicad.pro" ) );
if( !kicad_pro_template )
{
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
}
else
{
fn = kicad_pro_template;
}
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, wxEmptyString, fn.GetFullPath() );
cfg->DontCreateOnDemand();
SetProjectFullName( fn.GetFullPath() );
return cfg;
}
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams )
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, FORCE_LOCAL_CONFIG ) );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
cfg->Write( wxT( "update" ), DateAndTime() );
// @todo: pass in aLastClient wxString:
cfg->Write( wxT( "last_client" ), Pgm().App().GetAppName() );
// Save parameters
cfg->DeleteGroup( aGroupName ); // Erase all data
cfg->Flush();
cfg->SetPath( aGroupName );
cfg->Write( wxT( "version" ), CONFIG_VERSION );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
wxConfigSaveParams( cfg.get(), aParams, aGroupName );
cfg->SetPath( UNIX_STRING_DIR_SEP );
// cfg is deleted here by std::auto_ptr, that saves the *.pro file to disk
}
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams,
bool doLoadOnlyIfNew )
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, false ) );
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
wxString timestamp = cfg->Read( wxT( "update" ) );
if( doLoadOnlyIfNew && timestamp.size() &&
timestamp == m_pro_date_and_time )
{
return false;
}
m_pro_date_and_time = timestamp;
wxConfigLoadParams( cfg.get(), aParams, aGroupName );
return true;
}

196
common/search_stack.cpp Normal file
View File

@ -0,0 +1,196 @@
#include <macros.h>
#include <search_stack.h>
#include <wx/tokenzr.h>
#if defined(__MINGW32__)
#define PATH_SEPS wxT(";\r\n")
#else
#define PATH_SEPS wxT(":;\r\n") // unix == linux | mac
#endif
wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFullFilename )
{
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of
* these default paths
* Note we accept only sub paths,
* not relative paths starting by ../ that are not subpaths and are outside kicad libs paths
*/
wxFileName fn = aFullFilename;
wxString filename = aFullFilename;
unsigned pathlen = fn.GetPath().Len(); // path len, used to find the better (shortest)
// subpath within defaults paths
for( unsigned kk = 0; kk < GetCount(); kk++ )
{
fn = aFullFilename;
// Search for the shortest subpath within 'this':
if( fn.MakeRelativeTo( (*this)[kk] ) )
{
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
continue;
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found
{
filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len();
}
}
}
return filename;
}
void SEARCH_STACK::RemovePaths( const wxString& aPaths )
{
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK );
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND )
{
Remove( path );
}
}
}
void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
{
bool isCS = wxFileName::IsCaseSensitive();
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK );
// appending all of them, on large or negative aIndex
if( unsigned( aIndex ) >= GetCount() )
{
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND )
{
Add( path );
}
}
}
// inserting all of them:
else
{
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND )
{
Insert( path, aIndex );
aIndex++;
}
}
}
}
wxString SEARCH_STACK::FindFileInSearchPaths(
const wxString& aFilename, const wxArrayString* aSubdirs )
{
wxPathList paths;
for( unsigned i = 0; i < GetCount(); ++i )
{
wxFileName fn( (*this)[i] );
if( aSubdirs )
{
for( unsigned j = 0; j < aSubdirs->GetCount(); j++ )
fn.AppendDir( (*aSubdirs)[j] );
}
if( fn.DirExists() )
{
paths.Add( fn.GetPath() );
}
}
return paths.FindValidPath( aFilename );
}
void RETAINED_PATH::Clear()
{
m_retained_path.Clear();
}
wxString RETAINED_PATH::LastVisitedPath( const SEARCH_STACK& aSStack, const wxString& aSubPathToSearch )
{
if( !!m_retained_path )
return m_retained_path;
wxString path;
// Initialize default path to the main default lib path
// this is the second path in list (the first is the project path)
unsigned pcount = aSStack.GetCount();
if( pcount )
{
unsigned ipath = 0;
if( aSStack[0] == wxGetCwd() )
ipath = 1;
// First choice of path:
if( ipath < pcount )
path = aSStack[ipath];
// Search a sub path matching aSubPathToSearch
if( !aSubPathToSearch.IsEmpty() )
{
for( ; ipath < pcount; ipath++ )
{
if( aSStack[ipath].Contains( aSubPathToSearch ) )
{
path = aSStack[ipath];
break;
}
}
}
}
if( path.IsEmpty() )
path = wxGetCwd();
return path;
}
void RETAINED_PATH::SaveLastVisitedPath( const wxString& aPath )
{
m_retained_path = aPath;
}
#if defined(DEBUG)
void SEARCH_STACK::Show( const char* aPrefix ) const
{
printf( "%s SEARCH_STACK:\n", aPrefix );
for( unsigned i=0; i<GetCount(); ++i )
{
printf( " [%2i]:%s\n", i, TO_UTF8( (*this)[i] ) );
}
}
#endif

View File

@ -25,33 +25,30 @@
/*
This is a program launcher for a single KIFACE DSO. Initially it will only
mimic a KIWAY, not actually implement one, since only a single DSO is
supported by it.
This is a program launcher for a single KIFACE DSO. It only mimics a KIWAY,
not actually implements one, since only a single DSO is supported by it.
It is compiled multiple times, once for each standalone program and as such
gets different compiler command line supplied #defines from CMake.
*/
#include <macros.h>
#include <fctsys.h>
#include <wx/dynlib.h>
#include <wx/filename.h>
#include <kiway.h>
#include <wx/stdpaths.h>
#include <wx/snglinst.h>
#include <kiway.h>
#include <pgm_base.h>
#include <kiway_player.h>
#include <confirm.h>
/**
* Class PROCESS
* provides its own OnInit() handler.
*/
class PROCESS : public wxApp
{
public:
bool OnInit();
};
IMPLEMENT_APP( PROCESS )
// The functions we use will cause the program launcher to pull stuff in
// during linkage, keep the map file in mind to see what's going into it.
#if !wxCHECK_VERSION( 3, 0, 0 )
@ -107,41 +104,6 @@ static wxString wxJoin(const wxArrayString& arr, const wxChar sep,
#endif
// POLICY CHOICE: return the full path of the DSO to load from single_top.
static const wxString dso_full_path( const wxString& aAbsoluteArgv0 )
{
// Prefix basename with '_' and change extension to DSO_EXT.
// POLICY CHOICE: Keep same path, and therefore installer must put the major DSO
// in same dir as top process module. Obviously alternatives are possible
// and that is why this is a separate function. One alternative would be to use
// a portion of CMAKE_INSTALL_PREFIX and navigate to a "lib" dir, but that
// would require a recompile any time you chose to install into a different place.
// It is my decision to treat _eeschema.so and _pcbnew.so as "executables",
// not "libraries" in this regard, since most all program functionality lives
// in them. They are basically spin-offs from what was once a top process module.
// That may not make linux package maintainers happy, but that is not my job.
// Get over it. KiCad is not a trivial suite, and multiple platforms come
// into play, not merely linux. If it freaks you out, we can use a different
// file extension than ".so", but they are not purely libraries, else they
// would begin with "lib" in basename. Like I said, get over it, we're serving
// too many masters here: python, windows, linux, OSX, multiple versions of wx...
wxFileName fn( aAbsoluteArgv0 );
wxString basename( KIFACE_PREFIX ); // start with special prefix
basename += fn.GetName(); // add argv[0]'s basename
fn.SetName( basename );
// here a suffix == an extension with a preceding '.',
// so skip the preceding '.' to get an extension
fn.SetExt( KIFACE_SUFFIX + 1 ); // special extension, + 1 => &KIFACE_SUFFIX[1]
return fn.GetFullPath();
}
/// Put aPriorityPath in front of all paths in the value of aEnvVar.
const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPath )
{
@ -157,13 +119,13 @@ const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPa
/// Extend LIB_ENV_VAR list with the directory from which I came, prepending it.
void SetLibEnvVar( const wxString& aAbsoluteArgv0 )
{
// POLICY CHOICE: Keep same path, so that installer MAY put the
// "subsidiary shared libraries" in the same directory as the top process module.
// POLICY CHOICE 2: Keep same path, so that installer MAY put the
// "subsidiary DSOs" in the same directory as the kiway top process modules.
// A subsidiary shared library is one that is not a top level DSO, but rather
// some shared library that a top level DSO needs to even be loaded. It is
// a static link to a shared object from a top level DSO.
// This directory POLICY CHOICE is not the only dir in play, since LIB_ENV_VAR
// This directory POLICY CHOICE 2 is not the only dir in play, since LIB_ENV_VAR
// has numerous path options in it, as does DSO searching on linux, windows, and OSX.
// See "man ldconfig" on linux. What's being done here is for quick installs
// into a non-standard place, and especially for Windows users who may not
@ -186,28 +148,119 @@ void SetLibEnvVar( const wxString& aAbsoluteArgv0 )
#endif
}
// POLICY CHOICE 1: return the full path of the DSO to load from single_top.
static const wxString dso_full_path( const wxString& aAbsoluteArgv0 )
{
// Prefix basename with ${KIFACE_PREFIX} and change extension to ${KIFACE_SUFFIX}
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
static KIWAY standalone;
// POLICY CHOICE 1: Keep same path, and therefore installer must put the kiface DSO
// in same dir as top process module. Obviously alternatives are possible
// and that is why this is a separate function. One alternative would be to use
// a portion of CMAKE_INSTALL_PREFIX and navigate to a "lib" dir, but that
// would require a recompile any time you chose to install into a different place.
// It is my decision to treat _eeschema.kiface and _pcbnew.kiface as "executables",
// not "libraries" in this regard, since most all program functionality lives
// in them. They are basically spin-offs from what was once a top process module.
// That may not make linux package maintainers happy, but that is not my job.
// Get over it. KiCad is not a trivial suite, and multiple platforms come
// into play, not merely linux. For starters they will use extension ".kicad",
// but later in time morph to ".so". They are not purely libraries, else they
// would begin with "lib" in basename. Like I said, get over it, we're serving
// too many masters here: python, windows, linux, OSX, multiple versions of wx...
wxFileName fn( aAbsoluteArgv0 );
wxString basename( KIFACE_PREFIX ); // start with special prefix
basename += fn.GetName(); // add argv[0]'s basename
fn.SetName( basename );
// Here a "suffix" == an extension with a preceding '.',
// so skip the preceding '.' to get an extension
fn.SetExt( KIFACE_SUFFIX + 1 ); // + 1 => &KIFACE_SUFFIX[1]
return fn.GetFullPath();
}
// Use of this is arbitrary, remember single_top only knows about a single DSO.
// Could have used one from the KIWAY also.
static wxDynamicLibrary dso;
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
static KIWAY kiway;
// implement a PGM_BASE and a wxApp side by side:
/**
* Struct PGM_SINGLE_TOP
* implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
*/
static struct PGM_SINGLE_TOP : public PGM_BASE
{
bool OnPgmInit( wxApp* aWxApp ); // overload PGM_BASE virtual
void OnPgmExit(); // overload PGM_BASE virtual
void MacOpenFile( const wxString& aFileName ); // overload PGM_BASE virtual
} program;
PGM_BASE& Pgm()
{
return program;
}
/**
* Struct APP_SINGLE_TOP
* implements a bare naked wxApp (so that we don't become dependent on
* functionality in a wxApp derivative that we cannot deliver under wxPython).
*/
struct APP_SINGLE_TOP : public wxApp
{
bool OnInit() // overload wxApp virtual
{
return Pgm().OnPgmInit( this );
}
int OnExit() // overload wxApp virtual
{
Pgm().OnPgmExit();
return wxApp::OnExit();
}
/**
* Function MacOpenFile
* is specific to MacOSX (not used under Linux or Windows).
* MacOSX requires it for file association.
* @see http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void MacOpenFile( const wxString& aFileName ) // overload wxApp virtual
{
Pgm().MacOpenFile( aFileName );
}
};
IMPLEMENT_APP( APP_SINGLE_TOP );
/**
* Function get_kiface_getter
* returns a KIFACE_GETTER_FUNC for the current process's main implemation link image.
* returns a KIFACE_GETTER_FUNC for the current process's main implementation
* link image.
*
* @param aDSOName is an absolute full path to the DSO to load and find KIFACE_GETTER_FUNC within.
* @param aDSOName is an absolute full path to the DSO to load and find
* KIFACE_GETTER_FUNC within.
*
* @return KIFACE_GETTER_FUNC* - a pointer to a function which can be called to get the KIFACE
* or NULL if the getter func was not found. If not found, it is possibly not version compatible
* since the lookup is done by name and the name contains the API version.
* @return KIFACE_GETTER_FUNC* - a pointer to a function which can be called to
* get the KIFACE or NULL if the getter func was not found. If not found,
* it is possibly not version compatible since the lookup is done by name and
* the name contains the API version.
*/
static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
{
#if defined(BUILD_KIWAY_DLL)
void* addr = NULL;
if( !dso.Load( aDSOName, wxDL_VERBATIM | wxDL_NOW ) )
@ -223,6 +276,11 @@ static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
}
return (KIFACE_GETTER_FUNC*) addr;
#else
return &KIFACE_GETTER;
#endif
}
@ -230,32 +288,13 @@ static KIFACE* kiface;
static int kiface_version;
bool PROCESS::OnInit()
bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
{
// Choose to use argv command line processing in base class's OnInit().
// That choice is not mandatory, see wx's appbase.cpp OnInit().
if( !wxApp::OnInit() )
return false;
// first thing: set m_wx_app
m_wx_app = aWxApp;
wxStandardPathsBase& paths = wxStandardPaths::Get();
#if defined(DEBUG)
wxString dir = paths.GetLocalizedResourcesDir( wxT( "de" ),
wxStandardPaths::ResourceCat_None );
printf( "LocalizeResourcesDir:'%s'\n", TO_UTF8( dir ) );
wxString dummy( _( "translate this" ) );
#endif
wxString absoluteArgv0 = paths.GetExecutablePath();
#if 0 && defined(DEBUG)
printf( "argv[0]:'%s' absoluteArgv0:'%s'\n",
TO_UTF8( wxString( argv[0] ) ),
TO_UTF8( absoluteArgv0 )
);
#endif
wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
if( !wxIsAbsolutePath( absoluteArgv0 ) )
{
@ -267,6 +306,9 @@ bool PROCESS::OnInit()
// KIFACE has hard dependencies on subsidiary DSOs below it.
SetLibEnvVar( absoluteArgv0 );
if( !initPgm() )
return false;
wxString dname = dso_full_path( absoluteArgv0 );
// Get the getter.
@ -279,24 +321,170 @@ bool PROCESS::OnInit()
return false;
}
// Get the KIFACE, and give the DSO a single chance to do its
// "process level" initialization.
kiface = getter( &kiface_version, KIFACE_VERSION, &wxGetApp() );
// Get the KIFACE.
kiface = getter( &kiface_version, KIFACE_VERSION, this );
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is uconditional.
// KIFACE_GETTER_FUNC function comment (API) says the non-NULL is unconditional.
wxASSERT_MSG( kiface, wxT( "attempted DSO has a bug, failed to return a KIFACE*" ) );
// Use KIFACE to create a window that the KIFACE knows about,
// pass classId=0 for now. KIFACE::CreateWindow() is a virtual
// so we don't need to link to it.
wxFrame* frame = (wxFrame*) kiface->CreateWindow( 0, &standalone );
// Give the DSO a single chance to do its "process level" initialization.
// "Process level" specifically means stay away from any projects in there.
if( !kiface->OnKifaceStart( this ) )
return false;
SetTopWindow( frame );
// Use KIFACE to create a top window that the KIFACE knows about.
// TOP_FRAME is passed on compiler command line from CMake, and is one of
// the types in ID_DRAWFRAME_TYPE.
// KIFACE::CreateWindow() is a virtual so we don't need to link to it.
// Remember its in the *.kiface DSO.
#if 0
// this pulls in EDA_DRAW_FRAME type info, which we don't want in single_top
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( kiface->CreateWindow(
NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ) );
#else
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) kiface->CreateWindow(
NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE );
#endif
frame->Centre();
App().SetTopWindow( frame ); // wxApp gets a face.
// Open project or file specified on the command line:
int argc = App().argc;
if( argc > 1 )
{
#if defined(TOP_FRAME) && TOP_FRAME==GERBER_FRAME_TYPE
// gerbview handles multiple project data files, i.e. gerber files on cmd line.
std::vector<wxString> fileSet;
// Load all files specified on the command line.
for( int i=1; i<argc; ++i )
{
wxFileName fn( App().argv[i] );
if( fn.FileExists() )
fileSet.push_back( App().argv[i] );
}
wxFileName fn( fileSet[0] );
if( fn.GetPath().size() )
{
// wxSetWorkingDirectory does not like empty paths
wxSetWorkingDirectory( fn.GetPath() );
// @todo: setting CWD is taboo in a multi-project environment
}
// Use the KIWAY_PLAYER::OpenProjectFiles() API function:
if( !frame->OpenProjectFiles( fileSet ) )
{
// OpenProjectFiles() API asks that it report failure to the UI.
// Nothing further to say here.
// Fail the process startup if the file could not be opened,
// although this is an optional choice, one that can be reversed
// also in the KIFACE specific OpenProjectFiles() return value.
return false;
}
#else
wxFileName fn( argv[1] );
if( !fn.IsOk() )
{
return false;
}
#if defined(PGM_DATA_FILE_EXT)
// PGM_DATA_FILE_EXT is different for each compile, it may come from CMake
// on the compiler command line, or not.
if( !fn.GetExt() )
fn.SetExt( wxT( PGM_DATA_FILE_EXT ) );
#endif
if( !Pgm().LockFile( fn.GetFullPath() ) )
{
wxLogSysError( _( "This file is already open." ) );
return false;
}
if( fn.GetPath().size() )
{
// wxSetWorkingDirectory does not like empty paths
wxSetWorkingDirectory( fn.GetPath() );
// @todo: setting CWD is taboo in a multi-project environment
}
// Use the KIWAY_PLAYER::OpenProjectFiles() API function:
if( !frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
{
// OpenProjectFiles() API asks that it report failure to the UI.
// Nothing further to say here.
// Fail the process startup if the file could not be opened,
// although this is an optional choice, one that can be reversed
// also in the KIFACE specific OpenProjectFiles() return value.
return false;
}
#endif
}
else
{
/* The lean single_top program launcher has no access program settings,
else it would not be lean. That kind of functionality is in the
KIFACE now, but it cannot assume that it is the only KIFACE in memory.
So this looks like a dead concept here, or an expensive one in terms
of code size.
wxString dir;
if( m_pgmSettings->Read( workingDirKey, &dir ) && wxDirExists( dir ) )
{
wxSetWorkingDirectory( dir );
}
*/
}
frame->Show();
return true;
}
void PGM_SINGLE_TOP::OnPgmExit()
{
if( kiface )
kiface->OnKifaceEnd();
saveCommonSettings();
// write common settings to disk, and destroy everything in PGM_BASE,
// especially wxSingleInstanceCheckerImpl earlier than wxApp and earlier
// than static destruction would.
PGM_BASE::destroy();
}
void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName )
{
wxFileName filename( aFileName );
if( filename.FileExists() )
{
#if 0
// this pulls in EDA_DRAW_FRAME type info, which we don't want in single_top
// link image.
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
#else
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
#endif
if( frame )
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
}
}

129
common/systemdirsappend.cpp Normal file
View File

@ -0,0 +1,129 @@
#include <wx/stdpaths.h>
#include <common.h>
#include <search_stack.h>
#include <pgm_base.h>
// put your best guesses in here, send the computer on a wild goose chase, its
// got nothing else to do.
void SystemDirsAppend( SEARCH_STACK* aSearchStack )
{
// No clearing is done here, the most general approach is NOT to assume that
// our appends will be the only thing in the stack. This function has no
// knowledge of caller's intentions.
// wxPathList::AddEnvList() is broken, use SEARCH_STACK::AddPaths().
// SEARCH_STACK::AddPaths() will verify readability and existence of
// each directory before adding.
SEARCH_STACK maybe;
// User environment variable path is the first search path. Chances are
// if the user is savvy enough to set an environment variable they know
// what they are doing. It should take precedence over anything else.
// Otherwise don't set it.
maybe.AddPaths( wxGetenv( wxT( "KICAD" ) ) );
// This is from CMAKE_INSTALL_PREFIX.
// Useful when KiCad is installed by `make install`.
// Use as second ranked place.
maybe.AddPaths( wxT( DEFAULT_INSTALL_PATH ) );
// Add the directory for the user-dependent, program specific, data files:
// Unix: ~/.appname
// Windows: C:\Documents and Settings\username\Application Data\appname
// Mac: ~/Library/Application Support/appname
maybe.AddPaths( wxStandardPaths::Get().GetUserDataDir() );
{
// Should be full path to this program executable.
wxString bin_dir = Pgm().GetExecutablePath();
#if defined(__MINGW32__)
// bin_dir uses unix path separator. So to parse with wxFileName
// use windows separator, especially important for server inclusion:
// like: \\myserver\local_path .
bin_dir.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#endif
wxFileName bin_fn( bin_dir, wxEmptyString );
// Dir of the global (not user-specific), application specific, data files.
// From wx docs:
// Unix: prefix/share/appname
// Windows: the directory where the executable file is located
// Mac: appname.app/Contents/SharedSupport bundle subdirectory
wxString data_dir = wxStandardPaths::Get().GetDataDir();
if( bin_fn.GetPath() != data_dir )
{
// add data_dir if it is different from the bin_dir
maybe.AddPaths( data_dir );
}
// Up one level relative to binary path with "share" appended below.
bin_fn.RemoveLastDir();
maybe.AddPaths( bin_fn.GetPath() );
}
/* The normal OS program file install paths allow for a binary to be
* installed in a different path from the library files. This is
* useful for development purposes so the library and documentation
* files do not need to be installed separately. If someone can
* figure out a way to implement this without #ifdef, please do.
*/
#if defined(__MINGW32__)
maybe.AddPaths( wxGetenv( wxT( "PROGRAMFILES" ) ) );
#elif __WXMAC__
maybe.AddPaths( wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT( "/Library/Application Support" ) );
maybe.AddPaths( wxT( "/Library/Application Support" ) );
#else
maybe.AddPaths( wxGetenv( wxT( "PATH" ) ) );
#endif
#if defined(DEBUG) && 0
maybe.Show( "maybe wish list" );
#endif
// Append 1) kicad, 2) kicad/share, 3) share, and 4) share/kicad to each
// possible base path in 'maybe'. Since SEARCH_STACK::AddPaths() will verify
// readability and existence of each directory, not all of these will be
// actually appended.
for( unsigned i = 0; i < maybe.GetCount(); ++i )
{
wxFileName fn( maybe[i], wxEmptyString );
if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) )
{
fn.RemoveLastDir();
if( !fn.GetDirCount() )
continue; // at least on linux
}
aSearchStack->AddPaths( fn.GetPath() );
fn.AppendDir( wxT( "kicad" ) );
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad
fn.AppendDir( wxT( "share" ) );
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/kicad/share
fn.RemoveLastDir(); // ../ clear share
fn.RemoveLastDir(); // ../ clear kicad
fn.AppendDir( wxT( "share" ) );
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/share
fn.AppendDir( wxT( "kicad" ) );
aSearchStack->AddPaths( fn.GetPath() ); // add maybe[i]/share/kicad
}
#if defined(DEBUG) && 0
// final results:
aSearchStack->Show( __func__ );
#endif
}

View File

@ -31,13 +31,13 @@
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <class_base_screen.h>
#include <drawtxt.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <build_version.h>
@ -170,7 +170,7 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
break;
case 'K':
msg += productName + wxGetApp().GetAppName();
msg += productName + Pgm().App().GetAppName();
msg += wxT( " " ) + GetBuildVersion();
break;

View File

@ -90,7 +90,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize )
if( textSize > 3000 )
textSize = 3000;
return ReturnStringFromValue( aUnit, textSize );
return StringFromValue( aUnit, textSize );
}
@ -124,7 +124,7 @@ int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUni
{
int textsize;
textsize = ReturnValueFromString( aUnit, sizeText );
textsize = ValueFromString( aUnit, sizeText );
// Limit to reasonable size
if( textsize < 10 )
@ -209,8 +209,8 @@ wxPoint EDA_POSITION_CTRL::GetValue()
{
wxPoint coord;
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() );
coord.x = ValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ValueFromString( m_UserUnit, m_FramePosY->GetValue() );
return coord;
}
@ -230,11 +230,11 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.x );
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.x );
m_FramePosX->Clear();
m_FramePosX->SetValue( msg );
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.y );
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.y );
m_FramePosY->Clear();
m_FramePosY->SetValue( msg );
}
@ -279,7 +279,7 @@ EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title,
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value );
wxString stringvalue = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
@ -301,7 +301,7 @@ int EDA_VALUE_CTRL::GetValue()
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString( m_UserUnit, txtvalue );
coord = ValueFromString( m_UserUnit, txtvalue );
return coord;
}
@ -312,7 +312,7 @@ void EDA_VALUE_CTRL::SetValue( int new_value )
m_Value = new_value;
buffer = ReturnStringFromValue( m_UserUnit, m_Value );
buffer = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl->SetValue( buffer );
}

View File

@ -37,7 +37,7 @@
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <class_base_screen.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <kicad_device_context.h>
#include <hotkeys_basic.h>
#include <menus_helpers.h>

View File

@ -1,8 +1,7 @@
add_definitions( -DCVPCB )
###
# Includes
###
set( MAKE_LINK_MAPS true )
add_definitions( -DCVPCB )
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
@ -15,12 +14,13 @@ include_directories(
${INC_AFTER}
)
###
# Sources
###
set( CVPCB_DIALOGS
dialogs/dialog_cvpcb_config.cpp
dialogs/dialog_cvpcb_config_fbp.cpp
# These 2 still use search paths, which don't exist in footprint land.
# dialogs/dialog_cvpcb_config.cpp
# dialogs/dialog_cvpcb_config_fbp.cpp
dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp
../pcbnew/dialogs/dialog_fp_lib_table.cpp
@ -40,101 +40,187 @@ set( CVPCB_SRCS
class_footprints_listbox.cpp
class_library_listbox.cpp
cvframe.cpp
cvpcb.cpp
listboxes.cpp
menubar.cpp
readwrite_dlgs.cpp
tool_cvpcb.cpp
)
###
# Windows resource file
###
if( WIN32 )
if( MINGW )
# CVPCB_RESOURCES variable is set by the macro.
mingw_resource_compiler( cvpcb )
else()
set( CVPCB_RESOURCES cvpcb.rc )
endif()
if( MINGW )
# CVPCB_RESOURCES variable is set by the macro.
mingw_resource_compiler( cvpcb )
endif()
###
# Apple resource files
###
if( APPLE )
set( CVPCB_RESOURCES cvpcb.icns cvpcb_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb_doc.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/cvpcb_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE cvpcb.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.cvpcb )
endif()
###
# Create the cvpcb executable
###
add_executable( cvpcb WIN32 MACOSX_BUNDLE
${CVPCB_SRCS}
${CVPCB_DIALOGS}
${CVPCB_RESOURCES}
)
###
# Set properties for APPLE on cvpcb target
###
if( APPLE )
set_target_properties( cvpcb PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist )
if( USE_KIWAY_DLLS )
add_executable( cvpcb WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=CVPCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL"
)
target_link_libraries( cvpcb
#singletop # replaces common, giving us restrictive control and link warnings.
# There's way too much crap coming in from common yet.
common
bitmaps
${wxWidgets_LIBRARIES}
)
if( MAKE_LINK_MAPS )
set_target_properties( cvpcb PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=cvpcb.map" )
endif()
# the main cvpcb program, in DSO form.
add_library( cvpcb_kiface MODULE
cvpcb.cpp
${CVPCB_SRCS}
${CVPCB_DIALOGS}
${CVPCB_RESOURCES}
)
set_target_properties( cvpcb_kiface PROPERTIES
OUTPUT_NAME cvpcb
PREFIX ${KIFACE_PREFIX}
SUFFIX ${KIFACE_SUFFIX}
)
target_link_libraries( cvpcb_kiface
3d-viewer
pcbcommon
pcad2kicadpcb
common
bitmaps
polygon
gal
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
${GDI_PLUS_LIBRARIES}
${GLEW_LIBRARIES}
${CAIRO_LIBRARIES}
${PIXMAN_LIBRARY}
)
# Only for win32 cross compilation using MXE
if( WIN32 AND MSYS AND CMAKE_CROSSCOMPILING )
target_link_libraries( cvpcb_kiface
opengl32
glu32
pixman-1
fontconfig
freetype
bz2
)
endif()
if( BUILD_GITHUB_PLUGIN )
target_link_libraries( cvpcb_kiface github_plugin )
endif()
# Must follow github_plugin
target_link_libraries( cvpcb_kiface ${Boost_LIBRARIES} )
if( UNIX AND NOT APPLE )
# -lrt must follow Boost
target_link_libraries( cvpcb_kiface rt )
endif()
if( APPLE )
set_target_properties( cvpcb PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
endif()
set_source_files_properties( cvpcb.cpp PROPERTIES
# The KIFACE is in cvpcb.cpp, export it:
COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL"
)
if( MAKE_LINK_MAPS )
set_target_properties( cvpcb_kiface PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_cvpcb.kiface.map" )
endif()
# if building cvpcb, then also build cvpcb_kiface if out of date.
add_dependencies( cvpcb cvpcb_kiface )
# these 2 binaries are a matched set, keep them together:
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( TARGETS cvpcb_kiface
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
else()
add_executable( cvpcb WIN32 MACOSX_BUNDLE
${CVPCB_SRCS}
${CVPCB_DIALOGS}
${CVPCB_RESOURCES}
)
target_link_libraries( cvpcb
3d-viewer
pcbcommon
pcad2kicadpcb
common
bitmaps
polygon
gal
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
${GDI_PLUS_LIBRARIES}
${GLEW_LIBRARIES}
${CAIRO_LIBRARIES}
${PIXMAN_LIBRARY}
)
# Only for win32 cross compilation using MXE
if( WIN32 AND MSYS AND CMAKE_CROSSCOMPILING )
target_link_libraries( cvpcb
opengl32
glu32
pixman-1
fontconfig
freetype
bz2
)
endif()
if( BUILD_GITHUB_PLUGIN )
target_link_libraries( cvpcb github_plugin )
endif()
# Must follow github_plugin
target_link_libraries( cvpcb ${Boost_LIBRARIES} )
if( APPLE )
set_target_properties( cvpcb PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
endif()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
###
# Link executable target cvpcb with correct libraries
###
target_link_libraries( cvpcb
3d-viewer
pcbcommon
pcad2kicadpcb
common
bitmaps
polygon
gal
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
${GDI_PLUS_LIBRARIES}
${GLEW_LIBRARIES}
${CAIRO_LIBRARIES}
${PIXMAN_LIBRARY}
)
# Only for win32 cross compilation using MXE
if( WIN32 AND MSYS AND CMAKE_CROSSCOMPILING )
target_link_libraries(cvpcb
opengl32
glu32
pixman-1
fontconfig
freetype
bz2
)
endif()
if( BUILD_GITHUB_PLUGIN )
target_link_libraries( cvpcb github_plugin )
endif()
# Must follow github_plugin
target_link_libraries( cvpcb ${Boost_LIBRARIES} )
###
# Add cvpcb as install target
###
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)

View File

@ -29,9 +29,10 @@
#include <fctsys.h>
#include <common.h>
#include <project.h>
#include <confirm.h>
#include <gestfich.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kicad_string.h>
#include <macros.h>
@ -87,6 +88,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
char Line[1024];
FILE* file;
size_t ii;
SEARCH_STACK& search = Prj().SchSearchS();
if( m_netlist.IsEmpty() )
return;
@ -99,17 +101,17 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
if( !fn.HasExt() )
{
fn.SetExt( FootprintAliasFileExtension );
// above fails if filename have more than one point
// above fails if filename has more than one point
}
else
{
fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
}
tmp = wxGetApp().FindLibraryPath( fn );
tmp = search.FindValidPath( fn );
if( !tmp )
{
msg.Printf( _( "Footprint alias library file <%s> could not be found in the "
msg.Printf( _( "Footprint alias library file '%s' could not be found in the "
"default search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR );

View File

@ -27,11 +27,12 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <fp_lib_table.h>
#include <id.h>
#include <common.h>
#include <gestfich.h>
#include <param_config.h>
#include <config_params.h>
#include <wildcards_and_files_ext.h>
#include <fp_lib_table.h>
#include <confirm.h>
@ -46,24 +47,24 @@
#define GROUPEQU wxT("/cvpcb/libraries")
PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters()
{
if( !m_projectFileParams.empty() )
return m_projectFileParams;
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUPLIB,
PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&m_ModuleLibNames,
GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ),
&m_AliasLibNames,
GROUPEQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ),
&m_NetlistFileExtension ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
&m_UserLibraryPath,
GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUPLIB, PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "LibName" ), &m_ModuleLibNames, GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "EquName" ), &m_AliasLibNames, GROUPEQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING(
wxT( "NetIExt" ), &m_NetlistFileExtension ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME(
wxT( "LibDir" ), &m_UserLibraryPath, GROUPLIB ) );
return m_projectFileParams;
}
@ -71,42 +72,37 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
{
wxFileName fn = aFileName;
wxFileName fn( aFileName );
PROJECT& prj = Prj();
m_ModuleLibNames.Clear();
m_AliasLibNames.Clear();
if( fn.GetExt() != ProjectFileExtension )
fn.SetExt( ProjectFileExtension );
fn.SetExt( ProjectFileExtension );
wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
// was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( prj.PcbSearchS(), fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" );
// User library path takes precedent over default library search paths.
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
// empty the table, Load() it again below.
FootprintLibs()->Clear();
delete m_footprintLibTable;
/* this is done by ConfigLoad(), and that sets the env var too.
prj.SetProjectFullName( fn.GetFullPath() );
*/
// Attempt to load the project footprint library table if it exists.
m_footprintLibTable = new FP_LIB_TABLE();
if( m_DisplayFootprintFrame )
m_DisplayFootprintFrame->SetFootprintLibTable( m_footprintLibTable );
wxFileName projectFpLibTableFileName;
projectFpLibTableFileName = FP_LIB_TABLE::GetProjectFileName( fn );
FP_LIB_TABLE::SetProjectPathEnvVariable( projectFpLibTableFileName );
wxFileName projectFpLibTableFileName = FP_LIB_TABLE::GetProjectTableFileName( fn.GetFullPath() );
try
{
m_footprintLibTable->Load( projectFpLibTableFileName, m_globalFootprintTable );
// Stack the project specific FP_LIB_TABLE overlay on top of the global table.
// ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
// stack this way, all using the same global fallback table.
FootprintLibs()->Load( projectFpLibTableFileName, &GFootprintTable );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
}
@ -136,5 +132,11 @@ void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
if( !IsWritable( fn ) )
return;
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
// was:
// Pgm().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
PROJECT& prj = Prj();
SEARCH_STACK& search = prj.SchSearchS();
prj.ConfigSave( search, fn.GetFullPath(), GROUP, GetProjectFileParameters() );
}

View File

@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <class_drawpanel.h>
#include <class_drawpanel_gal.h>
@ -73,25 +73,24 @@ END_EVENT_TABLE()
#define DISPLAY_FOOTPRINTS_FRAME_NAME wxT( "CmpFrame" )
DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size, long style ) :
PCB_BASE_FRAME( parent, CVPCB_DISPLAY_FRAME_TYPE, title, pos, size,
style, DISPLAY_FOOTPRINTS_FRAME_NAME )
DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent ) :
PCB_BASE_FRAME( aKiway, aParent, CVPCB_DISPLAY_FRAME_TYPE, _( "Module" ),
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, DISPLAY_FOOTPRINTS_FRAME_NAME )
{
m_FrameName = DISPLAY_FOOTPRINTS_FRAME_NAME;
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon );
SetBoard( new BOARD() );
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
LoadSettings();
LoadSettings( config() );
// Initialize grid id to a default value if not found in config or bad:
if( (m_LastGridSizeId <= 0) ||
@ -149,7 +148,8 @@ DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME()
delete GetScreen();
SetScreen( NULL ); // Be sure there is no double deletion
( (CVPCB_MAINFRAME*) wxGetApp().GetTopWindow() )->m_DisplayFootprintFrame = NULL;
// a crash would be better than this uncommented:
// ( (CVPCB_MAINFRAME*) Pgm().GetTopWindow() )->m_DisplayFootprintFrame = NULL;
}
@ -438,7 +438,7 @@ void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
return;
}
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ), KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
m_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, _( "3D Viewer" ), KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
m_Draw3DFrame->Show( true );
}
@ -493,7 +493,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
fpname.c_str(), nickname.c_str() );
footprint = m_footprintLibTable->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
footprint = FootprintLibs()->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
}
catch( IO_ERROR ioe )
{

View File

@ -40,10 +40,7 @@ class CVPCB_MAINFRAME;
class DISPLAY_FOOTPRINTS_FRAME : public PCB_BASE_FRAME
{
public:
DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent );
~DISPLAY_FOOTPRINTS_FRAME();
void OnCloseWindow( wxCloseEvent& Event );

View File

@ -30,7 +30,7 @@
#include <fctsys.h>
#include <wxstruct.h>
#include <macros.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <wildcards_and_files_ext.h>
#include <cvpcb.h>

View File

@ -29,7 +29,8 @@
#include <fctsys.h>
#include <build_version.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <macros.h>
#include <confirm.h>
#include <eda_doc.h>
@ -104,9 +105,10 @@ END_EVENT_TABLE()
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
EDA_BASE_FRAME( NULL, CVPCB_FRAME_TYPE, title, wxDefaultPosition,
wxDefaultSize, style, CVPCB_MAINFRAME_NAME )
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
KIWAY_PLAYER( aKiway, aParent, CVPCB_FRAME_TYPE, wxT( "CvPCB" ), wxDefaultPosition,
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
{
m_FrameName = CVPCB_MAINFRAME_NAME;
m_ListCmp = NULL;
@ -119,9 +121,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
m_KeepCvpcbOpen = false;
m_undefinedComponentCnt = 0;
m_skipComponentSelect = false;
m_globalFootprintTable = NULL;
m_footprintLibTable = NULL;
m_NetlistFileExtension = wxT( "net" );
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
@ -137,7 +137,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
SetAutoLayout( true );
LoadSettings();
LoadSettings( config() );
if( m_FrameSize.x < FRAME_MIN_SIZE_X )
m_FrameSize.x = FRAME_MIN_SIZE_X;
@ -194,36 +194,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
m_auimgr.Update();
if( m_globalFootprintTable == NULL )
{
try
{
m_globalFootprintTable = new FP_LIB_TABLE();
if( !FP_LIB_TABLE::LoadGlobalTable( *m_globalFootprintTable ) )
{
DisplayInfoMessage( this, wxT( "You have run CvPcb for the first time using the "
"new footprint library table method of finding "
"footprints. CvPcb has either copied the default "
"table or created an empty table in your home "
"folder. You must first configure the library "
"table to include all footprint libraries not "
"included with KiCad. See the \"Footprint Library "
"Table\" section of the CvPcb documentation for "
"more information." ) );
}
}
catch( IO_ERROR ioe )
{
wxString msg;
msg.Printf( _( "An error occurred attempting to load the global footprint library "
"table:\n\n%s" ), GetChars( ioe.errorText ) );
DisplayError( this, msg );
}
m_footprintLibTable = new FP_LIB_TABLE( m_globalFootprintTable );
}
}
@ -233,28 +203,37 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
}
void CVPCB_MAINFRAME::LoadSettings()
FP_LIB_TABLE* CVPCB_MAINFRAME::FootprintLibs() const
{
wxASSERT( wxGetApp().GetSettings() != NULL );
PROJECT& prj = Prj();
FP_LIB_TABLE* tbl = dynamic_cast<FP_LIB_TABLE*>( prj.Elem( PROJECT::FPTBL ) );
wxConfig* cfg = wxGetApp().GetSettings();
if( !tbl )
{
tbl = new FP_LIB_TABLE( &GFootprintTable );
prj.Elem( PROJECT::FPTBL, tbl );
}
EDA_BASE_FRAME::LoadSettings();
cfg->Read( KeepCvpcbOpenEntry, &m_KeepCvpcbOpen, true );
cfg->Read( FootprintDocFileEntry, &m_DocModulesFileName,
return tbl;
}
void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg )
{
EDA_BASE_FRAME::LoadSettings( aCfg );
aCfg->Read( KeepCvpcbOpenEntry, &m_KeepCvpcbOpen, true );
aCfg->Read( FootprintDocFileEntry, &m_DocModulesFileName,
DEFAULT_FOOTPRINTS_LIST_FILENAME );
}
void CVPCB_MAINFRAME::SaveSettings()
void CVPCB_MAINFRAME::SaveSettings( wxConfigBase* aCfg )
{
wxASSERT( wxGetApp().GetSettings() != NULL );
EDA_BASE_FRAME::SaveSettings( aCfg );
wxConfig* cfg = wxGetApp().GetSettings();
EDA_BASE_FRAME::SaveSettings();
cfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen );
cfg->Write( FootprintDocFileEntry, m_DocModulesFileName );
aCfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen );
aCfg->Write( FootprintDocFileEntry, m_DocModulesFileName );
int state = 0;
@ -267,7 +246,7 @@ void CVPCB_MAINFRAME::SaveSettings()
if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) )
state |= FOOTPRINTS_LISTBOX::BY_LIBRARY;
cfg->Write( wxT( FILTERFOOTPRINTKEY ), state );
aCfg->Write( wxT( FILTERFOOTPRINTKEY ), state );
}
@ -321,10 +300,10 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
}
// Close the help frame
if( wxGetApp().GetHtmlHelpController() )
if( Pgm().GetHtmlHelpController() )
{
if( wxGetApp().GetHtmlHelpController()->GetFrame() )// returns NULL if no help frame active
wxGetApp().GetHtmlHelpController()->GetFrame()->Close( true );
if( Pgm().GetHtmlHelpController()->GetFrame() )// returns NULL if no help frame active
Pgm().GetHtmlHelpController()->GetFrame()->Close( true );
}
if( m_NetlistFileName.IsOk() )
@ -460,9 +439,8 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
{
wxString oldPath;
wxFileName newFileName;
int id = event.GetId();
wxFileName newFileName;
if( id >= wxID_FILE1 && id <= wxID_FILE9 )
{
@ -483,45 +461,59 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
if( newFileName == m_NetlistFileName )
return;
if( m_NetlistFileName.DirExists() )
oldPath = m_NetlistFileName.GetPath();
OpenProjectFiles( std::vector<wxString>( 1, newFileName.GetFullPath() ) );
}
/* Update the library search path list. */
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 );
m_NetlistFileName = newFileName;
ReadNetListAndLinkFiles();
bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
if( aFileSet.size() == 1 )
{
m_NetlistFileName = aFileSet[0];
ReadNetListAndLinkFiles();
UpdateTitle();
return true;
}
return false;
}
void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event )
{
DIALOG_CVPCB_CONFIG ConfigFrame( this );
/* This is showing FOOTPRINT search paths, which are obsoleted.
I am removing this for the time being, since cvpcb will soon be part of pcbnew.
ConfigFrame.ShowModal();
DIALOG_CVPCB_CONFIG dlg( this );
dlg.ShowModal();
*/
}
void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
{
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, m_globalFootprintTable, m_footprintLibTable );
int r = InvokePcbLibTableEditor( this, &GFootprintTable, FootprintLibs() );
if( r & 1 )
{
try
{
FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() );
m_globalFootprintTable->Format( &sf, 0 );
GFootprintTable.Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Error occurred saving the global footprint library "
"table:\n\n%s" ), ioe.errorText.GetData() );
wxString msg = wxString::Format( _(
"Error occurred saving the global footprint library "
"table:\n\n%s" ),
GetChars( ioe.errorText ) );
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
@ -535,7 +527,7 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
try
{
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
m_footprintLibTable->Format( &sf, 0 );
FootprintLibs()->Format( &sf, 0 );
tableChanged = true;
}
catch( IO_ERROR& ioe )
@ -550,7 +542,7 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
if( tableChanged )
{
BuildLIBRARY_LISTBOX();
m_footprints.ReadFootprintFiles( m_footprintLibTable );
m_footprints.ReadFootprintFiles( FootprintLibs() );
}
}
@ -576,7 +568,7 @@ void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
{
GetAssociatedDocument( this, m_DocModulesFileName, &wxGetApp().GetLibraryPathList() );
GetAssociatedDocument( this, m_DocModulesFileName, &Kiface().KifaceSearch() );
}
@ -748,16 +740,17 @@ void CVPCB_MAINFRAME::DisplayStatus()
bool CVPCB_MAINFRAME::LoadFootprintFiles()
{
FP_LIB_TABLE* fptbl = FootprintLibs();
// Check if there are footprint libraries in the footprint library table.
if( m_footprintLibTable == NULL || !m_footprintLibTable->GetLogicalLibs().size() )
if( !fptbl || !fptbl->GetLogicalLibs().size() )
{
wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
"library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
return false;
}
if( m_footprintLibTable != NULL )
m_footprints.ReadFootprintFiles( m_footprintLibTable );
m_footprints.ReadFootprintFiles( fptbl );
if( m_footprints.GetErrorCount() )
{
@ -770,20 +763,18 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
void CVPCB_MAINFRAME::UpdateTitle()
{
wxString title;
wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) );
if( m_NetlistFileName.IsOk() && m_NetlistFileName.FileExists() )
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath();
title += m_NetlistFileName.GetFullPath();
if( !m_NetlistFileName.IsFileWritable() )
title += _( " [Read Only]" );
}
else
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + _( " [no file]" );
title += _( "[no file]" );
}
SetTitle( title );
@ -868,7 +859,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
// File header.
static char HeaderLinkFile[] = { "Cmp-Mod V01" };
static char headerLinkFile[] = "Cmp-Mod V01";
bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
@ -876,7 +867,7 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
COMPONENT* component;
FILE* outputFile;
wxFileName fn( aFullFileName );
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) );
outputFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
@ -896,8 +887,8 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
* IdModule = BUS_PC;
* EndCmp
*/
retval |= fprintf( outputFile, "%s", HeaderLinkFile );
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( Title ) );
retval |= fprintf( outputFile, "%s", headerLinkFile );
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( title ) );
retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) );
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
@ -919,15 +910,9 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
void CVPCB_MAINFRAME::CreateScreenCmp()
{
if( m_DisplayFootprintFrame == NULL )
if( !m_DisplayFootprintFrame )
{
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE );
m_DisplayFootprintFrame->SetFootprintLibTable( m_footprintLibTable );
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( &Kiway(), this );
m_DisplayFootprintFrame->Show( true );
}
else
@ -1023,11 +1008,11 @@ void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX()
wxFONTWEIGHT_NORMAL ) );
}
if( m_footprintLibTable )
if( FootprintLibs() )
{
wxArrayString libNames;
std::vector< wxString > libNickNames = m_footprintLibTable->GetLogicalLibs();
std::vector< wxString > libNickNames = FootprintLibs()->GetLogicalLibs();
for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
libNames.Add( libNickNames[ii] );

View File

@ -27,8 +27,11 @@
*/
#include <fctsys.h>
#include <macros.h>
#include <fp_lib_table.h>
#include <gr_basic.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <wxstruct.h>
#include <confirm.h>
#include <gestfich.h>
@ -56,11 +59,13 @@ const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.eq
const wxString titleLibLoadError( _( "Library Load Error" ) );
#if 0 // add this logic to OpenProjectFiles()
/*
* MacOSX: Needed for file association
* http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void EDA_APP::MacOpenFile( const wxString& aFileName )
void PGM_BASE::MacOpenFile( const wxString& aFileName )
{
wxFileName filename = aFileName;
wxString oldPath;
@ -74,73 +79,153 @@ void EDA_APP::MacOpenFile( const wxString& aFileName )
oldPath = frame->m_NetlistFileName.GetPath();
// Update the library search path list.
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath );
if( Pgm().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
Pgm().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
Pgm().GetLibraryPathList().Insert( filename.GetPath(), 0 );
frame->m_NetlistFileName = filename;
frame->ReadNetListAndLinkFiles();
}
#endif
// Create a new application object
IMPLEMENT_APP( EDA_APP )
namespace CV {
/************************************/
/* Called to initialize the program */
/************************************/
bool EDA_APP::OnInit()
static struct IFACE : public KIFACE_I
{
wxFileName filename;
wxString message;
CVPCB_MAINFRAME* frame = NULL;
// Of course all are virtual overloads, implementations of the KIFACE.
InitEDA_Appl( wxT( "CvPcb" ), APP_CVPCB_T );
IFACE( const char* aName, KIWAY::FACE_T aType ) :
KIFACE_I( aName, aType )
{}
SetFootprintLibTablePath();
bool OnKifaceStart( PGM_BASE* aProgram );
if( m_Checker && m_Checker->IsAnotherRunning() )
void OnKifaceEnd();
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
{
if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) )
return false;
switch( aClassId )
{
case CVPCB_FRAME_TYPE:
{
CVPCB_MAINFRAME* frame = new CVPCB_MAINFRAME( aKiway, aParent );
return frame;
}
break;
default:
;
}
return NULL;
}
if( argc > 1 )
/**
* Function IfaceOrAddress
* return a pointer to the requested object. The safest way to use this
* is to retrieve a pointer to a static instance of an interface, similar to
* how the KIFACE interface is exported. But if you know what you are doing
* use it to retrieve anything you want.
*
* @param aDataId identifies which object you want the address of.
*
* @return void* - and must be cast into the know type.
*/
void* IfaceOrAddress( int aDataId )
{
filename = argv[1];
wxSetWorkingDirectory( filename.GetPath() );
return NULL;
}
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings( reopenLastUsedDirectory );
} kiface( "cvpcb", KIWAY::FACE_CVPCB );
} // namespace
using namespace CV;
static PGM_BASE* process;
KIFACE_I& Kiface() { return kiface; }
// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
return &kiface;
}
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
FP_LIB_TABLE GFootprintTable;
// A short lived implementation. cvpcb will get combine into pcbnew shortly, so
// we skip setting KISYSMOD here for now. User should set the environment
// variable.
bool IFACE::OnKifaceStart( PGM_BASE* aProgram )
{
// This is process level, not project level, initialization of the DSO.
// Do nothing in here pertinent to a project!
start_common();
/* Now that there are no *.mod files in the standard library, this function
has no utility. User should simply set the variable manually.
Looking for *.mod files which do not exist is fruitless.
// SetFootprintLibTablePath();
*/
g_DrawBgColor = BLACK;
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
frame = new CVPCB_MAINFRAME( Title );
// Show the frame
SetTopWindow( frame );
frame->Show( true );
frame->m_NetlistFileExtension = wxT( "net" );
if( filename.IsOk() && filename.FileExists() )
try
{
frame->m_NetlistFileName = filename;
frame->LoadProjectFile( filename.GetFullPath() );
// The global table is not related to a specific project. All projects
// will use the same global table. So the KIFACE::OnKifaceStart() contract
// of avoiding anything project specific is not violated here.
if( frame->ReadNetListAndLinkFiles() )
if( !FP_LIB_TABLE::LoadGlobalTable( GFootprintTable ) )
{
frame->m_NetlistFileExtension = filename.GetExt();
return true;
DisplayInfoMessage( NULL, wxT(
"You have run CvPcb for the first time using the "
"new footprint library table method for finding "
"footprints. CvPcb has either copied the default "
"table or created an empty table in your home "
"folder. You must first configure the library "
"table to include all footprint libraries not "
"included with KiCad. See the \"Footprint Library "
"Table\" section of the CvPcb documentation for "
"more information." ) );
}
}
frame->UpdateTitle();
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"An error occurred attempting to load the global footprint library "
"table:\n\n%s" ),
GetChars( ioe.errorText )
);
DisplayError( NULL, msg );
return false;
}
return true;
}
void IFACE::OnKifaceEnd()
{
end_common();
}

View File

@ -35,7 +35,7 @@
#include <footprint_info.h>
#include <wxBasePcbFrame.h>
#include <param_config.h>
#include <config_params.h>
/* Forward declarations of all top-level window classes. */
@ -47,22 +47,17 @@ class DISPLAY_FOOTPRINTS_FRAME;
class COMPONENT;
class FP_LIB_TABLE;
namespace CV { struct IFACE; }
/**
* The CvPcb application main window.
*/
class CVPCB_MAINFRAME : public EDA_BASE_FRAME
class CVPCB_MAINFRAME : public KIWAY_PLAYER
{
friend struct CV::IFACE;
wxArrayString m_footprintListEntries;
/// The global footprint library table.
FP_LIB_TABLE* m_globalFootprintTable;
/// The project footprint library table. This is a combination of the project
/// footprint library table and the global footprint table. This is the one to
/// use when finding a #MODULE.
FP_LIB_TABLE* m_footprintLibTable;
public:
bool m_KeepCvpcbOpen;
FOOTPRINTS_LISTBOX* m_FootprintList;
@ -87,10 +82,19 @@ protected:
// (in automatic selection/deletion of associations)
PARAM_CFG_ARRAY m_projectFileParams;
CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent );
public:
CVPCB_MAINFRAME( const wxString& title, long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~CVPCB_MAINFRAME();
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ); // overload KIWAY_PLAYER
/**
* Function FootprintLibs
* @return the project #FP_LIB_TABLE.
*/
FP_LIB_TABLE* FootprintLibs() const;
/**
* Function OnSelectComponent
* Called when clicking on a component in component list window
@ -226,23 +230,9 @@ public:
*/
void LoadProjectFile( const wxString& aFileName );
/**
* Function LoadSettings
* loads the CvPcb main frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
virtual void LoadSettings();
void LoadSettings( wxConfigBase* aCfg ); // override virtual
/**
* Function SaveSettings
* save the CvPcb frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
virtual void SaveSettings();
void SaveSettings( wxConfigBase* aCfg ); // override virtual
/**
* Function DisplayStatus

View File

@ -29,7 +29,7 @@
#include <fctsys.h>
#include <wx/tokenzr.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
@ -43,18 +43,19 @@
#include <wildcards_and_files_ext.h>
DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* parent ) :
DIALOG_CVPCB_CONFIG_FBP( parent )
DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* aParent ) :
DIALOG_CVPCB_CONFIG_FBP( aParent )
{
wxString title;
wxFileName fn = parent->m_NetlistFileName;
wxString title;
wxFileName fn = aParent->m_NetlistFileName;
fn.SetExt( ProjectFileExtension );
m_Parent = parent;
m_Config = wxGetApp().GetCommonSettings();
m_Parent = aParent;
m_Config = Pgm().CommonSettings();
Init( );
title.Format( _( "Project file: <%s>" ), GetChars( fn.GetFullPath() ) );
title.Format( _( "Project file: '%s'" ), GetChars( fn.GetFullPath() ) );
SetTitle( title );
if( GetSizer() )
@ -93,7 +94,7 @@ void DIALOG_CVPCB_CONFIG::Init()
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
wxPathList libpaths = Pgm().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
@ -112,9 +113,9 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
if( m_LibPathChanged )
{
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString( ii ) );
Pgm().RemoveLibraryPath( m_listUserPaths->GetString( ii ) );
wxGetApp().InsertLibraryPath( m_Parent->m_UserLibraryPath, 1 );
Pgm().InsertLibraryPath( m_Parent->m_UserLibraryPath, 1 );
}
EndModal( wxID_CANCEL );
@ -295,7 +296,8 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
insert = true;
wildcard = FootprintAliasFileWildcard;
wxListBox * list = m_ListEquiv;
wxListBox* list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{
@ -317,7 +319,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
libpath = Pgm().LastVisitedLibraryPath();
wxFileDialog FilesDialog( this, _( "Footprint library files:" ), libpath,
wxEmptyString, wildcard,
@ -334,7 +336,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
fn = Filenames[jj];
if( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
Pgm().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
@ -343,7 +345,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* because it preserve use of default libraries paths, when the path
* is a sub path of these default paths
*/
libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );
libfilename = Pgm().FilenameWithRelativePathInSearchList( fn.GetFullPath() );
// Remove extension:
fn = libfilename;
@ -372,7 +374,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
{
wxString path = wxGetApp().ReturnLastVisitedLibraryPath();
wxString path = Pgm().LastVisitedLibraryPath();
bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
path,
@ -416,10 +418,10 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
m_listUserPaths->Insert( path, ipos );
m_LibPathChanged = true;
wxGetApp().InsertLibraryPath( path, ipos + 1 );
Pgm().InsertLibraryPath( path, ipos + 1 );
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
wxPathList libpaths = Pgm().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
@ -432,7 +434,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
DisplayError( this, _( "Path already in use" ) );
}
wxGetApp().SaveLastVisitedLibraryPath( path );
Pgm().SaveLastVisitedLibraryPath( path );
}
@ -445,13 +447,13 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
if( ii >= 0 )
{
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
Pgm().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
m_listUserPaths->Delete( ii );
m_LibPathChanged = true;
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
wxPathList libpaths = Pgm().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
@ -466,7 +468,7 @@ void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
wxString FullFileName;
wxString docpath, filename;
docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) );
docpath = Pgm().LastVisitedLibraryPath( wxT( "doc" ) );
wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
wxEmptyString, PdfFileWildcard,
@ -485,8 +487,8 @@ void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
* a sub path of these default paths
*/
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
Pgm().SaveLastVisitedLibraryPath( fn.GetPath() );
filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( FullFileName );
filename = Pgm().FilenameWithRelativePathInSearchList( FullFileName );
m_TextHelpModulesFileName->SetValue( filename );
}

View File

@ -14,8 +14,9 @@ class DIALOG_CVPCB_CONFIG : public DIALOG_CVPCB_CONFIG_FBP
{
private:
CVPCB_MAINFRAME* m_Parent;
wxConfig * m_Config;
wxString m_UserLibDirBufferImg;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg;
bool m_LibListChanged;
bool m_LibPathChanged;

View File

@ -27,7 +27,8 @@
* @brief (Re)Create the menubar for CvPcb
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
#include <menus_helpers.h>
@ -74,11 +75,13 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu();
Kiface().GetFileHistory().UseMenu( openRecentMenu );
Kiface().GetFileHistory().AddFilesToMenu();
AddMenuItem( filesMenu, openRecentMenu, -1,
_( "Open &Recent" ),
_( "Open a recent opened netlist document" ),
@ -115,7 +118,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
KiBitmap( library_table_xpm ) );
// Language submenu
wxGetApp().AddMenuLanguageList( preferencesMenu );
Pgm().AddMenuLanguageList( preferencesMenu );
// Keep open on save
item = new wxMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,

View File

@ -119,6 +119,49 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
}
/**
* Function missingLegacyLibs
* tests the list of \a aLibNames by URI to determine if any of them are missing from
* the #FP_LIB_TABLE.
*
* @note The missing legacy footprint library test is performed by using old library
* file path lookup method. If the library is found, it is compared against all
* of the URIs in the table rather than the nickname. This was done because the
* user could change the nicknames from the default table. Using the full path
* is more reliable.
*
* @param aLibNames is the list of legacy library names.
* @param aErrorMsg is a pointer to a wxString object to store the URIs of any missing
* legacy library paths. Can be NULL.
* @return true if there are missing legacy libraries. Otherwise false.
*/
static bool missingLegacyLibs( FP_LIB_TABLE* aTbl, SEARCH_STACK& aSStack,
const wxArrayString& aLibNames, wxString* aErrorMsg )
{
bool retv = false;
for( unsigned i = 0; i < aLibNames.GetCount(); i++ )
{
wxFileName fn( wxEmptyString, aLibNames[i], LegacyFootprintLibPathExtension );
wxString legacyLibPath = aSStack.FindValidPath( fn );
if( legacyLibPath.IsEmpty() )
continue;
if( aTbl->FindRowByURI( legacyLibPath ) == 0 )
{
retv = true;
if( aErrorMsg )
*aErrorMsg += wxT( "\"" ) + legacyLibPath + wxT( "\"\n" );
}
}
return retv;
}
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
{
COMPONENT* component;
@ -164,7 +207,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
// Check if footprint links were generated before the footprint library table was implemented.
if( isLegacy )
{
if( m_footprintLibTable->MissingLegacyLibs( m_ModuleLibNames, &missingLibs ) )
if( missingLegacyLibs( FootprintLibs(), Prj().PcbSearchS(), m_ModuleLibNames, &missingLibs ) )
{
msg = wxT( "The following legacy libraries are defined in the project file "
"were not found in the footprint library table:\n\n" ) + missingLibs;
@ -188,7 +231,9 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
msg.Clear();
WX_STRING_REPORTER reporter( &msg );
if( !m_footprintLibTable->ConvertFromLegacy( m_netlist, m_ModuleLibNames, &reporter ) )
SEARCH_STACK& search = Prj().SchSearchS();
if( !FootprintLibs()->ConvertFromLegacy( search, m_netlist, m_ModuleLibNames, &reporter ) )
{
HTML_MESSAGE_BOX dlg( this, wxEmptyString );
@ -270,7 +315,7 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
fn.SetExt( ComponentFileExtension );
// Save the project specific footprint library table.
if( !m_footprintLibTable->IsEmpty( false ) )
if( !FootprintLibs()->IsEmpty( false ) )
{
wxFileName fpLibFileName = fn;
fpLibFileName.ClearExt();
@ -282,9 +327,9 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
{
try
{
m_footprintLibTable->Save( fpLibFileName );
FootprintLibs()->Save( fpLibFileName );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this,
wxString::Format( _( "An error occurred attempting to save the "

View File

@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <common.h>
#include <bitmaps.h>
@ -41,7 +41,7 @@
void CVPCB_MAINFRAME::ReCreateHToolbar()
{
wxConfig* config = wxGetApp().GetSettings();
wxConfigBase* config = Kiface().KifaceSettings();
if( m_mainToolBar != NULL )
return;

View File

@ -1,4 +1,4 @@
set( MAKE_LINK_MAPS false )
set( MAKE_LINK_MAPS true )
add_definitions( -DEESCHEMA )
@ -191,11 +191,11 @@ endif()
# auto-generate cmp_library_lexer.h and cmp_library_keywords.cpp for the component
# library format.
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
TLIB_T
)
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
TLIB_T
)
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords
@ -235,22 +235,35 @@ set_source_files_properties( dialogs/dialog_bom.cpp
)
# not ready for even building yet:
if( USE_KIWAY_DLLS )
add_executable( eeschema WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=SCHEMATIC_FRAME_TYPE;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL"
)
target_link_libraries( eeschema
#singletop # replaces common, giving us restrictive control and link warnings.
# There's way too much crap coming in from common yet.
common
bitmaps
${wxWidgets_LIBRARIES}
)
# the DSO (KIFACE) housing the main eeschema code:
add_library( eeschema_kiface MODULE
${EESCHEMA_SRCS}
${EESCHEMA_COMMON_SRCS}
${EESCHEMA_RESOURCES}
)
target_link_libraries( eeschema_kiface
common
bitmaps
polygon
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
set_target_properties( eeschema_kiface PROPERTIES
# Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
# _eeschema.so, _eeschema.dll, or _eeschema.kiface
@ -259,6 +272,14 @@ if( USE_KIWAY_DLLS )
SUFFIX ${KIFACE_SUFFIX}
)
# The KIFACE is in eeschema.cpp, export it:
set_source_files_properties( eeschema.cpp PROPERTIES
COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL"
)
# if building eeschema, then also build eeschema_kiface if out of date.
add_dependencies( eeschema eeschema_kiface )
if( APPLE )
set_target_properties( eeschema_kiface PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
@ -266,31 +287,46 @@ if( USE_KIWAY_DLLS )
endif()
if( MAKE_LINK_MAPS )
# generate a link map with cross reference
# generate link map with cross reference
set_target_properties( eeschema_kiface PROPERTIES
LINK_FLAGS "-Wl,-cref -Wl,-Map=${KIFACE_PRE}eeschema.${KIFACE_EXT}.map"
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=${KIFACE_PREFIX}eeschema${KIFACE_SUFFIX}.map"
)
set_target_properties( eeschema PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=eeschema.map"
)
endif()
target_link_libraries( eeschema_kiface
# these 2 binaries are a matched set, keep them together:
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( TARGETS eeschema_kiface
# actual filename subject to change at milestone C)
# modular-kicad blueprint.
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
else()
add_executable( eeschema WIN32 MACOSX_BUNDLE
../common/single_top.cpp
${EESCHEMA_SRCS}
${EESCHEMA_COMMON_SRCS}
${EESCHEMA_RESOURCES}
)
target_link_libraries( eeschema
common
# lib_kicad
bitmaps
polygon
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
# Note that this filename is subject to change at milestone C) of
# modular-kicad blueprint.
install( TARGETS eeschema_kiface
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
else()
add_executable( eeschema WIN32 MACOSX_BUNDLE
${EESCHEMA_SRCS}
${EESCHEMA_COMMON_SRCS}
${EESCHEMA_RESOURCES}
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=SCHEMATIC_FRAME_TYPE;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL"
)
if( APPLE )
@ -299,19 +335,12 @@ else()
)
endif()
target_link_libraries( eeschema
common
bitmaps
polygon
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
install( TARGETS eeschema
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
add_subdirectory( plugins )

View File

@ -32,7 +32,7 @@
#include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <appl_wxstruct.h>
#include <kiface_i.h>
#include <wxEeschemaStruct.h>
#include <build_version.h>
#include <wildcards_and_files_ext.h>
@ -145,8 +145,8 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
return false;
wxString filename = dlg.GetPath();
wxString title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
title += wxT( " " ) + filename;
wxString title = wxT( "Eeschema " ) + GetBuildVersion() + wxT( ' ' ) + filename;
SetTitle( title );
int response = wxMessageBox( _( "Do you want to force all the footprint fields visibility?" ),

View File

@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
@ -64,7 +64,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
int SCH_EDIT_FRAME::ReturnBlockCommand( int key )
int SCH_EDIT_FRAME::BlockCommand( int key )
{
int cmd = BLOCK_IDLE;

View File

@ -41,7 +41,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
bool aErase );
int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
int LIB_EDIT_FRAME::BlockCommand( int key )
{
int cmd = BLOCK_IDLE;

View File

@ -258,7 +258,7 @@ wxString LIB_COMPONENT::GetLibraryName()
}
wxString LIB_COMPONENT::ReturnSubReference( int aUnit, bool aAddSeparator )
wxString LIB_COMPONENT::SubReference( int aUnit, bool aAddSeparator )
{
wxString subRef;
@ -568,7 +568,7 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert
{
wxASSERT( pinList[i]->Type() == LIB_PIN_T );
pinList[i]->ReturnPinStringNum( pNumber );
pinList[i]->PinStringNum( pNumber );
if( aNumber == pNumber )
return pinList[i];

View File

@ -664,7 +664,7 @@ public:
bool IsMulti() { return m_unitCount > 1; }
/**
* Function ReturnSubReference
* Function SubReference
* @return the sub reference for component having multiple parts per package.
* The sub reference identify the part (or unit)
* @param aUnit = the part identifier ( 1 to max count)
@ -672,7 +672,7 @@ public:
* by the separator symbol (if any)
* Note: this is a static function.
*/
static wxString ReturnSubReference( int aUnit, bool aAddSeparator = true );
static wxString SubReference( int aUnit, bool aAddSeparator = true );
// Accessors to sub ref parameters
static int GetSubpartIdSeparator() { return m_subpartIdSeparator; }

View File

@ -353,7 +353,7 @@ wxString NETLIST_OBJECT::GetShortNetName() const
netName = wxT("Net-(");
netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
netName << wxT("-Pad")
<< LIB_PIN::ReturnPinStringNum( m_netNameCandidate->m_PinNum )
<< LIB_PIN::PinStringNum( m_netNameCandidate->m_PinNum )
<< wxT(")");
}
}

View File

@ -33,7 +33,7 @@
#include <sch_sheet_path.h>
#include <lib_pin.h> // LIB_PIN::ReturnPinStringNum( m_PinNum )
#include <lib_pin.h> // LIB_PIN::PinStringNum( m_PinNum )
class NETLIST_OBJECT_LIST;
class SCH_COMPONENT;
@ -179,7 +179,7 @@ public:
wxString GetPinNumText()
{
// hide the ugliness in here, but do it inline.
return LIB_PIN::ReturnPinStringNum( m_PinNum );
return LIB_PIN::PinStringNum( m_PinNum );
}
/** For Pins (NET_PINS):

View File

@ -592,12 +592,12 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ),
GetChars( componentFlatList[ii].GetRef() ),
componentFlatList[ii].m_NumRef,
GetChars( LIB_COMPONENT::ReturnSubReference(
GetChars( LIB_COMPONENT::SubReference(
componentFlatList[ii].m_Unit ) ),
GetChars( componentFlatList[ii].m_Value->GetText() ),
GetChars( componentFlatList[next].GetRef() ),
componentFlatList[next].m_NumRef,
GetChars( LIB_COMPONENT::ReturnSubReference(
GetChars( LIB_COMPONENT::SubReference(
componentFlatList[next].m_Unit ) ),
GetChars( componentFlatList[next].m_Value->GetText() ) );

View File

@ -28,7 +28,7 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <macros.h>
#include <eda_dde.h>
#include <wxEeschemaStruct.h>
@ -58,17 +58,11 @@
void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{
char line[1024];
char* idcmd;
char* text;
wxString part_ref, msg;
SCH_EDIT_FRAME* frame;
frame = (SCH_EDIT_FRAME*)wxGetApp().GetTopWindow();
strncpy( line, cmdline, sizeof(line) - 1 );
idcmd = strtok( line, " \n\r" );
text = strtok( NULL, "\"\n\r" );
char* idcmd = strtok( line, " \n\r" );
char* text = strtok( NULL, "\"\n\r" );
if( (idcmd == NULL) || (text == NULL) )
return;
@ -76,14 +70,14 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( strcmp( idcmd, "$PART:" ) != 0 )
return;
part_ref = FROM_UTF8( text );
wxString part_ref = FROM_UTF8( text );
/* look for a complement */
idcmd = strtok( NULL, " \n\r" );
if( idcmd == NULL ) // component only
{
frame->FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
return;
}
@ -92,23 +86,23 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( text == NULL )
return;
msg = FROM_UTF8( text );
wxString msg = FROM_UTF8( text );
if( strcmp( idcmd, "$REF:" ) == 0 )
{
frame->FindComponentAndItem( part_ref, true, FIND_REFERENCE, msg, false );
FindComponentAndItem( part_ref, true, FIND_REFERENCE, msg, false );
}
else if( strcmp( idcmd, "$VAL:" ) == 0 )
{
frame->FindComponentAndItem( part_ref, true, FIND_VALUE, msg, false );
FindComponentAndItem( part_ref, true, FIND_VALUE, msg, false );
}
else if( strcmp( idcmd, "$PAD:" ) == 0 )
{
frame->FindComponentAndItem( part_ref, true, FIND_PIN, msg, false );
FindComponentAndItem( part_ref, true, FIND_PIN, msg, false );
}
else
{
frame->FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString, false );
}
}
@ -126,14 +120,14 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT*
{
case SCH_FIELD_T:
case LIB_FIELD_T:
{
if( LibItem == NULL )
break;
{
if( !LibItem )
break;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
}
break;
sprintf( Line, "$PART: %s", TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
SendCommand( MSG_TO_PCB, Line );
}
break;
case SCH_COMPONENT_T:
LibItem = (SCH_COMPONENT*) objectToSync;
@ -142,7 +136,7 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT*
break;
case LIB_PIN_T:
if( LibItem == NULL )
if( !LibItem )
break;
Pin = (LIB_PIN*) objectToSync;
@ -150,7 +144,7 @@ void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT*
if( Pin->GetNumber() )
{
wxString pinnum;
Pin->ReturnPinStringNum( pinnum );
Pin->PinStringNum( pinnum );
sprintf( Line, "$PIN: %s $PART: %s", TO_UTF8( pinnum ),
TO_UTF8( LibItem->GetField( REFERENCE )->GetText() ) );
}

View File

@ -26,15 +26,15 @@
* @file database.cpp
*/
#include "fctsys.h"
#include "confirm.h"
#include "eda_doc.h"
#include "kicad_string.h"
#include "wxstruct.h"
#include <fctsys.h>
#include <confirm.h>
#include <eda_doc.h>
#include <kicad_string.h>
#include <draw_frame.h>
#include <macros.h>
#include "protos.h"
#include "class_library.h"
#include "dialog_helpers.h"
#include <protos.h>
#include <class_library.h>
#include <dialog_helpers.h>
#include <boost/foreach.hpp>

View File

@ -29,21 +29,20 @@
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <wxEeschemaStruct.h>
#include <class_drawpanel.h>
#include <invoke_sch_dialog.h>
#include <dialog_annotate_base.h>
#include <kiface_i.h>
#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT( "AnnotateAutoCloseOption" )
#define KEY_ANNOTATE_USE_SILENTMODE wxT( "AnnotateSilentMode" )
#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT( "AnnotateAutoCloseOption" )
#define KEY_ANNOTATE_USE_SILENTMODE wxT( "AnnotateSilentMode" )
class wxConfig;
class wxConfigBase;
/**
@ -57,7 +56,7 @@ public:
private:
SCH_EDIT_FRAME* m_Parent;
wxConfig* m_Config;
wxConfigBase* m_Config;
/// Initialises member variables
void InitValues();
@ -112,7 +111,7 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent )
void DIALOG_ANNOTATE::InitValues()
{
m_Config = wxGetApp().GetSettings();
m_Config = Kiface().KifaceSettings();
if( m_Config )
{

View File

@ -29,7 +29,8 @@
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
#include <wxEeschemaStruct.h>
@ -161,7 +162,7 @@ private:
// the first is the title
// the second is the command line
wxArrayString m_plugins;
wxConfig* m_config; // to store the "plugins"
wxConfigBase* m_config; // to store the "plugins"
public:
// Constructor and destructor
@ -169,7 +170,7 @@ public:
~DIALOG_BOM();
private:
void OnPluginSelected( wxCommandEvent& event );
void OnPluginSelected( wxCommandEvent& event );
void OnRunPlugin( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnHelp( wxCommandEvent& event );
@ -177,10 +178,10 @@ private:
void OnChoosePlugin( wxCommandEvent& event );
void OnRemovePlugin( wxCommandEvent& event );
void OnEditPlugin( wxCommandEvent& event );
void OnCommandLineEdited( wxCommandEvent& event );
void OnNameEdited( wxCommandEvent& event );
void OnCommandLineEdited( wxCommandEvent& event );
void OnNameEdited( wxCommandEvent& event );
void pluginInit();
void pluginInit();
void installPluginsList();
};
@ -195,7 +196,7 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) :
DIALOG_BOM_BASE( parent )
{
m_parent = parent;
m_config = wxGetApp().GetSettings();
m_config = Kiface().KifaceSettings();
installPluginsList();
GetSizer()->SetSizeHints( this );
@ -377,38 +378,37 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
*/
void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event )
{
wxString FullFileName, Mask, Path;
wxString mask = wxT( "*" );
wxString path = Pgm().GetExecutablePath();
Mask = wxT( "*" );
Path = wxGetApp().GetExecutablePath();
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
Path,
FullFileName,
wxString fullFileName = EDA_FileSelector( _( "Plugin files:" ),
path,
wxEmptyString,
Mask,
wxEmptyString,
mask,
this,
wxFD_OPEN,
true
);
if( FullFileName.IsEmpty() )
if( fullFileName.IsEmpty() )
return;
// Creates a default command line,
// suitable to run the external tool xslproc or python
// The default command line depending on plugin extension, currently
// "xsl" or "exe" or "py"
wxString cmdLine;
wxFileName fn( FullFileName );
wxString ext = fn.GetExt();
wxString cmdLine;
wxFileName fn( fullFileName );
wxString ext = fn.GetExt();
if( ext == wxT("xsl" ) )
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars( fullFileName ) );
else if( ext == wxT("exe" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("\"%s\" < \"%%I\" > \"%%O\""), GetChars(FullFileName) );
cmdLine.Printf(wxT("\"%s\" < \"%%I\" > \"%%O\""), GetChars( fullFileName ) );
else if( ext == wxT("py" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars(FullFileName) );
cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars( fullFileName ) );
else
cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
cmdLine.Printf(wxT("\"%s\""), GetChars( fullFileName ) );
m_textCtrlCommand->SetValue( cmdLine );
}
@ -449,7 +449,7 @@ void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
}
}
AddDelimiterString( pluginName );
wxString editorname = wxGetApp().GetEditorName();
wxString editorname = Pgm().GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, pluginName );

View File

@ -4,7 +4,7 @@
#include <fctsys.h>
#include <gr_basic.h>
#include <wxstruct.h>
#include <draw_frame.h>
#include <class_drawpanel.h>
#include <general.h>

View File

@ -26,10 +26,11 @@
*/
#include <fctsys.h>
#include <kiway.h>
#include <common.h>
#include <confirm.h>
#include <gestfich.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <general.h>
#include <libeditframe.h>
@ -435,22 +436,22 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event )
{
wxString FullFileName, mask;
wxString docpath, filename;
PROJECT& prj = Prj();
SEARCH_STACK& search = prj.SchSearchS();
docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) );
wxString docpath = prj.RPath(PROJECT::DOC).LastVisitedPath( search, wxT( "doc" ) );
wxString mask = wxT( "*" );
mask = wxT( "*" );
FullFileName = EDA_FileSelector( _( "Doc Files" ),
docpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
wxEmptyString, /* extension par defaut */
mask, /* Masque d'affichage */
wxString fullFileName = EDA_FileSelector( _( "Doc Files" ),
docpath,
wxEmptyString,
wxEmptyString,
mask,
this,
wxFD_OPEN,
true
);
if( FullFileName.IsEmpty() )
if( fullFileName.IsEmpty() )
return;
/* If the path is already in the library search paths
@ -460,10 +461,12 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
* because it preserve use of default libraries paths, when the path is a sub path of
* these default paths
*/
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
wxFileName fn = fullFileName;
prj.RPath(PROJECT::DOC).SaveLastVisitedPath( fn.GetPath() );
wxString filename = search.FilenameWithRelativePathInSearchList( fullFileName );
filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( FullFileName );
// Filenames are always stored in unix like mode, ie separator "\" is stored as "/"
// to ensure files are identical under unices and windows
#ifdef __WINDOWS__

View File

@ -29,7 +29,7 @@
#include <wx/hyperlink.h>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
@ -766,10 +766,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// top of each other.
}
wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x );
wxString coordText = StringFromValue( g_UserUnit, coord.x );
posXTextCtrl->SetValue( coordText );
coordText = ReturnStringFromValue( g_UserUnit, coord.y );
coordText = StringFromValue( g_UserUnit, coord.y );
posYTextCtrl->SetValue( coordText );
}
@ -828,8 +828,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
field.SetBold( (style & 2 ) != 0 );
wxPoint pos;
pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
field.SetTextPosition( pos );
return true;

View File

@ -203,7 +203,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) );
m_staticSizeUnits->SetLabel( msg );
msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->GetSize().x );
msg = StringFromValue( g_UserUnit, m_CurrentText->GetSize().x );
m_TextSize->SetValue( msg );
if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T
@ -272,7 +272,7 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UserUnit, text );
value = ValueFromString( g_UserUnit, text );
m_CurrentText->SetSize( wxSize( value, value ) );
if( m_TextShape )

View File

@ -27,7 +27,7 @@
#include <algorithm>
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <confirm.h>
#include <class_drawpanel.h>
#include <wxEeschemaStruct.h>
@ -675,13 +675,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
// top of each other.
}
wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x );
wxString coordText = StringFromValue( g_UserUnit, coord.x );
posXTextCtrl->SetValue( coordText );
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing
NEGATE( coord.y );
coordText = ReturnStringFromValue( g_UserUnit, coord.y );
coordText = StringFromValue( g_UserUnit, coord.y );
posYTextCtrl->SetValue( coordText );
}
@ -747,8 +747,8 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
field.SetItalic( (style & 1 ) != 0 );
field.SetBold( (style & 2 ) != 0 );
wxPoint pos( ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() ),
ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() ) );
wxPoint pos( ValueFromString( g_UserUnit, posXTextCtrl->GetValue() ),
ValueFromString( g_UserUnit, posYTextCtrl->GetValue() ) );
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing

View File

@ -53,7 +53,7 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base()
m_CommonConvert->Show(false);
m_CommonUnit->Show(false);
msg = ReturnStringFromValue( g_UserUnit, m_textsize );
msg = StringFromValue( g_UserUnit, m_textsize );
m_TextSize->SetValue( msg );
if( m_textorient == TEXT_ORIENT_VERT )
@ -132,7 +132,7 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
{
m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_textsize = ReturnValueFromString( g_UserUnit, msg );
m_textsize = ValueFromString( g_UserUnit, msg );
switch( m_TextHJustificationOpt->GetSelection() )
{

View File

@ -27,10 +27,12 @@
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <kiway.h>
#include <confirm.h>
#include <gestfich.h>
#include <wxEeschemaStruct.h>
#include <invoke_sch_dialog.h>
#include <general.h>
#include <netlist.h>
@ -40,20 +42,50 @@
#include <wx/tokenzr.h>
#include <dialog_eeschema_config.h>
#include <dialog_eeschema_config_fbp.h>
class SCH_EDIT_FRAME;
class EDA_DRAW_FRAME;
class DIALOG_EESCHEMA_CONFIG : public DIALOG_EESCHEMA_CONFIG_FBP
{
public:
DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* parent, wxFrame* activeWindow );
private:
SCH_EDIT_FRAME* m_Parent;
bool m_LibListChanged;
bool m_LibPathChanged;
wxString m_UserLibDirBufferImg; // Copy of original g_UserLibDirBuffer
// event handlers, overiding the fbp handlers
void Init();
void OnCloseWindow( wxCloseEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnAddOrInsertPath( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
};
DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* aSchFrame,
EDA_DRAW_FRAME* aParent )
: DIALOG_EESCHEMA_CONFIG_FBP( aParent )
wxFrame* aParent ) :
DIALOG_EESCHEMA_CONFIG_FBP( aParent )
{
wxString msg;
m_Parent = aSchFrame;
Init();
msg.Printf( _( "from <%s>" ), GetChars( wxGetApp().GetCurrentOptionFile() ) );
wxString msg = wxString::Format(
_( "from '%s'" ),
GetChars( Prj().GetProjectFullName() ) );
SetTitle( msg );
if( GetSizer() )
@ -74,21 +106,22 @@ void DIALOG_EESCHEMA_CONFIG::Init()
m_ListLibr->InsertItems( m_Parent->GetComponentLibraries(), 0 );
// Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( Token.HasMoreTokens() )
wxStringTokenizer tokenizer( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( tokenizer.HasMoreTokens() )
{
wxString path = Token.GetNextToken();
wxString path = tokenizer.GetNextToken();
if( wxFileName::DirExists( path ) )
m_listUserPaths->Append( path );
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
SEARCH_STACK& libpaths = Prj().SchSearchS();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii]);
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
// select the first path after the current path project
@ -153,7 +186,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
EXCHG( libnames[jj], libnames[jj+1]);
}
m_ListLibr->Set(libnames);
m_ListLibr->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
@ -168,13 +201,15 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event )
{
// Recreate the user lib path
if ( m_LibPathChanged )
{
for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString(ii) );
SEARCH_STACK& lib_search = Prj().SchSearchS();
wxGetApp().InsertLibraryPath( m_Parent->GetUserLibraryPath(), 1);
// Recreate the user lib path
if( m_LibPathChanged )
{
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
lib_search.RemovePaths( m_listUserPaths->GetString(ii) );
lib_search.AddPaths( m_Parent->GetUserLibraryPath(), 1 );
}
EndModal( wxID_CANCEL );
@ -184,13 +219,13 @@ void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event )
void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
{
// Recreate the user lib path
if ( m_LibPathChanged )
if( m_LibPathChanged )
{
wxString path;
for ( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{
if ( ii > 0 )
if( ii > 0 )
path << wxT( ";" );
path << m_listUserPaths->GetString( ii );
@ -206,7 +241,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
{
wxArrayString list;
for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ )
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ )
list.Add( m_ListLibr->GetString( ii ) );
// Recreate lib list
@ -268,10 +303,13 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
*/
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
{
int ii;
wxString libfilename;
wxFileName fn;
wxArrayInt selections;
int ii;
wxString libfilename;
wxFileName fn;
wxArrayInt selections;
PROJECT& prj = Prj();
SEARCH_STACK& search = prj.SchSearchS();
m_ListLibr->GetSelections( selections );
@ -282,28 +320,28 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
else
ii = 0;
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
wxString libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if ( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
if( libpath.IsEmpty() )
libpath = prj.RPath(PROJECT::SCH_LIB).LastVisitedPath( search );
wxFileDialog FilesDialog( this, _( "Library files:" ), libpath,
wxFileDialog filesDialog( this, _( "Library files:" ), libpath,
wxEmptyString, SchematicLibraryFileWildcard,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
if( FilesDialog.ShowModal() != wxID_OK )
if( filesDialog.ShowModal() != wxID_OK )
return;
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
wxArrayString filenames;
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
filesDialog.GetPaths( filenames );
for( unsigned jj = 0; jj < filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
fn = filenames[jj];
if ( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
if( jj == 0 )
prj.RPath(PROJECT::SCH_LIB).SaveLastVisitedPath( fn.GetPath() );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
@ -312,14 +350,14 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* because it preserve use of default libraries paths, when the path
* is a sub path of these default paths
*/
libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );
libfilename = search.FilenameWithRelativePathInSearchList( fn.GetFullPath() );
// Remove extension:
fn = libfilename;
fn.SetExt(wxEmptyString);
fn.SetExt( wxEmptyString );
libfilename = fn.GetFullPath();
//Add or insert new library name, if not already in list
// Add or insert new library name, if not already in list
if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_LibListChanged = true;
@ -342,7 +380,9 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
{
wxString path = wxGetApp().ReturnLastVisitedLibraryPath();
PROJECT& prj = Prj();
SEARCH_STACK& search = Prj().SchSearchS();
wxString path = prj.RPath(PROJECT::SCH_LIB).LastVisitedPath( search );
bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
path, wxDD_DEFAULT_STYLE,
@ -359,14 +399,14 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
{
int ipos = m_listUserPaths->GetCount();
if ( event.GetId() == wxID_INSERT_PATH )
if( event.GetId() == wxID_INSERT_PATH )
{
if ( ipos )
if( ipos )
ipos--;
int jj = m_listUserPaths->GetSelection();
if ( jj >= 0 )
if( jj >= 0 )
ipos = jj;
}
@ -375,7 +415,8 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES )
{ // Make it relative
{
// Make it relative
wxFileName fn = path;
fn.MakeRelativeTo( wxT(".") );
path = fn.GetPathWithSep() + fn.GetFullName();
@ -383,15 +424,15 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
m_listUserPaths->Insert(path, ipos);
m_LibPathChanged = true;
wxGetApp().InsertLibraryPath( path, ipos+1 );
search.AddPaths( path, ipos+1 );
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
for( unsigned ii = 0; ii < search.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii]);
m_DefaultLibraryPathslistBox->Append( search[ii] );
}
}
else
@ -399,30 +440,42 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
DisplayError( this, _("Path already in use") );
}
wxGetApp().SaveLastVisitedLibraryPath( path );
prj.RPath(PROJECT::SCH_LIB).SaveLastVisitedPath( path );
}
void DIALOG_EESCHEMA_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
{
SEARCH_STACK& lib_search = Prj().SchSearchS();
int ii = m_listUserPaths->GetSelection();
if ( ii < 0 )
if( ii < 0 )
ii = m_listUserPaths->GetCount()-1;
if ( ii >= 0 )
if( ii >= 0 )
{
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
lib_search.RemovePaths( m_listUserPaths->GetStringSelection() );
m_listUserPaths->Delete( ii );
m_LibPathChanged = true;
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
for( unsigned ii = 0; ii < lib_search.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
m_DefaultLibraryPathslistBox->Append( lib_search[ii] );
}
}
int InvokeEeschemaConfig( SCH_EDIT_FRAME* aEditFrame, wxFrame* aParent )
{
DIALOG_EESCHEMA_CONFIG dlg( aEditFrame, aParent );
dlg.ShowModal();
return 1;
}

View File

@ -1,42 +0,0 @@
#ifndef _DIALOG_EESCHEMA_CONFIG_H_
#define _DIALOG_EESCHEMA_CONFIG_H_
#include <dialog_eeschema_config_fbp.h>
class SCH_EDIT_FRAME;
class EDA_DRAW_FRAME;
class DIALOG_EESCHEMA_CONFIG : public DIALOG_EESCHEMA_CONFIG_FBP
{
private:
SCH_EDIT_FRAME* m_Parent;
bool m_LibListChanged;
bool m_LibPathChanged;
wxString m_UserLibDirBufferImg; // Copy of original g_UserLibDirBuffer
private:
// event handlers, overiding the fbp handlers
void Init();
void OnCloseWindow( wxCloseEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnAddOrInsertPath( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* parent, EDA_DRAW_FRAME* activeWindow );
~DIALOG_EESCHEMA_CONFIG() {};
};
#endif // _DIALOG_EESCHEMA_CONFIG_H_

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

View File

@ -20,8 +20,10 @@
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -44,7 +46,7 @@
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// C++ code generated with wxFormBuilder (version Nov 5 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -11,6 +11,9 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -28,7 +31,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EESCHEMA_CONFIG_FBP
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
class DIALOG_EESCHEMA_CONFIG_FBP : public DIALOG_SHIM
{
private:

View File

@ -32,7 +32,7 @@
#include <class_drawpanel.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <appl_wxstruct.h>
#include <pgm_base.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <invoke_sch_dialog.h>
@ -562,7 +562,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
if( WriteDiagnosticERC( dlg.GetPath() ) )
{
Close( true );
ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) );
ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) );
}
}
}

View File

@ -94,10 +94,10 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
if( ! IsShown() ) // do nothing at init time
return;
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize());
int pinNameSize = ValueFromString( g_UserUnit, GetNameTextSize() );
int pinNumSize = ValueFromString( g_UserUnit, GetPadNameTextSize());
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength() );
int pinLength = ValueFromString( g_UserUnit, GetLength() );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
int pinType = GetElectricalType();

Some files were not shown because too many files have changed in this diff Show More