Commit 143af269 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Eeschema: code cleanup, remove dead code and some global and useless variables

parent 63257245
Loading
Loading
Loading
Loading
+70 −6
Original line number Original line Diff line number Diff line
@@ -41,9 +41,11 @@
# tools are required.  If MAINTAIN_PNG is defined, then you are a PNG maintainer
# tools are required.  If MAINTAIN_PNG is defined, then you are a PNG maintainer
# and will need the following tools findable in your PATH:
# and will need the following tools findable in your PATH:
#
#
# 1) imagemagick - all its programs must be on your PATH
# 1) inkscape - command line mode is used, must be on your PATH
# 2) inkscape - command line mode is used, must be on your PATH
# 2) pngcrush - this program must be on your PATH
# 3) pngcrush -
# 3) Under Windows only:
#           dos2unix - to convert End Of Lines to unix EOL (CRLF to LF)
#           this program must be on your PATH
#
#


# lower case is used for local variables, uppercase for global variables
# lower case is used for local variables, uppercase for global variables
@@ -69,20 +71,39 @@ option( MAINTAIN_PNGS
        "Set to true if you are a PNG maintainer and have the required tools given in the bitmaps_png/CMakeLists.txt file (default OFF)."
        "Set to true if you are a PNG maintainer and have the required tools given in the bitmaps_png/CMakeLists.txt file (default OFF)."
        OFF)
        OFF)



# Used Only to maintain PNG files (and therefore to recreate .cpp files)
# The png2cpp creates files with native End of Line format.
# To avoid mixed EOF formats in these .cpp files, it is good to
# convert them in Unix EOL format (LF)
# Under Windows, the well known dos2unix.exe does the conversion
# It is installed with MinGW and MSYS.
# It is very easy to install (just an executable to copy in a known path) if it is missing

if( WIN32 )
    set( CONVERT_EOL true )
    set( eol2unix_converter dos2unix )
else()
    set( CONVERT_EOL false )
endif( WIN32 )

include_directories(BEFORE ${INC_BEFORE})
include_directories(BEFORE ${INC_BEFORE})
include_directories(
include_directories(
    ${INC_AFTER}
    ${INC_AFTER}
    )
    )






# Plan for three sizes of bitmaps:
# Plan for three sizes of bitmaps:
# SMALL - for listboxes or comboboxes and perhaps menus
# SMALL - for menus
# MID   - for toolbars  26 x 26
# MID   - for toolbars  26 x 26
# BIG   - for program icons  48 x 48
# BIG   - for program icons  48 x 48
# which are given on three basename lists: BMAPS_SMALL, BMAPS_MID,a nd BMAPS_BIG
# which are given on three basename lists: BMAPS_SMALL, BMAPS_MID,a nd BMAPS_BIG
# respectively.  The basename is without file extension and without path.
# respectively.  The basename is without file extension and without path.
# A corresponding ${basename}.svg file must exist in 'sources' dir below here.
# A corresponding ${basename}.svg file must exist in 'sources' dir below here.



