diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index c45934f310..20228ca1ce 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -77,7 +77,7 @@ const wxString S3D_MASTER::GetShape3DFullFilename() return shapeName; wxString default_path; - wxGetEnv( wxT( KISYS3DMOD ), &default_path ); + wxGetEnv( KISYS3DMOD, &default_path ); if( default_path.IsEmpty() ) return shapeName; diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 5536b0b1c5..bf19745a01 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -40,13 +40,18 @@ #include <3d_struct.h> #include -#define KISYS3DMOD "KISYS3DMOD" +/// A variable name whose value holds the path of 3D shape files. +/// Currently an environment variable, eventually a project variable. +#define KISYS3DMOD wxT( "KISYS3DMOD" ) + +/// All 3D files are expected to be stored in LIB3D_FOLDER, or one of +/// its subdirectory. +#define LIB3D_FOLDER wxT( "packages3d" ) class EDA_3D_CANVAS; class PCB_BASE_FRAME; #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS) -#define LIB3D_PATH wxT( "packages3d" ) class EDA_3D_FRAME : public KIWAY_PLAYER diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 2da8c416f1..26a0c629c0 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -23,49 +23,128 @@ */ /* - * This file contains the global constants and variables used in the PCB - * applications Pcbnew, CvPcb, and GervView. The goal of this was to - * unobfuscate the original header file design that made it very difficult - * to figure out where these variables lived. Ideally, they should be pushed - * back into the application layer. + * This file contains some functions used in the PCB + * applications Pcbnew and CvPcb. */ #include +#include +#include + #include -#include - #include -#include -#include -#include - - -class MODULE; - - -DISPLAY_OPTIONS DisplayOpt; // Display options for board items - -int g_AnchorColor = BLUE; -int g_ModuleTextCMPColor = LIGHTGRAY; -int g_ModuleTextCUColor = MAGENTA; -int g_ModuleTextNOVColor = DARKGRAY; -int g_PadCUColor = GREEN; -int g_PadCMPColor = RED; - +#include <3d_viewer.h> /** - * Used in track creation, a list of track segments currently being created, - * with the newest track at the end of the list, sorted by new-ness. e.g. use - * TRACK->Back() to get the next older track, TRACK->Next() to get the next - * newer track. + * attempts to set the environment variable given by aKiSys3Dmod to a valid path. + * (typically "KISYS3DMOD" ) + * If the environment variable is already set, then it left as is to respect + * the wishes of the user. + * + * The path is determined by attempting to find the path modules/packages3d + * files in kicad tree. + * This may or may not be the best path but it provides the best solution for + * backwards compatibility with the previous 3D shapes search path implementation. + * + * @note This must be called after #SetBinDir() is called at least on Windows. + * Otherwise, the kicad path is not known (Windows specific) + * + * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" + * @param aProcess = the current process + * @return false if the aKiSys3Dmod path is not valid. */ -DLIST g_CurrentTrackList; - -void AccumulateDescription( wxString &aDesc, const wxString &aItem ) +bool Set3DShapesDefaultPath( const wxString& aKiSys3Dmod, const PGM_BASE* aProcess ) { - if( !aDesc.IsEmpty() ) - aDesc << wxT(", "); - aDesc << aItem; + wxString path; + + // Set the KISYS3DMOD environment variable for the current process, + // if it is not already defined in the user's environment and valid. + if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) ) + return true; + +#if 1 + // Try to find a valid path is standard KiCad paths + SEARCH_STACK& search = Kiface().KifaceSearch(); + path = search.FindValidPath( LIB3D_FOLDER ); + + if( !path.IsEmpty() ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } +#endif + + // Attempt to determine where the 3D shape libraries were installed using the + // legacy path: + // on Unix: /usr/local/kicad/share/modules/packages3d + // or /usr/share/kicad/modules/packages3d + // On Windows: bin../share/modules/packages3d + wxString relpath( wxT( "modules/" ) ); + relpath += LIB3D_FOLDER; + +// Apple MacOSx +#ifdef __WXMAC__ + path = wxT("/Library/Application Support/kicad/modules/packages3d/"); + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } + + path = wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT("/Library/Application Support/kicad/modules/packages3d/"); + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } + +#elif defined(__UNIX__) // Linux and non-Apple Unix + // Try the home directory: + path.Empty(); + wxGetEnv( wxT("HOME"), &path ); + path += wxT("/kicad/share/") + relpath; + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } + + // Try the standard install path: + path = wxT("/usr/local/kicad/share/") + relpath; + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } + + // Try the official distrib standard install path: + path = wxT("/usr/share/kicad/") + relpath; + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } + +#else // Windows + // On Windows, the install path is given by the path of executables + wxFileName fn; + fn.AssignDir( aProcess->GetExecutablePath() ); + fn.RemoveLastDir(); + path = fn.GetPathWithSep() + wxT("share/") + relpath; + + if( wxFileName::DirExists( path ) ) + { + wxSetEnv( aKiSys3Dmod, path ); + return true; + } +#endif + + return false; } diff --git a/common/project.cpp b/common/project.cpp index 0047d085ee..06d93ccdd2 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include // NAMELESS_PROJECT diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 541c464737..777fec8598 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -53,6 +53,8 @@ #include <3d_viewer.h> +DISPLAY_OPTIONS DisplayOpt; // General display options + BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME ) EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow ) diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 18dbed29d5..8cca374f1e 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -1,8 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2007 Jean-Pierre Charras, jp..charras at wanadoo.fr + * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck + * 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 @@ -29,12 +30,12 @@ #include #include #include -#include #include #include #include #include -#include +#include <3d_viewer.h> +#include #include #include @@ -50,13 +51,11 @@ COLORS_DESIGN_SETTINGS g_ColorsSettings; // Constant string definitions for CvPcb -const wxString RetroFileExtension( wxT( "stf" ) ); const wxString FootprintAliasFileExtension( wxT( "equ" ) ); // Wildcard for schematic retroannotation (import footprint names in schematic): const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) ); - #if 0 // add this logic to OpenProjectFiles() /* @@ -165,106 +164,6 @@ PGM_BASE& Pgm() } -/** - * Function set3DShapesPath - * attempts to set the environment variable given by aKiSys3Dmod to a valid path. - * (typically "KISYS3DMOD" ) - * If the environment variable is already set, - * then it left as is to respect the wishes of the user. - * - * The path is determined by attempting to find the path modules/packages3d - * files in kicad tree. - * This may or may not be the best path but it provides the best solution for - * backwards compatibility with the previous 3D shapes search path implementation. - * - * @note This must be called after #SetBinDir() is called at least on Windows. - * Otherwise, the kicad path is not known (Windows specific) - * - * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" - * @return false if the aKiSys3Dmod path is not valid. - */ -static bool set3DShapesPath( const wxString& aKiSys3Dmod ) -{ - wxString path; - - // Set the KISYS3DMOD environment variable for the current process, - // if it is not already defined in the user's environment and valid. - if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) ) - return true; - - // Attempt to determine where the 3D shape libraries were installed using the - // legacy path: - // on Unix: /usr/local/kicad/share/modules/packages3d - // or /usr/share/kicad/modules/packages3d - // On Windows: bin../share/modules/packages3d - wxString relpath( wxT( "modules/packages3d" ) ); - -// Apple MacOSx -#ifdef __WXMAC__ - path = wxT("/Library/Application Support/kicad/modules/packages3d/"); - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - path = wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT("/Library/Application Support/kicad/modules/packages3d/"); - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - -#elif defined(__UNIX__) // Linux and non-Apple Unix - // Try the home directory: - path.Empty(); - wxGetEnv( wxT("HOME"), &path ); - path += wxT("/kicad/share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - // Try the standard install path: - path = wxT("/usr/local/kicad/share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - // Try the official distrib standard install path: - path = wxT("/usr/share/kicad/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - -#else // Windows - // On Windows, the install path is given by the path of executables - wxFileName fn; - fn.AssignDir( Pgm().GetExecutablePath() ); - fn.RemoveLastDir(); - path = fn.GetPathWithSep() + wxT("share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } -#endif - - return false; -} - - //!!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it. FP_LIB_TABLE GFootprintTable; @@ -282,8 +181,10 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) start_common( aCtlBits ); - // Set 3D shape path from environment variable KISYS3DMOD - set3DShapesPath( wxT("KISYS3DMOD") ); + // Set 3D shape path (environment variable KISYS3DMOD (if not defined or valid) + // Currently, called here, but could be moved ( OpenProjectFiles() ? ) + // if KISYS3DMOD is defined in a project config file + Set3DShapesDefaultPath( KISYS3DMOD, aProgram ); /* Now that there are no *.mod files in the standard library, this function has no utility. User should simply set the variable manually. diff --git a/cvpcb/cvpcb.h b/cvpcb/cvpcb.h index f5f76f433b..d463fde8d2 100644 --- a/cvpcb/cvpcb.h +++ b/cvpcb/cvpcb.h @@ -17,8 +17,6 @@ wxLC_SINGLE_SEL | wxVSCROLL | wxHSCROLL ) extern const wxString FootprintAliasFileExtension; -extern const wxString RetroFileExtension; - extern const wxString FootprintAliasFileWildcard; diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 2e18cc6bff..daafdfc788 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ + /** * @file pcbcommon.h */ @@ -5,31 +28,35 @@ #ifndef PCBCOMMON_H_ #define PCBCOMMON_H_ +class PGM_BASE; -#include -#include +/** + * attempts to set (when not set or valid) the environment variable given by aKiSys3Dmod + * (typically "KISYS3DMOD" ) to a valid path. + * If the environment variable is already set, then it left as is to respect + * the wishes of the user. + * + * The path is determined by attempting to find the path modules/packages3d + * files in kicad tree. + * This may or may not be the best path but it provides the best solution for + * backwards compatibility with the previous 3D shapes search path implementation. + * + * @note This must be called after #SetBinDir() is called at least on Windows. + * Otherwise, the kicad path is not known (Windows specific) + * + * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" + * @param aProcess = the current process + * @return false if the aKiSys3Dmod path is not valid. + */ +bool Set3DShapesDefaultPath( const wxString& aKiSys3Dmod, const PGM_BASE* aProcess ); -#define MIN_DRAW_WIDTH 1 ///< Minimum trace drawing width. - - -class D_PAD; -class TRACK; -class BOARD; -class DISPLAY_OPTIONS; - -extern DISPLAY_OPTIONS DisplayOpt; - -extern int g_CurrentVersionPCB; - -/// List of segments of the trace currently being drawn. -extern DLIST g_CurrentTrackList; - -#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment - -#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created - /// Utility for comma separated lists -void AccumulateDescription( wxString &aDesc, const wxString &aItem ); +inline void AccumulateDescription( wxString &aDesc, const wxString &aItem ) +{ + if( !aDesc.IsEmpty() ) + aDesc << wxT(", "); + aDesc << aItem; +} #endif // PCBCOMMON_H_ diff --git a/pcbnew/autorouter/auto_place_footprints.cpp b/pcbnew/autorouter/auto_place_footprints.cpp index f14a2385f9..0b76c64d7e 100644 --- a/pcbnew/autorouter/auto_place_footprints.cpp +++ b/pcbnew/autorouter/auto_place_footprints.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/autorouter/graphpcb.cpp b/pcbnew/autorouter/graphpcb.cpp index 15e9d2f94a..0aacee6f99 100644 --- a/pcbnew/autorouter/graphpcb.cpp +++ b/pcbnew/autorouter/graphpcb.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/autorouter/routing_matrix.cpp b/pcbnew/autorouter/routing_matrix.cpp index 7875afb13c..0a85e585d6 100644 --- a/pcbnew/autorouter/routing_matrix.cpp +++ b/pcbnew/autorouter/routing_matrix.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include diff --git a/pcbnew/autorouter/solve.cpp b/pcbnew/autorouter/solve.cpp index a88395e189..dbc9c68937 100644 --- a/pcbnew/autorouter/solve.cpp +++ b/pcbnew/autorouter/solve.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 8369cb0a65..d8dc94391c 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -31,9 +31,7 @@ #include #include #include -#include #include -//#include #include #include #include diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 33254ac942..7523968c8d 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index d8b75825ca..5508bd05ec 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 07a984b3d6..6fd4e2ef9d 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 96cb0ff53f..b680e9b3d3 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 5791563007..25359962cf 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index ba59dda554..e54946c335 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index d7abf9ec1e..cee079c8d6 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index ead126d9ce..67a4627caf 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include // ID_TRACK_BUTT #include #include diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index f03b0d87ce..25b6a95a9e 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -40,7 +40,6 @@ #include // enum PCB_VISIBLE #include #include -#include #include #include diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index ff61a8f9f2..4e1b647e89 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 48b43b161b..e3caf65bf9 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 8c5c8a5850..b7c4a76c07 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index fbb1b79da0..b07936d61e 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index fc2a679346..cd4bb0d905 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 911a473dda..d84b7c05ad 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index ed514b3f7c..49c596c2dc 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index 18800c09e0..a5f8548b3e 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index aa15953537..b91d3d1109 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -242,7 +242,7 @@ void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() { wxString default_path; - wxGetEnv( wxT( KISYS3DMOD ), &default_path ); + wxGetEnv( KISYS3DMOD, &default_path ); #ifdef __WINDOWS__ default_path.Replace( wxT( "/" ), wxT( "\\" ) ); #endif @@ -393,11 +393,6 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected( wxCommandEvent& event ) } -void DIALOG_MODULE_BOARD_EDITOR::Add3DShape( wxCommandEvent& event ) -{ - Browse3DLib( event ); -} - void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event ) { @@ -423,92 +418,72 @@ void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape( wxCommandEvent& event ) } -void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) +void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile() { PROJECT& prj = Prj(); - SEARCH_STACK& search = Kiface().KifaceSearch(); - wxString fullpath; - wxString kisys3dmod = wxGetenv( wxT( KISYS3DMOD ) ); + // here, the KISYS3DMOD default path for 3D shape files is expected + // to be already defined (when starting Pcbnew, it is defined + // from the user defined env variable, or set to a default value) + wxFileName fn( wxGetenv( KISYS3DMOD ), wxEmptyString ); + wxString default3DPath = fn.GetPathWithSep(); - if( !kisys3dmod || !wxFileName::IsDirReadable( kisys3dmod ) ) - { - fullpath = search.FindValidPath( LIB3D_PATH ); - } + wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); - if( !fullpath ) - { - fullpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); - if( !fullpath ) - fullpath = search.LastVisitedPath( LIB3D_PATH ); - } - -#ifdef __WINDOWS__ - fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); -#endif - - wxString fullfilename; - wxString shortfilename; + if( !initialpath ) + initialpath = default3DPath; wxString fileFilters = wxGetTranslation( Shapes3DFileWildcard ); fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); - fullfilename = EDA_FileSelector( _( "3D Shape:" ), - fullpath, - wxEmptyString, - wxEmptyString, - wxGetTranslation( fileFilters ), - this, - wxFD_OPEN, - true - ); + wxString filename = EDA_FileSelector( _( "3D Shape:" ), initialpath, + wxEmptyString, wxEmptyString, + fileFilters, this, wxFD_OPEN, true ); - if( fullfilename.IsEmpty() ) + if( filename.IsEmpty() ) return; - wxFileName fn = fullfilename; + fn = filename; prj.SetRString( PROJECT::VIEWER_3D_PATH, fn.GetPath() ); - /* If the file 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 + /* If the file path is already in the 3D shape file default path + * just add the file name relative to this path to the list. + * Otherwise, add the file name with a full or relative path. + * The relative path, when possible, is preferable + * because it preserve use of default path, when the path is a sub path of this path */ - shortfilename = search.FilenameWithRelativePathInSearchList( - fullfilename, wxPathOnly( Prj().GetProjectFullName() ) ); + wxString rootpath = filename.SubString( 0, default3DPath.Length()-1 ); + bool useRelPath = rootpath.IsSameAs( default3DPath, wxFileName::IsCaseSensitive() ); - wxFileName aux = shortfilename; - if( aux.IsAbsolute() ) + if( useRelPath ) + fn.MakeRelativeTo( default3DPath ); + else // Absolute path given, not a subpath of the default path, + // therefore ask if the user wants a relative (to the default path) one { - // Absolute path, ask if the user wants a relative one - int diag = wxMessageBox( - _( "Use a relative path?" ), - _( "Path type" ), - wxYES_NO | wxICON_QUESTION, this ); + wxString msg; + msg.Printf( _( "Use a path relative to '%s'?" ), GetChars( default3DPath ) ); + int diag = wxMessageBox( msg, _( "Path type" ), + wxYES_NO | wxICON_QUESTION, this ); - if( diag == wxYES ) - { - // Make it relative - aux.MakeRelativeTo( wxT(".") ); - shortfilename = aux.GetPathWithSep() + aux.GetFullName(); - } + if( diag == wxYES ) // Make it relative to the default 3D path + fn.MakeRelativeTo( default3DPath ); } + filename = fn.GetFullPath(); + S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); #ifdef __WINDOWS__ - // Store filename in Unix notation - shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); + // In Kicad files, filenames and paths are stored using Unix notation + filename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif - new3DShape->SetShape3DName( shortfilename ); + new3DShape->SetShape3DName( filename ); m_Shapes3D_list.push_back( new3DShape ); - m_3D_ShapeNameListBox->Append( shortfilename ); + m_3D_ShapeNameListBox->Append( filename ); if( m_LastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h index 4792584a74..2fc02dfb4f 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.h @@ -31,16 +31,21 @@ public: ~DIALOG_MODULE_BOARD_EDITOR(); private: + void BrowseAndAdd3DShapeFile(); void InitBoardProperties(); void InitModeditProperties(); void Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource ); void TransfertDisplayTo3DValues( int aIndexSelection ); + + // virtual event functions void OnEditValue( wxCommandEvent& event ); void OnEditReference( wxCommandEvent& event ); void On3DShapeSelection( wxCommandEvent& event ); void On3DShapeNameSelected( wxCommandEvent& event ); - void Browse3DLib( wxCommandEvent& event ); - void Add3DShape( wxCommandEvent& event ); + void Add3DShape( wxCommandEvent& event ) + { + BrowseAndAdd3DShapeFile(); + } void Remove3DShape( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 3debc1be0f..0703853f47 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -93,7 +93,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() // Display the default path, given by environment variable KISYS3DMOD wxString default_path; - wxGetEnv( wxT( KISYS3DMOD ), &default_path ); + wxGetEnv( KISYS3DMOD, &default_path ); #ifdef __WINDOWS__ default_path.Replace( wxT( "/" ), wxT( "\\" ) ); #endif @@ -288,88 +288,77 @@ void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event) } -void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) +void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile() { PROJECT& prj = Prj(); - SEARCH_STACK& search = Kiface().KifaceSearch(); - wxString fullpath; - wxString kisys3dmod = wxGetenv( wxT( KISYS3DMOD ) ); + // here, the KISYS3DMOD default path for 3D shape files is expected + // to be already defined (when starting Pcbnew, it is defined + // from the user defined env variable, or set to a default value) + wxFileName fn( wxGetenv( KISYS3DMOD ), wxEmptyString ); + wxString default3DPath = fn.GetPathWithSep(); - if( !kisys3dmod || !wxFileName::IsDirReadable( kisys3dmod ) ) - { - fullpath = search.FindValidPath( LIB3D_PATH ); - } + wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); - if( !fullpath ) - { - fullpath = prj.GetRString( PROJECT::VIEWER_3D_PATH ); - if( !fullpath ) - fullpath = search.LastVisitedPath( LIB3D_PATH ); - } + if( !initialpath ) + initialpath = default3DPath; #ifdef __WINDOWS__ - fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); + initialpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif - wxString fullfilename, shortfilename; wxString fileFilters = wxGetTranslation( Shapes3DFileWildcard ); fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); - fullfilename = EDA_FileSelector( _( "3D Shape:" ), - fullpath, - wxEmptyString, - wxEmptyString, - wxGetTranslation( fileFilters ), - this, - wxFD_OPEN, - true - ); + wxString filename = EDA_FileSelector( _( "3D Shape:" ), initialpath, + wxEmptyString, wxEmptyString, + wxGetTranslation( fileFilters ), + this, wxFD_OPEN, true ); - if( fullfilename.IsEmpty() ) + if( filename.IsEmpty() ) return; - wxFileName fn = fullfilename; + fn = filename; prj.SetRString( PROJECT::VIEWER_3D_PATH, fn.GetPath() ); - /* If the file 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 + /* If the file path is already in the 3D shape file default path + * just add the file name relative to this path to the list. + * Otherwise, add the file name with a full or relative path. + * The relative path, when possible, is preferable + * because it preserve use of default path, when the path is a sub path of this path */ - shortfilename = search.FilenameWithRelativePathInSearchList( - fullfilename, wxPathOnly( Prj().GetProjectFullName() ) ); + wxString rootpath = filename.SubString( 0, default3DPath.Length()-1 ); + bool useRelPath = rootpath.IsSameAs( default3DPath, wxFileName::IsCaseSensitive() ); - wxFileName aux = shortfilename; + if( useRelPath ) + fn.MakeRelativeTo( default3DPath ); + else // Absolute path given, not a subpath of the default path, + // therefore ask if the user wants a relative (to the default path) one + { + wxString msg; + msg.Printf( _( "Use a path relative to '%s'?" ), GetChars( default3DPath ) ); + int diag = wxMessageBox( msg, _( "Path type" ), + wxYES_NO | wxICON_QUESTION, this ); - if( aux.IsAbsolute() ) - { // Absolute path, ask if the user wants a relative one - int diag = wxMessageBox( - _( "Use a relative path?" ), - _( "Path type" ), - wxYES_NO | wxICON_QUESTION, this ); - - if( diag == wxYES ) - { // Make it relative - aux.MakeRelativeTo( wxT( "." ) ); - shortfilename = aux.GetPathWithSep() + aux.GetFullName(); - } + if( diag == wxYES ) // Make it relative to the default 3D path + fn.MakeRelativeTo( default3DPath ); } + filename = fn.GetFullPath(); + S3D_MASTER* new3DShape = new S3D_MASTER(NULL); #ifdef __WINDOWS__ // Store filename in Unix notation - shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); + filename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif - new3DShape->SetShape3DName( shortfilename ); + new3DShape->SetShape3DName( filename ); m_shapes3D_list.push_back( new3DShape ); - m_3D_ShapeNameListBox->Append( shortfilename ); + m_3D_ShapeNameListBox->Append( filename ); if( m_lastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.h b/pcbnew/dialogs/dialog_edit_module_for_Modedit.h index 69d77862dd..83f91b12a6 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.h +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.h @@ -34,14 +34,20 @@ public: ~DIALOG_MODULE_MODULE_EDITOR(); private: + void BrowseAndAdd3DShapeFile(); void initModeditProperties(); void Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource ); void TransfertDisplayTo3DValues( int aIndexSelection ); + + // virtual event functions void OnEditValue( wxCommandEvent& event ); void OnEditReference( wxCommandEvent& event ); void On3DShapeSelection( wxCommandEvent& event ); void On3DShapeNameSelected( wxCommandEvent& event ); - void BrowseAndAdd3DLib( wxCommandEvent& event ); + void Add3DShape( wxCommandEvent& event ) + { + BrowseAndAdd3DShapeFile(); + } void Remove3DShape( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.cpp index 093a513828..4431dc3b64 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.cpp @@ -327,7 +327,7 @@ DIALOG_MODULE_MODULE_EDITOR_BASE::DIALOG_MODULE_MODULE_EDITOR_BASE( wxWindow* pa m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditReference ), NULL, this ); m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditValue ), NULL, this ); m_3D_ShapeNameListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::On3DShapeNameSelected ), NULL, this ); - m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::BrowseAndAdd3DLib ), NULL, this ); + m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Add3DShape ), NULL, this ); m_buttonRemove->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Remove3DShape ), NULL, this ); m_sdbSizerStdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnCancelClick ), NULL, this ); m_sdbSizerStdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnOkClick ), NULL, this ); @@ -339,7 +339,7 @@ DIALOG_MODULE_MODULE_EDITOR_BASE::~DIALOG_MODULE_MODULE_EDITOR_BASE() m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditReference ), NULL, this ); m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditValue ), NULL, this ); m_3D_ShapeNameListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::On3DShapeNameSelected ), NULL, this ); - m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::BrowseAndAdd3DLib ), NULL, this ); + m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Add3DShape ), NULL, this ); m_buttonRemove->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Remove3DShape ), NULL, this ); m_sdbSizerStdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnCancelClick ), NULL, this ); m_sdbSizerStdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnOkClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.fbp b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.fbp index f78792055f..098cd0381c 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.fbp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.fbp @@ -4173,7 +4173,7 @@ - BrowseAndAdd3DLib + Add3DShape diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.h b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.h index 839854b525..17e741b5d0 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.h +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit_base.h @@ -109,7 +109,7 @@ class DIALOG_MODULE_MODULE_EDITOR_BASE : public DIALOG_SHIM virtual void OnEditReference( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditValue( wxCommandEvent& event ) { event.Skip(); } virtual void On3DShapeNameSelected( wxCommandEvent& event ) { event.Skip(); } - virtual void BrowseAndAdd3DLib( wxCommandEvent& event ) { event.Skip(); } + virtual void Add3DShape( wxCommandEvent& event ) { event.Skip(); } virtual void Remove3DShape( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index e1e31d67e0..e6265bd9fb 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 6d5bf405da..20e418ef72 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -36,6 +36,7 @@ #include #include +#include <3d_viewer.h> // for KISYS3DMOD #include #include #include @@ -713,6 +714,9 @@ private: // the current project. unique.insert( PROJECT_VAR_NAME ); unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() ); + // This special environment variable is used to locad 3d shapes + unique.insert( KISYS3DMOD ); + unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() ); m_path_subs_grid->AppendRows( unique.size() ); diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 696859b820..d9346fef61 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index b4998f2a4d..c8cd64fd5e 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index e888eeb38d..ea17ac0f5a 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_scripting.cpp b/pcbnew/dialogs/dialog_scripting.cpp index 7b20997a58..2370350f15 100644 --- a/pcbnew/dialogs/dialog_scripting.cpp +++ b/pcbnew/dialogs/dialog_scripting.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 787a73827e..2fc9a19727 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index ee6af0fd1a..52b3f3c846 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 7312a741d2..9954671ff5 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index ade0736df6..03f3fe3fcb 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 7b53172267..a1eaefe4b7 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include <3d_viewer.h> #include #include diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index ab4023846a..ccfc7cf37c 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -8,7 +8,6 @@ #include #include #include <3d_viewer.h> -#include #include #include diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 0e0c92cc3c..82ca685bca 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -33,7 +33,6 @@ #include #include #include <3d_viewer.h> -#include #include #include diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 7e0b895135..e555c5688c 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 15b42f134d..fbf138753f 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index e28b6c84bd..5a02231bbf 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index e9a8e8c2c7..a5da9dc222 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -36,13 +36,11 @@ #include #include #include -//#include #include #include #include #include #include -#include #include #include diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 3400c2b0d8..cce650c686 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 00dbc83123..c7d5377fd3 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 8e9c83b67a..111b79bc76 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -40,7 +40,6 @@ #include #include #include <3d_viewer.h> -#include #include #include diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index d6a357e1bc..60139f5761 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index c9d3d00f5b..94d4eea73f 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -35,7 +35,6 @@ #include #include #include <3d_viewer.h> -#include #include #include #include diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index eae74d2662..e52ad9f5d1 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 6a36f6ade2..6c93577c0f 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 3ac2545545..7a80887203 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 3f729c0444..e08f32bd62 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c2e20cfb0f..8b9dae04f7 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -35,7 +35,6 @@ #include #include #include -#include // enum PCB_VISIBLE #include #include #include diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 384a3ca405..db578ec9ce 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -42,8 +42,6 @@ #include #include #include -#include -#include <3d_viewer.h> #include #include @@ -52,7 +50,6 @@ #include #include -#include #include #include #include @@ -81,7 +78,9 @@ int g_MaxLinksShowed; int g_MagneticPadOption = capture_cursor_in_track_tool; int g_MagneticTrackOption = capture_cursor_in_track_tool; -wxPoint g_Offset_Module; /* Distance to offset module trace when moving. */ +wxPoint g_Offset_Module; // module offset used when moving a footprint + +DISPLAY_OPTIONS DisplayOpt; // General display options /* Name of the document footprint list * usually located in share/modules/footprints_doc @@ -90,6 +89,13 @@ wxPoint g_Offset_Module; /* Distance to offset module trace when moving. */ wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" ); +/* + * Used in track creation, a list of track segments currently being created, + * with the newest track at the end of the list, sorted by new-ness. e.g. use + * TRACK->Back() to get the next older track, TRACK->Next() to get the next + * newer track. + */ +DLIST g_CurrentTrackList; namespace PCB { @@ -205,105 +211,6 @@ PGM_BASE& Pgm() } #endif -/** - * Function set3DShapesPath - * attempts to set the environment variable given by aKiSys3Dmod to a valid path. - * (typically "KISYS3DMOD" ) - * If the environment variable is already set, - * then it left as is to respect the wishes of the user. - * - * The path is determined by attempting to find the path modules/packages3d - * files in kicad tree. - * This may or may not be the best path but it provides the best solution for - * backwards compatibility with the previous 3D shapes search path implementation. - * - * @note This must be called after #SetBinDir() is called at least on Windows. - * Otherwise, the kicad path is not known (Windows specific) - * - * @param aKiSys3Dmod = the value of environment variable, typically "KISYS3DMOD" - * @return false if the aKiSys3Dmod path is not valid. - */ -static bool set3DShapesPath( const wxString& aKiSys3Dmod ) -{ - wxString path; - - // Set the KISYS3DMOD environment variable for the current process, - // if it is not already defined in the user's environment and valid. - if( wxGetEnv( aKiSys3Dmod, &path ) && wxFileName::DirExists( path ) ) - return true; - - // Attempt to determine where the 3D shape libraries were installed using the - // legacy path: - // on Unix: /usr/local/kicad/share/modules/packages3d - // or /usr/share/kicad/modules/packages3d - // On Windows: bin../share/modules/packages3d - wxString relpath( wxT( "modules/packages3d" ) ); - -// Apple MacOSx -#ifdef __WXMAC__ - path = wxT("/Library/Application Support/kicad/modules/packages3d/"); - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - path = wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT("/Library/Application Support/kicad/modules/packages3d/"); - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - -#elif defined(__UNIX__) // Linux and non-Apple Unix - // Try the home directory: - path.Empty(); - wxGetEnv( wxT("HOME"), &path ); - path += wxT("/kicad/share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - // Try the standard install path: - path = wxT("/usr/local/kicad/share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - - // Try the official distrib standard install path: - path = wxT("/usr/share/kicad/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } - -#else // Windows - // On Windows, the install path is given by the path of executables - wxFileName fn; - fn.AssignDir( Pgm().GetExecutablePath() ); - fn.RemoveLastDir(); - path = fn.GetPathWithSep() + wxT("share/") + relpath; - - if( wxFileName::DirExists( path ) ) - { - wxSetEnv( aKiSys3Dmod, path ); - return true; - } -#endif - - return false; -} - #if defined(KICAD_SCRIPTING) static bool scriptingSetup() @@ -412,8 +319,10 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) // display the real hotkeys in menus or tool tips ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr ); - // Set 3D shape path from environment variable KISYS3DMOD - set3DShapesPath( wxT(KISYS3DMOD) ); + // Set 3D shape path (environment variable KISYS3DMOD) if not defined or valid + // Currently, called here, but could be moved ( OpenProjectFiles() ? ) + // if KISYS3DMOD is defined in a project config file + Set3DShapesDefaultPath( KISYS3DMOD, aProgram ); try { diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 59bdcbe799..edc9dee1ae 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -8,6 +8,7 @@ #include // wxWidgets include. #include // IS_DRAGGED and IN_EDIT definitions. +#include #include // to define DMils2iu() conversion function #include @@ -37,6 +38,7 @@ enum ENDPOINT_T { #define TEXTS_MIN_SIZE DMils2iu( 50 ) ///< Minimum text size in Pcbnew units value (50 * 0.0001 mils) #define TEXTS_MAX_SIZE DMils2iu( 10000 ) ///< Maximum text size in Pcbnew units value (1 inch) ) #define TEXTS_MAX_WIDTH DMils2iu( 5000 ) ///< Maximum text width in Pcbnew units value (0.5 inches) +#define MIN_DRAW_WIDTH 1 ///< Minimum trace drawing width in pixels. // Flag to force the SKETCH mode to display items (.m_Flags member) @@ -71,6 +73,16 @@ extern int g_MagneticTrackOption; extern wxPoint g_Offset_Module; // Offset trace when moving footprint. +/// List of segments of the trace currently being drawn. +class TRACK; +extern DLIST g_CurrentTrackList; +#define g_CurrentTrackSegment g_CurrentTrackList.GetLast() ///< most recently created segment +#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created + + +class DISPLAY_OPTIONS; +extern DISPLAY_OPTIONS DisplayOpt; + enum MagneticPadOptionValues { no_effect, capture_cursor_in_track_tool, diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index f9f9c41153..37e676260d 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 36ac8b41bd..e320209ece 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index e1d965dbc4..17bba06016 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index af367974fc..54c5f49318 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -30,8 +30,6 @@ #include #include #include -#include - #include #include #include diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 29de1909db..d14681ede8 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -213,7 +212,7 @@ public: Add( ACT_SwitchPosture ); AppendSeparator(); - + CONTEXT_TRACK_WIDTH_MENU* trackMenu = new CONTEXT_TRACK_WIDTH_MENU; trackMenu->SetBoard( aBoard ); AppendSubMenu( trackMenu, wxT( "Select Track Width" ) ); @@ -594,7 +593,7 @@ void ROUTER_TOOL::performRouting() if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; } - + handleCommonEvents( *evt ); } diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 576806f483..b32b0321b4 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index a33915fe4b..d1891935c2 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -35,10 +35,7 @@ #include #include <3d_viewer.h> #include -#include - #include - #include #include #include diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index da1d028aca..7579d91290 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index c61ba0d5bd..a7ae9bff0d 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include