Commit 95aa1919 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

* 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.
parents 898ed744 6bfff89f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
    }
@@ -1053,7 +1053,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() )
+86 −90
Original line number Diff line number Diff line
@@ -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>
@@ -40,23 +41,24 @@
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   keyShowGrid( wxT( "ShowGrid3D" ) );
static const wxString   keyShowGridSize( wxT( "Grid3DSize" ) );
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 keyShowGrid[] =             wxT( "ShowGrid3D" );
static const wxChar keyShowGridSize[] =         wxT( "Grid3DSize" );
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 )
@@ -74,10 +76,12 @@ 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,
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;
@@ -89,7 +93,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
@@ -141,92 +145,84 @@ 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, &prms.m_BgColor.m_Red, 0.0 );
        config->Read( keyBgColor_Green, &prms.m_BgColor.m_Green, 0.0 );
        config->Read( keyBgColor_Blue, &prms.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 );
    aCfg->Read( keyShowRealisticMode, &tmp, false );
    prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );

        config->Read( keyShowAxis, &tmp, true );
    aCfg->Read( keyShowAxis, &tmp, true );
    prms.SetFlag( FL_AXIS, tmp );

        config->Read( keyShowGrid, &tmp, true );
    aCfg->Read( keyShowGrid, &tmp, true );
    prms.SetFlag( FL_GRID, tmp );

        config->Read( keyShowGridSize, &prms.m_3D_Grid, 10.0 );
    aCfg->Read( keyShowGridSize, &prms.m_3D_Grid, 10.0 );
    prms.SetFlag( FL_MODULE, tmp );

        config->Read( keyShowFootprints, &tmp, true );
    aCfg->Read( keyShowFootprints, &tmp, true );
    prms.SetFlag( FL_MODULE, tmp );

        config->Read( keyShowCopperThickness, &tmp, false );
    aCfg->Read( keyShowCopperThickness, &tmp, false );
    prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );

        config->Read( keyShowZones, &tmp, true );
    aCfg->Read( keyShowZones, &tmp, true );
    prms.SetFlag( FL_ZONE, tmp );

        config->Read( keyShowAdhesiveLayers, &tmp, true );
    aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
    prms.SetFlag( FL_ADHESIVE, tmp );

        config->Read( keyShowSilkScreenLayers, &tmp, true );
    aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
    prms.SetFlag( FL_SILKSCREEN, tmp );

        config->Read( keyShowSolderMaskLayers, &tmp, true );
    aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
    prms.SetFlag( FL_SOLDERMASK, tmp );

        config->Read( keyShowSolderPasteLayers, &tmp, true );
    aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
    prms.SetFlag( FL_SOLDERPASTE, tmp );

        config->Read( keyShowCommentsLayer, &tmp, true );
    aCfg->Read( keyShowCommentsLayer, &tmp, true );
    prms.SetFlag( FL_COMMENTS, tmp );

        config->Read( keyShowEcoLayers, &tmp, true );
    aCfg->Read( keyShowEcoLayers, &tmp, true );
    prms.SetFlag( FL_ECO, tmp );

        config->Read( keyShowBoardBody, &tmp, true );
    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

    if( !config )
        return;

    EDA_BASE_FRAME::SaveSettings();

    class INFO3D_VISU& prms = g_Parm_3D_Visu;
    config->Write( keyBgColor_Red, prms.m_BgColor.m_Red );
    config->Write( keyBgColor_Green, prms.m_BgColor.m_Green );
    config->Write( keyBgColor_Blue, prms.m_BgColor.m_Blue );
    config->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE )  );
    config->Write( keyShowAxis, prms.GetFlag( FL_AXIS )  );
    config->Write( keyShowGrid, prms.GetFlag( FL_GRID )  );
    config->Write( keyShowGridSize, prms.m_3D_Grid  );
    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 )  );
    EDA_BASE_FRAME::SaveSettings( aCfg );

    INFO3D_VISU& prms = g_Parm_3D_Visu;

    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( keyShowGrid, prms.GetFlag( FL_GRID )  );
    aCfg->Write( keyShowGridSize, prms.m_3D_Grid  );
    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 )  );
}


+1 −1
Original line number Diff line number Diff line
@@ -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>
+13 −7
Original line number Diff line number Diff line
@@ -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)
@@ -53,24 +53,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 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();
@@ -125,8 +130,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 );
+33 −22
Original line number Diff line number Diff line
@@ -23,8 +23,9 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
# reports.
#

option( USE_KIWAY_DLLS
    "Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." OFF )
#option( USE_KIWAY_DLLS "Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." ON )
set( USE_KIWAY_DLLS true )  # this is now mandatory, the code is the same anyways, the old code is gone.


# 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,
@@ -115,6 +116,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}" )
@@ -189,12 +196,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 (apple ld doesn't support it)
        if( NOT APPLE )
            set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
@@ -221,11 +222,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()

@@ -349,6 +350,12 @@ add_definitions(-DWX_COMPATIBILITY)
find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" )

# Dick 5-Feb-2014:
# Marco: We 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

# Handle target used to specify if a target needs wx-widgets or other libraries
# Always defined, empty if no libraries are to be build
add_custom_target( lib-dependencies )
@@ -440,14 +447,18 @@ endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
#####################
# Find GLEW library #
#####################
if( NOT GLEW_FOUND )
    find_package( GLEW )
    check_find_package_result( GLEW_FOUND "GLEW" )
endif()

######################
# Find Cairo library #
######################
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
#################################################
@@ -484,7 +495,7 @@ 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) )
endif()

# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )
Loading