# small icons (16x16) needed in listboxes
# small icons (16x16) needed in listboxes
set( BMAPS_SMALL
set( BMAPS_SMALL
    pinorient_right
    pinorient_right
@@ -113,6 +134,7 @@ set( BMAPS_SMALL
    tree_sel
    tree_sel
    )
    )



# image basenames that go into the toolbar sized destinations, i.e. 26x26
# image basenames that go into the toolbar sized destinations, i.e. 26x26
set( BMAPS_MID
set( BMAPS_MID
    add_arc
    add_arc
@@ -248,6 +270,7 @@ set( BMAPS_MID
    gerber_open_dcode_file
    gerber_open_dcode_file
    gerbview_drill_file
    gerbview_drill_file
    gerbview_clear_layers
    gerbview_clear_layers
    gerber_open_dcode_file
    gerbview_open_recent_drill_files
    gerbview_open_recent_drill_files
    general_deletions
    general_deletions
    general_ratsnest
    general_ratsnest
@@ -541,7 +564,8 @@ function( svg2png inputFile outFile pngWidth pngHeight )


    add_custom_command(
    add_custom_command(
        OUTPUT ${outFile}
        OUTPUT ${outFile}
        COMMAND ${Inkscape_EXECUTABLE} --export-area-snap -f ${inputFile} -e ${outFile} -w ${pngWidth} -h ${pngHeight} > ${TMP_DIR}/${bmn}.inkscape.log
        COMMAND ${Inkscape_EXECUTABLE} --export-area-snap -f ${inputFile} -e ${outFile}
            -w ${pngWidth} -h ${pngHeight} > ${TMP_DIR}/${bmn}.inkscape.log
        DEPENDS ${inputFile}
        DEPENDS ${inputFile}
        COMMENT "Creating ${pngHeight} pixel tall ${outFile}"
        COMMENT "Creating ${pngHeight} pixel tall ${outFile}"
        )
        )
@@ -566,22 +590,41 @@ function( png2png inputFile outFile )
        )
        )
endfunction()
endfunction()



# Function png2cpp
# Function png2cpp
# converts a single *.png to *.cpp
# converts a single *.png to *.cpp
if( CONVERT_EOL )
function( png2cpp inputFile outFile )
function( png2cpp inputFile outFile )
    add_custom_command(
    add_custom_command(
        OUTPUT  ${outFile}
        OUTPUT  ${outFile}


        COMMAND rm -f ${outFile}.tmp
        COMMAND ${CMAKE_COMMAND} -DinputFile=${inputFile} -DoutCppFile=${outFile}
        COMMAND ${CMAKE_COMMAND} -DinputFile=${inputFile} -DoutCppFile=${outFile}
            -P ${CMAKE_MODULE_PATH}/PNG2cpp.cmake
            -P ${CMAKE_MODULE_PATH}/PNG2cpp.cmake


        DEPENDS ${inputFile} ${CMAKE_MODULE_PATH}/PNG2cpp.cmake
        DEPENDS ${inputFile} ${CMAKE_MODULE_PATH}/PNG2cpp.cmake


        POST_BUILD
        COMMAND ${eol2unix_EXECUTABLE} ${outFile}

        COMMENT "Creating (with unix eol) ${outFile}"
    )
endfunction()

else( CONVERT_EOL )
function( png2cpp inputFile outFile )
    add_custom_command(
        OUTPUT  ${outFile}

        COMMAND ${CMAKE_COMMAND} -DinputFile=${inputFile} -DoutCppFile=${outFile}
            -P ${CMAKE_MODULE_PATH}/PNG2cpp.cmake

        DEPENDS ${inputFile} ${CMAKE_MODULE_PATH}/PNG2cpp.cmake
        COMMENT "Creating ${outFile}"
        COMMENT "Creating ${outFile}"
        )
        )
endfunction()
endfunction()


endif(CONVERT_EOL)



# Function bitmap_dir
# Function bitmap_dir
# converts all the basenames in bmapList found in hardcoded 'sources' dir
# converts all the basenames in bmapList found in hardcoded 'sources' dir
@@ -652,6 +695,7 @@ if( MAINTAIN_PNGS )
        endif( NOT pngcrush_EXECUTABLE )
        endif( NOT pngcrush_EXECUTABLE )
    endif( NOT pngcrush_FOUND )
    endif( NOT pngcrush_FOUND )



    # these 3 cmake commands for each desired bitmap size set, repeat as needed:
    # these 3 cmake commands for each desired bitmap size set, repeat as needed:
    bitmap_dir( 16 16 "${BMAPS_SMALL}" )
    bitmap_dir( 16 16 "${BMAPS_SMALL}" )


@@ -659,6 +703,26 @@ if( MAINTAIN_PNGS )


    bitmap_dir( 48 48 "${BMAPS_BIG}" )
    bitmap_dir( 48 48 "${BMAPS_BIG}" )


if(CONVERT_EOL)
    # dos2unix is required to convert EOL format (CRLF) to unix EOL format (LF)
    set( eol2unix_FOUND FALSE )

    if( NOT eol2unix_FOUND )
        find_program( eol2unix_EXECUTABLE ${eol2unix_converter} DOC "The EOL to LF converter program." )

        if( NOT eol2unix_EXECUTABLE )
            message( FATAL_ERROR "Could not find the ${eol2unix_converter} EOL to LF converter program." )
        else( NOT eol2unix_EXECUTABLE )
            set( eol2unix_FOUND TRUE )
            set( eol2unix_EXECUTABLE ${eol2unix_EXECUTABLE}
                 CACHE FILEPATH "Path and file name of the end of line converter program." )
            message( STATUS "The ${eol2unix_converter} EOL to LF converter program found." )
        endif( NOT eol2unix_EXECUTABLE )
    endif( NOT eol2unix_FOUND )
elseif(APPLE)
        #TODO: see if a EOL converted is needed # OSX
endif(CONVERT_EOL)

    #message( "CPP_LIST: ${CPP_LIST}" )
    #message( "CPP_LIST: ${CPP_LIST}" )


    # a target with no output, just so changes get built
    # a target with no output, just so changes get built
+5 −0
Original line number Original line Diff line number Diff line
@@ -177,6 +177,11 @@
// HPGL scale factor (1 PLU = 1/40mm = 25 micrometers)
// HPGL scale factor (1 PLU = 1/40mm = 25 micrometers)
static const double PLUsPERDECIMIL = 0.102041;
static const double PLUsPERDECIMIL = 0.102041;


HPGL_PLOTTER::HPGL_PLOTTER()
{
    SetPenSpeed( 40 );      // Default pen speed = 40 cm/s
    SetPenNumber( 1 );      // Default pen num = 1
}


void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
                                double aScale, bool aMirror )
                                double aScale, bool aMirror )
