diff --git a/.bzrignore b/.bzrignore
index 03bd5c449c..1512d59482 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -3,13 +3,16 @@ boost_root
common/netlist_keywords.*
common/netlist_lexer.h
common/pcb_plot_params_lexer.h
-common/page_layout_reader_keywords.cpp
+common/page_layout/page_layout_reader_keywords.cpp
common/fp_lib_table_keywords.*
include/fp_lib_table_lexer.h
include/netlist_lexer.h
include/page_layout_reader_lexer.h
eeschema/cmp_library_lexer.h
eeschema/cmp_library_keywords.*
+eeschema/dialogs/dialog_bom_cfg_keywords.cpp
+eeschema/dialogs/dialog_bom_cfg_lexer.h
+eeschema/dialogs/dialog_bom_help_html.h
eeschema/template_fieldnames_keywords.*
eeschema/template_fieldnames_lexer.h
pcbnew/dialogs/dialog_freeroute_exchange_help_html.h
diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp
index d48deecfb3..248cd3bb3d 100644
--- a/3d-viewer/3d_canvas.cpp
+++ b/3d-viewer/3d_canvas.cpp
@@ -489,24 +489,24 @@ void EDA_3D_CANVAS::InitGL()
m_ZTop = 10.0;
glDisable( GL_CULL_FACE ); // show back faces
-
glEnable( GL_DEPTH_TEST ); // Enable z-buferring
-
+ glEnable( GL_ALPHA_TEST );
glEnable( GL_LINE_SMOOTH );
+// glEnable(GL_POLYGON_SMOOTH); // creates issues with some graphic cards
+ glShadeModel( GL_SMOOTH );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
- /* speedups */
+ // speedups
glEnable( GL_DITHER );
- glShadeModel( GL_SMOOTH );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
- glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); // can be GL_FASTEST
+ glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
- /* blend */
+ // Initialize alpha blending function.
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- }
+}
// set viewing projection
diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp
index 380fec090c..230bbc06e5 100644
--- a/3d-viewer/3d_draw.cpp
+++ b/3d-viewer/3d_draw.cpp
@@ -49,7 +49,6 @@
#include <3d_draw_basic_functions.h>
// Imported function:
-extern void SetGLColor( EDA_COLOR_T color );
extern void Set_Object_Data( std::vector& aVertices, double aBiuTo3DUnits );
extern void CheckGLError();
@@ -147,11 +146,66 @@ void EDA_3D_CANVAS::Redraw( bool finish )
SwapBuffers();
}
+// Helper function: initialize the copper color to draw the board
+// in realistic mode.
+static inline void SetGLCopperColor()
+{
+ // Generates a golden yellow color, near board "copper" color
+ const double lum = 0.7/255.0;
+ glColor4f( 255.0*lum, 223.0*lum, 0.0*lum, 1.0 );
+}
+
+// Helper function: initialize the color to draw the epoxy layers
+// ( body board and solder mask layers) in realistic mode.
+static inline void SetGLEpoxyColor( double aTransparency = 1.0 )
+{
+ // Generates an epoxy color, near board color
+ const double lum = 0.2/255.0;
+ glColor4f( 100.0*lum, 255.0*lum, 180.0*lum, aTransparency );
+}
+
+// Helper function: initialize the color to draw the non copper layers
+// in realistic mode and normal mode.
+static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
+{
+ if( g_Parm_3D_Visu.IsRealisticMode() )
+ {
+ switch( aLayer )
+ {
+ case SOLDERPASTE_N_BACK:
+ case SOLDERPASTE_N_FRONT:
+ SetGLColor( DARKGRAY, 0.7 );
+ break;
+
+ case SILKSCREEN_N_BACK:
+ case SILKSCREEN_N_FRONT:
+ SetGLColor( LIGHTGRAY, 0.9 );
+ break;
+
+ case SOLDERMASK_N_BACK:
+ case SOLDERMASK_N_FRONT:
+ SetGLEpoxyColor( 0.7 );
+ break;
+
+ default:
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayer );
+ SetGLColor( color, 0.7 );
+ break;
+ }
+ }
+ else
+ {
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayer );
+ SetGLColor( color, 0.7 );
+ }
+}
+
void EDA_3D_CANVAS::BuildBoard3DView()
{
PCB_BASE_FRAME* pcbframe = Parent()->Parent();
BOARD* pcb = pcbframe->GetBoard();
+ bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// Number of segments to draw a circle using segments
const int segcountforcircle = 16;
@@ -161,14 +215,29 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
- CPOLYGONS_LIST bufferPolys;
- bufferPolys.reserve( 200000 ); // Reserve for large board (tracks mainly)
- CPOLYGONS_LIST bufferZonesPolys;
- bufferPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly )
- CPOLYGONS_LIST currLayerHoles; // Contains holes for the current layer
- CPOLYGONS_LIST allLayerHoles; // Contains through holes, calculated only once
+ CPOLYGONS_LIST bufferPolys;
+ bufferPolys.reserve( 200000 ); // Reserve for large board (tracks mainly)
+
+ CPOLYGONS_LIST bufferPcbOutlines; // stores the board main outlines
+ CPOLYGONS_LIST allLayerHoles; // Contains through holes, calculated only once
allLayerHoles.reserve( 20000 );
+
+ // Build a polygon from edge cut items
+ wxString msg;
+ if( ! pcb->GetBoardPolygonOutlines( bufferPcbOutlines,
+ allLayerHoles, &msg ) )
+ {
+ msg << wxT("\n\n") <<
+ _("Unable to calculate the board outlines.\n"
+ "Therefore use the board boundary box.");
+ wxMessageBox( msg );
+ }
+
+ CPOLYGONS_LIST bufferZonesPolys;
+ bufferZonesPolys.reserve( 500000 ); // Reserve for large board ( copper zones mainly )
+
+ CPOLYGONS_LIST currLayerHoles; // Contains holes for the current layer
bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once
bool hightQualityMode = false;
@@ -179,7 +248,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
&& layer >= g_Parm_3D_Visu.m_CopperLayersCount )
continue;
- if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
+ if( !Is3DLayerEnabled( layer ) )
continue;
bufferPolys.RemoveAllContours();
@@ -243,7 +312,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
// Draw copper zones
- if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] )
+ if( g_Parm_3D_Visu.GetFlag( FL_ZONE ) )
{
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
@@ -282,7 +351,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
}
- // bufferPolys contains polygons to merge. Many overlaps . Calculate merged polygons
+ // bufferPolys contains polygons to merge. Many overlaps .
+ // Calculate merged polygons
if( bufferPolys.GetCornersCount() == 0 )
continue;
@@ -301,11 +371,17 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Merge polygons, remove holes
currLayerPolyset -= polysetHoles;
- EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
- SetGLColor( color );
+ if( realistic_mode )
+ SetGLCopperColor();
+ else
+ {
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
+ SetGLColor( color );
+ }
+
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
bufferPolys.RemoveAllContours();
@@ -336,14 +412,65 @@ void EDA_3D_CANVAS::BuildBoard3DView()
Draw3DPadHole( pad );
}
+ // Draw board substrate:
+ if( bufferPcbOutlines.GetCornersCount() &&
+ ( realistic_mode || g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) ) )
+ {
+ int copper_thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
+ // a small offset between substrate and external copper layer to avoid artifacts
+ // when drawing copper items on board
+ int epsilon = Millimeter2iu( 0.01 );
+ int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
+ int board_thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
+ - g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
+ // items on copper layers and having a thickness = copper_thickness
+ // are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
+ // therefore substrate position is copper_thickness/2 to
+ // substrate_height - copper_thickness/2
+ zpos += (copper_thickness + epsilon) / 2;
+ board_thickness -= copper_thickness + epsilon;
+
+ if( realistic_mode )
+ SetGLEpoxyColor();
+ else
+ {
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( EDGE_N );
+ SetGLColor( color, 0.7 );
+ }
+
+ glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( LAYER_N_FRONT ) );
+ KI_POLYGON_SET currLayerPolyset;
+ KI_POLYGON_SET polysetHoles;
+
+ // Add polygons, without holes
+ bufferPcbOutlines.ExportTo( currLayerPolyset );
+
+ // Build holes list
+ allLayerHoles.ExportTo( polysetHoles );
+
+ // remove holes
+ currLayerPolyset -= polysetHoles;
+
+ bufferPcbOutlines.RemoveAllContours();
+ bufferPcbOutlines.ImportFrom( currLayerPolyset );
+
+ // for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
+ // sides
+ Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2,
+ board_thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
+ }
+
// draw graphic items, not on copper layers
+ KI_POLYGON_SET brdpolysetHoles;
+ allLayerHoles.ExportTo( brdpolysetHoles );
+
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
layer++ )
{
if( !Is3DLayerEnabled( layer ) )
continue;
- if( !g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
+ if( layer == EDGE_N && g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) )
continue;
bufferPolys.RemoveAllContours();
@@ -407,16 +534,35 @@ void EDA_3D_CANVAS::BuildBoard3DView()
// Calculate merged polygons and remove pads and vias holes
if( bufferPolys.GetCornersCount() == 0 )
continue;
-
KI_POLYGON_SET currLayerPolyset;
KI_POLYGON_SET polyset;
- bufferPolys.ExportTo( polyset );
- // merge polys:
- currLayerPolyset += polyset;
- EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
+ // Solder mask layers are "negative" layers.
+ // Shapes should be removed from the full board area.
+ if( layer == SOLDERMASK_N_BACK || layer == SOLDERMASK_N_FRONT )
+ {
+ bufferPcbOutlines.ExportTo( currLayerPolyset );
+ bufferPolys.Append( allLayerHoles );
+ bufferPolys.ExportTo( polyset );
+ currLayerPolyset -= polyset;
+ }
+ // Remove holes from Solder paste layers and siklscreen
+ else if( layer == SOLDERPASTE_N_BACK || layer == SOLDERPASTE_N_FRONT
+ || layer == SILKSCREEN_N_BACK || layer == SILKSCREEN_N_FRONT )
+ {
+ bufferPolys.ExportTo( currLayerPolyset );
+ currLayerPolyset -= brdpolysetHoles;
+ }
+ else // usuall layers, merge polys built from each item shape:
+ {
+ bufferPolys.ExportTo( polyset );
+ currLayerPolyset += polyset;
+ }
+
+ SetGLTechLayersColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
+ glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
if( layer == EDGE_N )
{
@@ -425,9 +571,17 @@ void EDA_3D_CANVAS::BuildBoard3DView()
zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK )
+ (thickness / 2);
}
-
- SetGLColor( color );
- glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
+ else
+ {
+ // for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
+ // sides.
+ // However for top layers, zpos should be the bottom layer pos,
+ // and for bottom layers, zpos should be the top layer pos.
+ if( Get3DLayer_Z_Orientation( layer ) > 0 )
+ zpos += thickness/2;
+ else
+ zpos -= thickness/2 ;
+ }
bufferPolys.RemoveAllContours();
bufferPolys.ImportFrom( currLayerPolyset );
@@ -458,7 +612,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
// draw axis
- if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] )
+ if( g_Parm_3D_Visu.GetFlag( FL_AXIS ) )
{
glEnable( GL_COLOR_MATERIAL );
SetGLColor( WHITE );
@@ -490,7 +644,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
BuildBoard3DView();
// Draw grid
- if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] )
+ if( g_Parm_3D_Visu.GetFlag( FL_GRID ) )
DrawGrid( g_Parm_3D_Visu.m_3D_Grid );
glEndList();
@@ -517,6 +671,7 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines
EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
+ double transparency = 0.4;
glNormal3f( 0.0, 0.0, 1.0 );
@@ -539,9 +694,9 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
- SetGLColor( gridcolor );
+ SetGLColor( gridcolor, transparency );
else
- SetGLColor( gridcolor_marker );
+ SetGLColor( gridcolor_marker, transparency );
int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM );
@@ -588,9 +743,9 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
- SetGLColor( gridcolor );
+ SetGLColor( gridcolor, transparency );
else
- SetGLColor( gridcolor_marker );
+ SetGLColor( gridcolor_marker, transparency );
double delta = ii * aGriSizeMM * IU_PER_MM;
@@ -615,9 +770,9 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
- SetGLColor( gridcolor );
+ SetGLColor( gridcolor, transparency);
else
- SetGLColor( gridcolor_marker );
+ SetGLColor( gridcolor_marker, transparency );
double delta = ii * aGriSizeMM * IU_PER_MM * scale;
@@ -654,8 +809,14 @@ void EDA_3D_CANVAS::Draw3DViaHole( SEGVIA* aVia )
aVia->ReturnLayerPair( &top_layer, &bottom_layer );
// Drawing via hole:
- EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() );
- SetGLColor( color );
+ if( g_Parm_3D_Visu.IsRealisticMode() )
+ SetGLCopperColor();
+ else
+ {
+ EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetShape() );
+ SetGLColor( color );
+ }
+
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( top_layer ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) - thickness;
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer ) + thickness / 2;
@@ -670,7 +831,7 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas )
// Draw module shape: 3D shape if exists (or module outlines if not exists)
S3D_MASTER* struct3D = m_3D_Drawings;
- if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] )
+ if( g_Parm_3D_Visu.GetFlag( FL_MODULE ) )
{
double zpos;
@@ -721,7 +882,11 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
- SetGLColor( DARKGRAY );
+ if( g_Parm_3D_Visu.IsRealisticMode() )
+ SetGLCopperColor();
+ else
+ SetGLColor( DARKGRAY );
+
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ) + thickness / 2;
int holeHeight = height - thickness;
@@ -762,7 +927,8 @@ void EDA_3D_CANVAS::Draw3DPadHole( D_PAD* aPad )
bool Is3DLayerEnabled( LAYER_NUM aLayer )
{
- int flg;
+ DISPLAY3D_FLG flg;
+ bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// see if layer needs to be shown
// check the flags
@@ -770,41 +936,57 @@ bool Is3DLayerEnabled( LAYER_NUM aLayer )
{
case ADHESIVE_N_BACK:
case ADHESIVE_N_FRONT:
- flg = g_Parm_3D_Visu.FL_ADHESIVE;
+ flg = FL_ADHESIVE;
break;
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
- flg = g_Parm_3D_Visu.FL_SOLDERPASTE;
+ flg = FL_SOLDERPASTE;
break;
case SILKSCREEN_N_BACK:
case SILKSCREEN_N_FRONT:
- flg = g_Parm_3D_Visu.FL_SILKSCREEN;
+ flg = FL_SILKSCREEN;
break;
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
- flg = g_Parm_3D_Visu.FL_SOLDERMASK;
+ flg = FL_SOLDERMASK;
break;
case DRAW_N:
case COMMENT_N:
- flg = g_Parm_3D_Visu.FL_COMMENTS;
+ if( realistic_mode )
+ return false;
+
+ flg = FL_COMMENTS;
break;
case ECO1_N:
case ECO2_N:
- flg = g_Parm_3D_Visu.FL_ECO;
+ if( realistic_mode )
+ return false;
+
+ flg = FL_ECO;
+ break;
+
+ case LAYER_N_BACK:
+ case LAYER_N_FRONT:
+ return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer )
+ || realistic_mode;
break;
default:
- // the layer was not a layer with a flag, so show it
- return true;
+ // the layer is an internal copper layer
+ if( realistic_mode )
+ return false;
+
+ return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
}
// if the layer has a flag, return the flag
- return g_Parm_3D_Visu.m_DrawFlags[flg];
+ return g_Parm_3D_Visu.GetFlag( flg ) &&
+ g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer );
}
diff --git a/3d-viewer/3d_draw_basic_functions.cpp b/3d-viewer/3d_draw_basic_functions.cpp
index fbe1fb6277..ef49a3e4bb 100644
--- a/3d-viewer/3d_draw_basic_functions.cpp
+++ b/3d-viewer/3d_draw_basic_functions.cpp
@@ -34,7 +34,6 @@
#include
#include <3d_draw_basic_functions.h>
-
// Imported function:
extern void Set_Object_Data( std::vector& aVertices, double aBiuTo3DUnits );
extern void CheckGLError();
@@ -122,7 +121,7 @@ static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList,
}
-void SetGLColor( EDA_COLOR_T color )
+void SetGLColor( EDA_COLOR_T color, double alpha )
{
double red, green, blue;
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
@@ -130,7 +129,7 @@ void SetGLColor( EDA_COLOR_T color )
red = colordata.m_Red / 255.0;
blue = colordata.m_Blue / 255.0;
green = colordata.m_Green / 255.0;
- glColor3f( red, green, blue );
+ glColor4f( red, green, blue, alpha );
}
diff --git a/3d-viewer/3d_draw_basic_functions.h b/3d-viewer/3d_draw_basic_functions.h
index 9f40bc0821..a4fb60ab34 100644
--- a/3d-viewer/3d_draw_basic_functions.h
+++ b/3d-viewer/3d_draw_basic_functions.h
@@ -37,7 +37,7 @@
* @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
- * If aThickness 1 0, a solid object is drawn.
+ * If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2
*/
@@ -118,5 +118,12 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
int aRadius, int aHeight, int aThickness,
int aZpos, double aBiuTo3DUnits );
+/**
+ * Set the current 3D color from a Kicad color, with optional transparency
+ * @param aColor = a EDA_COLOR_T kicad color index
+ * @param aTransparency = the color transparency (default = 1.0 = no transparency)
+ */
+void SetGLColor( EDA_COLOR_T aColor, double aTransparency = 1.0 );
+
#endif // _3D_DRAW_BASIC_FUNCTIONS_H_
diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp
index 6167ca7154..41e75cccb5 100644
--- a/3d-viewer/3d_frame.cpp
+++ b/3d-viewer/3d_frame.cpp
@@ -47,6 +47,7 @@ static const wxString keySizey( wxT( "Size_y" ) );
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" ) );
@@ -56,6 +57,7 @@ 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" ) );
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
@@ -152,6 +154,7 @@ void EDA_3D_FRAME::GetSettings()
{
wxString text;
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
+ class INFO3D_VISU& prms = g_Parm_3D_Visu;
if( config )
{
@@ -166,19 +169,43 @@ void EDA_3D_FRAME::GetSettings()
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 );
- class INFO3D_VISU& prms = g_Parm_3D_Visu;
- config->Read( keyShowAxis, &prms.m_DrawFlags[prms.FL_AXIS], true );
- config->Read( keyShowFootprints, &prms.m_DrawFlags[prms.FL_MODULE], true );
- config->Read( keyShowCopperThickness,
- &prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS],
- false );
- config->Read( keyShowZones, &prms.m_DrawFlags[prms.FL_ZONE], true );
- config->Read( keyShowAdhesiveLayers, &prms.m_DrawFlags[prms.FL_ADHESIVE], true );
- config->Read( keyShowSilkScreenLayers, &prms.m_DrawFlags[prms.FL_SILKSCREEN], true );
- config->Read( keyShowSolderMaskLayers, &prms.m_DrawFlags[prms.FL_SOLDERMASK], true );
- config->Read( keyShowSolderPasteLayers, &prms.m_DrawFlags[prms.FL_SOLDERPASTE], true );
- config->Read( keyShowCommentsLayer, &prms.m_DrawFlags[prms.FL_COMMENTS], true );
- config->Read( keyShowEcoLayers, &prms.m_DrawFlags[prms.FL_ECO], true );
+
+ bool tmp;
+ config->Read( keyShowRealisticMode, &tmp, false );
+ prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
+
+ config->Read( keyShowAxis, &tmp, true );
+ prms.SetFlag( FL_AXIS, tmp );
+
+ config->Read( keyShowFootprints, &tmp, true );
+ prms.SetFlag( FL_MODULE, tmp );
+
+ config->Read( keyShowCopperThickness, &tmp, false );
+ prms.SetFlag( FL_USE_COPPER_THICKNESS, tmp );
+
+ config->Read( keyShowZones, &tmp, true );
+ prms.SetFlag( FL_ZONE, tmp );
+
+ config->Read( keyShowAdhesiveLayers, &tmp, true );
+ prms.SetFlag( FL_ADHESIVE, tmp );
+
+ config->Read( keyShowSilkScreenLayers, &tmp, true );
+ prms.SetFlag( FL_SILKSCREEN, tmp );
+
+ config->Read( keyShowSolderMaskLayers, &tmp, true );
+ prms.SetFlag( FL_SOLDERMASK, tmp );
+
+ config->Read( keyShowSolderPasteLayers, &tmp, true );
+ prms.SetFlag( FL_SOLDERPASTE, tmp );
+
+ config->Read( keyShowCommentsLayer, &tmp, true );
+ prms.SetFlag( FL_COMMENTS, tmp );
+
+ config->Read( keyShowEcoLayers, &tmp, true );
+ prms.SetFlag( FL_ECO, tmp );
+
+ config->Read( keyShowBoardBody, &tmp, true );
+ prms.SetFlag( FL_SHOW_BOARD_BODY, tmp );
}
}
@@ -195,16 +222,18 @@ void EDA_3D_FRAME::SaveSettings()
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( keyShowAxis, prms.m_DrawFlags[prms.FL_AXIS] );
- config->Write( keyShowFootprints, prms.m_DrawFlags[prms.FL_MODULE] );
- config->Write( keyShowCopperThickness, prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS] );
- config->Write( keyShowZones, prms.m_DrawFlags[prms.FL_ZONE] );
- config->Write( keyShowAdhesiveLayers, prms.m_DrawFlags[prms.FL_ADHESIVE] );
- config->Write( keyShowSilkScreenLayers, prms.m_DrawFlags[prms.FL_SILKSCREEN] );
- config->Write( keyShowSolderMaskLayers, prms.m_DrawFlags[prms.FL_SOLDERMASK] );
- config->Write( keyShowSolderPasteLayers, prms.m_DrawFlags[prms.FL_SOLDERPASTE] );
- config->Write( keyShowCommentsLayer, prms.m_DrawFlags[prms.FL_COMMENTS] );
- config->Write( keyShowEcoLayers, prms.m_DrawFlags[prms.FL_ECO] );
+ 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 ) );
if( IsIconized() )
return;
@@ -355,53 +384,63 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
Set3DBgColor();
return;
+ case ID_MENU3D_REALISTIC_MODE:
+ g_Parm_3D_Visu.SetFlag( FL_USE_REALISTIC_MODE, isChecked );
+ NewDisplay();
+ return;
+
+ case ID_MENU3D_SHOW_BOARD_BODY:
+ g_Parm_3D_Visu.SetFlag( FL_SHOW_BOARD_BODY, isChecked );
+ NewDisplay();
+ return;
+
case ID_MENU3D_AXIS_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_AXIS, isChecked );
NewDisplay();
return;
case ID_MENU3D_MODULE_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_MODULE, isChecked );
NewDisplay();
return;
case ID_MENU3D_USE_COPPER_THICKNESS:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
NewDisplay();
return;
case ID_MENU3D_ZONE_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_ZONE, isChecked );
NewDisplay();
return;
case ID_MENU3D_ADHESIVE_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_ADHESIVE, isChecked );
NewDisplay();
return;
case ID_MENU3D_SILKSCREEN_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_SILKSCREEN, isChecked );
NewDisplay();
return;
case ID_MENU3D_SOLDER_MASK_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_SOLDERMASK, isChecked );
NewDisplay();
return;
case ID_MENU3D_SOLDER_PASTE_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_SOLDERPASTE, isChecked );
NewDisplay();
return;
case ID_MENU3D_COMMENTS_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_COMMENTS, isChecked );
NewDisplay();
return;
case ID_MENU3D_ECO_ONOFF:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] = isChecked;
+ g_Parm_3D_Visu.SetFlag( FL_ECO, isChecked );
NewDisplay();
return;
@@ -431,26 +470,26 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
switch( id )
{
case ID_MENU3D_GRID_NOGRID:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = false;
+ g_Parm_3D_Visu.SetFlag( FL_GRID, false );
break;
case ID_MENU3D_GRID_10_MM:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
+ g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 10.0;
break;
case ID_MENU3D_GRID_5_MM:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
+ g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 5.0;
break;
case ID_MENU3D_GRID_2P5_MM:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
+ g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 2.5;
break;
case ID_MENU3D_GRID_1_MM:
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
+ g_Parm_3D_Visu.SetFlag( FL_GRID, true );
g_Parm_3D_Visu.m_3D_Grid = 1.0;
break;
diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp
index 5b49f781f5..461852f34c 100644
--- a/3d-viewer/3d_toolbar.cpp
+++ b/3d-viewer/3d_toolbar.cpp
@@ -1,9 +1,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
- * Copyright (C) 2011 Wayne Stambaugh
- * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
+ * Copyright (C) 2013 Wayne Stambaugh
+ * Copyright (C) 1992-2013 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
@@ -158,17 +158,19 @@ void EDA_3D_FRAME::CreateMenuBar()
menuBar->Append( prefsMenu, _( "&Preferences" ) );
+ AddMenuItem( prefsMenu, ID_MENU3D_REALISTIC_MODE,
+ _( "Realistic Mode" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
+ prefsMenu->AppendSeparator();
+
AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose background color" ), KiBitmap( palette_xpm ) );
- wxMenuItem* item;
- item = AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]);
// Creates grid menu
wxMenu * gridlistMenu = new wxMenu;
- item = AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
+ AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
_( "3D Grid" ), KiBitmap( grid_xpm ) );
gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true );
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
@@ -178,36 +180,42 @@ void EDA_3D_FRAME::CreateMenuBar()
gridlistMenu->Append( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString, true );
- item = AddMenuItem( prefsMenu, ID_MENU3D_USE_COPPER_THICKNESS,
+ prefsMenu->AppendSeparator();
+
+ AddMenuItem( prefsMenu, ID_MENU3D_SHOW_BOARD_BODY,
+ _( "Show Board Body" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
+
+ AddMenuItem( prefsMenu, ID_MENU3D_USE_COPPER_THICKNESS,
_( "Show Copper Thickness" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF,
_( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
- _( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
+ prefsMenu->AppendSeparator();
- item = AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
+ _( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
+
+ AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF,
_( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
_( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
_( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
- item = AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF,
+ AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF,
_( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
- SetMenuBarOptionsState();
SetMenuBar( menuBar );
+ SetMenuBarOptionsState();
}
void EDA_3D_FRAME::SetMenuBarOptionsState()
@@ -219,32 +227,41 @@ void EDA_3D_FRAME::SetMenuBarOptionsState()
wxMenuItem* item;
// Set the state of toggle menus according to the current display options
+ item = menuBar->FindItem( ID_MENU3D_REALISTIC_MODE );
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_USE_REALISTIC_MODE ) );
+
+ item = menuBar->FindItem( ID_MENU3D_SHOW_BOARD_BODY );
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) );
+
item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_USE_COPPER_THICKNESS ) );
item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_MODULE ) );
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_ZONE ) );
+
+ item = menuBar->FindItem( ID_MENU3D_AXIS_ONOFF );
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_AXIS ) );
item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_ADHESIVE ) );
item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_SILKSCREEN ) );
item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_SOLDERMASK ) );
item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_SOLDERPASTE ) );
item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_COMMENTS ) );
item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF );
- item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO]);
+ item->Check(g_Parm_3D_Visu.GetFlag( FL_ECO ));
}
void EDA_3D_FRAME::SetToolbars()
diff --git a/3d-viewer/3d_viewer_id.h b/3d-viewer/3d_viewer_id.h
index c64dd9de63..3af2a35db6 100644
--- a/3d-viewer/3d_viewer_id.h
+++ b/3d-viewer/3d_viewer_id.h
@@ -39,6 +39,8 @@ enum id_3dview_frm
ID_MENU3D_SOLDER_MASK_ONOFF,
ID_MENU3D_COMMENTS_ONOFF,
ID_MENU3D_ECO_ONOFF,
+ ID_MENU3D_SHOW_BOARD_BODY,
+ ID_MENU3D_REALISTIC_MODE,
ID_END_COMMAND_3D,
ID_TOOL_SET_VISIBLE_ITEMS,
diff --git a/3d-viewer/dialogs/dialog_3D_view_option.cpp b/3d-viewer/dialogs/dialog_3D_view_option.cpp
index e42abb5a40..2097ab7486 100644
--- a/3d-viewer/dialogs/dialog_3D_view_option.cpp
+++ b/3d-viewer/dialogs/dialog_3D_view_option.cpp
@@ -10,6 +10,7 @@ public:
private:
EDA_3D_FRAME* m_parent;
+ INFO3D_VISU & m_3Dprms;
void initDialog();
@@ -31,7 +32,7 @@ void EDA_3D_FRAME::Install_3D_ViewOptionDialog( wxCommandEvent& event )
DIALOG_3D_VIEW_OPTIONS::DIALOG_3D_VIEW_OPTIONS( EDA_3D_FRAME* parent )
- :DIALOG_3D_VIEW_OPTIONS_BASE( parent )
+ :DIALOG_3D_VIEW_OPTIONS_BASE( parent ), m_3Dprms( g_Parm_3D_Visu )
{
m_parent = parent;
@@ -55,24 +56,15 @@ void DIALOG_3D_VIEW_OPTIONS::initDialog()
m_bitmapECO->SetBitmap( KiBitmap( edit_sheet_xpm ) );
// Check/uncheck checkboxes
- m_checkBoxCuThickness->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] );
- m_checkBox3Dshapes->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] );
- m_checkBoxAreas->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] );
- m_checkBoxSilkscreen->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] );
- m_checkBoxSolderMask->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] );
- m_checkBoxSolderpaste->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] );
- m_checkBoxAdhesive->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] );
- m_checkBoxComments->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] );
- m_checkBoxECO->SetValue(
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] );
+ m_checkBoxCuThickness->SetValue( m_3Dprms.GetFlag( FL_USE_COPPER_THICKNESS ) );
+ m_checkBox3Dshapes->SetValue( m_3Dprms.GetFlag( FL_MODULE ) );
+ m_checkBoxAreas->SetValue( m_3Dprms.GetFlag( FL_ZONE ) );
+ m_checkBoxSilkscreen->SetValue( m_3Dprms.GetFlag( FL_SILKSCREEN ) );
+ m_checkBoxSolderMask->SetValue( m_3Dprms.GetFlag( FL_SOLDERMASK ) );
+ m_checkBoxSolderpaste->SetValue( m_3Dprms.GetFlag( FL_SOLDERPASTE ) );
+ m_checkBoxAdhesive->SetValue( m_3Dprms.GetFlag( FL_ADHESIVE ) );
+ m_checkBoxComments->SetValue( m_3Dprms.GetFlag( FL_COMMENTS ) );
+ m_checkBoxECO->SetValue( m_3Dprms.GetFlag( FL_ECO ) );
}
void DIALOG_3D_VIEW_OPTIONS::OnShowAllClick( wxCommandEvent& event )
@@ -105,24 +97,16 @@ void DIALOG_3D_VIEW_OPTIONS::OnShowNoneClick( wxCommandEvent& event )
void DIALOG_3D_VIEW_OPTIONS::OnOKClick( wxCommandEvent& event )
{
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] =
- m_checkBoxCuThickness->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] =
- m_checkBox3Dshapes->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] =
- m_checkBoxAreas->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] =
- m_checkBoxSilkscreen->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] =
- m_checkBoxSolderMask->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] =
- m_checkBoxSolderpaste->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] =
- m_checkBoxAdhesive->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] =
- m_checkBoxComments->GetValue();
- g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] =
- m_checkBoxECO->GetValue();
+ m_3Dprms.SetFlag( FL_USE_COPPER_THICKNESS,
+ m_checkBoxCuThickness->GetValue() );
+ m_3Dprms.SetFlag( FL_MODULE, m_checkBox3Dshapes->GetValue() );
+ m_3Dprms.SetFlag( FL_ZONE, m_checkBoxAreas->GetValue() );
+ m_3Dprms.SetFlag( FL_SILKSCREEN, m_checkBoxSilkscreen->GetValue() );
+ m_3Dprms.SetFlag( FL_SOLDERMASK, m_checkBoxSolderMask->GetValue() );
+ m_3Dprms.SetFlag( FL_SOLDERPASTE, m_checkBoxSolderpaste->GetValue() );
+ m_3Dprms.SetFlag( FL_ADHESIVE, m_checkBoxAdhesive->GetValue() );
+ m_3Dprms.SetFlag( FL_COMMENTS, m_checkBoxComments->GetValue() );
+ m_3Dprms.SetFlag( FL_ECO, m_checkBoxECO->GetValue( ) );
EndModal( wxID_OK );
}
diff --git a/3d-viewer/info3d_visu.cpp b/3d-viewer/info3d_visu.cpp
index 54ef070d93..0dc0f04848 100644
--- a/3d-viewer/info3d_visu.cpp
+++ b/3d-viewer/info3d_visu.cpp
@@ -39,7 +39,7 @@
// Thickness of copper
// TODO: define the actual copper thickness by user
-#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 µm
+#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 um
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
#define EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM ) // for 1.6 mm
@@ -68,10 +68,10 @@ INFO3D_VISU::INFO3D_VISU()
// default all special item layers Visible
for( ii = 0; ii < FL_LAST; ii++ )
- m_DrawFlags[ii] = true;
+ m_drawFlags[ii] = true;
- m_DrawFlags[FL_GRID] = false;
- m_DrawFlags[FL_USE_COPPER_THICKNESS] = false;
+ SetFlag( FL_GRID, false );
+ SetFlag( FL_USE_COPPER_THICKNESS, false );
}
@@ -124,8 +124,10 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
m_EpoxyThickness * layer / (copper_layers_cnt - 1);
}
- double zpos_copper_back = m_LayerZcoord[0];
- double zpos_copper_front = m_EpoxyThickness;
+ #define layerThicknessMargin 1.1
+ double zpos_offset = m_NonCopperLayerThickness * layerThicknessMargin;
+ double zpos_copper_back = m_LayerZcoord[0] - layerThicknessMargin*m_CopperThickness/2;
+ double zpos_copper_front = m_EpoxyThickness + layerThicknessMargin*m_CopperThickness/2;
// Fill remaining unused copper layers and front layer zpos
// with m_EpoxyThickness
@@ -138,54 +140,44 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ )
{
double zpos;
- #define NonCopperLayerThicknessMargin 1.1
switch( layer_id )
{
case ADHESIVE_N_BACK:
- zpos = zpos_copper_back -
- 4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_back - 4 * zpos_offset;
break;
case ADHESIVE_N_FRONT:
- zpos = zpos_copper_front +
- 4 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_front + 4 * zpos_offset;
break;
case SOLDERPASTE_N_BACK:
- zpos = zpos_copper_back -
- 3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_back - 3 * zpos_offset;
break;
case SOLDERPASTE_N_FRONT:
- zpos = zpos_copper_front +
- 3 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_front + 3 * zpos_offset;
break;
case SOLDERMASK_N_BACK:
- zpos = zpos_copper_back -
- 1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_back - 1 * zpos_offset;
break;
case SOLDERMASK_N_FRONT:
- zpos = zpos_copper_front +
- 1 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_front + 1 * zpos_offset;
break;
case SILKSCREEN_N_BACK:
- zpos = zpos_copper_back -
- 2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_back - 2 * zpos_offset;
break;
case SILKSCREEN_N_FRONT:
- zpos = zpos_copper_front +
- 2 * m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ zpos = zpos_copper_front + 2 * zpos_offset;
break;
default:
zpos = zpos_copper_front +
- (layer_id - FIRST_NON_COPPER_LAYER + 5) *
- m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
+ (layer_id - FIRST_NON_COPPER_LAYER + 5) * zpos_offset;
break;
}
diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h
index 08b4a97e42..b32ea84c8a 100644
--- a/3d-viewer/info3d_visu.h
+++ b/3d-viewer/info3d_visu.h
@@ -63,25 +63,27 @@ public: S3D_COLOR()
};
/* information needed to display 3D board */
+enum DISPLAY3D_FLG {
+ FL_AXIS=0, FL_MODULE, FL_ZONE,
+ FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
+ FL_COMMENTS, FL_ECO,
+ FL_GRID,
+ FL_USE_COPPER_THICKNESS,
+ FL_SHOW_BOARD_BODY,
+ FL_USE_REALISTIC_MODE,
+ FL_LAST
+};
+
+
class INFO3D_VISU
{
public:
- enum DISPLAY3D_FLG {
- FL_AXIS=0, FL_MODULE, FL_ZONE,
- FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
- FL_COMMENTS, FL_ECO,
- FL_GRID,
- FL_USE_COPPER_THICKNESS,
- FL_LAST
- };
-
double m_Beginx, m_Beginy; // position of mouse (used in drag commands)
double m_Quat[4]; // orientation of 3D view
double m_Rot[4]; // rotation parameters of 3D view
double m_Zoom; // 3D zoom value
double m_3D_Grid; // 3D grid value, in mm
S3D_COLOR m_BgColor;
- bool m_DrawFlags[FL_LAST]; // Enable/disable flags (see DISPLAY3D_FLG list)
wxPoint m_BoardPos; // center board actual position in board units
wxSize m_BoardSize; // board actual size in board units
int m_CopperLayersCount; // Number of copper layers actually used by the board
@@ -98,10 +100,18 @@ private:
double m_CopperThickness; // Copper thickness (normalized)
double m_EpoxyThickness; // Epoxy thickness (normalized)
double m_NonCopperLayerThickness; // Non copper layers thickness
+ bool m_drawFlags[FL_LAST]; // Enable/disable flags (see DISPLAY3D_FLG list)
public: INFO3D_VISU();
~INFO3D_VISU();
+ // Accessors
+ bool GetFlag( DISPLAY3D_FLG aFlag ) const { return m_drawFlags[aFlag]; }
+ bool SetFlag( DISPLAY3D_FLG aFlag, bool aState )
+ {
+ return m_drawFlags[aFlag] = aState;
+ }
+
/**
* Function InitSettings
* Initialize info 3D Parameters from aBoard
@@ -133,11 +143,14 @@ public: INFO3D_VISU();
* note: the thickness (Z size) of the copper is not the thickness
* of the layer (the thickness of the layer is the epoxy thickness / layer count)
*
- * Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
+ * Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set,
+ * and normal mode, returns 0
*/
int GetCopperThicknessBIU() const
{
- return m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
+ bool use_copper_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) ||
+ GetFlag( FL_USE_REALISTIC_MODE );
+ return use_copper_thickness ?
KiROUND( m_CopperThickness / m_BiuTo3Dunits )
: 0;
}
@@ -156,11 +169,13 @@ public: INFO3D_VISU();
* @return the thickness (Z size) of a technical layer,
* in Board Internal Units
*
- * Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
+ * Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int GetNonCopperLayerThicknessBIU() const
{
- return m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
+ bool use_copper_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) ||
+ GetFlag( FL_USE_REALISTIC_MODE );
+ return use_copper_thickness ?
KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits )
: 0;
}
@@ -170,7 +185,7 @@ public: INFO3D_VISU();
* @return the thickness (Z size) of the copper or a technical layer,
* in Board Internal Units, depending on the layer id
*
- * Note: if m_DrawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
+ * Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int GetLayerObjectThicknessBIU( int aLayerId) const
{
@@ -178,6 +193,8 @@ public: INFO3D_VISU();
GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU();
}
+
+ bool IsRealisticMode() { return GetFlag( FL_USE_REALISTIC_MODE ); }
};
extern INFO3D_VISU g_Parm_3D_Visu;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a7bf0c001..3c389cee92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,10 +14,6 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
# reports.
#
-# Russian GOST patch
-option( wxUSE_UNICODE "enable/disable building unicode ( default OFF)" )
-option( KICAD_GOST "enable/disable building using GOST notation for multiple gates per package ( default OFF)" )
-
#for those who bored with uppercase
option( KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected" )
@@ -53,11 +49,10 @@ option( KICAD_SCRIPTING_WXPYTHON
option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" )
-#option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
+option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
-#Set version option (stable or testing)
-
+# Set version option (stable or testing)
if( KICAD_STABLE_VERSION)
add_definitions( -DKICAD_STABLE_VERSION )
message( STATUS "Building stable version of KiCad" )
@@ -70,6 +65,13 @@ endif()
set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake
CACHE PATH "Location of KiCad downloads, suggested is a dir common to all builds, i.e. global." )
+if( UNIX )
+ set( KICAD_USER_CONFIG_DIR $ENV{HOME} CACHE PATH "Location of user specifig KiCad config files" )
+elseif( MINGW )
+ set( KICAD_USER_CONFIG_DIR $ENV{%APPDATA%} CACHE PATH "Location of user specifig KiCad config files" )
+endif()
+mark_as_advanced( KICAD_USER_CONFIG_DIR )
+
#================================================
# Set flags for GCC.
@@ -77,72 +79,60 @@ set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake
if( CMAKE_COMPILER_IS_GNUCXX )
- set( KICAD_GCC_RELEASE_BUILD_FLAGS "-O2" )
- set( KICAD_GCC_RELEASE_DEBUG_FLAGS "" )
-
execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE )
- # Added -Wno-narrowing on 10/7/12 to prevent a huge number of warnings when
- # compiling with GCC 4.7. This appears to be caused by and int to unsigned
- # conversion in the Boost polygon library. At some point in the future when
- # Boost is updated to the next version, -Wno-narrowing should be removed to
- # see if the problem has been resolved. Wayne.
- #
- # Also note the optimization level is -O1 instead of the usual -O2 level
- # because boost::polygon has a function ( inflate polygon) broken by
- # the -O2 level with GCC 4.7 (works fine with with GCC 4.6).
+ # 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" )
+ set( CMAKE_CXX_FLAGS "-Wall" )
+
+ # The optimization level is -O1 instead of the usual -O2 level because
+ # boost::polygon has a function (inflate polygon) broken by the -O2 level
+ # with GCC 4.7.0 to 4.7.2 (works fine with with GCC 4.6 and 4.7.3).
# This lower optimization level does not have a significant change on the speed.
- #
- # As newer versions of GCC and/or Boost are released, this code needs reviewed to
- # determine if the problems above have been fixed either in Boost or GCC.
- if( GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7 )
- set( KICAD_GCC_RELEASE_BUILD_FLAGS "-Wno-narrowing -O1" )
- set( KICAD_GCC_DEBUG_BUILD_FLAGS "-Wno-narrowing" )
+ # See also:
+ # https://bugs.launchpad.net/kicad/+bug/1056926
+ # https://svn.boost.org/trac/boost/ticket/7983
+ if( GCC_VERSION VERSION_EQUAL 4.7.0 OR ( GCC_VERSION VERSION_GREATER 4.7.0 AND GCC_VERSION VERSION_LESS 4.7.3 ) )
+ set( CMAKE_C_FLAGS_RELEASE "-O1" )
+ set( CMAKE_CXX_FLAGS_RELEASE "-O1" )
+ else()
+ set( CMAKE_C_FLAGS_RELEASE "-O2" )
+ set( CMAKE_CXX_FLAGS_RELEASE "-O2" )
endif()
- if( CMAKE_BUILD_TYPE STREQUAL Debug )
- message( STATUS
- "Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"" )
- else()
- message( STATUS
- "Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"" )
- endif()
+ set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" )
+ set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" )
+
+ set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG" )
+ set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
if( MINGW )
- # According to some sources, under Windows -fPIC option is not needed:
- # http://mingw.5.n7.nabble.com/Option-fPIC-not-supported-td18480.html
-
# Set default flags for Release build.
- set( CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG" )
- set( CMAKE_CXX_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s -static-libgcc -static-libstdc++" )
# Set default flags for Debug build.
- set( CMAKE_C_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG" )
- set( CMAKE_CXX_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG" )
set( CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++") # SWIG macros on Windows
else()
# We build DLL/DSOs from static libraries, so create position independent code
# for all cases, since we do not have DLL/DSO specific static libraries.
- # This flag could be localized to any object file going into a DLL/DSO in the future.
- set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
- set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
+ # Subdirectories via add_subdirectores() reference this variable, and it is either set or empty,
+ # empty for Windows.
+ set( PIC_FLAG -fPIC )
+
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
# Thou shalt not link vaporware and tell us it's a valid DSO:
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" ) # needed by SWIG macros on linux
# Set default flags for Release build.
- set( CMAKE_C_FLAGS_RELEASE "${KICAD_GCC_RELEASE_BUILD_FLAGS} -Wall -DNDEBUG" )
- set( CMAKE_CXX_FLAGS_RELEASE "${KICAD_GCC_RELEASE_BUILD_FLAGS} -Wall -DNDEBUG" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
- # Set default flags for Debug build.
- set( CMAKE_C_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG" )
- set( CMAKE_CXX_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG" )
endif()
# quiet GCC 4.8.1 while in boost
@@ -152,14 +142,6 @@ if( CMAKE_COMPILER_IS_GNUCXX )
endif( CMAKE_COMPILER_IS_GNUCXX )
-if( wxUSE_UNICODE )
- add_definitions( -DwxUSE_UNICODE )
-endif()
-
-if( KICAD_GOST )
- add_definitions( -DKICAD_GOST )
-endif()
-
if( KICAD_KEEPCASE )
add_definitions( -DKICAD_KEEPCASE )
endif()
@@ -393,6 +375,7 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema )
add_subdirectory( gerbview )
add_subdirectory( kicad )
+add_subdirectory( lib_dxf )
add_subdirectory( pcbnew )
add_subdirectory( polygon )
add_subdirectory( pagelayout_editor )
@@ -442,20 +425,26 @@ endif()
#================================================
-# make uninstall rules
+# "make uninstall" rules
#================================================
configure_file(
- "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
- IMMEDIATE @ONLY )
+ "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY )
add_custom_target( uninstall
- "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
#================================================
-# Installation parameters
+# Installation
#================================================
+
+add_custom_target( install_user_configuration_files
+ "${CMAKE_COMMAND}" -E copy "${PROJECT_SOURCE_DIR}/template/fp-lib-table" ${KICAD_USER_CONFIG_DIR}/
+ COMMENT "Install template fp-lib-table into your home directory."
+ )
+
install( FILES INSTALL.txt
DESTINATION ${KICAD_DOCS}
COMPONENT resources )
@@ -469,15 +458,16 @@ install( FILES resources/freeroute.jnlp
###
if( UNIX )
install( DIRECTORY scripts
- DESTINATION ${KICAD_DOCS}
- COMPONENT resources
- PATTERN ".svn" EXCLUDE )
+ DESTINATION ${KICAD_DOCS}
+ COMPONENT resources
+ )
endif()
###
# FreeDesktop .desktop and MIME resources
###
if( UNIX )
+
# Set paths
set( UNIX_MIME_DIR resources/linux/mime )
set( UNIX_MIMELNK_FILES ${UNIX_MIME_DIR}/mimelnk )
@@ -489,25 +479,46 @@ if( UNIX )
install( DIRECTORY ${UNIX_MIMELNK_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
COMPONENT resources
- PATTERN ".svn" EXCLUDE )
+ )
# Install Mime directory
install( DIRECTORY ${UNIX_ICONS_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
COMPONENT resources
- PATTERN ".svn" EXCLUDE )
+ )
# Install Icons
install( DIRECTORY ${UNIX_MIME_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
COMPONENT resources
- PATTERN ".svn" EXCLUDE )
+ )
# Install Applications directory (.desktop files)
install( DIRECTORY ${UNIX_APPLICATIONS_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
COMPONENT resources
- PATTERN ".svn" EXCLUDE )
+ )
endif()
-include( CTest )
+#include( CTest )
+
+
+if( UNIX AND NOT APPLE )
+
+ # Create a *.deb file:
+ set( CPACK_GENERATOR "DEB" )
+ set( CPACK_DEBIAN_PACKAGE_MAINTAINER "http://launchpad.net/kicad" )
+
+ set( CPACK_PACKAGE_VERSION_MAJOR 1 )
+ set( CPACK_PACKAGE_VERSION_MINOR 0 )
+ set( CPACK_PACKAGE_VERSION_PATCH 0 )
+ #set( CPACK_PACKAGE_CONTACT Firstname Lastname )
+ set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." )
+
+ # Tell debian CPack about all files which are configuration files
+ add_conffiles() # clear file
+ add_conffiles( ${KICAD_USER_CONFIG_DIR}/fp-lib-table ) # append to it
+
+ include( CPack )
+
+endif()
diff --git a/CMakeModules/CreateBzrVersionHeader.cmake b/CMakeModules/CreateBzrVersionHeader.cmake
index 38f0f0b7d3..a17a48ebda 100644
--- a/CMakeModules/CreateBzrVersionHeader.cmake
+++ b/CMakeModules/CreateBzrVersionHeader.cmake
@@ -56,11 +56,7 @@ macro( create_bzr_version_header )
if( Kicad_REPO_LAST_CHANGED_DATE )
string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3"
_kicad_bzr_date ${Kicad_REPO_LAST_CHANGED_DATE} )
- if( KICAD_GOST )
- set( KICAD_BUILD_VERSION "(${_kicad_bzr_date} BZR ${Kicad_REPO_REVISION} GOST)" )
- else( KICAD_GOST )
- set( KICAD_BUILD_VERSION "(${_kicad_bzr_date} BZR ${Kicad_REPO_REVISION})" )
- endif( KICAD_GOST )
+ set( KICAD_BUILD_VERSION "(${_kicad_bzr_date} BZR ${Kicad_REPO_REVISION})" )
# Definition to conditionally use date and revision returned from the
# Bazaar log command instead of hand coded date and revision in
diff --git a/CMakeModules/Functions.cmake b/CMakeModules/Functions.cmake
index 3d9ec9d21b..e3d7f8c9ec 100644
--- a/CMakeModules/Functions.cmake
+++ b/CMakeModules/Functions.cmake
@@ -55,3 +55,17 @@ function( make_lexer inputFile outHeaderFile outCppFile enum )
endfunction()
+
+# Is a macro instead of function so there's a higher probability that the
+# scope of CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA is global
+macro( add_conffiles )
+ if( ${ARGC} STREQUAL "0" )
+ # remove the file when user passes no arguments, which he should do exactly once at top
+ file( REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conffiles )
+ else()
+ foreach( filename ${ARGV} )
+ file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/conffiles "${filename}\n" )
+ endforeach()
+ set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/conffiles )
+ endif()
+endmacro( add_conffiles )
diff --git a/CMakeModules/PerformFeatureChecks.cmake b/CMakeModules/PerformFeatureChecks.cmake
index e1cc304ab6..86ad7c5a84 100644
--- a/CMakeModules/PerformFeatureChecks.cmake
+++ b/CMakeModules/PerformFeatureChecks.cmake
@@ -63,11 +63,11 @@ macro(perform_feature_checks)
# included in pyport.h which is where the problem ocurrs without this
# fix.
check_include_file("stdint.h" HAVE_STDINT_H)
-
+
if( HAVE_STDINT_H )
add_definitions( -DHAVE_STDINT_H )
endif()
-
+
# no place is this used, and "HAVE_STRINGS_H", if present in config.h then
# conflicts with /usr/include/python2.6/Python.h. Please rename the macro if
# re-introduce this.
@@ -81,14 +81,8 @@ macro(perform_feature_checks)
# Some platforms define malloc and free in malloc.h instead of stdlib.h.
check_symbol_exists(malloc "stdlib.h" MALLOC_IN_STDLIB_H)
- # Use ISO C++ conformant names to disable Visual C++ warnings.
- check_symbol_exists(_stricmp "string.h" HAVE_ISO_STRICMP)
- check_symbol_exists(_strnicmp "string.h" HAVE_ISO_STRNICMP)
- check_symbol_exists(_snprintf "stdio.h" HAVE_ISO_SNPRINTF)
-
# Check for functions in math.h.
check_include_file("math.h" HAVE_MATH_H)
- check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)
# Check for functions in C++ cmath.
check_include_file_cxx(cmath HAVE_CXX_CMATH)
diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in
index 1a2e75c7ae..fdb4804295 100644
--- a/CMakeModules/cmake_uninstall.cmake.in
+++ b/CMakeModules/cmake_uninstall.cmake.in
@@ -8,13 +8,13 @@ string( REGEX REPLACE "\n" ";" files "${files}" )
foreach( file ${files} )
message( STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"" )
if( EXISTS "$ENV{DESTDIR}${file}" )
- EXEC_PROGRAM(
+ exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
- if( NOT "${rm_retval}" STREQUAL 0 )
- message( FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"" )
+ if( NOT "${rm_retval}" STREQUAL "0" )
+ message( STATUS "Problem when removing \"$ENV{DESTDIR}${file}\"" )
endif()
else()
message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." )
diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake
index 7f8cd4cd19..da209b0b39 100644
--- a/CMakeModules/config.h.cmake
+++ b/CMakeModules/config.h.cmake
@@ -7,27 +7,9 @@
#cmakedefine HAVE_STRNCASECMP
-#cmakedefine HAVE_ISO_STRICMP
-
-#cmakedefine HAVE_ISO_STRNICMP
-
-#cmakedefine HAVE_ISO_SNPRINTF
-
-#if defined( HAVE_ISO_SNPRINTF )
-#define snprintf _snprintf
-#endif
-
-
// Handle platform differences in math.h
#cmakedefine HAVE_MATH_H
-#cmakedefine HAVE_ISO_HYPOT
-
-#if defined( HAVE_ISO_HYPOT )
-#define hypot _hypot
-#endif
-
-
// Handle platform differences in C++ cmath.
#cmakedefine HAVE_CXX_CMATH
@@ -57,14 +39,10 @@
#if defined( HAVE_STRCASECMP )
#define stricmp strcasecmp
-#elif defined( HAVE_ISO_STRICMP )
-#define stricmp _stricmp
#endif
#if defined( HAVE_STRNCASECMP )
#define strnicmp strncasecmp
-#elif defined( HAVE_ISO_STRNICMP )
-#define strnicmp _strnicmp
#endif
// Use Posix getc_unlocked() instead of getc() when it's available.
diff --git a/CMakeModules/download_avhttp.cmake b/CMakeModules/download_avhttp.cmake
new file mode 100644
index 0000000000..6fa9f423b4
--- /dev/null
+++ b/CMakeModules/download_avhttp.cmake
@@ -0,0 +1,59 @@
+# This program source code file is part of KICAD, a free EDA CAD application.
+#
+# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck
+# Copyright (C) 2013 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
+
+
+
+# Download av_http and install into ${PREFIX}, typically in our KiCad source tree.
+# Assumes include( ExternalProject ) was done inline previous to this file
+# and that set( DOWNLOAD_DIR ... ) was set in a higher context.
+
+#------------------------------------------------------------------------------------------
+
+# soon cmake will have https support, switch to a true download then:
+#set( AVHTTP_RELEASE ??? )
+#set( AVHTTP_MD5 ???? ) # re-calc this on every RELEASE change
+
+#----------------------------------------------------------------------------------------
+
+
+# Where the library is to be installed.
+set( PREFIX ${DOWNLOAD_DIR}/avhttp )
+
+
+# Install the AVHTTP header only library ${PREFIX}
+ExternalProject_Add( avhttp
+ PREFIX ${PREFIX}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR} # no true download yet
+
+ # grab it from a local zip file for now, cmake caller's source dir
+ URL ${CMAKE_CURRENT_SOURCE_DIR}/avhttp-master.zip
+ DEPENDS boost
+
+ CONFIGURE_COMMAND ""
+
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory
+ )
+
+
+set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" )
+mark_as_advanced( AVHTTP_INCLUDE_DIR )
diff --git a/CMakeModules/download_boost.cmake b/CMakeModules/download_boost.cmake
index 02d2add3e3..53786baed0 100644
--- a/CMakeModules/download_boost.cmake
+++ b/CMakeModules/download_boost.cmake
@@ -29,13 +29,8 @@
#---------------------------------------------------------------------
-if( false )
- set( BOOST_RELEASE 1.53.0 )
- set( BOOST_MD5 a00d22605d5dbcfb4c9936a9b35bc4c2 ) # re-calc this on every RELEASE change
-else()
- set( BOOST_RELEASE 1.54.0 )
- set( BOOST_MD5 15cb8c0803064faef0c4ddf5bc5ca279 ) # re-calc this on every RELEASE change
-endif()
+set( BOOST_RELEASE 1.54.0 )
+set( BOOST_MD5 15cb8c0803064faef0c4ddf5bc5ca279 ) # re-calc this on every RELEASE change
# The boost headers [and static libs if built] go here, at the top of KiCad
# source tree in boost_root.
@@ -44,15 +39,22 @@ set( BOOST_ROOT "${PROJECT_SOURCE_DIR}/boost_root" )
if( BUILD_GITHUB_PLUGIN )
# Space separated list which indicates the subset of boost libraries to compile.
+ # Chosen libraries are based on AVHTTP requirements, and possibly
+ # unit_test_framework for its own worth.
set( BOOST_LIBS_BUILT
- #filesystem
- system
- #regex
- #program_options
- #date_time
- #thread
+ #context
+ #coroutine
+ date_time
#exception
- unit_test_framework
+ filesystem
+ iostreams
+ locale
+ program_options
+ regex
+ #signals
+ system
+ thread
+ #unit_test_framework
)
endif()
@@ -73,35 +75,54 @@ set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )
set( headers_src "${PREFIX}/src/boost/boost" )
-# don't look at this:
function( set_boost_lib_names libs output )
foreach( lib ${libs} )
- set( fullpath_lib, "${BOOST_ROOT}/lib/libboost_${lib}.a" )
- message( STATUS "fullpath_lib:${fullpath_lib}" )
- set( output ${output} ${fullpath_lib} )
+ set( fullpath_lib "${BOOST_ROOT}/lib/libboost_${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}" )
+ list( APPEND results ${fullpath_lib} )
endforeach()
+ # set the results into variable represented by output into caller's scope
+ set( ${output} ${results} PARENT_SCOPE )
endfunction()
if( BUILD_GITHUB_PLUGIN )
- # (BTW "test" yields "unit_test_framework" when passed to bootstrap.{sh,bat} ).
- message( STATUS "BOOST_LIBS_BUILT:${BOOST_LIBS_BUILT}" )
- string( REPLACE "unit_test_framework" "test" libs_csv "${BOOST_LIBS_BUILT}" )
- message( STATUS "REPLACE libs_csv:${libs_csv}" )
+ # It will probably be simpler to make this the only path in the future.
- string( REGEX REPLACE "\\;" "," libs_csv "${libs_csv}" )
- message( STATUS "libs_csv:${libs_csv}" )
+ # (BTW "test" yields "unit_test_framework" when passed to bootstrap.sh ).
+ #message( STATUS "BOOST_LIBS_BUILT:${BOOST_LIBS_BUILT}" )
+ string( REPLACE "unit_test_framework" "test" boost_libs_list "${BOOST_LIBS_BUILT}" )
+ #message( STATUS "REPLACE libs_csv:${boost_libs_list}" )
if( MINGW )
- set( bootstrap "bootstart.bat mingw" )
+ 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
+ # version 1.54.
+ set( bootstrap cmd.exe /c "bootstrap.bat mingw" )
+ else()
+ set( bootstrap ./bootstrap.bat mingw )
+ endif()
+
+ foreach( lib ${boost_libs_list} )
+ set( b2_libs ${b2_libs} --with-${lib} )
+ endforeach()
+ unset( PIC_STUFF )
else()
- set( bootstrap bootstrap.sh )
+ 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( PIC_STUFF "cflags=${PIC_FLAG}" )
+ set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
+ unset( b2_libs )
endif()
ExternalProject_Add( boost
PREFIX "${PREFIX}"
DOWNLOAD_DIR "${DOWNLOAD_DIR}"
+ INSTALL_DIR "${BOOST_ROOT}"
URL http://downloads.sourceforge.net/project/boost/boost/${BOOST_RELEASE}/boost_${BOOST_VERS}.tar.bz2
URL_MD5 ${BOOST_MD5}
@@ -114,28 +135,56 @@ if( BUILD_GITHUB_PLUGIN )
BINARY_DIR "${PREFIX}/src/boost/"
CONFIGURE_COMMAND ${bootstrap}
- --with-libraries=${libs_csv}
- BUILD_COMMAND b2
+ BUILD_COMMAND ./b2
variant=release
threading=multi
toolset=gcc
- link=static
- --prefix=${BOOST_ROOT}
+ ${PIC_STUFF}
+ ${b2_libs}
+ #link=static
+ --prefix=
install
INSTALL_COMMAND ""
)
- file( GLOB boost_libs "${BOOST_ROOT}/lib/*" )
- #message( STATUS BOOST_ROOT:${BOOST_ROOT} boost_libs:${boost_libs} )
- set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" )
- set( Boost_INCLUDE_DIR "${BOOST_ROOT}/include" CACHE FILEPATH "Boost include directory" )
+ if( MINGW )
+ execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.[0-9]+.*" "\\1\\2" BOOST_GCC_VERSION ${GCC_VERSION} )
+ #message( STATUS "BOOST_GCC_VERSION: ${BOOST_GCC_VERSION}" )
+
+ string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9])" "\\1_\\2" BOOST_LIB_VERSION ${BOOST_RELEASE} )
+ #message( STATUS "BOOST_LIB_VERSION: ${BOOST_LIB_VERSION}" )
+
+ # adjust the names of the libraries to suit the build. There's no
+ # symbolic links provided on the MinGW build to allow us to use
+ # generic names for the libs
+ foreach( lib ${BOOST_LIBS_BUILT} )
+ set( mingw_boost_libs ${mingw_boost_libs} ${lib}-mgw${BOOST_GCC_VERSION}-mt-${BOOST_LIB_VERSION} )
+ endforeach()
+
+ set( BOOST_LIBS_BUILT ${mingw_boost_libs} )
+ set( BOOST_INCLUDE "${BOOST_ROOT}/include/boost-${BOOST_LIB_VERSION}" )
+ unset( mingw_boost_libs )
+ endif()
+
+ set( boost_libs "" )
+ set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs )
+
+ set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" )
+ set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" )
+
+ mark_as_advanced( Boost_LIBRARIES Boost_INCLUDE_DIR )
+
+ #message( STATUS "BOOST_ROOT:${BOOST_ROOT} BOOST_LIBRARIES:${BOOST_LIBRARIES}" )
+ #message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" )
else( BUILD_GITHUB_PLUGIN )
-
ExternalProject_Add( boost
PREFIX "${PREFIX}"
DOWNLOAD_DIR "${DOWNLOAD_DIR}"
diff --git a/CMakeModules/download_openssl.cmake b/CMakeModules/download_openssl.cmake
new file mode 100644
index 0000000000..18c4cc37b7
--- /dev/null
+++ b/CMakeModules/download_openssl.cmake
@@ -0,0 +1,149 @@
+# This program source code file is part of KICAD, a free EDA CAD application.
+#
+# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck
+# Copyright (C) 2013 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
+
+
+
+# Download OPENSSL and install into ${PREFIX}, typically in our KiCad source tree.
+# Assumes include( ExternalProject ) was done inline previous to this file
+# and that set( DOWNLOAD_DIR ... ) was set in a higher context.
+
+#------------------------------------------------------------------------------------------
+
+set( OPENSSL_RELEASE "1.0.1e" )
+set( OPENSSL_MD5 66bf6f10f060d561929de96f9dfe5b8c ) # re-calc on every RELEASE change
+
+#----------------------------------------------------------------------------------------
+
+unset( PIC_FLAG )
+set( CFLAGS CFLAGS=${CMAKE_C_FLAGS} )
+
+if( MINGW ) # either MINGW or cross compiling?
+ if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+ set( MINGW32 true )
+ set( MACHINE x86_32 )
+ elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+ set( MINGW64 true )
+ set( MACHINE x86_64 )
+ endif()
+
+ if( MINGW32 )
+ set( HOST "--host=i586-pc-mingw32" )
+ elseif( MINGW64 )
+ set( HOST "--host=x86_64-pc-mingw32" )
+ endif()
+
+ set( CC "CC=${CMAKE_C_COMPILER}" )
+ set( RANLIB "RANLIB=${CMAKE_RANLIB}" )
+ set( AR "AR=${CMAKE_AR}" )
+else()
+ set( PIC_FLAG -fPIC )
+endif()
+
+string( TOLOWER ${CMAKE_HOST_SYSTEM_NAME} build )
+
+# Force some configure scripts into knowing this is a cross-compilation, if it is.
+set( BUILD --build=${CMAKE_HOST_SYSTEM_PROCESSOR}-pc-${build} )
+
+
+# http://www.blogcompiler.com/2011/12/21/openssl-for-windows/
+# http://qt-project.org/wiki/Compiling-OpenSSL-with-MinGW
+set( PREFIX ${DOWNLOAD_DIR}/openssl-${OPENSSL_RELEASE} )
+
+unset( CROSS )
+if( MINGW32 )
+ set( MW mingw )
+ set( CROSS "CROSS_COMPILE=${CROSS_COMPILE}" )
+elseif( MINGW64 )
+ set( MW mingw64 )
+ set( CROSS "CROSS_COMPILE=${CROSS_COMPILE}" )
+endif()
+
+ExternalProject_Add(
+ openssl
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ PREFIX ${PREFIX}
+ TIMEOUT 60
+ URL http://www.openssl.org/source/openssl-${OPENSSL_RELEASE}.tar.gz
+ URL_MD5 ${OPENSSL_MD5}
+
+ # mingw uses msvcrt.dll's printf() which cannot handle %zd, so having
+ # BIO_snprintf() reference printf()'s formating attributes is a bug, since
+ # BIO_snprintf() does its own formatting and is different from msvcrt's printf().
+
+ # This one would be easier if Windows folks could be asked to install "patch.exe"
+ # PATCH_COMMAND patch -p0 < ${PROJECT_SOURCE_DIR}/patches/openssl-1.0.1e.patch
+
+ # This one requires the bzr commit below, since bzr patch only knows a working tree.
+ PATCH_COMMAND bzr patch -p0 ${PROJECT_SOURCE_DIR}/patches/openssl-1.0.1e.patch
+
+ # this requires that perl be installed:
+ CONFIGURE_COMMAND
+ ${CROSS}
+ /Configure
+ ${MW}
+ --prefix=
+ ${PIC_FLAG} # empty for MINGW
+ shared
+
+ BUILD_IN_SOURCE 1
+ BUILD_COMMAND make depend
+ COMMAND make
+ INSTALL_COMMAND make install
+ )
+
+# In order to use "bzr patch", we have to have a bzr working tree, this means a bzr repo
+# must be created and source committed to it. These extra steps do that.
+
+set( target "openssl" )
+
+ExternalProject_Add_Step( ${target} bzr_commit_${target}
+ COMMAND bzr ci -q -m pristine
+ COMMENT "committing pristine ${target} files to '${target} scratch repo'"
+ DEPENDERS patch
+ )
+
+ExternalProject_Add_Step( ${target} bzr_add_${target}
+ COMMAND bzr add -q
+ COMMENT "adding pristine ${target} files to '${target} scratch repo'"
+ DEPENDERS bzr_commit_${target}
+ )
+
+ExternalProject_Add_Step( ${target} bzr_init_${target}
+ COMMAND bzr init -q
+ COMMENT "creating '${target} scratch repo' specifically for tracking ${target} patches"
+ DEPENDERS bzr_add_${target}
+ DEPENDEES download
+ )
+
+# The spelling of these is always taken from CMake Module's FindXYZ.cmake file:
+set( OPENSSL_INCLUDE_DIR
+ ${PREFIX}/include
+ CACHE FILEPATH "OPENSSL include directory"
+ )
+
+set( OPENSSL_LIBRARIES
+ ${PREFIX}/lib/libssl.a
+ ${PREFIX}/lib/libcrypto.a
+ CACHE STRING "OPENSSL libraries"
+ )
+set( OPENSSL_FOUND true )
+
diff --git a/Documentation/compiling/build-config.txt b/Documentation/compiling/build-config.txt
index 6daa3618e7..b3bb8ba99a 100644
--- a/Documentation/compiling/build-config.txt
+++ b/Documentation/compiling/build-config.txt
@@ -111,11 +111,6 @@ This option is used to enable or disable building KiCad with images in menu
items. If this is not defined when CMake is used to create the build files,
images will be included in menu items on all platforms except OSX.
-KICAD_GOST (ON/OFF)
--------------------
-This option is used to enable or disable the GOST notation for multiple gates
-per package in Eeschema. The default is OFF
-
KICAD_KEEPCASE (ON/OFF)
-----------------------
This option enables or disables turning off the automatic component name
diff --git a/Documentation/guidelines/UIpolicies.txt b/Documentation/guidelines/UIpolicies.txt
index a8d3a45d7e..7d80c6197e 100644
--- a/Documentation/guidelines/UIpolicies.txt
+++ b/Documentation/guidelines/UIpolicies.txt
@@ -73,4 +73,11 @@ Dialogs:
within the dialog, but for testing purposes please do not exceed this dialog
size should the user have selected a font size of 13 points.
+Quoting:
+ Filenames and paths should be emphasized with <> angle brackets. Anything
+ else should be emphasized with single quotes ''. e.g.:
+
+
+ 'FOOTPRINTNAME'
+ 'anything else'
diff --git a/INSTALL.txt b/INSTALL.txt
index d77f83ebf6..7e1b6e33a1 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -128,13 +128,17 @@ project is created.
Installation from source code
-----------------------------
- Some dependencies must be satisfied for the correct installation of KiCad:
+Some dependencies must be satisfied for the correct installation of KiCad:
under Linux:
wxWidgets >= 2.8.11 http://www.wxwidgets.org/
+(needs to be compiled with unicode support)
under Windows:MacOSX
-wxWidgets >= 2.9.3 http://www.wxwidgets.org/
-CMake >= 2.6.4 http://www.cmake.org/
-Boost C++ Libraries (files used by kicad are provided in kicad sources) http://www.boost.org/
+wxWidgets >= 2.9.4 http://www.wxwidgets.org/
+
+CMake >= 2.8.1 http://www.cmake.org/
+Boost C++ Libraries:
+ files used by kicad are autmatically downloaded and patched if needed
+ from boost site ( http://www.boost.org/ )
OpenGL
Linux: Mesa 3D Graphics Library http://www.mesa3d.org/
Windows: built-in
@@ -186,12 +190,6 @@ configured and builded with "--enable-monolithic --disable-shared" parameters.
For building dinamically linked executables. Can be used only if wxWidgets
configured and builded with "--disable-monolithic --enable-shared" parameters.
--DwxUSE_UNICODE=ON
-Require on locale utf8 for build the KiCad with cyrillic fonts support.
-
--DKICAD_GOST=ON
-Build the KiCad with russian GOST support.
-
-DKICAD_KEEPCASE=ON
Build the KiCad with no component name conversion to uppercase (if you want your
ADuC.../Si.../bq... components named as just so).
diff --git a/TODO.txt b/TODO.txt
index 7a7a30ec34..9e7ac7a7c1 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -140,25 +140,20 @@ PCBNew
various zoom factors. I believe that a fixed distance in pixels might make
for a friendlier UI.
-*) Check that the new load visibility BOARD settings is properly setting the toolbar
- buttons like show grid or ratsnest. Add PCB_EDIT_FRAME::SetVisibleElements() so
- toolbar crap is not known to a BOARD.
-
-*) Finish removing global access requirements from PLUGINs, so that:
- *) a BOARD is a fully self contained document description.
- *) plugin developers do not have to access globals, since a plugin could
- very well be a dynamically loaded DLL/DSO in the future.
- One final problem remains is the BASE_SCREEN's grid origin. An easy
- solution is to move just that one field into the BOARD.
-
-*) Add ::Footprint*() functions to EAGLE_PLUGIN, so that Eagle footprint libraries
- can be used in situ.
-
-*) Add a library table for Pcbnew like that in the sweet library and get rid of the
- damn search path strategy. This will enable concurrent usage of various types
- of PLUGIN::Footprint*() functions. At least LEGACY and KICAD are both needed
- concurrently.
-
*) Add a hot key to toggle the 45 degree constraint on and off so that it can be
changed when drawing a trace.
+
+Dick's Final TODO List:
+======================
+*) Rewrite
+ PCB_BASE_FRAME::Save_Module_In_Library
+ PCB_EDIT_FRAME::ArchiveModulesOnBoard
+ to use FP_LIB_TABLE mechanisms.
+*) write options dialog for fp table dialog.
+*) Apply Fabrizio and Alexander's linux desktop patches after unifying them.
+*) Get licensing cleaned up.
+*) Re-arrange the repo architecture.
+*) Merge KiCad GAL/TOM/ORSON if nobody else does.
+*) DLL-ization of pcbnew & eeschema
+ http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 7c195331d7..6a226f0b9f 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -126,6 +126,7 @@ set(COMMON_SRCS
filter_reader.cpp
gestfich.cpp
getrunningmicrosecs.cpp
+ grid_tricks.cpp
gr_basic.cpp
hotkeys_basic.cpp
hotkey_grid_table.cpp
@@ -212,11 +213,15 @@ set(PCB_COMMON_SRCS
../pcbnew/sel_layer.cpp
../pcbnew/pcb_plot_params.cpp
../pcbnew/io_mgr.cpp
+ ../pcbnew/plugin.cpp
../pcbnew/eagle_plugin.cpp
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
../pcbnew/gpcb_plugin.cpp
../pcbnew/pcb_netlist.cpp
+ ../pcbnew/specctra.cpp
+ ../pcbnew/specctra_export.cpp
+ ../pcbnew/specctra_keywords.cpp
pcb_plot_params_keywords.cpp
pcb_keywords.cpp
../pcbnew/pcb_parser.cpp
@@ -237,6 +242,17 @@ set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES
add_library(pcbcommon STATIC ${PCB_COMMON_SRCS})
+# auto-generate specctra_lexer.h and specctra_keywords.cpp
+make_lexer(
+ ${PROJECT_SOURCE_DIR}/pcbnew/specctra.keywords
+ ${PROJECT_SOURCE_DIR}/pcbnew/specctra_lexer.h
+ ${PROJECT_SOURCE_DIR}/pcbnew/specctra_keywords.cpp
+ DSN
+
+ # Pass header file with dependency on *_lexer.h as extra_arg
+ specctra.h
+ )
+
# auto-generate netlist_lexer.h and netlist_keywords.cpp
make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
@@ -255,7 +271,7 @@ make_lexer(
${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params_keywords.cpp
PCBPLOTPARAMS_T
- # Pass header file with dependency on *_lexer.h as extra_arg
+ # Pass header file with dependencies on *_lexer.h as extra_arg
${PROJECT_SOURCE_DIR}/pcbnew/pcb_plot_params.h
)
@@ -287,11 +303,7 @@ make_lexer(
TB_READER_T
)
-# The dsntest may not build properly using MS Visual Studio.
-if(NOT MSVC)
- # This one gets made only when testing.
- # to build it, first enable #define STAND_ALONE at top of dsnlexer.cpp
- add_executable( dsntest EXCLUDE_FROM_ALL dsnlexer.cpp )
- target_link_libraries( dsntest common ${wxWidgets_LIBRARIES} rt )
-
-endif( NOT MSVC )
+# This one gets made only when testing.
+# to build it, first enable #define STAND_ALONE at top of dsnlexer.cpp
+add_executable( dsntest EXCLUDE_FROM_ALL dsnlexer.cpp )
+target_link_libraries( dsntest common ${wxWidgets_LIBRARIES} rt )
diff --git a/common/base_struct.cpp b/common/base_struct.cpp
index de90271fd2..9250e1068d 100644
--- a/common/base_struct.cpp
+++ b/common/base_struct.cpp
@@ -38,6 +38,10 @@
#include "../eeschema/dialogs/dialog_schematic_find.h"
+
+const wxString traceFindReplace( wxT( "KicadFindReplace" ) );
+
+
enum textbox {
ID_TEXTBOX_LIST = 8010
};
@@ -190,8 +194,28 @@ bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText )
wxCHECK_MSG( IsReplaceable(), false,
wxT( "Attempt to replace text in <" ) + GetClass() + wxT( "> item." ) );
- return aText.Replace( aSearchData.GetFindString(),
- aSearchData.GetReplaceString(), false ) != 0;
+ wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText.Upper() : aText;
+
+ int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
+ aSearchData.GetFindString() :
+ aSearchData.GetFindString().Upper() );
+
+ if( result == wxNOT_FOUND )
+ return false;
+
+ wxString prefix = aText.Left( result );
+ wxString suffix;
+
+ if( aSearchData.GetFindString().length() + result < aText.length() )
+ suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
+
+ wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
+ GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
+ GetChars( suffix ) );
+
+ aText = prefix + aSearchData.GetReplaceString() + suffix;
+
+ return true;
}
@@ -336,6 +360,36 @@ bool EDA_RECT::Contains( const EDA_RECT& aRect ) const
}
+/* Intersects
+ * test for a common area between segment and rect.
+ * return true if at least a common point is found
+ */
+bool EDA_RECT::Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const
+{
+ wxPoint point2, point4;
+
+ if( Contains( aPoint1 ) || Contains( aPoint2 ) )
+ return true;
+
+ point2.x = GetEnd().x;
+ point2.y = GetOrigin().y;
+ point4.x = GetOrigin().x;
+ point4.y = GetEnd().y;
+
+ //Only need to test 3 sides since a straight line cant enter and exit on same side
+ if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin() , point2 ) )
+ return true;
+
+ if( SegmentIntersectsSegment( aPoint1, aPoint2, point2 , GetEnd() ) )
+ return true;
+
+ if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd() , point4 ) )
+ return true;
+
+ return false;
+}
+
+
/* Intersects
* test for a common area between 2 rect.
* return true if at least a common point is found
diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp
index c59999b9a3..c02f6c1e98 100644
--- a/common/class_bitmap_base.cpp
+++ b/common/class_bitmap_base.cpp
@@ -46,11 +46,12 @@
BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
{
- m_Scale = 1.0; // 1.0 = original bitmap size
+ m_Scale = 1.0; // 1.0 = original bitmap size
m_bitmap = NULL;
m_image = NULL;
- m_pixelScaleFactor = 3.33; // a value OK for bitmaps using 300 PPI
- // (Eeschema uses currently 1000PPI
+ m_ppi = 300; // the bitmap definition. the default is 300PPI
+ m_pixelScaleFactor = 1000.0 / m_ppi; // a value OK for bitmaps using 300 PPI
+ // for Eeschema which uses currently 1000PPI
}
@@ -72,6 +73,7 @@ void BITMAP_BASE::ImportData( BITMAP_BASE* aItem )
*m_image = *aItem->m_image;
*m_bitmap = *aItem->m_bitmap;
m_Scale = aItem->m_Scale;
+ m_ppi = aItem->m_ppi;
m_pixelScaleFactor = aItem->m_pixelScaleFactor;
}
@@ -121,6 +123,35 @@ bool BITMAP_BASE::SaveData( FILE* aFile ) const
return true;
}
+void BITMAP_BASE::SaveData( wxArrayString& aPngStrings ) const
+{
+ if( m_image )
+ {
+ wxMemoryOutputStream stream;
+ m_image->SaveFile( stream, wxBITMAP_TYPE_PNG );
+
+ // Write binary data in hexadecimal form (ASCII)
+ wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
+ char* begin = (char*) buffer->GetBufferStart();
+ wxString line;
+ for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
+ {
+ if( ii >= 32 )
+ {
+ ii = 0;
+ aPngStrings.Add( line );
+ line.Empty();
+ }
+
+ line << wxString::Format( wxT("%2.2X "), *begin & 0xFF );
+ }
+
+ // Add last line:
+ if( !line.IsEmpty() )
+ aPngStrings.Add( line );
+ }
+}
+
bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
{
@@ -130,9 +161,13 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
while( true )
{
if( !aLine.ReadLine() )
+ {
+ aErrorMsg = wxT("Unexpected end of data");
return false;
+ }
line = aLine.Line();
+
if( strnicmp( line, "EndData", 4 ) == 0 )
{
// all the PNG date is read.
diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp
index 468e9085b2..5ed5ec0f55 100644
--- a/common/common_plotGERBER_functions.cpp
+++ b/common/common_plotGERBER_functions.cpp
@@ -67,6 +67,10 @@ bool GERBER_PLOTTER::StartPlot()
if( outputFile == NULL )
return false;
+ /* Set coordinate format to 3.4 absolute, leading zero omitted */
+ fputs( "%FSLAX34Y34*%\n", outputFile );
+ fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n", outputFile );
+
wxString Title = creator + wxT( " " ) + GetBuildVersion();
fprintf( outputFile, "G04 (created by %s) date %s*\n",
TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
@@ -74,10 +78,6 @@ bool GERBER_PLOTTER::StartPlot()
/* Mass parameter: unit = INCHES */
fputs( "%MOIN*%\n", outputFile );
- /* Set coordinate format to 3.4 absolute, leading zero omitted */
- fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n",
- outputFile );
-
/* Specify linear interpol (G01), unit = INCH (G70), abs format (G90) */
fputs( "G01*\nG70*\nG90*\n", outputFile );
fputs( "G04 APERTURE LIST*\n", outputFile );
diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp
index 4ef644430a..0178c8db02 100644
--- a/common/common_plot_functions.cpp
+++ b/common/common_plot_functions.cpp
@@ -35,6 +35,7 @@
#include
#include
#include "worksheet_shape_builder.h"
+#include "class_worksheet_dataitem.h"
#include
@@ -137,6 +138,20 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
poly->IsFilled() ? FILLED_SHAPE : NO_FILL );
}
break;
+
+ case WS_DRAW_ITEM_BASE::wsg_bitmap:
+ {
+ WS_DRAW_ITEM_BITMAP* bm = (WS_DRAW_ITEM_BITMAP*) item;
+
+ WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)bm->GetParent();
+
+ if( parent->m_ImageBitmap == NULL )
+ break;
+
+ parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
+ plotColor, PLOTTER::DEFAULT_LINE_WIDTH );
+ }
+ break;
}
}
}
diff --git a/common/confirm.cpp b/common/confirm.cpp
index 2a76b4e6ba..b44186da9b 100644
--- a/common/confirm.cpp
+++ b/common/confirm.cpp
@@ -1,3 +1,27 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
+ * Copyright (C) 1992-2013 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 confirm.cpp
* @brief utilities to display some error, warning and info short messges
@@ -7,6 +31,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -14,22 +39,25 @@
class DIALOG_EXIT: public DIALOG_EXIT_BASE
{
public:
- DIALOG_EXIT( wxWindow * parent, const wxString& aMessage ) :
- DIALOG_EXIT_BASE( parent )
+ DIALOG_EXIT( wxWindow *aParent, const wxString& aMessage ) :
+ DIALOG_EXIT_BASE( aParent )
{
m_bitmap->SetBitmap( KiBitmap( dialog_warning_xpm ) );
- if( ! aMessage.IsEmpty() )
+
+ if( !aMessage.IsEmpty() )
m_TextInfo->SetLabel( aMessage );
+
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
};
private:
- void OnSaveAndExit( wxCommandEvent& event ) { EndModal( wxID_OK ); }
+ void OnSaveAndExit( wxCommandEvent& event ) { EndModal( wxID_YES ); }
void OnCancel( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); }
void OnExitNoSave( wxCommandEvent& event ) { EndModal( wxID_NO ); }
};
+
int DisplayExitDialog( wxWindow* parent, const wxString& aMessage )
{
DIALOG_EXIT dlg( parent, aMessage );
@@ -38,6 +66,7 @@ int DisplayExitDialog( wxWindow* parent, const wxString& aMessage )
return ret;
}
+
void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
{
wxMessageDialog* dialog;
@@ -76,14 +105,52 @@ void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title,
}
-bool IsOK( wxWindow* parent, const wxString& text )
+bool IsOK( wxWindow* aParent, const wxString& aMessage )
{
- int ii;
+ wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ),
+ wxYES_NO | wxCENTRE | wxICON_HAND );
- ii = wxMessageBox( text, _( "Confirmation" ), wxYES_NO | wxCENTRE | wxICON_HAND, parent );
-
- if( ii == wxYES )
- return true;
-
- return false;
+ return dlg.ShowModal() == wxID_YES;
+}
+
+
+class DIALOG_YES_NO_CANCEL : public DIALOG_EXIT
+{
+public:
+ DIALOG_YES_NO_CANCEL( wxWindow *aParent,
+ const wxString& aPrimaryMessage,
+ const wxString& aSecondaryMessage = wxEmptyString,
+ const wxString& aYesButtonText = wxEmptyString,
+ const wxString& aNoButtonText = wxEmptyString,
+ const wxString& aCancelButtonText = wxEmptyString ) :
+ DIALOG_EXIT( aParent, aSecondaryMessage )
+ {
+ m_TextInfo->SetLabel( aPrimaryMessage );
+
+ if( aSecondaryMessage.IsEmpty() )
+ m_staticText2->Hide();
+
+ m_buttonSaveAndExit->SetLabel( aYesButtonText.IsEmpty() ? wxGetStockLabel( wxID_YES ) :
+ aYesButtonText );
+ m_buttonExitNoSave->SetLabel( aNoButtonText.IsEmpty() ? wxGetStockLabel( wxID_NO ) :
+ aNoButtonText );
+ m_buttonCancel->SetLabel( aCancelButtonText.IsEmpty() ? wxGetStockLabel( wxID_CANCEL ) :
+ aCancelButtonText );
+ GetSizer()->Fit( this );
+ GetSizer()->SetSizeHints( this );
+ };
+};
+
+
+int YesNoCancelDialog( wxWindow* aParent,
+ const wxString& aPrimaryMessage,
+ const wxString& aSecondaryMessage,
+ const wxString& aYesButtonText,
+ const wxString& aNoButtonText,
+ const wxString& aCancelButtonText )
+{
+ DIALOG_YES_NO_CANCEL dlg( aParent, aPrimaryMessage, aSecondaryMessage,
+ aYesButtonText, aNoButtonText, aCancelButtonText );
+
+ return dlg.ShowModal();
}
diff --git a/common/dialogs/dialog_hotkeys_editor.cpp b/common/dialogs/dialog_hotkeys_editor.cpp
index 25aea233a5..a1457febca 100644
--- a/common/dialogs/dialog_hotkeys_editor.cpp
+++ b/common/dialogs/dialog_hotkeys_editor.cpp
@@ -54,7 +54,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
m_hotkeys = hotkeys;
m_curEditingRow = -1;
- m_table = new HotkeyGridTable( hotkeys );
+ m_table = new HOTKEY_EDITOR_GRID_TABLE( hotkeys );
m_hotkeyGrid->SetTable( m_table, true );
m_hotkeyGrid->AutoSizeColumn( 0 );
@@ -76,7 +76,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
{
/* edit the live hotkey table */
- HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
+ HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
EDA_HOTKEY_CONFIG* section;
@@ -91,7 +91,7 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
EDA_HOTKEY* info = *info_ptr;
/* find the corresponding hotkey */
- HotkeyGridTable::hotkey_spec_vector::iterator i;
+ HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector::iterator i;
for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
{
@@ -158,7 +158,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event )
int newRow = event.GetRow();
- if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) )
+ if( ( event.GetCol() != 1 ) || ( m_table->IsHeader( newRow ) ) )
{
m_curEditingRow = -1;
}
diff --git a/common/dialogs/dialog_hotkeys_editor_base.cpp b/common/dialogs/dialog_hotkeys_editor_base.cpp
index 401015f1b6..175ab779ee 100644
--- a/common/dialogs/dialog_hotkeys_editor_base.cpp
+++ b/common/dialogs/dialog_hotkeys_editor_base.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Sep 8 2010)
+// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
-HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
+HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( 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 );
@@ -55,8 +55,10 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind
m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 );
b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
+
bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
+
this->SetSizer( bMainSizer );
this->Layout();
diff --git a/common/dialogs/dialog_hotkeys_editor_base.fbp b/common/dialogs/dialog_hotkeys_editor_base.fbp
index d89482acaf..a4cb362dfa 100644
--- a/common/dialogs/dialog_hotkeys_editor_base.fbp
+++ b/common/dialogs/dialog_hotkeys_editor_base.fbp
@@ -2,11 +2,13 @@
*/
- bool writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList );
+ bool writeListOfNetsCADSTAR( FILE* f );
/**
* Function makeGenericRoot
@@ -229,6 +229,10 @@ class NETLIST_EXPORT_TOOL
XNODE* makeGenericLibraries();
public:
+ NETLIST_EXPORT_TOOL( NETLIST_OBJECT_LIST * aMasterList )
+ {
+ m_masterList = aMasterList;
+ }
/**
* Function WriteKiCadNetList
@@ -353,6 +357,8 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
/* Function WriteNetListFile
* creates the netlist file. Netlist info must be existing
+ * (call BuildNetListBase() to create this info )
+ * param aConnectedItemsList = the initialized list of connected items
* param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* param aFullFileName = full netlist file name
* param aNetlistOptions = netlist options using OR'ed bits.
@@ -360,12 +366,13 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
* return true if success.
*/
-bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileName,
+bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList,
+ int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions )
{
bool ret = true;
FILE* f = NULL;
- NETLIST_EXPORT_TOOL helper;
+ NETLIST_EXPORT_TOOL helper( aConnectedItemsList );
bool open_file = aFormat < NET_TYPE_CUSTOM1;
if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) )
@@ -438,8 +445,6 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
DBG(printf("commandLine:'%s'\n", TO_UTF8( commandLine ) );)
ProcessExecute( commandLine, wxEXEC_SYNC );
-
- // ::wxRemoveFile( tmpFile.GetFullPath() );
}
break;
}
@@ -462,7 +467,7 @@ static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
}
-void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString* aResult,
+void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString& aResult,
const wxString& aNetNameFormat, NETLIST_OBJECT* aPin )
{
int netcode = aPin->GetNet();
@@ -470,34 +475,14 @@ void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString* aResult,
// Not wxString::Clear(), which would free memory. We want the worst
// case wxString memory to grow to avoid reallocation from within the
// caller's loop.
- aResult->Empty();
+ aResult.Empty();
- if( netcode != 0 && aPin->m_FlagOfConnection == PAD_CONNECT )
+ if( netcode != 0 && aPin->GetConnectionType() == PAD_CONNECT )
{
- NETLIST_OBJECT* netref = aPin->m_NetNameCandidate;
- if( netref )
- *aResult = netref->m_Label;
+ aResult = aPin->GetNetName();
- if( !aResult->IsEmpty() )
- {
- // prefix non global label names with the sheet path, to avoid name collisions
- if( netref->m_Type != NET_PINLABEL && netref->m_Type != NET_GLOBLABEL )
- {
- wxString lnet = *aResult;
-
- *aResult = netref->m_SheetList.PathHumanReadable();
-
- // If sheet path is too long, use the time stamp name instead
- if( aResult->Length() > 32 )
- *aResult = netref->m_SheetList.Path();
-
- *aResult += lnet;
- }
- }
- else
- {
- aResult->Printf( aNetNameFormat.GetData(), netcode );
- }
+ if( aResult.IsEmpty() ) // No net name: give a name from net code
+ aResult.Printf( aNetNameFormat.GetData(), netcode );
}
}
@@ -871,31 +856,16 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericListOfNets()
m_LibParts.clear(); // must call this function before using m_LibParts.
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
{
- NETLIST_OBJECT* nitem = g_NetObjectslist[ii];
+ NETLIST_OBJECT* nitem = m_masterList->GetItem( ii );
SCH_COMPONENT* comp;
// New net found, write net id;
if( ( netCode = nitem->GetNet() ) != lastNetCode )
{
sameNetcodeCount = 0; // item count for this net
-
- netName.Empty();
-
- // Find a label for this net, if it exists.
- NETLIST_OBJECT* netref = nitem->m_NetNameCandidate;
- if( netref )
- {
- if( netref->m_Type != NET_PINLABEL && netref->m_Type != NET_GLOBLABEL )
- {
- // usual net name, prefix it by the sheet path
- netName = netref->m_SheetList.PathHumanReadable();
- }
-
- netName += netref->m_Label;
- }
-
+ netName = nitem->GetNetName();
lastNetCode = netCode;
}
@@ -905,10 +875,10 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericListOfNets()
if( nitem->m_Flag != 0 ) // Redundant pin, skip it
continue;
- comp = (SCH_COMPONENT*) nitem->m_Link;
+ comp = nitem->GetComponentParent();
// Get the reference for the net name and the main parent component
- ref = comp->GetRef( &nitem->m_SheetList );
+ ref = comp->GetRef( &nitem->m_SheetPath );
if( ref[0] == wxChar( '#' ) )
continue;
@@ -1069,8 +1039,8 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericComponents()
bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
{
// Prepare list of nets generation
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
- g_NetObjectslist[ii]->m_Flag = 0;
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
+ m_masterList->GetItem( ii )->m_Flag = 0;
std::auto_ptr xroot( makeGenericRoot() );
@@ -1092,8 +1062,8 @@ bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName )
{
// Prepare list of nets generation
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
- g_NetObjectslist[ii]->m_Flag = 0;
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
+ m_masterList->GetItem( ii )->m_Flag = 0;
// output the XML format netlist.
wxXmlDocument xdoc;
@@ -1125,8 +1095,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
// Prepare list of nets generation (not used here, but...
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
- g_NetObjectslist[ii]->m_Flag = 0;
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
+ m_masterList->GetItem( ii )->m_Flag = 0;
ret |= fprintf( f, "* To exclude a component from the Spice Netlist add [Spice_Netlist_Enabled] user FIELD set to: N\n" );
ret |= fprintf( f, "* To reorder the component spice node sequence add [Spice_Node_Sequence] user FIELD and define sequence: 2,1,0\n" );
@@ -1316,7 +1286,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
if( !pin )
continue;
- sprintPinNetName( &netName , wxT( "N-%.6d" ), pin );
+ sprintPinNetName( netName , wxT( "N-%.6d" ), pin );
if( netName.IsEmpty() )
netName = wxT( "?" );
@@ -1404,8 +1374,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
// Prepare list of nets generation
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
- g_NetObjectslist[ii]->m_Flag = 0;
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
+ m_masterList->GetItem( ii )->m_Flag = 0;
// Create netlist module section
m_ReferencesAlreadyFound.Clear();
@@ -1470,7 +1440,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
if( !pin )
continue;
- sprintPinNetName( &netName, wxT( "N-%.6d" ), pin );
+ sprintPinNetName( netName, wxT( "N-%.6d" ), pin );
if( netName.IsEmpty() )
netName = wxT( "?" );
@@ -1521,7 +1491,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
{
ret |= fprintf( f, "{ Pin List by Nets\n" );
- if( !writeGENERICListOfNets( f, g_NetObjectslist ) )
+ if( !writeGENERICListOfNets( f, *m_masterList ) )
ret = -1;
ret |= fprintf( f, "}\n" );
@@ -1536,9 +1506,9 @@ bool NETLIST_EXPORT_TOOL::addPinToComponentPinList( SCH_COMPONENT* aComponent,
SCH_SHEET_PATH* aSheetPath, LIB_PIN* aPin )
{
// Search the PIN description for Pin in g_NetObjectslist
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
{
- NETLIST_OBJECT* pin = g_NetObjectslist[ii];
+ NETLIST_OBJECT* pin = m_masterList->GetItem( ii );
if( pin->m_Type != NET_PIN )
continue;
@@ -1550,7 +1520,7 @@ bool NETLIST_EXPORT_TOOL::addPinToComponentPinList( SCH_COMPONENT* aComponent,
continue;
// most expensive test at the end.
- if( pin->m_SheetList != *aSheetPath )
+ if( pin->m_SheetPath != *aSheetPath )
continue;
m_SortedComponentPinList.push_back( pin );
@@ -1601,7 +1571,7 @@ void NETLIST_EXPORT_TOOL::eraseDuplicatePins( )
if( m_SortedComponentPinList[idxref]->m_PinNum != m_SortedComponentPinList[jj]->m_PinNum )
break;
- if( m_SortedComponentPinList[idxref]->m_FlagOfConnection == PAD_CONNECT )
+ if( m_SortedComponentPinList[idxref]->GetConnectionType() == PAD_CONNECT )
{
m_SortedComponentPinList[jj]->m_Flag = 1;
m_SortedComponentPinList[jj] = NULL;
@@ -1609,7 +1579,7 @@ void NETLIST_EXPORT_TOOL::eraseDuplicatePins( )
else /* the reference pin is not connected: remove this pin if the
* other pin is connected */
{
- if( m_SortedComponentPinList[jj]->m_FlagOfConnection == PAD_CONNECT )
+ if( m_SortedComponentPinList[jj]->GetConnectionType() == PAD_CONNECT )
{
m_SortedComponentPinList[idxref]->m_Flag = 1;
m_SortedComponentPinList[idxref] = NULL;
@@ -1682,49 +1652,33 @@ bool NETLIST_EXPORT_TOOL::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST&
for( unsigned ii = 0; ii < aObjectsList.size(); ii++ )
{
SCH_COMPONENT* comp;
+ NETLIST_OBJECT* nitem = aObjectsList[ii];
// New net found, write net id;
- if( ( netCode = aObjectsList[ii]->GetNet() ) != lastNetCode )
+ if( ( netCode = nitem->GetNet() ) != lastNetCode )
{
sameNetcodeCount = 0; // Items count for this net
- netName.Empty();
-
- // Find a label (if exists) for this net.
- NETLIST_OBJECT* netref;
- netref = aObjectsList[ii]->m_NetNameCandidate;
- if( netref )
- netName = netref->m_Label;
+ netName = nitem->GetNetName();
netcodeName.Printf( wxT( "Net %d " ), netCode );
- netcodeName += wxT( "\"" );
- if( !netName.IsEmpty() )
- {
- if( ( netref->m_Type != NET_PINLABEL )
- && ( netref->m_Type != NET_GLOBLABEL ) )
- {
- // usual net name, prefix it by the sheet path
- netcodeName += netref->m_SheetList.PathHumanReadable();
- }
- netcodeName += netName;
- }
- netcodeName += wxT( "\"" );
+ netcodeName << wxT( "\"" ) << netName << wxT( "\"" );
// Add the netname without prefix, in cases we need only the
// "short" netname
- netcodeName += wxT( " \"" ) + netName + wxT( "\"" );
+ netcodeName += wxT( " \"" ) + nitem->GetShortNetName() + wxT( "\"" );
lastNetCode = netCode;
}
- if( aObjectsList[ii]->m_Type != NET_PIN )
+ if( nitem->m_Type != NET_PIN )
continue;
- if( aObjectsList[ii]->m_Flag != 0 ) // Redundant pin, skip it
+ if( nitem->m_Flag != 0 ) // Redundant pin, skip it
continue;
- comp = (SCH_COMPONENT*) aObjectsList[ii]->m_Link;
+ comp = nitem->GetComponentParent();
// Get the reference for the net name and the main parent component
- ref = comp->GetRef( &aObjectsList[ii]->m_SheetList );
+ ref = comp->GetRef( &nitem->m_SheetPath );
if( ref[0] == wxChar( '#' ) )
continue; // Pseudo component (Like Power symbol)
@@ -1750,7 +1704,7 @@ bool NETLIST_EXPORT_TOOL::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST&
if( sameNetcodeCount >= 2 )
ret |= fprintf( f, " %s %.4s\n", TO_UTF8( ref ),
- (const char*) &aObjectsList[ii]->m_PinNum );
+ (const char*) &nitem->m_PinNum );
}
return ret >= 0;
@@ -1779,8 +1733,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
ret |= fprintf( f, "\n" );
// Prepare list of nets generation
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
- g_NetObjectslist[ii]->m_Flag = 0;
+ for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
+ m_masterList->GetItem( ii )->m_Flag = 0;
// Create netlist module section
m_ReferencesAlreadyFound.Clear();
@@ -1822,7 +1776,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
m_SortedComponentPinList.clear();
- if( ! writeListOfNetsCADSTAR( f, g_NetObjectslist ) )
+ if( ! writeListOfNetsCADSTAR( f ) )
ret = -1; // set error
ret |= fprintf( f, "\n%sEND\n", TO_UTF8( StartLine ) );
@@ -1831,7 +1785,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
}
-bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
+bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f )
{
int ret = 0;
wxString InitNetDesc = StartLine + wxT( "ADD_TER" );
@@ -1841,48 +1795,37 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
int print_ter = 0;
int NetCode, lastNetCode = -1;
SCH_COMPONENT* Cmp;
- wxString NetName;
+ wxString netName;
- for( ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( ii = 0; ii < m_masterList->size(); ii++ )
{
+ NETLIST_OBJECT* nitem = m_masterList->GetItem( ii );
+
// Get the NetName of the current net :
- if( ( NetCode = aObjectsList[ii]->GetNet() ) != lastNetCode )
+ if( ( NetCode = nitem->GetNet() ) != lastNetCode )
{
- NetName.Empty();
-
- NETLIST_OBJECT* netref;
- netref = aObjectsList[ii]->m_NetNameCandidate;
- if( netref )
- NetName = netref->m_Label;
-
+ netName = nitem->GetNetName();
netcodeName = wxT( "\"" );
- if( !NetName.IsEmpty() )
- {
- if( ( netref->m_Type != NET_PINLABEL )
- && ( netref->m_Type != NET_GLOBLABEL ) )
- {
- // usual net name, prefix it by the sheet path
- netcodeName +=
- netref->m_SheetList.PathHumanReadable();
- }
- netcodeName += NetName;
- }
+
+ if( !netName.IsEmpty() )
+ netcodeName << netName;
else // this net has no name: create a default name $
netcodeName << wxT( "$" ) << NetCode;
+
netcodeName += wxT( "\"" );
lastNetCode = NetCode;
print_ter = 0;
}
- if( aObjectsList[ii]->m_Type != NET_PIN )
+ if( nitem->m_Type != NET_PIN )
continue;
- if( aObjectsList[ii]->m_Flag != 0 )
+ if( nitem->m_Flag != 0 )
continue;
- Cmp = (SCH_COMPONENT*) aObjectsList[ii]->m_Link;
- wxString refstr = Cmp->GetRef( &(aObjectsList[ii]->m_SheetList) );
+ Cmp = nitem->GetComponentParent();
+ wxString refstr = Cmp->GetRef( &nitem->m_SheetPath );
if( refstr[0] == '#' )
continue; // Power supply symbols.
@@ -1892,7 +1835,7 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
{
char buf[5];
wxString str_pinnum;
- strncpy( buf, (char*) &aObjectsList[ii]->m_PinNum, 4 );
+ strncpy( buf, (char*) &nitem->m_PinNum, 4 );
buf[4] = 0;
str_pinnum = FROM_UTF8( buf );
InitNetDescLine.Printf( wxT( "\n%s %s %.4s %s" ),
@@ -1909,18 +1852,18 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
ret |= fprintf( f, "%s %s %.4s\n",
TO_UTF8( StartNetDesc ),
TO_UTF8( refstr ),
- (char*) &aObjectsList[ii]->m_PinNum );
+ (char*) &nitem->m_PinNum );
print_ter++;
break;
default:
ret |= fprintf( f, " %s %.4s\n",
TO_UTF8( refstr ),
- (char*) &aObjectsList[ii]->m_PinNum );
+ (char*) &nitem->m_PinNum );
break;
}
- aObjectsList[ii]->m_Flag = 1;
+ nitem->m_Flag = 1;
}
return ret >= 0;
diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp
index 9ca38ee584..2b3e77f05f 100644
--- a/eeschema/netlist.cpp
+++ b/eeschema/netlist.cpp
@@ -1,9 +1,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
- * Copyright (C) 2011 Wayne Stambaugh
- * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
+ * Copyright (C) 2013 Wayne Stambaugh
+ * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,8 +30,8 @@
#include
#include
-#include
#include
+#include
#include
#include
#include
@@ -45,130 +45,118 @@
#include
-
-const SCH_SHEET_PATH BOM_LABEL::emptySheetPath;
-
-
-enum BUS_OR_WIRE
-{
- IS_WIRE = 0,
- IS_BUS = 1
-};
+#define IS_WIRE false
+#define IS_BUS true
// Buffer to build the list of items used in netlist and erc calculations
-NETLIST_OBJECT_LIST g_NetObjectslist;
+NETLIST_OBJECT_LIST s_NetObjectslist( true );
//#define NETLIST_DEBUG
-static void PropageNetCode( int OldNetCode, int NewNetCode, BUS_OR_WIRE IsBus );
-static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
-static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int start );
-static void SegmentToPointConnect( NETLIST_OBJECT* Jonction, BUS_OR_WIRE IsBus, int start );
-static void LabelConnect( NETLIST_OBJECT* Label );
-static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer );
-static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer );
-
-static void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer );
-static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer );
-
-// Sort functions used here:
-static bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
-static bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 );
-
-// Local variables
-static int LastNetCode, LastBusNetCode;
-
-
-#if defined(DEBUG)
-
-void dumpNetTable()
+NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
{
- for( unsigned idx = 0; idx < g_NetObjectslist.size(); ++idx )
- {
- g_NetObjectslist[idx]->Show( std::cout, idx );
- }
-}
-
-#endif
-
-
-wxString BOM_LABEL::GetText() const
-{
- const SCH_TEXT* tmp = (SCH_TEXT*) m_label;
-
- return tmp->GetText();
+ if( m_isOwner )
+ FreeList();
+ else
+ Clear();
}
/*
- * Routine to free memory used to calculate the netlist TabNetItems = pointer
- * to the main table (list items)
+ * Delete all objects in list and clear list
+ * (free memory used to store info about NETLIST_OBJECT items)
*/
-static void FreeNetObjectsList( NETLIST_OBJECT_LIST& aNetObjectsBuffer )
+void NETLIST_OBJECT_LIST::FreeList()
{
- for( unsigned i = 0; i < aNetObjectsBuffer.size(); i++ )
- delete aNetObjectsBuffer[i];
+ std::vector::iterator iter;
- aNetObjectsBuffer.clear();
+ for( iter = begin(); iter != end(); iter++ )
+ {
+ NETLIST_OBJECT* item = *iter;
+ delete item;
+ }
+
+ clear();
+}
+
+void NETLIST_OBJECT_LIST::SortListbyNetcode()
+{
+ sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
+}
+
+void NETLIST_OBJECT_LIST::SortListbySheet()
+{
+ sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
}
/*
* Build net list connection table.
- *
- * Updates:
- * g_NetObjectslist
+ * Initializes s_NetObjectslist
*/
-void SCH_EDIT_FRAME::BuildNetListBase()
+NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::BuildNetListBase()
{
- int NetCode;
- SCH_SHEET_PATH* sheet;
- wxString msg, activity;
wxBusyCursor Busy;
- activity = _( "Building net list:" );
- SetStatusText( activity );
+ // Creates the flattened sheet list:
+ SCH_SHEET_LIST aSheets;
- FreeNetObjectsList( g_NetObjectslist );
+ // Build netlist info
+ bool success = s_NetObjectslist.BuildNetListInfo( aSheets );
- /* Build the sheet (not screen) list (flattened)*/
- SCH_SHEET_LIST sheets;
-
- /* Fill g_NetObjectslist with items used in connectivity calculation */
- for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
+ if( !success )
{
- for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
- {
- item->GetNetListItem( g_NetObjectslist, sheet );
- }
+ SetStatusText( _("No Objects" ) );
+ return &s_NetObjectslist;
}
- if( g_NetObjectslist.size() == 0 )
- return; // no objects
-
/* The new %zu specification is needed to properly format a size_t
* value (returned by size(), here) */
- activity += wxString::Format( _( " net count = %zu" ),
- g_NetObjectslist.size() );
- SetStatusText( activity );
+ wxString msg;
- /* Sort objects by Sheet */
+ msg.Printf( _( "Net count = %zu" ), s_NetObjectslist.size() );
+ SetStatusText( msg );
- sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsBySheet );
+ return &s_NetObjectslist;
+}
- activity += _( ", connections... " );
- SetStatusText( activity );
+/* the master function of NETLIST_OBJECT_LIST class.
+ * Build the list of connected objects (pins, labels ...) and
+ * all info needed to generate netlists or run ERC diags
+ */
+bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
+{
+ s_NetObjectslist.SetOwner( true );
+ s_NetObjectslist.FreeList();
- sheet = &(g_NetObjectslist[0]->m_SheetList);
- LastNetCode = LastBusNetCode = 1;
+ SCH_SHEET_PATH* sheet;
- for( unsigned ii = 0, istart = 0; ii < g_NetObjectslist.size(); ii++ )
+ // Fill list with connected items from the flattened sheet list
+ for( sheet = aSheets.GetFirst(); sheet != NULL;
+ sheet = aSheets.GetNext() )
{
- NETLIST_OBJECT* net_item = g_NetObjectslist[ii];
-
- if( net_item->m_SheetList != *sheet ) // Sheet change
+ for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
{
- sheet = &(net_item->m_SheetList);
+ item->GetNetListItem( *this, sheet );
+ }
+ }
+
+ if( size() == 0 )
+ return false;
+
+ // Sort objects by Sheet
+ SortListbySheet();
+
+ sheet = &(GetItem( 0 )->m_SheetPath);
+ m_lastNetCode = m_lastBusNetCode = 1;
+
+ for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
+ {
+ NETLIST_OBJECT* net_item = GetItem( ii );
+
+ if( net_item->m_SheetPath != *sheet ) // Sheet change
+ {
+ sheet = &(net_item->m_SheetPath);
istart = ii;
}
@@ -186,47 +174,47 @@ void SCH_EDIT_FRAME::BuildNetListBase()
break;
case NET_SEGMENT:
- /* Control connections point to point type without bus. */
+ // Test connections point to point type without bus.
if( net_item->GetNet() == 0 )
{
- net_item->SetNet( LastNetCode );
- LastNetCode++;
+ net_item->SetNet( m_lastNetCode );
+ m_lastNetCode++;
}
- PointToPointConnect( net_item, IS_WIRE, istart );
+ pointToPointConnect( net_item, IS_WIRE, istart );
break;
case NET_JUNCTION:
- /* Control of the junction outside BUS. */
+ // Control of the junction outside BUS.
if( net_item->GetNet() == 0 )
{
- net_item->SetNet( LastNetCode );
- LastNetCode++;
+ net_item->SetNet( m_lastNetCode );
+ m_lastNetCode++;
}
- SegmentToPointConnect( net_item, IS_WIRE, istart );
+ segmentToPointConnect( net_item, IS_WIRE, istart );
/* Control of the junction, on BUS. */
if( net_item->m_BusNetCode == 0 )
{
- net_item->m_BusNetCode = LastBusNetCode;
- LastBusNetCode++;
+ net_item->m_BusNetCode = m_lastBusNetCode;
+ m_lastBusNetCode++;
}
- SegmentToPointConnect( net_item, IS_BUS, istart );
+ segmentToPointConnect( net_item, IS_BUS, istart );
break;
case NET_LABEL:
case NET_HIERLABEL:
case NET_GLOBLABEL:
- /* Control connections type junction without bus. */
+ // Test connections type junction without bus.
if( net_item->GetNet() == 0 )
{
- net_item->SetNet( LastNetCode );
- LastNetCode++;
+ net_item->SetNet( m_lastNetCode );
+ m_lastNetCode++;
}
- SegmentToPointConnect( net_item, IS_WIRE, istart );
+ segmentToPointConnect( net_item, IS_WIRE, istart );
break;
case NET_SHEETBUSLABELMEMBER:
@@ -237,11 +225,11 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Control type connections point to point mode bus */
if( net_item->m_BusNetCode == 0 )
{
- net_item->m_BusNetCode = LastBusNetCode;
- LastBusNetCode++;
+ net_item->m_BusNetCode = m_lastBusNetCode;
+ m_lastBusNetCode++;
}
- PointToPointConnect( net_item, IS_BUS, istart );
+ pointToPointConnect( net_item, IS_BUS, istart );
break;
case NET_BUSLABELMEMBER:
@@ -250,33 +238,27 @@ void SCH_EDIT_FRAME::BuildNetListBase()
/* Control connections similar has on BUS */
if( net_item->GetNet() == 0 )
{
- net_item->m_BusNetCode = LastBusNetCode;
- LastBusNetCode++;
+ net_item->m_BusNetCode = m_lastBusNetCode;
+ m_lastBusNetCode++;
}
- SegmentToPointConnect( net_item, IS_BUS, istart );
+ segmentToPointConnect( net_item, IS_BUS, istart );
break;
}
}
#if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "\n\nafter sheet local\n\n";
- dumpNetTable();
+ DumpNetTable();
#endif
- activity += _( "done" );
- SetStatusText( activity );
-
/* Updating the Bus Labels Netcode connected by Bus */
- ConnectBusLabels( g_NetObjectslist );
-
- activity += _( ", bus labels..." );
- SetStatusText( activity );
+ connectBusLabels();
/* Group objects by label. */
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- switch( g_NetObjectslist[ii]->m_Type )
+ switch( GetItem( ii )->m_Type )
{
case NET_PIN:
case NET_SHEETLABEL:
@@ -291,7 +273,7 @@ void SCH_EDIT_FRAME::BuildNetListBase()
case NET_PINLABEL:
case NET_BUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
- LabelConnect( g_NetObjectslist[ii] );
+ labelConnect( GetItem( ii ) );
break;
case NET_SHEETBUSLABELMEMBER:
@@ -306,58 +288,111 @@ void SCH_EDIT_FRAME::BuildNetListBase()
#if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "\n\nafter sheet global\n\n";
- dumpNetTable();
+ DumpNetTable();
#endif
- activity += _( "done" );
- SetStatusText( activity );
-
- /* Connection hierarchy. */
- activity += _( ", hierarchy..." );
- SetStatusText( activity );
-
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ // Connection between hierarchy sheets
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- if( g_NetObjectslist[ii]->m_Type == NET_SHEETLABEL
- || g_NetObjectslist[ii]->m_Type == NET_SHEETBUSLABELMEMBER )
- SheetLabelConnect( g_NetObjectslist[ii] );
+ if( GetItem( ii )->m_Type == NET_SHEETLABEL
+ || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
+ sheetLabelConnect( GetItem( ii ) );
}
- /* Sort objects by NetCode */
- sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode );
+ // Sort objects by NetCode
+ SortListbyNetcode();
#if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "\n\nafter qsort()\n";
- dumpNetTable();
+ DumpNetTable();
#endif
- activity += _( "done" );
- SetStatusText( activity );
-
/* Compress numbers of Netcode having consecutive values. */
- LastNetCode = NetCode = 0;
+ int NetCode = 0;
+ m_lastNetCode = 0;
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- if( g_NetObjectslist[ii]->GetNet() != LastNetCode )
+ if( GetItem( ii )->GetNet() != m_lastNetCode )
{
NetCode++;
- LastNetCode = g_NetObjectslist[ii]->GetNet();
+ m_lastNetCode = GetItem( ii )->GetNet();
}
- g_NetObjectslist[ii]->SetNet( NetCode );
+ GetItem( ii )->SetNet( NetCode );
}
- /* Assignment of m_FlagOfConnection based connection or not. */
- SetUnconnectedFlag( g_NetObjectslist );
+ // Set the minimal connection info:
+ setUnconnectedFlag();
- /* find the best label object to give the best net name to each net */
- FindBestNetNameForEachNet( g_NetObjectslist );
+ // find the best label object to give the best net name to each net
+ findBestNetNameForEachNet();
+
+ return true;
+}
+
+// Helper function to give a priority to sort labels:
+// NET_PINLABEL and NET_GLOBLABEL are global labels
+// and the priority is hight
+static int getPriority( const NETLIST_OBJECT* Objet )
+{
+ switch( Objet->m_Type )
+ {
+ case NET_PIN: return 1;
+ case NET_LABEL: return 2;
+ case NET_HIERLABEL: return 3;
+ case NET_PINLABEL: return 4;
+ case NET_GLOBLABEL: return 5;
+ default: break;
+ }
+
+ return 0;
+}
+
+/* function evalLabelsPriority used by findBestNetNameForEachNet()
+ * evalLabelsPriority calculates the priority of alabel1 and aLabel2
+ * return true if alabel1 has a highter priority than aLabel2
+ */
+static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
+ const NETLIST_OBJECT* aLabel2 )
+{
+ int priority1 = getPriority( aLabel1 );
+ int priority2 = getPriority( aLabel2 );
+
+ if( priority1 != priority2 )
+ return priority1 > priority2;
+
+ // Objects have here the same priority, therefore they have the same type.
+
+ // for global labels, we select the best candidate by alphabetic order
+ // because they have no sheetpath as prefix name
+ // for other labels, we select them before by sheet deep order
+ // because the actual name is /sheetpath/label
+ // and for a given path length, by alphabetic order
+
+ if( aLabel1->m_Type == NET_PINLABEL || aLabel1->m_Type == NET_GLOBLABEL )
+ return aLabel1->m_Label.Cmp( aLabel2->m_Label );
+
+ // not global: names are prefixed by their sheetpath
+ // use name defined in higher hierarchical sheet
+ // (i.e. shorter path because paths are ///...
+ // and timestamp = 8 letters.
+ if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() )
+ return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length();
+
+ // Sheet paths have the same length: use alphabetic label name order
+ // For labels on sheets having an equivalent deep in hierarchy, use
+ // alphabetic label name order:
+ if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
+ return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
+
+ return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
+ aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
}
/**
- * Function FindBestNetNameForEachNet
+ * Function findBestNetNameForEachNet
* fill the .m_NetNameCandidate member of each item of aNetItemBuffer
* with a reference to the "best" NETLIST_OBJECT usable to give a name to the net
* If no suitable object found, .m_NetNameCandidate is filled with 0.
@@ -367,39 +402,37 @@ void SCH_EDIT_FRAME::BuildNetListBase()
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
* alphabetic order.
*/
-void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
+void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
{
- if( aNetItemBuffer.size() == 0 )
- return; // Should not occur: if this function is called, obviously some items exist in list
-
- NETLIST_OBJECT_LIST candidates;
int netcode = 0; // current netcode for tested items
- unsigned idxstart = 0; // index of the first item of this net
+ unsigned idxstart = 0; // index of the first item of this net
+ NETLIST_OBJECT* item;
+ NETLIST_OBJECT* candidate;
- for( unsigned ii = 0; ii <= aNetItemBuffer.size(); ii++ )
+ // Pass 1: find the best name for labelled nets:
+ item = NULL;
+ candidate = NULL;
+ for( unsigned ii = 0; ii <= size(); ii++ )
{
- NETLIST_OBJECT* item;
- if( ii == aNetItemBuffer.size() ) // last item already found
+ if( ii == size() ) // last item already found
netcode = -2;
else
- item = aNetItemBuffer[ii];
+ item = GetItem( ii );
- if( netcode != item->GetNet() ) // End of net found
+ if( netcode != item->GetNet() ) // End of net found
{
- if( candidates.size() ) // One or more labels exists, find the best
+ if( candidate ) // One or more labels exists, find the best
{
- NETLIST_OBJECT* bestlabel = FindBestNetName( candidates );
-
for (unsigned jj = idxstart; jj < ii; jj++ )
- aNetItemBuffer[jj]->m_NetNameCandidate = bestlabel;
+ GetItem( jj )->SetNetNameCandidate( candidate );
}
if( netcode == -2 )
break;
netcode = item->GetNet();
- candidates.clear();
+ candidate = NULL;
idxstart = ii;
}
@@ -409,140 +442,117 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
case NET_LABEL:
case NET_PINLABEL:
case NET_GLOBLABEL:
- candidates.push_back( item );
+ // A candidate is found: select the better between the previous
+ // and this one
+ if( candidate == NULL )
+ candidate = item;
+ else
+ {
+ if( evalLabelsPriority( item, candidate ) )
+ // item has a highter priority than candidate
+ // so update the best candidate
+ candidate = item;
+ }
break;
default:
break;
}
}
-}
+ // Pass 2: find the best name for not labelled nets:
+ // The "default" net name is Net-<[_Pad>
+ // (see NETLIST_OBJECT::GetShortNetName())
+ // therefore the "best" is the short net name alphabetically classed first
+ // (to avoid net names changes when the net is not modified,
+ // even if components are moved or deleted and undelete or replaced, as long
+ // the reference is kept)
-/**
- * Function FindBestNetName
- * @return a reference to the "best" label that can be used to give a name
- * to a net.
- * @param aLabelItemBuffer = list of NETLIST_OBJECT type labels candidates.
- * labels are local labels, hierarchical labels or pin labels
- * labels in included sheets have a lower priority than labels in the current sheet.
- * so labels inside the root sheet have the higher priority.
- * pin labels are global labels and have the higher priority
- * local labels have the lower priority
- * labels having the same priority are sorted by alphabetic order.
- *
- */
-static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
-{
- if( aLabelItemBuffer.size() == 0 )
- return NULL;
-
- // Define a priority (from low to high) to sort labels:
- // NET_PINLABEL and NET_GLOBLABEL are global labels
- // and priority >= NET_PRIO_MAX-1 is for global connections
- // ( i.e. for labels that are not prefixed by a sheetpath)
- #define NET_PRIO_MAX 4
-
- static int priority_order[NET_PRIO_MAX+1] = {
- NET_ITEM_UNSPECIFIED,
- NET_LABEL,
- NET_HIERLABEL,
- NET_PINLABEL,
- NET_GLOBLABEL };
-
- NETLIST_OBJECT*item = aLabelItemBuffer[0];
-
- // Calculate item priority (initial priority)
- int item_priority = 0;
-
- for( unsigned ii = 0; ii <= NET_PRIO_MAX; ii++ )
+ // Build the list of items with no net names
+ NETLIST_OBJECT_LIST list;
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- if ( item->m_Type == priority_order[ii] )
- {
- item_priority = ii;
- break;
- }
+ item = GetItem( ii );
+ if( !item->HasNetNameCandidate() )
+ list.push_back( item );
}
- for( unsigned ii = 1; ii < aLabelItemBuffer.size(); ii++ )
+ if( list.size() == 0 )
+ return;
+
+ idxstart = 0;
+ candidate = NULL;
+ netcode = list.GetItemNet( 0 );
+
+ for( unsigned ii = 0; ii <= list.size(); ii++ )
{
- NETLIST_OBJECT* candidate = aLabelItemBuffer[ii];
+ if( ii < list.size() )
+ item = list.GetItem( ii );
- // Calculate candidate priority
- int candidate_priority = 0;
-
- for( unsigned prio = 0; prio <= NET_PRIO_MAX; prio++ )
+ if( netcode != item->GetNet() || ii >= list.size() ) // End of net found
{
- if ( candidate->m_Type == priority_order[prio] )
+ if( candidate )
{
- candidate_priority = prio;
+ for (unsigned jj = idxstart; jj < ii; jj++ )
+ {
+ NETLIST_OBJECT* obj = list.GetItem( jj );
+ obj->SetNetNameCandidate( candidate );
+ }
+ }
+
+ if( ii >= list.size() )
break;
- }
- }
- if( candidate_priority > item_priority )
- {
- item = candidate;
- item_priority = candidate_priority;
- }
- else if( candidate_priority == item_priority )
- {
- // for global labels, we select the best candidate by alphabetic order
- // because they have no sheetpath as prefix name
- // for other labels, we select them before by sheet deep order
- // because the actual name is /sheetpath/label
- // and for a given path length, by alphabetic order
- if( item_priority >= NET_PRIO_MAX-1 ) // global label or pin label
- { // selection by alphabetic order:
- if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
- item = candidate;
- }
- else // not global: names are prefixed by their sheetpath
+ netcode = item->GetNet();
+ candidate = NULL;
+ idxstart = ii;
+ }
+
+ // Examine all pins of the net to find the best candidate,
+ // i.e. the first net name candidate, by alphabetic order
+ // the net names are names bu_ilt by GetShortNetName
+ // (Net-<{reference}-Pad{pad number}> like Net-
+ // Not named nets do not have usually a lot of members.
+ // Many have only 2 members(a pad and a non connection symbol)
+ if( item->m_Type == NET_PIN )
+ {
+ // A candidate is found, however components which are not in
+ // netlist are not candidate because some have their reference
+ // changed each time the netlist is built (power components)
+ // and anyway obviously they are not a good candidate
+ SCH_COMPONENT* link = item->GetComponentParent();
+ if( link && link->IsInNetlist() )
{
- // use name defined in higher hierarchical sheet
- // (i.e. shorter path because paths are ///...
- // and timestamp = 8 letters.
- if( candidate->m_SheetList.Path().Length() < item->m_SheetList.Path().Length() )
+ // select the better between the previous and this one
+ item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
+
+ if( candidate == NULL )
+ candidate = item;
+ else
{
- item = candidate;
- }
- else if( candidate->m_SheetList.Path().Length() == item->m_SheetList.Path().Length() )
- {
- // For labels on sheets having an equivalent deep in hierarchy, use
- // alphabetic label name order:
- if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
- item = candidate;
- else if( candidate->m_Label.Cmp( item->m_Label ) == 0 )
- {
- if( candidate->m_SheetList.PathHumanReadable().Cmp( item->m_SheetList.PathHumanReadable() ) < 0 )
- item = candidate;
- }
+ if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
+ candidate = item;
}
}
}
}
-
- return item;
}
/*
- * Connect sheets by sheetLabels
+ * Propagate net codes from a parent sheet to an include sheet,
+ * from a pin sheet connection
*/
-static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
+void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
{
if( SheetLabel->GetNet() == 0 )
return;
- /* Calculate the number of nodes in the corresponding sheetlabel */
-
- /* Comparison with SheetLabel GLABELS sub sheet to group Netcode */
-
- for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- NETLIST_OBJECT* ObjetNet = g_NetObjectslist[ii];
+ NETLIST_OBJECT* ObjetNet = GetItem( ii );
- if( ObjetNet->m_SheetList != SheetLabel->m_SheetListInclude )
+ if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
continue; //use SheetInclude, not the sheet!!
if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
@@ -554,9 +564,9 @@ static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
if( ObjetNet->m_Label.CmpNoCase( SheetLabel->m_Label ) != 0 )
continue; //different names.
- /* Propagate Netcode having all the objects of the same Netcode. */
+ // Propagate Netcode having all the objects of the same Netcode.
if( ObjetNet->GetNet() )
- PropageNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
+ propageNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
else
ObjetNet->SetNet( SheetLabel->GetNet() );
}
@@ -564,17 +574,17 @@ static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
/*
- * Routine that analyzes the type labels xxBUSLABELMEMBER
- * Propagate Netcode between the corresponding labels (ie when
- * Their member number is the same) when they are connected
- * Generally by their BusNetCode
- * Uses and updates the variable LastNetCode
+ * Analyzes the labels type bus member (
+ * Propagate net codes between the corresponding labels (ie when
+ * the is the same) when they are connected
+ * uqsually by their BusNetCode
+ * Uses and updates the variable m_lastNetCode
*/
-static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
+void NETLIST_OBJECT_LIST::connectBusLabels()
{
- for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- NETLIST_OBJECT* Label = aNetItemBuffer[ii];
+ NETLIST_OBJECT* Label = GetItem( ii );
if( (Label->m_Type == NET_SHEETBUSLABELMEMBER)
|| (Label->m_Type == NET_BUSLABELMEMBER)
@@ -582,13 +592,13 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
{
if( Label->GetNet() == 0 )
{
- Label->SetNet( LastNetCode );
- LastNetCode++;
+ Label->SetNet( m_lastNetCode );
+ m_lastNetCode++;
}
- for( unsigned jj = ii + 1; jj < aNetItemBuffer.size(); jj++ )
+ for( unsigned jj = ii + 1; jj < size(); jj++ )
{
- NETLIST_OBJECT* LabelInTst = aNetItemBuffer[jj];
+ NETLIST_OBJECT* LabelInTst = GetItem( jj );
if( (LabelInTst->m_Type == NET_SHEETBUSLABELMEMBER)
|| (LabelInTst->m_Type == NET_BUSLABELMEMBER)
|| (LabelInTst->m_Type == NET_HIERBUSLABELMEMBER) )
@@ -602,7 +612,7 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
if( LabelInTst->GetNet() == 0 )
LabelInTst->SetNet( Label->GetNet() );
else
- PropageNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
+ propageNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
}
}
}
@@ -611,38 +621,34 @@ static void ConnectBusLabels( NETLIST_OBJECT_LIST& aNetItemBuffer )
/*
- * PropageNetCode propagates Netcode NewNetCode on all elements
- * belonging to the former Netcode OldNetCode
- * If IsBus == 0; Netcode is the member who is spreading
- * If IsBus != 0; is the member who is spreading BusNetCode
+ * propageNetCode propagates the net code NewNetCode to all elements
+ * having previously the net code OldNetCode
+ * If IsBus == false, m_Netcode is used to propagate the new net code
+ * If IsBus == true, m_BusNetCode is used to propagate the new net code
*/
-static void PropageNetCode( int OldNetCode, int NewNetCode, BUS_OR_WIRE IsBus )
+void NETLIST_OBJECT_LIST::propageNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus )
{
- if( OldNetCode == NewNetCode )
+ if( aOldNetCode == aNewNetCode )
return;
- if( IsBus == IS_WIRE ) // Propagate NetCode
+ if( aIsBus == false ) // Propagate NetCode
{
- for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
+ for( unsigned jj = 0; jj < size(); jj++ )
{
- NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
+ NETLIST_OBJECT* objet = GetItem( jj );
- if( Objet->GetNet() == OldNetCode )
- {
- Objet->SetNet( NewNetCode );
- }
+ if( objet->GetNet() == aOldNetCode )
+ objet->SetNet( aNewNetCode );
}
}
- else /* Propagate BusNetCode */
+ else // Propagate BusNetCode
{
- for( unsigned jj = 0; jj < g_NetObjectslist.size(); jj++ )
+ for( unsigned jj = 0; jj < size(); jj++ )
{
- NETLIST_OBJECT* Objet = g_NetObjectslist[jj];
+ NETLIST_OBJECT* objet = GetItem( jj );
- if( Objet->m_BusNetCode == OldNetCode )
- {
- Objet->m_BusNetCode = NewNetCode;
- }
+ if( objet->m_BusNetCode == aOldNetCode )
+ objet->m_BusNetCode = aNewNetCode;
}
}
}
@@ -667,19 +673,20 @@ static void PropageNetCode( int OldNetCode, int NewNetCode, BUS_OR_WIRE IsBus )
* Leaf schema
* (There can be no physical connection between elements of different sheets)
*/
-static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int start )
+void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus,
+ int start )
{
int netCode;
- if( IsBus == IS_WIRE ) // Objects other than BUS and BUSLABELS
+ if( aIsBus == false ) // Objects other than BUS and BUSLABELS
{
- netCode = Ref->GetNet();
+ netCode = aRef->GetNet();
- for( unsigned i = start; i < g_NetObjectslist.size(); i++ )
+ for( unsigned i = start; i < size(); i++ )
{
- NETLIST_OBJECT* item = g_NetObjectslist[i];
+ NETLIST_OBJECT* item = GetItem( i );
- if( item->m_SheetList != Ref->m_SheetList ) //used to be > (why?)
+ if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
continue;
switch( item->m_Type )
@@ -693,15 +700,15 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int sta
case NET_PINLABEL:
case NET_JUNCTION:
case NET_NOCONNECT:
- if( Ref->m_Start == item->m_Start
- || Ref->m_Start == item->m_End
- || Ref->m_End == item->m_Start
- || Ref->m_End == item->m_End )
+ if( aRef->m_Start == item->m_Start
+ || aRef->m_Start == item->m_End
+ || aRef->m_End == item->m_Start
+ || aRef->m_End == item->m_End )
{
if( item->GetNet() == 0 )
item->SetNet( netCode );
else
- PropageNetCode( item->GetNet(), netCode, IS_WIRE );
+ propageNetCode( item->GetNet(), netCode, IS_WIRE );
}
break;
@@ -717,13 +724,13 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int sta
}
else /* Object type BUS, BUSLABELS, and junctions. */
{
- netCode = Ref->m_BusNetCode;
+ netCode = aRef->m_BusNetCode;
- for( unsigned i = start; im_SheetList != Ref->m_SheetList )
+ if( item->m_SheetPath != aRef->m_SheetPath )
continue;
switch( item->m_Type )
@@ -745,15 +752,15 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int sta
case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_JUNCTION:
- if( Ref->m_Start == item->m_Start
- || Ref->m_Start == item->m_End
- || Ref->m_End == item->m_Start
- || Ref->m_End == item->m_End )
+ if( aRef->m_Start == item->m_Start
+ || aRef->m_Start == item->m_End
+ || aRef->m_End == item->m_Start
+ || aRef->m_End == item->m_End )
{
if( item->m_BusNetCode == 0 )
item->m_BusNetCode = netCode;
else
- PropageNetCode( item->m_BusNetCode, netCode, IS_BUS );
+ propageNetCode( item->m_BusNetCode, netCode, IS_BUS );
}
break;
}
@@ -763,131 +770,111 @@ static void PointToPointConnect( NETLIST_OBJECT* Ref, BUS_OR_WIRE IsBus, int sta
/*
- * Search if a junction is connected to segments and propagate the junction Netcode
- * to objects connected by the junction.
- * The junction must have a valid Netcode
+ * Search connections betweena junction and segments
+ * Propagate the junction net code to objects connected by this junction.
+ * The junction must have a valid net code
* The list of objects is expected sorted by sheets.
- * Search is done from index aIdxStart to the last element of g_NetObjectslist
+ * Search is done from index aIdxStart to the last element of list
*/
-static void SegmentToPointConnect( NETLIST_OBJECT* aJonction, BUS_OR_WIRE aIsBus, int aIdxStart )
+void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
+ bool aIsBus, int aIdxStart )
{
- for( unsigned i = aIdxStart; i < g_NetObjectslist.size(); i++ )
+ for( unsigned i = aIdxStart; i < size(); i++ )
{
- NETLIST_OBJECT* Segment = g_NetObjectslist[i];
+ NETLIST_OBJECT* segment = GetItem( i );
- // if different sheets, no physical connection between elements is possible.
- if( Segment->m_SheetList != aJonction->m_SheetList )
+ // if different sheets, obviously no physical connection between elements.
+ if( segment->m_SheetPath != aJonction->m_SheetPath )
continue;
if( aIsBus == IS_WIRE )
{
- if( Segment->m_Type != NET_SEGMENT )
+ if( segment->m_Type != NET_SEGMENT )
continue;
}
else
{
- if( Segment->m_Type != NET_BUS )
+ if( segment->m_Type != NET_BUS )
continue;
}
- if( SegmentIntersect( Segment->m_Start, Segment->m_End, aJonction->m_Start ) )
+ if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
{
- /* Propagation Netcode has all the objects of the same Netcode. */
+ // Propagation Netcode has all the objects of the same Netcode.
if( aIsBus == IS_WIRE )
{
- if( Segment->GetNet() )
- PropageNetCode( Segment->GetNet(), aJonction->GetNet(), aIsBus );
+ if( segment->GetNet() )
+ propageNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
else
- Segment->SetNet( aJonction->GetNet() );
+ segment->SetNet( aJonction->GetNet() );
}
else
{
- if( Segment->m_BusNetCode )
- PropageNetCode( Segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
+ if( segment->m_BusNetCode )
+ propageNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
else
- Segment->m_BusNetCode = aJonction->m_BusNetCode;
+ segment->m_BusNetCode = aJonction->m_BusNetCode;
}
}
}
}
-/*****************************************************************
- * Function which connects the groups of object which have the same label
- *******************************************************************/
-void LabelConnect( NETLIST_OBJECT* LabelRef )
+/*
+ * This function merges the net codes of groups of objects already connected
+ * to labels (wires, bus, pins ... ) when 2 labels are equivalents
+ * (i.e. group objects connected by labels)
+ */
+void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
{
- if( LabelRef->GetNet() == 0 )
+ if( aLabelRef->GetNet() == 0 )
return;
- for( unsigned i = 0; i < g_NetObjectslist.size(); i++ )
+ for( unsigned i = 0; i < size(); i++ )
{
- if( g_NetObjectslist[i]->GetNet() == LabelRef->GetNet() )
+ NETLIST_OBJECT* item = GetItem( i );
+
+ if( item->GetNet() == aLabelRef->GetNet() )
continue;
- if( g_NetObjectslist[i]->m_SheetList != LabelRef->m_SheetList )
+ if( item->m_SheetPath != aLabelRef->m_SheetPath )
{
- if( (g_NetObjectslist[i]->m_Type != NET_PINLABEL
- && g_NetObjectslist[i]->m_Type != NET_GLOBLABEL
- && g_NetObjectslist[i]->m_Type != NET_GLOBBUSLABELMEMBER) )
+ if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
+ && item->m_Type != NET_GLOBBUSLABELMEMBER )
continue;
- if( (g_NetObjectslist[i]->m_Type == NET_GLOBLABEL
- || g_NetObjectslist[i]->m_Type == NET_GLOBBUSLABELMEMBER)
- && g_NetObjectslist[i]->m_Type != LabelRef->m_Type )
+ if( (item->m_Type == NET_GLOBLABEL
+ || item->m_Type == NET_GLOBBUSLABELMEMBER)
+ && item->m_Type != aLabelRef->m_Type )
//global labels only connect other global labels.
continue;
}
- // regular labels are sheet-local;
// NET_HIERLABEL are used to connect sheets.
- // NET_LABEL is sheet-local (***)
- // NET_GLOBLABEL is global.
+ // NET_LABEL are local to a sheet
+ // NET_GLOBLABEL are global.
// NET_PINLABEL is a kind of global label (generated by a power pin invisible)
- NETLIST_ITEM_T ntype = g_NetObjectslist[i]->m_Type;
-
- if( ntype == NET_LABEL
- || ntype == NET_GLOBLABEL
- || ntype == NET_HIERLABEL
- || ntype == NET_BUSLABELMEMBER
- || ntype == NET_GLOBBUSLABELMEMBER
- || ntype == NET_HIERBUSLABELMEMBER
- || ntype == NET_PINLABEL )
+ if( item->IsLabelType() )
{
- if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
+ if( item->m_Label.CmpNoCase( aLabelRef->m_Label ) != 0 )
continue;
- if( g_NetObjectslist[i]->GetNet() )
- PropageNetCode( g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), IS_WIRE );
+ if( item->GetNet() )
+ propageNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
else
- g_NetObjectslist[i]->SetNet( LabelRef->GetNet() );
+ item->SetNet( aLabelRef->GetNet() );
}
}
}
-/* Comparison routine for sorting by increasing Netcode
- * table of elements connected (TabPinSort) by qsort ()
+/* Set the m_ConnectionType member of items in list
+ * depending on the connection type:
+ * UNCONNECTED, PAD_CONNECT or NOCONNECT_SYMBOL_PRESENT
+ * The list is expected sorted by order of net code,
+ * i.e. items having the same net code are grouped
*/
-bool SortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
-{
- return Objet1->GetNet() < Objet2->GetNet();
-}
-
-
-/* Comparison routine for sorting items by Sheet Number ( used by qsort )
- */
-
-bool SortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
-{
- return Objet1->m_SheetList.Cmp( Objet2->m_SheetList ) < 0;
-}
-
-
-/* Routine positioning member. FlagNoConnect ELEMENTS
- * List of objects NetList, sorted by order of Netcode
- */
-static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
+void NETLIST_OBJECT_LIST::setUnconnectedFlag()
{
NETLIST_OBJECT* NetItemRef;
unsigned NetStart, NetEnd;
@@ -895,27 +882,27 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
NetStart = NetEnd = 0;
StateFlag = UNCONNECTED;
- for( unsigned ii = 0; ii < aNetItemBuffer.size(); ii++ )
+ for( unsigned ii = 0; ii < size(); ii++ )
{
- NetItemRef = aNetItemBuffer[ii];
+ NetItemRef = GetItem( ii );
if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
StateFlag = NOCONNECT_SYMBOL_PRESENT;
/* Analysis of current net. */
unsigned idxtoTest = ii + 1;
- if( ( idxtoTest >= aNetItemBuffer.size() )
- || ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
+ if( ( idxtoTest >= size() )
+ || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
{
- /* Net analysis to update m_FlagOfConnection */
+ /* Net analysis to update m_ConnectionType */
NetEnd = idxtoTest;
- /* set m_FlagOfConnection member to StateFlag for all items of
+ /* set m_ConnectionType member to StateFlag for all items of
* this net: */
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
- aNetItemBuffer[kk]->m_FlagOfConnection = StateFlag;
+ GetItem( kk )->m_ConnectionType = StateFlag;
- if( idxtoTest >= aNetItemBuffer.size() )
+ if( idxtoTest >= size() )
return;
/* Start Analysis next Net */
@@ -934,11 +921,11 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
*/
for( ; ; idxtoTest++ )
{
- if( ( idxtoTest >= aNetItemBuffer.size() )
- || ( NetItemRef->GetNet() != aNetItemBuffer[idxtoTest]->GetNet() ) )
+ if( ( idxtoTest >= size() )
+ || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
break;
- switch( aNetItemBuffer[idxtoTest]->m_Type )
+ switch( GetItem( idxtoTest )->m_Type )
{
case NET_ITEM_UNSPECIFIED:
wxMessageBox( wxT( "BuildNetListBase() error" ) );
@@ -973,3 +960,4 @@ static void SetUnconnectedFlag( NETLIST_OBJECT_LIST& aNetItemBuffer )
}
}
}
+
diff --git a/eeschema/netlist.h b/eeschema/netlist.h
index 2dd7f977e7..bed55d2c80 100644
--- a/eeschema/netlist.h
+++ b/eeschema/netlist.h
@@ -37,6 +37,7 @@
#include
#include
#include
+#include
/// netlist types
@@ -483,7 +484,7 @@ private:
/**
* Class BOM_LABEL
- * is used to build a BOM by handling the list of labels in schematic because in a
+ * is used to build a List of Labels by handling the list of labels in schematic because in a
* complex hierarchy, a label is used more than once and has more than one sheet path
* so we must create a flat list of labels.
*/
@@ -512,7 +513,11 @@ public:
const SCH_SHEET_PATH& GetSheetPath() const { return m_sheetPath; }
- wxString GetText() const;
+ wxString GetText() const
+ {
+ const SCH_TEXT* tmp = (SCH_TEXT*) m_label;
+ return tmp->GetText();
+ }
};
diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp
index 6dfef208e6..9bf9dcea0e 100644
--- a/eeschema/onleftclick.cpp
+++ b/eeschema/onleftclick.cpp
@@ -34,7 +34,6 @@
#include
#include
-#include
#include
#include
#include
@@ -43,6 +42,7 @@
#include
#include
#include
+#include
#include
diff --git a/eeschema/protos.h b/eeschema/protos.h
index 47341416b5..1da8164820 100644
--- a/eeschema/protos.h
+++ b/eeschema/protos.h
@@ -21,12 +21,6 @@ class SCH_ITEM;
//void DisplayCmpDoc( wxString& Name );
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName );
-
-/*********************/
-/* DANGLING_ENDS.CPP */
-/*********************/
-bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint );
-
// operations_on_item_lists.cpp
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
diff --git a/eeschema/sch_collectors.cpp b/eeschema/sch_collectors.cpp
index a0f4554fad..6f8562091e 100644
--- a/eeschema/sch_collectors.cpp
+++ b/eeschema/sch_collectors.cpp
@@ -28,7 +28,7 @@
#include
-#include
+#include
#include
#include
#include
@@ -347,7 +347,7 @@ bool SCH_FIND_COLLECTOR::PassedEnd() const
if( GetCount() == 0 )
return true;
- if( !(flags & FR_SEARCH_WRAP) )
+ if( !(flags & FR_SEARCH_WRAP) || (flags & FR_SEARCH_REPLACE) )
{
if( flags & wxFR_DOWN )
{
@@ -454,7 +454,7 @@ EDA_ITEM* SCH_FIND_COLLECTOR::GetItem( SCH_FIND_COLLECTOR_DATA& aData )
}
-bool SCH_FIND_COLLECTOR::ReplaceItem()
+bool SCH_FIND_COLLECTOR::ReplaceItem( SCH_SHEET_PATH* aSheetPath )
{
if( PassedEnd() )
return false;
@@ -464,15 +464,10 @@ bool SCH_FIND_COLLECTOR::ReplaceItem()
EDA_ITEM* item = m_List[ m_foundIndex ];
- bool replaced = item->Replace( m_findReplaceData );
+ bool replaced = item->Replace( m_findReplaceData, aSheetPath );
- // If the replace was successful, remove the item from the find list to prevent
- // iterating back over it again.
if( replaced )
- {
- Remove( m_foundIndex );
- m_data.erase( m_data.begin() + m_foundIndex );
- }
+ m_forceSearch = true;
return replaced;
}
diff --git a/eeschema/sch_collectors.h b/eeschema/sch_collectors.h
index d8851e0d89..299ea9ec62 100644
--- a/eeschema/sch_collectors.h
+++ b/eeschema/sch_collectors.h
@@ -237,15 +237,6 @@ class SCH_FIND_COLLECTOR : public COLLECTOR
/// performed even if the search criteria hasn't changed.
bool m_forceSearch;
- /**
- * Function PassedEnd
- * tests if #m_foundIndex is beyond the end of the list give the current
- * find/replace criterial in #m_findReplaceData.
- *
- * @return True if #m_foundIndex has crossed the end of the found item list.
- */
- bool PassedEnd() const;
-
/**
* Function dump
* is a helper to dump the items in the find list for debugging purposes.
@@ -266,8 +257,24 @@ public:
m_forceSearch = false;
}
+ void Empty()
+ {
+ m_foundIndex = 0;
+ COLLECTOR::Empty();
+ m_data.clear();
+ }
+
void SetForceSearch() { m_forceSearch = true; }
+ /**
+ * Function PassedEnd
+ * tests if #m_foundIndex is beyond the end of the list give the current
+ * find/replace criterial in #m_findReplaceData.
+ *
+ * @return True if #m_foundIndex has crossed the end of the found item list.
+ */
+ bool PassedEnd() const;
+
/**
* Function UpdateIndex
* updates the list index according to the current find and replace criteria.
@@ -326,7 +333,7 @@ public:
*
* @return True if the text replace occurred otherwise false.
*/
- bool ReplaceItem();
+ bool ReplaceItem( SCH_SHEET_PATH* aSheetPath = NULL );
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
@@ -340,6 +347,8 @@ public:
* value searches the entire schematic hierarchy.
*/
void Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData, SCH_SHEET_PATH* aSheetPath = NULL );
+
+ void IncrementIndex() { m_foundIndex += 1; }
};
diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index 9d59c7d1d9..22861fe5f4 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -1720,8 +1720,8 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
}
-void SCH_COMPONENT::GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath )
+void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath )
{
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( GetLibName() );
@@ -1741,9 +1741,9 @@ void SCH_COMPONENT::GetNetListItem( vector& aNetListItems,
wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) pin;
- item->m_SheetList = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
item->m_Type = NET_PIN;
item->m_Link = (SCH_ITEM*) this;
item->m_ElectricalType = pin->GetType();
@@ -1757,9 +1757,9 @@ void SCH_COMPONENT::GetNetListItem( vector& aNetListItems,
{
/* There is an associated PIN_LABEL. */
item = new NETLIST_OBJECT();
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = NULL;
- item->m_SheetList = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
item->m_Type = NET_PINLABEL;
item->m_Label = pin->GetName();
item->m_Start = pos;
@@ -1888,6 +1888,16 @@ bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
return false;
}
+/* return true if the component is in netlist
+ * which means this is not a power component, or something
+ * like a component reference starting by #
+ */
+bool SCH_COMPONENT::IsInNetlist() const
+{
+ SCH_FIELD* rf = GetField( REFERENCE );
+ return ! rf->GetText().StartsWith( wxT( "#" ) );
+}
+
void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
{
diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h
index f315be39c9..5e52ad2406 100644
--- a/eeschema/sch_component.h
+++ b/eeschema/sch_component.h
@@ -40,7 +40,7 @@ class SCH_SHEET_PATH;
class LIB_ITEM;
class LIB_PIN;
class LIB_COMPONENT;
-
+class NETLIST_OBJECT_LIST;
/// A container for several SCH_FIELD items
typedef std::vector SCH_FIELDS;
@@ -365,6 +365,13 @@ public:
bool IsConnectable() const { return true; }
+ /**
+ * @return true if the component is in netlist
+ * which means this is not a power component, or something
+ * like a component reference starting by #
+ */
+ bool IsInNetlist() const;
+
void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
@@ -384,8 +391,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_component_xpm; }
- void GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath );
+ void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index 9ed6e461d1..67256b5653 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -431,8 +431,11 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
bool isReplaced;
wxString text = GetFullyQualifiedText();
- if( m_id == REFERENCE && aAuxData != NULL )
+ if( m_id == REFERENCE )
{
+ wxCHECK_MSG( aAuxData != NULL, false,
+ wxT( "Cannot replace reference designator without valid sheet path." ) );
+
wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
wxT( "Invalid replace component reference field call." ) ) ;
@@ -443,8 +446,8 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
- if( component->GetPartCount() > 1 )
- text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );
+ // if( component->GetPartCount() > 1 )
+ // text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );
isReplaced = EDA_ITEM::Replace( aSearchData, text );
diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp
index 7373f05337..4b1bcbceb8 100644
--- a/eeschema/sch_junction.cpp
+++ b/eeschema/sch_junction.cpp
@@ -36,6 +36,7 @@
#include
#include
+#include
int SCH_JUNCTION::m_symbolSize = 40; // Default diameter of the junction symbol
@@ -173,13 +174,13 @@ void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
-void SCH_JUNCTION::GetNetListItem( vector& aNetListItems,
+void SCH_JUNCTION::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetList = *aSheetPath;
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this;
item->m_Type = NET_JUNCTION;
item->m_Start = item->m_End = m_pos;
diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h
index 3466fdd79b..7371622887 100644
--- a/eeschema/sch_junction.h
+++ b/eeschema/sch_junction.h
@@ -31,6 +31,7 @@
#include
+class NETLIST_OBJECT_LIST;
class SCH_JUNCTION : public SCH_ITEM
{
@@ -86,7 +87,7 @@ public:
BITMAP_DEF GetMenuImage() const { return add_junction_xpm; }
- void GetNetListItem( vector& aNetListItems, SCH_SHEET_PATH* aSheetPath );
+ void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }
diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp
index c95de0a913..4cc9821b04 100644
--- a/eeschema/sch_line.cpp
+++ b/eeschema/sch_line.cpp
@@ -516,16 +516,16 @@ BITMAP_DEF SCH_LINE::GetMenuImage() const
}
-void SCH_LINE::GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath )
+void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath )
{
// Net list item not required for graphic lines.
if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) )
return;
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetList = *aSheetPath;
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this;
item->m_Start = m_start;
item->m_End = m_end;
diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h
index 6288aab4eb..8ae7735f81 100644
--- a/eeschema/sch_line.h
+++ b/eeschema/sch_line.h
@@ -32,6 +32,7 @@
#include
+class NETLIST_OBJECT_LIST;
/**
* Class SCH_LINE
@@ -128,7 +129,7 @@ public:
BITMAP_DEF GetMenuImage() const;
- void GetNetListItem( vector& aNetListItems, SCH_SHEET_PATH* aSheetPath );
+ void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;
diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp
index 8225ee6e40..662ebd756a 100644
--- a/eeschema/sch_no_connect.cpp
+++ b/eeschema/sch_no_connect.cpp
@@ -188,13 +188,13 @@ void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
-void SCH_NO_CONNECT::GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath )
+void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath )
{
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetList = *aSheetPath;
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = this;
item->m_Type = NET_NOCONNECT;
item->m_Start = item->m_End = m_pos;
diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h
index 31b04a0281..ccb71d47be 100644
--- a/eeschema/sch_no_connect.h
+++ b/eeschema/sch_no_connect.h
@@ -32,6 +32,7 @@
#include
+class NETLIST_OBJECT_LIST;
class SCH_NO_CONNECT : public SCH_ITEM
{
@@ -86,7 +87,7 @@ public:
BITMAP_DEF GetMenuImage() const { return noconn_xpm; }
- void GetNetListItem( vector& aNetListItems, SCH_SHEET_PATH* aSheetPath );
+ void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }
diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index 1ee074e744..52d512a78a 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -40,9 +40,8 @@
#include
#include
-#include
-#include
#include
+#include
#include
#include
#include
@@ -52,6 +51,7 @@
#include
#include
#include
+#include
#include
@@ -101,7 +101,7 @@ static GRID_TYPE SchematicGridList[] = {
SCH_SCREEN::SCH_SCREEN() : BASE_SCREEN( SCH_SCREEN_T ),
- m_paper( wxT( "A4" ), IsGOST() )
+ m_paper( wxT( "A4" ) )
{
size_t i;
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index d655bf9fb7..7c0c97e1c8 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -37,7 +37,6 @@
#include
#include
-#include
#include
#include
#include
@@ -1073,8 +1072,8 @@ wxPoint SCH_SHEET::GetResizePosition() const
}
-void SCH_SHEET::GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath )
+void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath )
{
SCH_SHEET_PATH sheetPath = *aSheetPath;
sheetPath.Push( this );
@@ -1082,8 +1081,8 @@ void SCH_SHEET::GetNetListItem( vector& aNetListItems,
for( size_t i = 0; i < m_pins.size(); i++ )
{
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetListInclude = sheetPath;
- item->m_SheetList = *aSheetPath;
+ item->m_SheetPathInclude = sheetPath;
+ item->m_SheetPath = *aSheetPath;
item->m_Comp = &m_pins[i];
item->m_Link = this;
item->m_Type = NET_SHEETLABEL;
diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h
index fd170da5e0..99a668e3bc 100644
--- a/eeschema/sch_sheet.h
+++ b/eeschema/sch_sheet.h
@@ -42,6 +42,7 @@ class SCH_SHEET_PIN;
class SCH_SHEET_PATH;
class DANGLING_END_ITEM;
class SCH_EDIT_FRAME;
+class NETLIST_OBJECT_LIST;
#define MIN_SHEET_WIDTH 500
@@ -541,8 +542,8 @@ public:
BITMAP_DEF GetMenuImage() const { return add_hierarchical_subsheet_xpm; }
- void GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath );
+ void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath );
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp
index 71f777dc22..23ef5272c3 100644
--- a/eeschema/sch_sheet_path.cpp
+++ b/eeschema/sch_sheet_path.cpp
@@ -438,6 +438,7 @@ SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet )
m_index = 0;
m_count = 0;
m_List = NULL;
+ m_isRootSheet = false;
if( aSheet == NULL )
aSheet = g_RootSheet;
@@ -518,6 +519,9 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( const wxString aPath, bool aHumanReada
void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
{
+ if( aSheet == g_RootSheet )
+ m_isRootSheet = true;
+
if( m_List == NULL )
{
int count = aSheet->CountSheets();
@@ -702,3 +706,25 @@ bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
return found;
}
+
+
+bool SCH_SHEET_LIST::IsComplexHierarchy()
+{
+ wxString fileName;
+
+ for( int i = 0; i < GetCount(); i++ )
+ {
+ fileName = GetSheet( i )->Last()->GetFileName();
+
+ for( int j = 0; j < GetCount(); j++ )
+ {
+ if( i == j )
+ continue;
+
+ if( fileName == GetSheet( j )->Last()->GetFileName() )
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h
index 4ab4237064..dcfe9b690a 100644
--- a/eeschema/sch_sheet_path.h
+++ b/eeschema/sch_sheet_path.h
@@ -292,6 +292,7 @@ private:
* returning the next item in m_List. Also used for
* internal calculations in BuildSheetList()
*/
+ bool m_isRootSheet;
SCH_SHEET_PATH m_currList;
public:
@@ -442,6 +443,15 @@ public:
bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
bool aSetVisible );
+ /**
+ * Function IsComplexHierarchy
+ * searches all of the sheets for duplicate files names which indicates a complex
+ * hierarchy.
+ *
+ * @return true if the #SCH_SHEET_LIST is a complex hierarchy.
+ */
+ bool IsComplexHierarchy();
+
private:
/**
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 77acb3d096..abfc85948b 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -535,7 +535,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
wxT( "Dangling end type list overflow. Bad programmer!" ) );
DANGLING_END_ITEM & nextItem = aItemList[ii];
- m_isDangling = !SegmentIntersect( item.GetPosition(), nextItem.GetPosition(), m_Pos );
+ m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_Pos );
}
break;
@@ -613,15 +613,15 @@ wxString SCH_TEXT::GetSelectMenuText() const
}
-void SCH_TEXT::GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath )
+void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath )
{
if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
return;
NETLIST_OBJECT* item = new NETLIST_OBJECT();
- item->m_SheetList = *aSheetPath;
- item->m_SheetListInclude = *aSheetPath;
+ item->m_SheetPath = *aSheetPath;
+ item->m_SheetPathInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this;
item->m_Type = NET_LABEL;
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index dff401acc6..3b135d0265 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -37,6 +37,7 @@
class LINE_READER;
+class NETLIST_OBJECT_LIST;
/* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
@@ -196,8 +197,8 @@ public:
virtual BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
- virtual void GetNetListItem( vector& aNetListItems,
- SCH_SHEET_PATH* aSheetPath );
+ virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
+ SCH_SHEET_PATH* aSheetPath );
virtual wxPoint GetPosition() const { return m_Pos; }
diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp
index 3f6f9efce6..8f3d425bb1 100644
--- a/eeschema/schedit.cpp
+++ b/eeschema/schedit.cpp
@@ -47,6 +47,7 @@
#include
#include
#include
+#include
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
@@ -126,7 +127,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
break;
- HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
SetRepeatItem( NULL );
SetSheetNumberAndCount();
break;
@@ -313,7 +316,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case wxID_COPY: // really this is a Save block for paste
- HandleBlockEndByPopUp( BLOCK_SAVE, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_SAVE );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
break;
case ID_POPUP_PLACE_BLOCK:
@@ -323,23 +328,31 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_ZOOM_BLOCK:
- HandleBlockEndByPopUp( BLOCK_ZOOM, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
break;
case ID_POPUP_DELETE_BLOCK:
m_canvas->MoveCursorToCrossHair();
- HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
SetSheetNumberAndCount();
break;
case ID_POPUP_COPY_BLOCK:
m_canvas->MoveCursorToCrossHair();
- HandleBlockEndByPopUp( BLOCK_COPY, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_COPY );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
break;
case ID_POPUP_DRAG_BLOCK:
m_canvas->MoveCursorToCrossHair();
- HandleBlockEndByPopUp( BLOCK_DRAG, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
break;
case ID_POPUP_SCH_ADD_JUNCTION:
@@ -735,7 +748,8 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
// Allows block rotate operation on hot key.
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
- HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
+ screen->m_BlockLocate.SetCommand( BLOCK_ROTATE );
+ HandleBlockEnd( &dc );
return;
}
@@ -761,7 +775,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
{
case SCH_COMPONENT_T:
if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
- OrientComponent( CMP_ROTATE_CLOCKWISE );
+ OrientComponent( CMP_ROTATE_CLOCKWISE );
else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
OrientComponent( CMP_ROTATE_COUNTERCLOCKWISE );
else
@@ -817,6 +831,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
// Set the locat filter, according to the edit command
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
const KICAD_T* filterListAux = NULL;
+
switch( aEvent.GetId() )
{
case ID_SCH_EDIT_COMPONENT_REFERENCE:
@@ -837,13 +852,12 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
default:
break;
}
- item = LocateAndShowItem( data->GetPosition(), filterList,
- aEvent.GetInt() );
+
+ item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
// If no item found, and if an auxiliary filter exists, try to use it
if( !item && filterListAux )
- item = LocateAndShowItem( data->GetPosition(), filterListAux,
- aEvent.GetInt() );
+ item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
// Exit if no item found at the current location or the item is already being edited.
if( (item == NULL) || (item->GetFlags() != 0) )
@@ -987,11 +1001,23 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
if( aEvent.GetId() == ID_SCH_MIRROR_X )
- HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
+ {
+ m_canvas->MoveCursorToCrossHair();
+ screen->m_BlockLocate.SetMessageBlock( this );
+ screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
+ HandleBlockEnd( &dc );
+ }
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
- HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
+ {
+ m_canvas->MoveCursorToCrossHair();
+ screen->m_BlockLocate.SetMessageBlock( this );
+ screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
+ HandleBlockEnd( &dc );
+ }
else
+ {
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
+ }
return;
}
diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp
index 76f7013047..6c4f4d086e 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -462,7 +462,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
case wxID_NO:
break;
- case wxID_OK:
case wxID_YES:
wxCommandEvent tmp( ID_SAVE_PROJECT );
OnSaveProject( tmp );
diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h
index ac97e87eb2..da0c511604 100644
--- a/gerbview/class_gbr_layout.h
+++ b/gerbview/class_gbr_layout.h
@@ -81,9 +81,12 @@ public:
* @param aDC = the current device context
* @param aDrawMode = GR_COPY, GR_OR ... (not always used)
* @param aOffset = an draw offset value
+ * @param aPrintBlackAndWhite = true to force black and white insdeat of color
+ * useful only to print/plot gebview layers
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
- GR_DRAWMODE aDrawMode, const wxPoint& aOffset );
+ GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
+ bool aPrintBlackAndWhite = false );
/**
* Function SetVisibleLayers
diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp
index e49e2bdf6c..da67c4989b 100644
--- a/gerbview/dialogs/dialog_print_using_printer.cpp
+++ b/gerbview/dialogs/dialog_print_using_printer.cpp
@@ -16,7 +16,6 @@
#include
#include
-#include
static long s_SelectedLayers;
static double s_ScaleList[] =
@@ -34,10 +33,10 @@ static wxPageSetupDialogData* g_pageSetupData = (wxPageSetupDialogData*) NULL;
static PRINT_PARAMETERS s_Parameters;
-/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base
+/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_BASE
* created by wxFormBuilder
*/
-class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base
+class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
@@ -76,17 +75,17 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
*/
{
if( g_PrintData == NULL ) // First print
- {
g_PrintData = new wxPrintData();
- if( !g_PrintData->Ok() )
- {
- DisplayError( this, _( "Error Init Printer info" ) );
- }
- g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
+ if( !g_PrintData->Ok() )
+ {
+ DisplayError( this, _( "Error Init Printer info" ) );
+ return;
}
- g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? wxPORTRAIT : wxLANDSCAPE );
+ g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );
+ g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ?
+ wxPORTRAIT : wxLANDSCAPE );
DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this );
@@ -97,24 +96,19 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
/*************************************************************************************/
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ) :
- DIALOG_PRINT_USING_PRINTER_base( parent )
+ DIALOG_PRINT_USING_PRINTER_BASE( parent )
/*************************************************************************************/
{
m_Parent = parent;
m_Config = wxGetApp().GetSettings();
InitValues( );
+ GetSizer()->SetSizeHints( this );
- if( GetSizer() )
- {
- GetSizer()->SetSizeHints( this );
- }
#ifdef __WXMAC__
/* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */
m_buttonPreview->Hide();
#endif
-
- m_buttonPrint->SetDefault();
}
@@ -130,7 +124,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
{
g_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins.
- // Margins are already set in Pcbnew, so we cans use 0
+ // Margins are already set in Pcbnew, so we can use 0
g_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
g_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
}
@@ -176,7 +170,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
s_SelectedLayers = 0;
- for( LAYER_NUM layer = FIRST_LAYER; layerSetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
@@ -52,6 +52,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
bmiddleLeftSizer->Add( m_FineAdjustXscaleTitle, 0, wxRIGHT|wxLEFT, 5 );
m_FineAdjustXscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+ m_FineAdjustXscaleOpt->SetMaxLength( 0 );
m_FineAdjustXscaleOpt->SetToolTip( _("Set X scale adjust for exact scale plotting") );
bmiddleLeftSizer->Add( m_FineAdjustXscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
@@ -61,6 +62,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
bmiddleLeftSizer->Add( m_FineAdjustYscaleTitle, 0, wxRIGHT|wxLEFT, 5 );
m_FineAdjustYscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+ m_FineAdjustYscaleOpt->SetMaxLength( 0 );
m_FineAdjustYscaleOpt->SetToolTip( _("Set Y scale adjust for exact scale plotting") );
bmiddleLeftSizer->Add( m_FineAdjustYscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
@@ -101,6 +103,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
b_buttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_buttonPrint->SetDefault();
b_buttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -114,22 +117,22 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
this->Layout();
// Connect Events
- this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
- m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnScaleSelectionClick ), NULL, this );
- m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPageSetup ), NULL, this );
- m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
- m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
- m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this );
+ this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
+ m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
+ m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this );
+ m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this );
+ m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this );
+ m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this );
}
-DIALOG_PRINT_USING_PRINTER_base::~DIALOG_PRINT_USING_PRINTER_base()
+DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE()
{
// Disconnect Events
- this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
- m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnScaleSelectionClick ), NULL, this );
- m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPageSetup ), NULL, this );
- m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
- m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
- m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this );
+ this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
+ m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
+ m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this );
+ m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this );
+ m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this );
+ m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this );
}
diff --git a/gerbview/dialogs/dialog_print_using_printer_base.fbp b/gerbview/dialogs/dialog_print_using_printer_base.fbp
index 4ec6f23826..15aa57c9ec 100644
--- a/gerbview/dialogs/dialog_print_using_printer_base.fbp
+++ b/gerbview/dialogs/dialog_print_using_printer_base.fbp
@@ -40,7 +40,7 @@
wxID_ANY
-1,-1
- DIALOG_PRINT_USING_PRINTER_base
+ DIALOG_PRINT_USING_PRINTER_BASE
551,314
wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
@@ -1002,7 +1002,7 @@
1
1
- 0
+ 1
0
Dock
0
diff --git a/gerbview/dialogs/dialog_print_using_printer_base.h b/gerbview/dialogs/dialog_print_using_printer_base.h
index 987c209eb0..9f014ed829 100644
--- a/gerbview/dialogs/dialog_print_using_printer_base.h
+++ b/gerbview/dialogs/dialog_print_using_printer_base.h
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Apr 10 2012)
+// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -11,6 +11,8 @@
#include
#include
#include
+class DIALOG_SHIM;
+
#include "dialog_shim.h"
#include
#include
@@ -29,9 +31,9 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-/// Class DIALOG_PRINT_USING_PRINTER_base
+/// Class DIALOG_PRINT_USING_PRINTER_BASE
///////////////////////////////////////////////////////////////////////////////
-class DIALOG_PRINT_USING_PRINTER_base : public DIALOG_SHIM
+class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM
{
private:
@@ -68,8 +70,8 @@ class DIALOG_PRINT_USING_PRINTER_base : public DIALOG_SHIM
public:
- DIALOG_PRINT_USING_PRINTER_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 551,314 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
- ~DIALOG_PRINT_USING_PRINTER_base();
+ DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 551,314 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
+ ~DIALOG_PRINT_USING_PRINTER_BASE();
};
diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp
index b680f86902..525081a5bb 100644
--- a/gerbview/draw_gerber_screen.cpp
+++ b/gerbview/draw_gerber_screen.cpp
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
@@ -56,10 +57,13 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
m_DisplayOptions.m_DisplayDCodes = false;
m_DisplayOptions.m_IsPrinting = true;
- m_canvas->SetPrintMirrored( aPrintMirrorMode );
+ PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*)aData;
- // XXX -1 as drawmode?
- GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, wxPoint( 0, 0 ) );
+ m_canvas->SetPrintMirrored( aPrintMirrorMode );
+ bool printBlackAndWhite = printParameters && printParameters->m_Print_Black_and_White;
+
+ GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE,
+ wxPoint( 0, 0 ), printBlackAndWhite );
m_canvas->SetPrintMirrored( false );
@@ -123,13 +127,13 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
* Redraw All GerbView layers, using a buffered mode or not
*/
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
- const wxPoint& aOffset )
+ const wxPoint& aOffset, bool aPrintBlackAndWhite )
{
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// to a temporary bitmap
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
- // If aDrawMode = -1, items are drawn to the main screen, and therefore
+ // If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore
// artifacts can happen with negative items or negative images
wxColour bgColor = MakeColour( g_DrawBgColor );
@@ -200,7 +204,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
- if( layer == 32 ) // last loop: draw active layer
+ if( layer == NB_GERBER_LAYERS ) // last loop: draw active layer
{
end = true;
layer = active_layer;
@@ -214,6 +218,12 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( gerber == NULL ) // Graphic layer not yet used
continue;
+ EDA_COLOR_T color = gerbFrame->GetLayerColor( layer );
+
+ // Force black and white draw mode on request:
+ if( aPrintBlackAndWhite )
+ gerbFrame->SetLayerColor( layer, g_DrawBgColor == BLACK ? WHITE : BLACK );
+
if( useBufferBitmap )
{
// Draw each layer into a bitmap first. Negative Gerber
@@ -299,6 +309,9 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
doBlit = true;
}
+
+ if( aPrintBlackAndWhite )
+ gerbFrame->SetLayerColor( layer, color );
}
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp
index e06f59f07b..a16843f1f0 100644
--- a/gerbview/excellon_read_drill_file.cpp
+++ b/gerbview/excellon_read_drill_file.cpp
@@ -56,6 +56,12 @@
* T0
* M30
*/
+ /*
+ * Note there are some variant of tool definition:
+ * T1F00S00C0.2 or T1C0.02F00S00 ... Feed Rate and Spindle Speed of Tool 1
+ * Feed Rate and Spindle Speed are just skipped because they are not used in a viewer
+ */
+
#include
#include
#include
@@ -73,6 +79,14 @@
#include
+// Default format for dimensions
+// number of digits in mantissa:
+static int fmtMantissaMM = 3;
+static int fmtMantissaInch = 4;
+// number of digits, integer part:
+static int fmtIntegerMM = 3;
+static int fmtIntegerInch = 2;
+
extern int ReadInt( char*& text, bool aSkipSeparator = true );
extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
@@ -334,7 +348,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
m_State = READ_PROGRAM_STATE;
break;
- case DRILL_REWIND_STOP: // TODO: what this command really is ?
+ case DRILL_REWIND_STOP: // End of header. No action in a viewer
m_State = READ_PROGRAM_STATE;
break;
@@ -426,12 +440,21 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
case DRILL_TOOL_INFORMATION:
// Read a tool definition like T1C0.02:
+ // or T1F00S00C0.02 or T1C0.02F00S00
// Read tool number:
iprm = ReadInt( text, false );
+ // Skip Feed rate and Spindle speed, if any here
+ while( *text && ( *text == 'F' || *text == 'S' ) )
+ {
+ text++;
+ ReadInt( text, false );
+ }
+
// Read tool shape
if( *text != 'C' )
- ReportMessage( _( "Tool definition <%c> not supported" ) );
+ ReportMessage( wxString:: Format(
+ _( "Tool definition <%c> not supported" ), *text ) );
if( *text )
text++;
@@ -622,19 +645,30 @@ bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text )
void EXCELLON_IMAGE::SelectUnits( bool aMetric )
{
- /* Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution (00.0000)
- * metric: Default fmt = 3.2 for X and Y axis: 5 digits, 1 micron resolution (00.000)
+ /* Coordinates are measured either in inch or metric (millimeters).
+ * Inch coordinates are in six digits (00.0000) with increments
+ * as small as 0.0001 (1/10,000).
+ * Metric coordinates can be measured in microns (thousandths of a millimeter)
+ * in one of the following three ways:
+ * Five digit 10 micron resolution (000.00)
+ * Six digit 10 micron resolution (0000.00)
+ * Six digit micron resolution (000.000)
+ */
+ /* Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution
+ * metric: Default fmt = 3.3 for X and Y axis: 6 digits, 1 micron resolution
*/
if( aMetric )
{
m_GerbMetric = true;
- m_FmtScale.x = m_FmtScale.y = 3; // number of digits in mantissa: here 2
- m_FmtLen.x = m_FmtLen.y = 5; // number of digits: here 3+2
+ // number of digits in mantissa
+ m_FmtScale.x = m_FmtScale.y = fmtMantissaMM;
+ // number of digits (mantissa+interger)
+ m_FmtLen.x = m_FmtLen.y = fmtIntegerMM+fmtMantissaMM;
}
else
{
m_GerbMetric = false;
- m_FmtScale.x = m_FmtScale.y = 4; // number of digits in mantissa: here 4
- m_FmtLen.x = m_FmtLen.y = 6; // number of digits: here 2+4
+ m_FmtScale.x = m_FmtScale.y = fmtMantissaInch;
+ m_FmtLen.x = m_FmtLen.y = fmtIntegerInch+fmtMantissaInch;
}
}
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index 5e3af4cadd..1594f5d7af 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -141,7 +141,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
wxFileDialog filedlg( this, _( "Board file name:" ),
path, fileName, LegacyPcbFileWildcard,
- wxFD_OPEN );
+ wxFD_SAVE );
if( filedlg.ShowModal() == wxID_CANCEL )
return;
@@ -233,7 +233,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
#define SEG_SHAPE 0
#define ARC_SHAPE 2
int shape = SEG_SHAPE;
-
+
// please note: the old PCB format only has integer support for angles
int angle = 0;
wxPoint seg_start, seg_end;
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index 9bfac36737..0aaeef6917 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -378,14 +378,14 @@ void GERBVIEW_FRAME::syncLayerBox()
UpdateTitleAndInfo();
}
-
void GERBVIEW_FRAME::Liste_D_Codes()
{
int ii, jj;
D_CODE* pt_D_code;
wxString Line;
wxArrayString list;
- double scale = IU_PER_MILS * 1000;
+ double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 :
+ IU_PER_MM;
LAYER_NUM curr_layer = getActiveLayer();
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
@@ -405,6 +405,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
list.Add( Line );
+ const char* units = g_UserUnit == INCHES ? "\"" : "mm";
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
{
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
@@ -415,19 +416,19 @@ void GERBVIEW_FRAME::Liste_D_Codes()
if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
continue;
- Line.Printf( wxT( "tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ),
+ Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s " ),
jj,
pt_D_code->m_Num_Dcode,
- pt_D_code->m_Size.y / scale,
- pt_D_code->m_Size.x / scale,
+ pt_D_code->m_Size.y / scale, units,
+ pt_D_code->m_Size.x / scale, units,
D_CODE::ShowApertureType( pt_D_code->m_Shape )
);
if( !pt_D_code->m_Defined )
- Line += wxT( " ?" );
+ Line += wxT( "(not used)" );
if( !pt_D_code->m_InUse )
- Line += wxT( " *" );
+ Line += wxT( "(in use)" );
list.Add( Line );
jj++;
diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h
index a50c9b2241..352a71f892 100644
--- a/include/appl_wxstruct.h
+++ b/include/appl_wxstruct.h
@@ -91,24 +91,27 @@ protected:
wxLocale* m_Locale;
/// The current language setting.
- int m_LanguageId;
+ int m_LanguageId;
/// The file name of the the program selected for browsing pdf files.
- wxString m_PdfBrowser;
+ wxString m_PdfBrowser;
+ wxPathList m_searchPaths;
+ wxFileHistory m_fileHistory;
+ wxString m_HelpFileName;
+ wxString m_EditorName;
+ wxString m_CurrentOptionFile;
+ wxString m_CurrentOptionFileDateAndTime;
+ wxPoint m_HelpPos;
+ wxSize m_HelpSize;
+ wxString m_Title;
+ wxPathList m_libSearchPaths;
+ wxFileName m_projectFileName;
+ wxString m_LastVisitedLibPath;
- wxPathList m_searchPaths;
- wxFileHistory m_fileHistory;
- wxString m_HelpFileName;
- wxString m_EditorName;
- wxString m_CurrentOptionFile;
- wxString m_CurrentOptionFileDateAndTime;
- wxPoint m_HelpPos;
- wxSize m_HelpSize;
- wxHtmlHelpController* m_HtmlCtrl;
- wxString m_Title;
- wxPathList m_libSearchPaths;
- wxFileName m_projectFileName;
- wxString m_LastVisitedLibPath;
+ /// last visited module library in the module editor or viewer
+ wxString m_module_nickname;
+
+ wxHtmlHelpController* m_HtmlCtrl;
public:
EDA_APP();
@@ -125,17 +128,15 @@ public:
void SetHtmlHelpController( wxHtmlHelpController* aController );
- wxString GetHelpFileName() const { return m_HelpFileName; }
-
- void SetHelpFileName( const wxString& aFileName ) { m_HelpFileName = aFileName; }
+ wxString GetHelpFileName() const { return m_HelpFileName; }
+ void SetHelpFileName( const wxString& aFileName ) { m_HelpFileName = aFileName; }
wxConfig* GetSettings() { return m_settings; }
wxConfig* GetCommonSettings() { return m_commonSettings; }
- wxString GetEditorName() const { return m_EditorName; }
-
- void SetEditorName( const wxString& aFileName ) { m_EditorName = aFileName; }
+ wxString GetEditorName() const { return m_EditorName; }
+ void SetEditorName( const wxString& aFileName ) { m_EditorName = aFileName; }
wxString GetCurrentOptionFile() const { return m_CurrentOptionFile; }
@@ -349,8 +350,8 @@ public:
*/
wxString& GetEditorName();
- const wxString& GetTitle() { return m_Title; }
- void SetTitle( const wxString& title ) { m_Title = title; }
+ const wxString& GetTitle() { return m_Title; }
+ void SetTitle( const wxString& aTitle ) { m_Title = aTitle; }
wxPathList& GetLibraryPathList() { return m_libSearchPaths; }
wxString FindLibraryPath( const wxString& fileName );
@@ -431,6 +432,9 @@ public:
* @return false if the KISYSMOD path is not valid.
*/
bool SetFootprintLibTablePath();
+
+ const wxString& GetModuleLibraryNickname() { return m_module_nickname; }
+ void SetModuleLibraryNickname( const wxString& aNickname ) { m_module_nickname = aNickname; }
};
diff --git a/include/base_struct.h b/include/base_struct.h
index 0e7ae53d65..530e0e1fc9 100644
--- a/include/base_struct.h
+++ b/include/base_struct.h
@@ -47,6 +47,10 @@ extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt );
#endif
+/// Flag to enable find and replace tracing using the WXTRACE environment variable.
+extern const wxString traceFindReplace;
+
+
/**
* Enum FILL_T
* is the set of fill types used in plotting or drawing enclosed areas.
@@ -203,11 +207,25 @@ public:
/**
* Function Intersects
+ * tests for a common area between rectangles.
+ *
+ * @param aRect A rectangle to test intersection with.
* @return bool - true if the argument rectangle intersects this rectangle.
* (i.e. if the 2 rectangles have at least a common point)
*/
bool Intersects( const EDA_RECT& aRect ) const;
+ /**
+ * Function Intersects
+ * tests for a common area between a segment and this rectangle.
+ *
+ * @param aPoint1 First point of the segment to test intersection with.
+ * @param aPoint2 Second point of the segment to test intersection with.
+ * @return bool - true if the argument segment intersects this rectangle.
+ * (i.e. if the segment and rectangle have at least a common point)
+ */
+ bool Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const;
+
/**
* Function operator(wxRect)
* overloads the cast operator to return a wxRect
@@ -441,18 +459,6 @@ public:
return false; // derived classes should override this function
}
- /**
- * Function HitTest
- * tests if the \a aRect intersects this object.
- * For now, an ending point must be inside \a aRect.
- *
- * @param aRect A reference to an EDA_RECT object containg the area to test.
- * @return True if \a aRect intersects the object, otherwise false.
- */
- virtual bool HitTest( const EDA_RECT& aRect ) const
- {
- return false; // derived classes should override this function
- }
/**
* Function GetBoundingBox
diff --git a/include/class_bitmap_base.h b/include/class_bitmap_base.h
index a735c2772b..db07c41d6c 100644
--- a/include/class_bitmap_base.h
+++ b/include/class_bitmap_base.h
@@ -6,8 +6,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 2011 jean-pierre.charras
- * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors.
+ * Copyright (C) 2013 jean-pierre.charras jp.charras at wanadoo.fr
+ * Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,13 +31,13 @@
#define _BITMAP_BASE_H_
-#include
+class PLOTTER;
/**
* This class handle bitmap images in KiCad.
* It is not intended to be used alone, but inside an other class,
* so all methods are protected ( or private )
- * It is used in SCH_BITMAP class (and other in futute)
+ * It is used in SCH_BITMAP class and WS_DRAW_ITEM_BITMAP (and other in future)
*
* Remember not all plotters are able to plot a bitmap
* Mainly GERBER plotters cannot.
@@ -54,6 +54,7 @@ private:
// to convert the bitmap size (in pixels)
// to internal KiCad units
// Usually does not change
+ int m_ppi; // the bitmap definition. the default is 300PPI
public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
@@ -106,13 +107,13 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
/**
* Function GetSize
- * @returns the actual size (in user units, not in pixels) of the image
+ * @return the actual size (in user units, not in pixels) of the image
*/
wxSize GetSize() const;
/**
* Function GetSizePixels
- * @returns the size in pixels of the image
+ * @return the size in pixels of the image
*/
wxSize GetSizePixels() const
{
@@ -122,6 +123,15 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
return wxSize(0,0);
}
+ /**
+ * @return the bitmap definition in ppi
+ * the default is 300 ppi
+ */
+ int GetPPI() const
+ {
+ return m_ppi;
+ }
+
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display
@@ -136,8 +146,8 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
/**
* Function ReadImageFile
- * Reads and stores an image file. Init the bitmap used to draw this item
- * format.
+ * Reads and stores in memory an image file.
+ * Init the bitmap format used to draw this item.
* supported images formats are format supported by wxImage
* if all handlers are loaded
* by default, .png, .jpeg are alway loaded
@@ -147,7 +157,6 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
bool ReadImageFile( const wxString& aFullFilename );
/**
- * Function
* writes the bitmap data to aFile
* The format is png, in Hexadecimal form:
* If the hexadecimal data is converted to binary it gives exactly a .png image data
@@ -156,9 +165,17 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
*/
bool SaveData( FILE* aFile ) const;
+ /**
+ * writes the bitmap data to an array string
+ * The format is png, in Hexadecimal form:
+ * If the hexadecimal data is converted to binary it gives exactly a .png image data
+ * @param aPngStrings The wxArrayString to write to.
+ */
+ void SaveData( wxArrayString& aPngStrings ) const;
+
/**
* Load an image data saved by SaveData (png, in Hexadecimal form)
- * @param aLine - Essentially this is file to read schematic junction from.
+ * @param aLine - the LINE_READER used to read the data file.
* @param aErrorMsg - Description of the error if an error occurs while loading the
* png bimap data.
* @return true if the bitmap loaded successfully.
@@ -191,7 +208,7 @@ public: BITMAP_BASE( const wxPoint& pos = wxPoint( 0, 0 ) );
* @param aDefaultColor = the color used to plot the rectangle when bitmap is not supported
* @param aDefaultPensize = the pen size used to plot the rectangle when bitmap is not supported
*/
- void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos,
+ void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos,
EDA_COLOR_T aDefaultColor, int aDefaultPensize );
};
diff --git a/include/class_board_item.h b/include/class_board_item.h
index f63e141ed7..338e931c62 100644
--- a/include/class_board_item.h
+++ b/include/class_board_item.h
@@ -227,6 +227,26 @@ public:
*/
wxString GetLayerName() const;
+ virtual bool HitTest( const wxPoint& aPosition )
+ {
+ return EDA_ITEM::HitTest( aPosition );
+ }
+
+ /**
+ * Function HitTest
+ * tests if the \a aRect intersects or contains this object (depending on \a aContained).
+ *
+ * @param aRect A reference to an EDA_RECT object containg the area to test.
+ * @param aContained Test if \a aRect contains this object completly.
+ * @param aAccuracy Increase the item bounding box by this amount.
+ * @return bool - True if \a aRect contains this object completly or if \a aRect intersects
+ * the object and \a aContained is False, otherwise false.
+ */
+ virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0) const
+ {
+ return false; // derived classes should override this function
+ }
+
/**
* Function FormatInternalUnits
diff --git a/include/class_drc_item.h b/include/class_drc_item.h
index 978178d185..421748322d 100644
--- a/include/class_drc_item.h
+++ b/include/class_drc_item.h
@@ -146,31 +146,45 @@ public:
wxString ShowHtml() const
{
wxString ret;
+ wxString mainText = m_MainText;
+ // a wxHtmlWindows does not like < and > in the text to display
+ // because these chars have a special meaning in html
+ mainText.Replace( wxT("<"), wxT("<") );
+ mainText.Replace( wxT(">"), wxT(">") );
+
+ wxString errText = GetErrorText();
+ errText.Replace( wxT("<"), wxT("<") );
+ errText.Replace( wxT(">"), wxT(">") );
+
if( m_noCoordinate )
{
// omit the coordinate, a NETCLASS has no location
ret.Printf( _( "ErrType(%d): %s" ),
m_ErrorCode,
- GetChars( GetErrorText() ),
- GetChars( m_MainText ) );
+ GetChars( errText ),
+ GetChars( mainText ) );
}
else if( m_hasSecondItem )
{
+ wxString auxText = m_AuxiliaryText;
+ auxText.Replace( wxT("<"), wxT("<") );
+ auxText.Replace( wxT(">"), wxT(">") );
+
// an html fragment for the entire message in the listbox. feel free
// to add color if you want:
ret.Printf( _( "ErrType(%d): %s" ),
m_ErrorCode,
- GetChars( GetErrorText() ),
- GetChars( ShowCoord( m_MainPosition )), GetChars( m_MainText ),
- GetChars( ShowCoord( m_AuxiliaryPosition )), GetChars( m_AuxiliaryText ) );
+ GetChars( errText ),
+ GetChars( ShowCoord( m_MainPosition )), GetChars( mainText ),
+ GetChars( ShowCoord( m_AuxiliaryPosition )), GetChars( auxText ) );
}
else
{
ret.Printf( _( "ErrType(%d): %s" ),
m_ErrorCode,
- GetChars( GetErrorText() ),
- GetChars( ShowCoord( m_MainPosition ) ), GetChars( m_MainText ) );
+ GetChars( errText ),
+ GetChars( ShowCoord( m_MainPosition ) ), GetChars( mainText ) );
}
return ret;
diff --git a/include/class_worksheet_dataitem.h b/include/class_worksheet_dataitem.h
index 8299843041..5be7fea9ad 100644
--- a/include/class_worksheet_dataitem.h
+++ b/include/class_worksheet_dataitem.h
@@ -8,6 +8,7 @@
#include ]