+6 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,10 @@
 * file extensions and wildcards used in kicad.
 * file extensions and wildcards used in kicad.
 */
 */


const wxString SchematicSymbolFileExtension( wxT( "sym" ) );
const wxString SchematicLibraryFileExtension( wxT( "lib" ) );
const wxString SchematicBackupFileExtension( wxT( "bak" ) );

const wxString VrmlFileExtension( wxT( "wrl" ) );
const wxString VrmlFileExtension( wxT( "wrl" ) );


const wxString ProjectFileExtension( wxT( "pro" ) );
const wxString ProjectFileExtension( wxT( "pro" ) );
@@ -51,6 +55,8 @@ const wxString FootprintPlaceFileExtension( wxT( "pos" ) );
// These strings are wildcards for file selection dialogs.
// These strings are wildcards for file selection dialogs.
// Because thes are static, one should explicitely call wxGetTranslation
// Because thes are static, one should explicitely call wxGetTranslation
// to display them translated.
// to display them translated.
const wxString SchematicSymbolFileWildcard( _( "KiCad drawing symbol file (*.sym)|*.sym" ) );
const wxString SchematicLibraryFileWildcard( _( "KiCad component library file (*.lib)|*.lib" ) );
const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) );
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
+5 −4
Original line number Original line Diff line number Diff line
@@ -83,8 +83,9 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
    }
    }


    wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition();
    wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition();
    SCH_EDIT_FRAME * frame = ( SCH_EDIT_FRAME * ) aPanel->GetParent();


    if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
    if( frame->GetForceHVLines() ) /* Coerce the line to vertical or horizontal one: */
        ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos );
        ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos );
    else
    else
        ( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos );
        ( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos );
@@ -152,7 +153,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )


        // We need 2 segments to go from a given start pin to an end point when the horizontal
        // We need 2 segments to go from a given start pin to an end point when the horizontal
        // and vertical lines only switch is on.
        // and vertical lines only switch is on.
        if( g_HVLines )
        if( GetForceHVLines() )
        {
        {
            nextSegment = new SCH_LINE( *segment );
            nextSegment = new SCH_LINE( *segment );
            nextSegment->SetFlags( IS_NEW );
            nextSegment->SetFlags( IS_NEW );
@@ -170,7 +171,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
        // Be aware prevSegment can be null when the horizontal and vertical lines only switch is off
        // Be aware prevSegment can be null when the horizontal and vertical lines only switch is off
        // when we create the first segment.
        // when we create the first segment.


        if( !g_HVLines )
        if( !GetForceHVLines() )
        {
        {
            // If only one segment is needed and it has a zero length, do not create a new one.
            // If only one segment is needed and it has a zero length, do not create a new one.
            if( segment->IsNull() )
            if( segment->IsNull() )
@@ -356,7 +357,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
        int idx = polyLine->GetCornerCount() - 1;
        int idx = polyLine->GetCornerCount() - 1;
        wxPoint pt = (*polyLine)[idx];
        wxPoint pt = (*polyLine)[idx];


        if( g_HVLines )
        if( GetForceHVLines() )
        {
        {
            /* Coerce the line to vertical or horizontal one: */
            /* Coerce the line to vertical or horizontal one: */
            if( std::abs( endpos.x - pt.x ) < std::abs( endpos.y - pt.y ) )
            if( std::abs( endpos.x - pt.x ) < std::abs( endpos.y - pt.y ) )
+0 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@


#include <boost/foreach.hpp>
#include <boost/foreach.hpp>



// Set this to 1 to print debugging output in alias and component destructors to verify
// Set this to 1 to print debugging output in alias and component destructors to verify
// objects get cleaned up properly.
// objects get cleaned up properly.
#if defined( TRACE_DESTRUCTOR )
#if defined( TRACE_DESTRUCTOR )
Loading