Merged upstream.

This commit is contained in:
Maciej Suminski 2013-10-28 21:34:06 +01:00
commit e13f862145
271 changed files with 99634 additions and 7264 deletions

View File

@ -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

View File

@ -489,21 +489,21 @@ 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 );
}

View File

@ -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<S3D_VERTEX>& 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;
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 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 );
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:
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 );
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 );
}

View File

@ -34,7 +34,6 @@
#include <info3d_visu.h>
#include <3d_draw_basic_functions.h>
// Imported function:
extern void Set_Object_Data( std::vector<S3D_VERTEX>& 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 );
}

View File

@ -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_

View File

@ -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;

View File

@ -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 <stambaughw@verizon.net>
* 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 <stambaughw@verizon.net>
* 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()

View File

@ -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,

View File

@ -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 );
}

View File

@ -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;
}

View File

@ -63,25 +63,27 @@ public: S3D_COLOR()
};
/* information needed to display 3D board */
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_SHOW_BOARD_BODY,
FL_USE_REALISTIC_MODE,
FL_LAST
};
class INFO3D_VISU
{
public:
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;

View File

@ -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)
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,7 +425,7 @@ endif()
#================================================
# make uninstall rules
# "make uninstall" rules
#================================================
configure_file(
"${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
@ -454,8 +437,14 @@ add_custom_target( uninstall
#================================================
# 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 )
@ -471,13 +460,14 @@ if( UNIX )
install( DIRECTORY scripts
DESTINATION ${KICAD_DOCS}
COMPONENT resources
PATTERN ".svn" EXCLUDE )
)
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 <email@company.com> )
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()

View File

@ -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 )
# Definition to conditionally use date and revision returned from the
# Bazaar log command instead of hand coded date and revision in

View File

@ -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 )

View File

@ -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)

View File

@ -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." )

View File

@ -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.

View File

@ -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 <dick@softplc.com>
# 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.
#-----<configure>-------------------------------------------------------------------------------------
# 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
#-----</configure>-----------------------------------------------------------------------------------
# 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 <SOURCE_DIR> <INSTALL_DIR>
)
set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" )
mark_as_advanced( AVHTTP_INCLUDE_DIR )

View File

@ -29,13 +29,8 @@
#-----<configure>----------------------------------------------------------------
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()
# 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.sh )
set( bootstrap ./bootstrap.bat mingw )
endif()
foreach( lib ${boost_libs_list} )
set( b2_libs ${b2_libs} --with-${lib} )
endforeach()
unset( PIC_STUFF )
else()
string( REGEX REPLACE "\\;" "," libs_csv "${boost_libs_list}" )
#message( STATUS "libs_csv:${libs_csv}" )
set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} )
# pass to *both* C and C++ compilers
set( 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_DIR>
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}"

View File

@ -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 <dick@softplc.com>
# 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.
#-----<configure>-------------------------------------------------------------------------------------
set( OPENSSL_RELEASE "1.0.1e" )
set( OPENSSL_MD5 66bf6f10f060d561929de96f9dfe5b8c ) # re-calc on every RELEASE change
#-----</configure>-----------------------------------------------------------------------------------
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}
<SOURCE_DIR>/Configure
${MW}
--prefix=<INSTALL_DIR>
${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 <SOURCE_DIR>
COMMENT "committing pristine ${target} files to '${target} scratch repo'"
DEPENDERS patch
)
ExternalProject_Add_Step( ${target} bzr_add_${target}
COMMAND bzr add -q <SOURCE_DIR>
COMMENT "adding pristine ${target} files to '${target} scratch repo'"
DEPENDERS bzr_commit_${target}
)
ExternalProject_Add_Step( ${target} bzr_init_${target}
COMMAND bzr init -q <SOURCE_DIR>
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 )

View File

@ -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

View File

@ -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.:
<filename.kicad_pcb>
<longpath/subdir>
'FOOTPRINTNAME'
'anything else'

View File

@ -131,10 +131,14 @@ Installation from source code
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).

View File

@ -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!/

View File

@ -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 )

View File

@ -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

View File

@ -49,8 +49,9 @@ BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
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.

View File

@ -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 );

View File

@ -35,6 +35,7 @@
#include <drawtxt.h>
#include <class_title_block.h>
#include "worksheet_shape_builder.h"
#include "class_worksheet_dataitem.h"
#include <wx/filename.h>
@ -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;
}
}
}

View File

@ -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 <common.h>
#include <wx/wx.h>
#include <wx/html/htmlwin.h>
#include <wx/stockitem.h>
#include <html_messagebox.h>
#include <dialog_exit_base.h>
#include <bitmaps.h>
@ -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() )
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();
}

View File

@ -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;
}

View File

@ -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();

View File

@ -2,11 +2,13 @@
<wxFormBuilder_Project>
<FileVersion major="1" minor="11" />
<object class="Project" expanded="1">
<property name="class_decoration" />
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_hotkeys_editor_base</property>
@ -14,73 +16,78 @@
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">dialog_hotkeys_editor_base</property>
<property name="namespace" />
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header" />
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="bg" />
<property name="center" />
<property name="context_help" />
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style" />
<property name="fg" />
<property name="font" />
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size" />
<property name="minimum_size" />
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">HOTKEYS_EDITOR_DIALOG_BASE</property>
<property name="pos" />
<property name="pos"></property>
<property name="size">304,235</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass" />
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Hotkeys Editor</property>
<property name="tooltip" />
<property name="validator_data_type" />
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable" />
<property name="window_extra_style" />
<property name="window_name" />
<property name="window_style" />
<event name="OnActivate" />
<event name="OnActivateApp" />
<event name="OnChar" />
<event name="OnClose" />
<event name="OnEnterWindow" />
<event name="OnEraseBackground" />
<event name="OnHibernate" />
<event name="OnIconize" />
<event name="OnIdle" />
<event name="OnInitDialog" />
<event name="OnKeyDown" />
<event name="OnKeyUp" />
<event name="OnKillFocus" />
<event name="OnLeaveWindow" />
<event name="OnLeftDClick" />
<event name="OnLeftDown" />
<event name="OnLeftUp" />
<event name="OnMiddleDClick" />
<event name="OnMiddleDown" />
<event name="OnMiddleUp" />
<event name="OnMotion" />
<event name="OnMouseEvents" />
<event name="OnMouseWheel" />
<event name="OnPaint" />
<event name="OnRightDClick" />
<event name="OnRightDown" />
<event name="OnRightUp" />
<event name="OnSetFocus" />
<event name="OnSize" />
<event name="OnUpdateUI" />
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size" />
<property name="minimum_size"></property>
<property name="name">bMainSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
@ -89,115 +96,142 @@
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="autosize_cols">1</property>
<property name="autosize_rows">0</property>
<property name="bg" />
<property name="cell_bg" />
<property name="cell_font" />
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text" />
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="col_label_size">30</property>
<property name="col_label_values" />
<property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">2</property>
<property name="column_sizes" />
<property name="context_help" />
<property name="column_sizes"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">1</property>
<property name="editing">0</property>
<property name="enabled">1</property>
<property name="fg" />
<property name="font" />
<property name="grid_line_color" />
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg" />
<property name="label_font" />
<property name="label_text" />
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="maximum_size" />
<property name="minimum_size" />
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_hotkeyGrid</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pos" />
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="row_label_size">0</property>
<property name="row_label_values" />
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes" />
<property name="row_sizes"></property>
<property name="rows">1</property>
<property name="size" />
<property name="subclass" />
<property name="tooltip" />
<property name="validator_data_type" />
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable" />
<property name="window_extra_style" />
<property name="window_name" />
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxDOUBLE_BORDER|wxTAB_TRAVERSAL|wxWANTS_CHARS</property>
<event name="OnChar">OnKeyPressed</event>
<event name="OnEnterWindow" />
<event name="OnEraseBackground" />
<event name="OnGridCellChange" />
<event name="OnGridCellLeftClick" />
<event name="OnGridCellLeftDClick" />
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick">OnRightClickOnCell</event>
<event name="OnGridCellRightDClick" />
<event name="OnGridCmdCellChange" />
<event name="OnGridCmdCellLeftClick" />
<event name="OnGridCmdCellLeftDClick" />
<event name="OnGridCmdCellRightClick" />
<event name="OnGridCmdCellRightDClick" />
<event name="OnGridCmdColSize" />
<event name="OnGridCmdEditorCreated" />
<event name="OnGridCmdEditorHidden" />
<event name="OnGridCmdEditorShown" />
<event name="OnGridCmdLabelLeftClick" />
<event name="OnGridCmdLabelLeftDClick" />
<event name="OnGridCmdLabelRightClick" />
<event name="OnGridCmdLabelRightDClick" />
<event name="OnGridCmdRangeSelect" />
<event name="OnGridCmdRowSize" />
<event name="OnGridCmdSelectCell" />
<event name="OnGridColSize" />
<event name="OnGridEditorCreated" />
<event name="OnGridEditorHidden" />
<event name="OnGridEditorShown" />
<event name="OnGridLabelLeftClick" />
<event name="OnGridLabelLeftDClick" />
<event name="OnGridLabelRightClick" />
<event name="OnGridLabelRightDClick" />
<event name="OnGridRangeSelect" />
<event name="OnGridRowSize" />
<event name="OnGridCellRightDClick"></event>
<event name="OnGridCmdCellChange"></event>
<event name="OnGridCmdCellLeftClick"></event>
<event name="OnGridCmdCellLeftDClick"></event>
<event name="OnGridCmdCellRightClick"></event>
<event name="OnGridCmdCellRightDClick"></event>
<event name="OnGridCmdColSize"></event>
<event name="OnGridCmdEditorCreated"></event>
<event name="OnGridCmdEditorHidden"></event>
<event name="OnGridCmdEditorShown"></event>
<event name="OnGridCmdLabelLeftClick"></event>
<event name="OnGridCmdLabelLeftDClick"></event>
<event name="OnGridCmdLabelRightClick"></event>
<event name="OnGridCmdLabelRightDClick"></event>
<event name="OnGridCmdRangeSelect"></event>
<event name="OnGridCmdRowSize"></event>
<event name="OnGridCmdSelectCell"></event>
<event name="OnGridColSize"></event>
<event name="OnGridEditorCreated"></event>
<event name="OnGridEditorHidden"></event>
<event name="OnGridEditorShown"></event>
<event name="OnGridLabelLeftClick"></event>
<event name="OnGridLabelLeftDClick"></event>
<event name="OnGridLabelRightClick"></event>
<event name="OnGridLabelRightDClick"></event>
<event name="OnGridRangeSelect"></event>
<event name="OnGridRowSize"></event>
<event name="OnGridSelectCell">OnClickOnCell</event>
<event name="OnKeyDown" />
<event name="OnKeyUp" />
<event name="OnKillFocus" />
<event name="OnLeaveWindow" />
<event name="OnLeftDClick" />
<event name="OnLeftDown" />
<event name="OnLeftUp" />
<event name="OnMiddleDClick" />
<event name="OnMiddleDown" />
<event name="OnMiddleUp" />
<event name="OnMotion" />
<event name="OnMouseEvents" />
<event name="OnMouseWheel" />
<event name="OnPaint" />
<event name="OnRightDClick" />
<event name="OnRightDown" />
<event name="OnRightUp" />
<event name="OnSetFocus" />
<event name="OnSize" />
<event name="OnUpdateUI" />
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -205,7 +239,7 @@
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size" />
<property name="minimum_size"></property>
<property name="name">b_buttonsSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
@ -214,56 +248,87 @@
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg" />
<property name="context_help" />
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg" />
<property name="font" />
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_OK</property>
<property name="label">OK</property>
<property name="maximum_size" />
<property name="minimum_size" />
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_OKButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pos" />
<property name="size" />
<property name="style" />
<property name="subclass" />
<property name="tooltip" />
<property name="validator_data_type" />
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable" />
<property name="window_extra_style" />
<property name="window_name" />
<property name="window_style" />
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnOKClicked</event>
<event name="OnChar" />
<event name="OnEnterWindow" />
<event name="OnEraseBackground" />
<event name="OnKeyDown" />
<event name="OnKeyUp" />
<event name="OnKillFocus" />
<event name="OnLeaveWindow" />
<event name="OnLeftDClick" />
<event name="OnLeftDown" />
<event name="OnLeftUp" />
<event name="OnMiddleDClick" />
<event name="OnMiddleDown" />
<event name="OnMiddleUp" />
<event name="OnMotion" />
<event name="OnMouseEvents" />
<event name="OnMouseWheel" />
<event name="OnPaint" />
<event name="OnRightDClick" />
<event name="OnRightDown" />
<event name="OnRightUp" />
<event name="OnSetFocus" />
<event name="OnSize" />
<event name="OnUpdateUI" />
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -271,56 +336,87 @@
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg" />
<property name="context_help" />
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg" />
<property name="font" />
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_CANCEL</property>
<property name="label">Close</property>
<property name="maximum_size" />
<property name="minimum_size" />
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name"> m_cancelButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pos" />
<property name="size" />
<property name="style" />
<property name="subclass" />
<property name="tooltip" />
<property name="validator_data_type" />
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable" />
<property name="window_extra_style" />
<property name="window_name" />
<property name="window_style" />
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">CancelClicked</event>
<event name="OnChar" />
<event name="OnEnterWindow" />
<event name="OnEraseBackground" />
<event name="OnKeyDown" />
<event name="OnKeyUp" />
<event name="OnKillFocus" />
<event name="OnLeaveWindow" />
<event name="OnLeftDClick" />
<event name="OnLeftDown" />
<event name="OnLeftUp" />
<event name="OnMiddleDClick" />
<event name="OnMiddleDown" />
<event name="OnMiddleUp" />
<event name="OnMotion" />
<event name="OnMouseEvents" />
<event name="OnMouseWheel" />
<event name="OnPaint" />
<event name="OnRightDClick" />
<event name="OnRightDown" />
<event name="OnRightUp" />
<event name="OnSetFocus" />
<event name="OnSize" />
<event name="OnUpdateUI" />
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -328,56 +424,87 @@
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg" />
<property name="context_help" />
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg" />
<property name="font" />
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_CANCEL</property>
<property name="label">Undo</property>
<property name="maximum_size" />
<property name="minimum_size" />
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_undoButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pos" />
<property name="size" />
<property name="style" />
<property name="subclass" />
<property name="tooltip" />
<property name="validator_data_type" />
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable" />
<property name="window_extra_style" />
<property name="window_name" />
<property name="window_style" />
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">UndoClicked</event>
<event name="OnChar" />
<event name="OnEnterWindow" />
<event name="OnEraseBackground" />
<event name="OnKeyDown" />
<event name="OnKeyUp" />
<event name="OnKillFocus" />
<event name="OnLeaveWindow" />
<event name="OnLeftDClick" />
<event name="OnLeftDown" />
<event name="OnLeftUp" />
<event name="OnMiddleDClick" />
<event name="OnMiddleDown" />
<event name="OnMiddleUp" />
<event name="OnMotion" />
<event name="OnMouseEvents" />
<event name="OnMouseWheel" />
<event name="OnPaint" />
<event name="OnRightDClick" />
<event name="OnRightDown" />
<event name="OnRightUp" />
<event name="OnSetFocus" />
<event name="OnSize" />
<event name="OnUpdateUI" />
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>

View File

@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////
// 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!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_hotkeys_editor_base__
#define __dialog_hotkeys_editor_base__
#ifndef __DIALOG_HOTKEYS_EDITOR_BASE_H__
#define __DIALOG_HOTKEYS_EDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
@ -26,7 +30,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class HOTKEYS_EDITOR_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog
class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM
{
private:
@ -52,4 +56,4 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog
};
#endif //__dialog_hotkeys_editor_base__
#endif //__DIALOG_HOTKEYS_EDITOR_BASE_H__

View File

@ -258,12 +258,15 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
{
m_orientationComboBox->Enable( true );
if( paperType.Contains( wxT( "A4" ) ) && IsGOST() )
#if 0
// ForcePortrait() does not exist, but could be useful.
// so I leave these lines, which could be seen as a todo feature
if( paperType.ForcePortrait() )
{
m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
m_orientationComboBox->Enable( false );
}
#endif
m_TextUserSizeX->Enable( false );
m_TextUserSizeY->Enable( false );
m_customFmt = false;

View File

@ -32,6 +32,13 @@
#include <trigo.h> // RotatePoint
#include <class_drawpanel.h> // EDA_DRAW_PANEL
// until bzr rev 4410, Y position of vertical justification
// of multiline texts was incorrectly calculated for BOTTOM
// and CENTER vertical justification. (Only the first line was justified)
// If this line is left uncommented, the bug is fixed, but
// creates a (very minor) issue for existing texts, mainly in Pcbnew
// because the text position is sometimes critical.
#define FIX_MULTILINE_VERT_JUSTIF
// Conversion to application internal units defined at build time.
#if defined( PCBNEW )
@ -90,6 +97,16 @@ int EDA_TEXT::LenSize( const wxString& aLine ) const
return ReturnGraphicTextWidth( aLine, m_Size.x, m_Italic, m_Bold );
}
/**
* Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
*/
int EDA_TEXT::GetInterline( int aTextThickness ) const
{
int thickness = aTextThickness <= 0 ? m_Thickness : aTextThickness;
return (( m_Size.y * 14 ) / 10) + thickness;
}
EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
{
@ -98,6 +115,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
wxArrayString* list = NULL;
wxString text = m_Text;
int thickness = ( aThickness < 0 ) ? m_Thickness : aThickness;
int linecount = 1;
if( m_MultilineAllowed )
{
@ -109,12 +127,14 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
text = list->Item( aLine );
else
text = list->Item( 0 );
linecount = list->GetCount();
}
}
// calculate the H and V size
int dx = LenSize( text );
int dy = GetInterline();
int dy = GetInterline( aThickness );
/* Creates bounding box (rectangle) for an horizontal text */
wxSize textsize = wxSize( dx, dy );
@ -183,6 +203,30 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY ) const
break;
}
if( linecount > 1 )
{
#ifdef FIX_MULTILINE_VERT_JUSTIF
int yoffset;
linecount -= 1;
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
yoffset = linecount * GetInterline() / 2;
rect.SetY( rect.GetY() - yoffset );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
yoffset = linecount * GetInterline( aThickness );
rect.SetY( rect.GetY() - yoffset );
break;
}
#endif
}
rect.Inflate( thickness / 2 );
rect.Normalize(); // Make h and v sizes always >= 0
@ -227,15 +271,31 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
offset.y = GetInterline();
#ifdef FIX_MULTILINE_VERT_JUSTIF
if( list->Count() > 1 )
{
switch( m_VJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
pos.y -= ( list->Count() - 1 ) * offset.y / 2;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
pos.y -= ( list->Count() - 1 ) * offset.y;
break;
}
}
#endif
RotatePoint( &offset, m_Orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
aDrawMode, aFillMode,
i ? UNSPECIFIED_COLOR : aAnchor_color,
txt, pos );
aDrawMode, aFillMode, txt, pos );
pos += offset;
}
@ -243,15 +303,21 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
}
else
drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
aDrawMode, aFillMode,
aAnchor_color, m_Text, m_Pos );
aDrawMode, aFillMode, m_Text, m_Pos );
// Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR )
{
GRDrawAnchor( aClipBox, aDC,
m_Pos.x + aOffset.x, m_Pos.y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color );
}
}
void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
EDA_COLOR_T aAnchor_color,
wxString& aText, wxPoint aPos )
{
int width = m_Thickness;
@ -262,14 +328,6 @@ void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
if( aDrawMode != UNSPECIFIED_DRAWMODE )
GRSetDrawMode( aDC, aDrawMode );
// Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR )
{
GRDrawAnchor( aClipBox, aDC,
aPos.x + aOffset.x, aPos.y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color );
}
if( aFillMode == SKETCH )
width = -width;

View File

@ -43,9 +43,12 @@
#include <class_module.h>
#if !defined( USE_FP_LIB_TABLE )
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintLibNames )
{
bool retv = true;
// Clear data before reading files
m_filesNotFound.Empty();
m_filesInvalid.Empty();
@ -56,10 +59,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
// Parse Libraries Listed
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
for( unsigned ii = 0; ii < aFootprintLibNames.GetCount(); ii++ )
{
// Footprint library file names can be fully qualified or file name only.
wxFileName filename = aFootprintsLibNames[ii];
wxFileName filename = aFootprintLibNames[ii];
if( !filename.FileExists() )
{
@ -67,19 +70,20 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
if( !filename.FileExists() )
{
filename = wxFileName( wxEmptyString, aFootprintsLibNames[ii],
filename = wxFileName( wxEmptyString, aFootprintLibNames[ii],
LegacyFootprintLibPathExtension );
filename = wxGetApp().FindLibraryPath( filename.GetFullName() );
}
}
wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ),
wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintLibNames[ii] ),
GetChars( filename.GetFullPath() ) );
if( !filename.FileExists() )
if( !filename.IsOk() || !filename.FileExists() )
{
m_filesNotFound << aFootprintsLibNames[ii] << wxT( "\n" );
m_filesNotFound << aFootprintLibNames[ii] << wxT( "\n" );
retv = false;
continue;
}
@ -110,6 +114,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
catch( IO_ERROR ioe )
{
m_filesInvalid << ioe.errorText << wxT( "\n" );
retv = false;
}
}
}
@ -124,45 +129,49 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
m_List.sort();
return true;
return retv;
}
#else
bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname )
{
bool retv = true;
// Clear data before reading files
m_filesNotFound.Empty();
m_filesInvalid.Empty();
m_List.clear();
std::vector< wxString > libNickNames = aTable.GetLogicalLibs();
std::vector< wxString > nicknames;
// Parse Libraries Listed
for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
if( !aNickname )
// do all of them
nicknames = aTable->GetLogicalLibs();
else
nicknames.push_back( *aNickname );
for( unsigned ii = 0; ii < nicknames.size(); ii++ )
{
const FP_LIB_TABLE::ROW* row = aTable.FindRow( libNickNames[ii] );
const wxString& nickname = nicknames[ii];
wxCHECK2_MSG( row != NULL, continue,
wxString::Format( wxT( "No library name <%s> found in footprint library "
"table." ), GetChars( libNickNames[ii] ) ) );
try
{
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
wxString path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() );
wxArrayString fpnames = pi->FootprintEnumerate( path );
wxArrayString fpnames = aTable->FootprintEnumerate( nickname );
for( unsigned i=0; i<fpnames.GetCount(); ++i )
{
std::auto_ptr<MODULE> m( pi->FootprintLoad( path, fpnames[i] ) );
std::auto_ptr<MODULE> m( aTable->FootprintLoad( nickname, fpnames[i] ) );
// we're loading what we enumerated, all must be there.
wxASSERT( m.get() );
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->SetLibraryName( libNickNames[ii] );
fpinfo->SetLibraryPath( path );
fpinfo->SetLibraryName( nickname );
//fpinfo->SetLibraryPath( path );
fpinfo->m_Module = fpnames[i];
fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH );
fpinfo->m_KeyWord = m->GetKeywords();
@ -174,14 +183,16 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
catch( IO_ERROR ioe )
{
m_filesInvalid << ioe.errorText << wxT( "\n" );
retv = false;
}
}
m_List.sort();
return true;
return retv;
}
#endif // USE_FP_LIB_TABLE
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
{

View File

@ -38,10 +38,46 @@
#include <fpid.h>
#include <fp_lib_table_lexer.h>
#include <fp_lib_table.h>
#include <class_module.h>
using namespace FP_LIB_TABLE_T;
/**
* Definition for enabling and disabling footprint library trace output. See the
* wxWidgets documentation on using the WXTRACE environment variable.
*/
static const wxString traceFpLibTable( wxT( "KicadFpLibTable" ) );
/// The evinronment variable name for the current project path. This is used interanally
/// at run time and is not exposed outside of the current process.
static wxString projectPathEnvVariableName( wxT( "KICAD_PRJ_PATH" ) );
/// The footprint library table name used when no project file is passed to Pcbnew or CvPcb.
/// This is used temporarily to store the project specific library table until the project
/// file being edited is save. It is then moved to the file fp-lib-table in the folder where
/// the project file is saved.
static wxString defaultProjectFileName( wxT( "prj-fp-lib-table" ) );
static wxString defaultFileName( wxT( "fp-lib-table" ) );
void FP_LIB_TABLE::ROW::SetType( const wxString& aType )
{
type = IO_MGR::EnumFromStr( aType );
if( IO_MGR::PCB_FILE_T( -1 ) == type )
type = IO_MGR::KICAD;
}
void FP_LIB_TABLE::ROW::SetFullURI( const wxString& aFullURI )
{
uri_user = aFullURI;
uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
}
FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
fallBack( aFallBackTable )
{
@ -50,6 +86,62 @@ FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
}
wxArrayString FP_LIB_TABLE::FootprintEnumerate( const wxString& aNickname )
{
const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin );
return row->plugin->FootprintEnumerate( row->GetFullURI( true ), row->GetProperties() );
}
MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& aFootprintName )
{
const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin );
MODULE* ret = row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName, row->GetProperties() );
// The library cannot know its own name, because it might have been renamed or moved.
// Therefore footprints cannot know their own library nickname when residing in
// a footprint library.
// Only at this API layer can we tell the footprint about its actual library nickname.
if( ret )
{
// remove "const"-ness, I really do want to set nickname without
// having to copy the FPID and its two strings, twice each.
FPID& fpid = (FPID&) ret->GetFPID();
fpid.SetLibNickname( row->GetNickName() );
}
return ret;
}
void FP_LIB_TABLE::FootprintSave( const wxString& aNickname, const MODULE* aFootprint )
{
const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin );
return row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() );
}
void FP_LIB_TABLE::FootprintDelete( const wxString& aNickname, const wxString& aFootprintName )
{
const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin );
return row->plugin->FootprintDelete( row->GetFullURI( true ), aFootprintName, row->GetProperties() );
}
bool FP_LIB_TABLE::IsFootprintLibWritable( const wxString& aNickname )
{
const ROW* row = FindRow( aNickname );
wxASSERT( (PLUGIN*) row->plugin );
return row->plugin->IsFootprintLibWritable( row->GetFullURI( true ) );
}
void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR )
{
/*
@ -205,6 +297,114 @@ void FP_LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
}
void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR )
{
wxFileName fn = GetProjectFileName( aPath );
wxLogTrace( traceFpLibTable, wxT( "Saving footprint libary table <%s>." ),
GetChars( fn.GetFullPath() ) );
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
Format( &sf, 0 );
}
#define OPT_SEP '|' ///< options separator character
PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList )
{
if( aOptionsList.size() )
{
const char* cp = &aOptionsList[0];
const char* end = cp + aOptionsList.size();
PROPERTIES props;
std::string pair;
// Parse all name=value pairs
while( cp < end )
{
pair.clear();
// Skip leading white space.
while( cp < end && isspace( *cp ) )
++cp;
// Find the end of pair/field
while( cp < end )
{
if( *cp=='\\' && cp+1<end && cp[1]==OPT_SEP )
{
++cp; // skip the escape
pair += *cp++; // add the separator
}
else if( *cp==OPT_SEP )
{
++cp; // skip the separator
break; // process the pair
}
else
pair += *cp++;
}
// stash the pair
if( pair.size() )
{
// first equals sign separates 'name' and 'value'.
size_t eqNdx = pair.find( '=' );
if( eqNdx != pair.npos )
{
std::string name = pair.substr( 0, eqNdx );
std::string value = pair.substr( eqNdx + 1 );
props[name] = value;
}
else
props[pair] = ""; // property is present, but with no value.
}
}
if( props.size() )
return new PROPERTIES( props );
}
return NULL;
}
std::string FP_LIB_TABLE::FormatOptions( const PROPERTIES* aProperties )
{
std::string ret;
if( aProperties )
{
for( PROPERTIES::const_iterator it = aProperties->begin(); it != aProperties->end(); ++it )
{
const std::string& name = it->first;
const std::string& value = it->second;
if( ret.size() )
ret += OPT_SEP;
ret += name;
// the separation between name and value is '='
if( value.size() )
ret += '=';
for( std::string::const_iterator si = value.begin(); si != value.end(); ++si )
{
// escape any separator in the value.
if( *si == OPT_SEP )
ret += '\\';
ret += *si;
}
}
}
return ret;
}
std::vector<wxString> FP_LIB_TABLE::GetLogicalLibs()
{
// Only return unique logical library names. Use std::set::insert() to
@ -232,9 +432,9 @@ std::vector<wxString> FP_LIB_TABLE::GetLogicalLibs()
}
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::findRow( const wxString& aNickName )
FP_LIB_TABLE::ROW* FP_LIB_TABLE::findRow( const wxString& aNickName ) const
{
FP_LIB_TABLE* cur = this;
FP_LIB_TABLE* cur = (FP_LIB_TABLE*) this;
do
{
@ -264,7 +464,7 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRowByURI( const wxString& aURI )
for( unsigned i = 0; i < cur->rows.size(); i++ )
{
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() );
wxString uri = cur->rows[i].GetFullURI( true );
if( wxFileName::GetPathSeparator() == wxChar( '\\' ) && uri.Find( wxChar( '/' ) ) >= 0 )
uri.Replace( wxT( "/" ), wxT( "\\" ) );
@ -306,36 +506,26 @@ bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace )
}
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aLibraryNickName )
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname )
throw( IO_ERROR )
{
const ROW* row = findRow( aLibraryNickName );
ROW* row = findRow( aNickname );
if( !row )
{
wxString msg = wxString::Format( _( "lib table contains no logical lib '%s'" ),
GetChars( aLibraryNickName ) );
GetChars( aNickname ) );
THROW_IO_ERROR( msg );
}
if( !row->plugin )
row->setPlugin( IO_MGR::PluginFind( row->type ) );
return row;
}
PLUGIN* FP_LIB_TABLE::PluginFind( const wxString& aLibraryNickName )
throw( IO_ERROR )
{
const ROW* row = FindRow( aLibraryNickName );
// row will never be NULL here.
PLUGIN* plugin = IO_MGR::PluginFind( row->type );
return plugin;
}
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString aString )
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
{
// We reserve the right to do this another way, by providing our own member
// function.
@ -343,9 +533,9 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString aString )
}
bool FP_LIB_TABLE::IsEmpty() const
bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
{
if( fallBack == NULL )
if( !aIncludeFallback || (fallBack == NULL) )
return rows.empty();
return fallBack->IsEmpty() && rows.empty();
@ -469,7 +659,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
for( unsigned i = 0; i < cur->rows.size(); i++ )
{
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() );
wxString uri = cur->rows[i].GetFullURI( true );
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 )
@ -481,6 +671,7 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
break;
}
}
} while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() );
if( libNickname.IsEmpty() )
@ -523,6 +714,55 @@ bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aL
}
void FP_LIB_TABLE::SetProjectPathEnvVariable( const wxFileName& aPath )
{
wxString path;
if( !aPath.IsOk() || !aPath.DirExists() )
path = wxEmptyString;
else
path = aPath.GetPath();
wxLogTrace( traceFpLibTable, wxT( "Setting env %s to <%s>." ),
GetChars( projectPathEnvVariableName ), GetChars( path ) );
wxSetEnv( projectPathEnvVariableName, path );
}
const wxString& FP_LIB_TABLE::GetProjectPathEnvVariableName() const
{
return projectPathEnvVariableName;
}
wxString FP_LIB_TABLE::GetProjectFileName( const wxFileName& aPath )
{
wxFileName fn = aPath;
// Set $KICAD_PRJ_PATH to user's configuration path if aPath is not set or does not exist.
if( !aPath.IsOk() || !aPath.DirExists() )
{
fn.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#if defined( __WINDOWS__ )
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.SetName( defaultProjectFileName );
}
else
{
fn.AssignDir( aPath.GetPath() );
fn.SetName( defaultFileName );
}
wxLogTrace( traceFpLibTable, wxT( "Project specific footprint library table file <%s>." ),
GetChars( fn.GetFullPath() ) );
return fn.GetFullPath();
}
bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
{
bool tableExists = true;
@ -532,10 +772,15 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
{
tableExists = false;
if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) )
{
THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path <%s>." ),
GetChars( fn.GetPath() ) ) );
}
// Attempt to copy the default global file table from the KiCad template folder to
// the users home configuration path.
wxString fileName( wxT( "fp_global_table" ) );
fileName = wxGetApp().FindLibraryPath( fileName );
wxString fileName = wxGetApp().FindLibraryPath( defaultFileName );
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
@ -566,29 +811,28 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
fn.SetName( GetFileName() );
wxLogTrace( traceFpLibTable, wxT( "Global footprint library table file <%s>." ),
GetChars( fn.GetFullPath() ) );
return fn.GetFullPath();
}
wxString FP_LIB_TABLE::GetFileName()
const wxString& FP_LIB_TABLE::GetFileName()
{
return wxString( wxT( "fp-lib-table" ) );
return defaultFileName;
}
void FP_LIB_TABLE::Load( const wxFileName& aFileName, FP_LIB_TABLE* aFallBackTable )
throw( IO_ERROR )
{
wxFileName fn = aFileName;
fallBack = aFallBackTable;
fn.SetName( FP_LIB_TABLE::GetFileName() );
fn.SetExt( wxEmptyString );
if( fn.FileExists() )
// Empty footprint library tables are valid.
if( aFileName.IsOk() && aFileName.FileExists() )
{
FILE_LINE_READER reader( fn.GetFullPath() );
FILE_LINE_READER reader( aFileName.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
Parse( &lexer );
}

282
common/grid_tricks.cpp Normal file
View File

@ -0,0 +1,282 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <grid_tricks.h>
#include <wx/tokenzr.h>
#include <wx/arrstr.h>
#include <wx/clipbrd.h>
// It works for table data on clipboard for an Excell spreadsheet,
// why not us too for now.
#define COL_SEP wxT( '\t' )
#define ROW_SEP wxT( '\n' )
enum
{
MYID_FIRST = -1,
MYID_CUT,
MYID_COPY,
MYID_PASTE,
MYID_SELECT,
MYID_LAST,
};
GRID_TRICKS::GRID_TRICKS( wxGrid* aGrid ):
m_grid( aGrid )
{
aGrid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridCellRightClick ), NULL, this );
aGrid->Connect( MYID_FIRST, MYID_LAST, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GRID_TRICKS::onPopupSelection ), NULL, this );
aGrid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( GRID_TRICKS::onKeyDown ), NULL, this );
aGrid->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( GRID_TRICKS::onRightDown ), NULL, this );
}
void GRID_TRICKS::getSelectedArea()
{
wxGridCellCoordsArray topLeft = m_grid->GetSelectionBlockTopLeft();
wxGridCellCoordsArray botRight = m_grid->GetSelectionBlockBottomRight();
wxArrayInt cols = m_grid->GetSelectedCols();
wxArrayInt rows = m_grid->GetSelectedRows();
DBG(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );)
if( topLeft.Count() && botRight.Count() )
{
m_sel_row_start = topLeft[0].GetRow();
m_sel_col_start = topLeft[0].GetCol();
m_sel_row_count = botRight[0].GetRow() - m_sel_row_start + 1;
m_sel_col_count = botRight[0].GetCol() - m_sel_col_start + 1;
}
else if( cols.Count() )
{
m_sel_col_start = cols[0];
m_sel_col_count = cols.Count();
m_sel_row_start = 0;
m_sel_row_count = m_grid->GetNumberRows();
}
else if( rows.Count() )
{
m_sel_col_start = 0;
m_sel_col_count = m_grid->GetNumberCols();
m_sel_row_start = rows[0];
m_sel_row_count = rows.Count();
}
else
{
m_sel_row_start = -1;
m_sel_col_start = -1;
m_sel_row_count = 0;
m_sel_col_count = 0;
}
//DBG(printf("m_sel_row_start:%d m_sel_col_start:%d m_sel_row_count:%d m_sel_col_count:%d\n", m_sel_row_start, m_sel_col_start, m_sel_row_count, m_sel_col_count );)
}
void GRID_TRICKS::showPopupMenu()
{
wxMenu menu;
menu.Append( MYID_CUT, _( "Cut\tCTRL+X" ), _( "Clear selected cells pasting original contents to clipboard" ) );
menu.Append( MYID_COPY, _( "Copy\tCTRL+C" ), _( "Copy selected cells to clipboard" ) );
menu.Append( MYID_PASTE, _( "Paste\tCTRL+V" ), _( "Paste clipboard cells to matrix at current cell" ) );
menu.Append( MYID_SELECT, _( "Select All\tCTRL+A" ), _( "Select all cells" ) );
getSelectedArea();
// if nothing is selected, disable cut and copy.
if( !m_sel_row_count && !m_sel_col_count )
{
menu.Enable( MYID_CUT, false );
menu.Enable( MYID_COPY, false );
}
bool have_cb_text = false;
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
have_cb_text = true;
wxTheClipboard->Close();
}
if( !have_cb_text )
{
// if nothing on clipboard, disable paste.
menu.Enable( MYID_PASTE, false );
}
m_grid->PopupMenu( &menu );
}
void GRID_TRICKS::onPopupSelection( wxCommandEvent& event )
{
int menu_id = event.GetId();
// assume getSelectedArea() was called by rightClickPopupMenu() and there's
// no way to have gotten here without that having been called.
switch( menu_id )
{
case MYID_CUT:
case MYID_COPY:
cutcopy( menu_id == MYID_CUT );
break;
case MYID_PASTE:
paste_clipboard();
break;
case MYID_SELECT:
m_grid->SelectAll();
break;
default:
;
}
}
void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
{
if( isCtl( 'A', ev ) )
{
m_grid->SelectAll();
}
else if( isCtl( 'C', ev ) )
{
getSelectedArea();
cutcopy( false );
}
else if( isCtl( 'V', ev ) )
{
getSelectedArea();
paste_clipboard();
}
else if( isCtl( 'X', ev ) )
{
getSelectedArea();
cutcopy( true );
}
else
ev.Skip();
}
void GRID_TRICKS::paste_clipboard()
{
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
wxTextDataObject data;
wxTheClipboard->GetData( data );
wxString cb_text = data.GetText();
paste_text( cb_text );
}
wxTheClipboard->Close();
m_grid->ForceRefresh();
}
}
void GRID_TRICKS::paste_text( const wxString& cb_text )
{
wxGridTableBase* tbl = m_grid->GetTable();
const int cur_row = std::max( getCursorRow(), 0 ); // no -1
const int cur_col = std::max( getCursorCol(), 0 );
wxStringTokenizer rows( cb_text, ROW_SEP, wxTOKEN_RET_EMPTY );
// if clipboard rows would extend past end of current table size...
if( int( rows.CountTokens() ) > tbl->GetNumberRows() - cur_row )
{
int newRowsNeeded = rows.CountTokens() - ( tbl->GetNumberRows() - cur_row );
tbl->AppendRows( newRowsNeeded );
}
for( int row = cur_row; rows.HasMoreTokens(); ++row )
{
wxString rowTxt = rows.GetNextToken();
wxStringTokenizer cols( rowTxt, COL_SEP, wxTOKEN_RET_EMPTY );
for( int col = cur_col; cols.HasMoreTokens(); ++col )
{
wxString cellTxt = cols.GetNextToken();
tbl->SetValue( row, col, cellTxt );
}
}
m_grid->AutoSizeColumns( false );
}
void GRID_TRICKS::cutcopy( bool doCut )
{
if( wxTheClipboard->Open() )
{
wxGridTableBase* tbl = m_grid->GetTable();
wxString txt;
// fill txt with a format that is compatible with most spreadsheets
for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row )
{
for( int col = m_sel_col_start; col < m_sel_col_start + m_sel_col_count; ++col )
{
txt += tbl->GetValue( row, col );
if( col < m_sel_col_start + m_sel_col_count - 1 ) // that was not last column
txt += COL_SEP;
if( doCut )
tbl->SetValue( row, col, wxEmptyString );
}
txt += ROW_SEP;
}
wxTheClipboard->SetData( new wxTextDataObject( txt ) );
wxTheClipboard->Close();
if( doCut )
{
m_grid->AutoSizeColumns( false );
m_grid->ForceRefresh();
}
}
}

View File

@ -4,174 +4,179 @@
* Reads the hotkey table from its stored format into a format suitable
* for a wxGrid.
*/
HotkeyGridTable::HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ) :
wxGridTableBase(),
m_hotkeys()
HOTKEY_EDITOR_GRID_TABLE::HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ) :
wxGridTableBase(), m_hotkeys()
{
EDA_HOTKEY_CONFIG* section;
for( section = origin; section->m_HK_InfoList; section++ )
{
hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( NULL, 0, 0 ) );
// Add a dummy hotkey_spec which is a header before each hotkey list
hotkey_spec spec( *section->m_SectionTag, NULL );
m_hotkeys.push_back( spec );
EDA_HOTKEY** info_ptr;
EDA_HOTKEY** hotkey_descr_list;
for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
// Add hotkeys descr
for( hotkey_descr_list = section->m_HK_InfoList; *hotkey_descr_list;
hotkey_descr_list++ )
{
EDA_HOTKEY* info = *info_ptr;
hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( info ) );
EDA_HOTKEY* hotkey_descr = *hotkey_descr_list;
hotkey_spec spec( *section->m_SectionTag, new EDA_HOTKEY( hotkey_descr ) );
m_hotkeys.push_back( spec );
}
}
}
HotkeyGridTable::hotkey_spec_vector& HotkeyGridTable::getHotkeys()
HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& HOTKEY_EDITOR_GRID_TABLE::getHotkeys()
{
return m_hotkeys;
}
int HotkeyGridTable::GetNumberRows()
int HOTKEY_EDITOR_GRID_TABLE::GetNumberRows()
{
return m_hotkeys.size();
}
int HotkeyGridTable::GetNumberCols()
int HOTKEY_EDITOR_GRID_TABLE::GetNumberCols()
{
return 2;
}
bool HotkeyGridTable::IsEmptyCell( int row, int col )
bool HOTKEY_EDITOR_GRID_TABLE::IsEmptyCell( int row, int col )
{
return col == 1 && m_hotkeys[row].second == 0;
return col == 1 && m_hotkeys[row].second == NULL;
}
wxString HotkeyGridTable::GetValue( int row, int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col )
{
EDA_HOTKEY* hotkey_descr = m_hotkeys[row].second;
if( col == 0 )
{
if( m_hotkeys[row].second == 0 )
if( hotkey_descr == NULL )
{
// section header
return m_hotkeys[row].first;
}
else
{
return m_hotkeys[row].second->m_InfoMsg;
return hotkey_descr->m_InfoMsg;
}
}
else
{
if( m_hotkeys[row].second == 0 )
if( hotkey_descr == NULL )
{
return wxString();
// section header
return wxEmptyString;
}
else
{
return ReturnKeyNameFromKeyCode( m_hotkeys[row].second->m_KeyCode );
return ReturnKeyNameFromKeyCode( hotkey_descr->m_KeyCode );
}
}
}
void HotkeyGridTable::SetValue( int row, int col, const wxString& value )
void HOTKEY_EDITOR_GRID_TABLE::SetValue( int row, int col, const wxString& value )
{
}
wxString HotkeyGridTable::GetTypeName( int row, int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetTypeName( int row, int col )
{
return wxGRID_VALUE_STRING;
}
bool HotkeyGridTable::CanGetValueAs( int row, int col, const wxString& typeName )
bool HOTKEY_EDITOR_GRID_TABLE::CanGetValueAs( int row, int col, const wxString& typeName )
{
return typeName == wxGRID_VALUE_STRING && col == 2;
}
bool HotkeyGridTable::CanSetValueAs( int row, int col, const wxString& typeName )
bool HOTKEY_EDITOR_GRID_TABLE::CanSetValueAs( int row, int col, const wxString& typeName )
{
return false;
}
long HotkeyGridTable::GetValueAsLong( int row, int col )
long HOTKEY_EDITOR_GRID_TABLE::GetValueAsLong( int row, int col )
{
return -1L;
}
double HotkeyGridTable::GetValueAsDouble( int row, int col )
double HOTKEY_EDITOR_GRID_TABLE::GetValueAsDouble( int row, int col )
{
return 0.0;
}
bool HotkeyGridTable::GetValueAsBool( int row, int col )
bool HOTKEY_EDITOR_GRID_TABLE::GetValueAsBool( int row, int col )
{
return false;
}
void HotkeyGridTable::SetValueAsLong( int row, int col, long value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsLong( int row, int col, long value )
{
}
void HotkeyGridTable::SetValueAsDouble( int row, int col, double value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsDouble( int row, int col, double value )
{
}
void HotkeyGridTable::SetValueAsBool( int row, int col, bool value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsBool( int row, int col, bool value )
{
}
void* HotkeyGridTable::GetValueAsCustom( int row, int col )
void* HOTKEY_EDITOR_GRID_TABLE::GetValueAsCustom( int row, int col )
{
return 0;
}
void HotkeyGridTable::SetValueAsCustom( int row, int col, void* value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsCustom( int row, int col, void* value )
{
}
wxString HotkeyGridTable::GetColLabelValue( int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetColLabelValue( int col )
{
return col == 0 ? _( "Command" ) : _( "Hotkey" );
}
bool HotkeyGridTable::isHeader( int row )
bool HOTKEY_EDITOR_GRID_TABLE::IsHeader( int row )
{
return m_hotkeys[row].second == 0;
return m_hotkeys[row].second == NULL;
}
void HotkeyGridTable::SetKeyCode( int row, long key )
void HOTKEY_EDITOR_GRID_TABLE::SetKeyCode( int row, long key )
{
m_hotkeys[row].second->m_KeyCode = key;
}
void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
void HOTKEY_EDITOR_GRID_TABLE::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
{
int row = 0;
EDA_HOTKEY_CONFIG* section;
for( section = origin; section->m_HK_InfoList; section++ )
{
++row;
++row; // Skip header
EDA_HOTKEY** info_ptr;
for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
@ -183,15 +188,10 @@ void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
}
HotkeyGridTable::~HotkeyGridTable()
HOTKEY_EDITOR_GRID_TABLE::~HOTKEY_EDITOR_GRID_TABLE()
{
hotkey_spec_vector::iterator i;
for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
{
if( i->second )
{
delete i->second;
}
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2013 Jean-Pierre Charras, j-p.charras at wanadoo.fr
* Copyright (C) 2010-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -212,17 +212,12 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
*/
static void AddModifierToKey( wxString& aFullKey, const wxString & aKey )
{
#if 0 // set to 0 for new behavior, 1 for old
aFullKey << wxT( " <" ) << aKey << wxT( ">" );
#else
if( (aKey.Length() == 1) && (aKey[0] >= 'A') && (aKey[0] <= 'Z'))
// We can use Shift+<key> as accelerator ans <key> for hot key
// We can use Shift+<key> as accelerator and <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_SHIFT << aKey;
else
// We must use Alt+<key> as accelerator ans <key> for hot key
aFullKey << wxT( "\t" ) << MODIFIER_ALT << aKey;
#endif
}
/* AddHotkeyName
@ -430,6 +425,10 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescL
if( !hk_decr->m_InfoMsg.Contains( wxT( "Macros" ) ) )
{
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
// Some chars should be modified, using html encoding, to be
// displayed by DisplayHtmlInfoMessage()
keyname.Replace( wxT("<"), wxT("&lt;") );
keyname.Replace( wxT(">"), wxT("&gt;") );
msg += wxT( "<tr><td>" ) + hk_decr->m_InfoMsg + wxT("</td>");
msg += wxT("<td><b>&nbsp;&nbsp;") + keyname + wxT( "</b></td></tr>" );
}

View File

@ -316,6 +316,7 @@ const wxString WORKSHEET_DATAITEM::GetClassName() const
case WS_SEGMENT: name = wxT("Line"); break;
case WS_RECT: name = wxT("Rect"); break;
case WS_POLYPOLYGON: name = wxT("Poly"); break;
case WS_BITMAP: name = wxT("Bitmap"); break;
}
return name;
@ -539,3 +540,38 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
}
}
/* set the pixel scale factor of the bitmap
* this factor depend on the application internal unit
* and the PPI bitmap factor
* the pixel scale factor should be initialized before drawing the bitmap
*/
void WORKSHEET_DATAITEM_BITMAP::SetPixelScaleFactor()
{
if( m_ImageBitmap )
{
// m_WSunits2Iu is the page layout unit to application internal unit
// i.e. the mm to to application internal unit
// however the bitmap definition is always known in pixels per inches
double scale = m_WSunits2Iu * 25.4 / m_ImageBitmap->GetPPI();
m_ImageBitmap->SetPixelScaleFactor( scale );
}
}
/* return the PPI of the bitmap
*/
int WORKSHEET_DATAITEM_BITMAP::GetPPI() const
{
if( m_ImageBitmap )
return m_ImageBitmap->GetPPI() / m_ImageBitmap->m_Scale;
return 300;
}
/*adjust the PPI of the bitmap
*/
void WORKSHEET_DATAITEM_BITMAP::SetPPI( int aBitmapPPI )
{
if( m_ImageBitmap )
m_ImageBitmap->m_Scale = (double) m_ImageBitmap->GetPPI() / aBitmapPPI;
}

View File

@ -156,6 +156,18 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
}
}
break;
case WS_DRAW_ITEM_BASE::wsg_bitmap:
{
WS_DRAW_ITEM_BITMAP* bitmap = (WS_DRAW_ITEM_BITMAP*) item;
if( markerSize )
{
drawMarker( aClipBox, aDC, bitmap->GetPosition(),
markerSize );
}
}
break;
}
}
}
@ -274,10 +286,10 @@ bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition)
*/
bool WS_DRAW_ITEM_RECT::HitTestStartPoint( const wxPoint& aPosition)
{
wxPoint pos = GetStart();
wxPoint dist = GetStart() - aPosition;
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
return true;
return false;
@ -313,10 +325,10 @@ bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition)
*/
bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
{
wxPoint pos = GetStart();
wxPoint dist = GetStart() - aPosition;
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
return true;
return false;
@ -326,10 +338,10 @@ bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
*/
bool WS_DRAW_ITEM_LINE::HitTestEndPoint( const wxPoint& aPosition)
{
wxPoint pos = GetEnd();
wxPoint dist = GetEnd() - aPosition;
if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
return true;
return false;
@ -365,3 +377,47 @@ void WS_DRAW_ITEM_LIST::Locate( std::vector <WS_DRAW_ITEM_BASE*>& aList,
}
}
}
/** The function to draw a WS_DRAW_ITEM_BITMAP
*/
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
{
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
if( parent->m_ImageBitmap )
{
parent->m_ImageBitmap->DrawBitmap( NULL, aDC, m_pos );
}
}
/**
* Virtual function
* return true if the point aPosition is on bitmap
*/
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition)
{
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
if( parent->m_ImageBitmap == NULL )
return false;
EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
rect.Move( m_pos );
return rect.Contains( aPosition );
}
/**
* return true if the point aPosition is on the reference point of this item.
*/
bool WS_DRAW_ITEM_BITMAP::HitTestStartPoint( const wxPoint& aPosition)
{
wxPoint dist = m_pos - aPosition;
if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
return true;
return false;
}

View File

@ -76,8 +76,11 @@ private:
throw( IO_ERROR, PARSE_ERROR );
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
throw( IO_ERROR, PARSE_ERROR );
void parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
throw( IO_ERROR, PARSE_ERROR );
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR );
void readOption( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR );
void readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem ) throw( IO_ERROR, PARSE_ERROR );
};
// PCB_PLOT_PARAMS_PARSER
@ -131,6 +134,12 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
aLayout->Append( item );
break;
case T_bitmap:
item = new WORKSHEET_DATAITEM_BITMAP( NULL );
parseBitmap( (WORKSHEET_DATAITEM_BITMAP*) item );
aLayout->Append( item );
break;
case T_tbtext:
NeedSYMBOLorNUMBER();
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
@ -306,6 +315,110 @@ void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON
}
}
#include <wx/mstream.h>
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
T token;
BITMAP_BASE* image = new BITMAP_BASE;
aItem->m_ImageBitmap = image;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_name:
NeedSYMBOLorNUMBER();
aItem->m_Name = FromUTF8();
NeedRIGHT();
break;
case T_pos:
parseCoordinate( aItem->m_Pos );
break;
case T_repeat:
aItem->m_RepeatCount = parseInt( -1, 100 );
NeedRIGHT();
break;
case T_incrx:
aItem->m_IncrementVector.x = parseDouble();
NeedRIGHT();
break;
case T_incry:
aItem->m_IncrementVector.y = parseDouble();
NeedRIGHT();
break;
case T_linewidth:
aItem->m_LineWidth = parseDouble();
NeedRIGHT();
break;
case T_scale:
aItem->m_ImageBitmap->m_Scale = parseDouble();
NeedRIGHT();
break;
case T_pngdata:
readPngdata( aItem );
break;
default:
Unexpected( CurText() );
break;
}
}
}
void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
std::string tmp;
T token;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_data:
NeedSYMBOLorNUMBER();
tmp += CurStr();
tmp += "\n";
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
tmp += "EndData";
wxString msg;
STRING_LINE_READER reader( tmp, wxT("Png kicad_wks data") );
if( ! aItem->m_ImageBitmap->LoadData( reader, msg ) )
{
wxLogMessage(msg);
}
}
void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
@ -630,7 +743,6 @@ void WORKSHEET_LAYOUT::SetDefaultLayout()
try
{
lp_parser.Parse( this );
SetDefaultDescrFlag( true );
}
catch( IO_ERROR ioe )
{
@ -652,7 +764,6 @@ void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append )
try
{
lp_parser.Parse( this );
SetDefaultDescrFlag( true );
}
catch( IO_ERROR ioe )
{
@ -716,7 +827,6 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append
try
{
lp_parser.Parse( this );
SetDefaultDescrFlag( false );
}
catch( IO_ERROR ioe )
{

View File

@ -14,6 +14,7 @@ notonpage1
line
rect
polygon
bitmap
tbtext
ltcorner
lbcorner
@ -23,6 +24,9 @@ name
pos
start
end
scale
pngdata
data
pts
xy
maxlen

View File

@ -62,11 +62,6 @@
#include <class_worksheet_dataitem.h>
// Temporary include. Will be removed when a GOST page layout descr file is available
#ifdef KICAD_GOST
#include "title_block_shapes_gost.cpp"
#endif
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock,
@ -74,16 +69,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
// Ugly hack: will be removed when a GOST page layout descr file is available
#ifdef KICAD_GOST
if( pglayout.IsDefaultDescr() )
{
((WS_DRAW_ITEM_LIST_GOST*)this)->BuildWorkSheetGraphicListGOST( aPageInfo,
aTitleBlock, aColor, aAltColor );
return;
}
#endif
#define milsTomm (25.4/1000)
m_titleBlock = &aTitleBlock;
@ -251,6 +236,21 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
}
}
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
((WORKSHEET_DATAITEM_BITMAP*)wsItem)->SetPixelScaleFactor();
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
{
if( jj && ! wsItem->IsInsidePage( jj ) )
continue;
Append( new WS_DRAW_ITEM_BITMAP( wsItem,
wsItem->GetStartPosUi( jj ) ) );
}
break;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,198 +0,0 @@
/**
* @file common/page_layout_default_description.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
* Copyright (C) 1992-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
* 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
*/
/* keyword used in page layout description are (see page_layout_reader.keywords)
* page_layout
* setup
* linewidth
* textlinewidth
* textsize
* comment
* line
* rect
* polygon
* tbtext
* ltcorner
* lbcorner
* rbcorner
* rtcorner
* name
* pos
* start
* end
* pts
* xy
* maxlen
* maxheight
* font
* bold
* italic
* size
* justify
* left
* center
* right
* top
* bottom
* rotate
* repeat
* incrx
* incry
* incrlabel
*/
/*
* Items use coordinates.
* A coordinate is defined relative to a page corner
* A coordinate is the X pos, the Y pos, and the corner which is the coordinate origin
* the default is the bottom right corner
* example: (start 10 0 ltcorner) or (start 20 10)
* The direction depends on the corner: a positive coordinate define a point
* from the corner origin, to the opposite corner.
*
* Items are defined by a name, coordinates in mm and some attributes,
* and can be repeated.
* for instance (repeat 2) (incrx 2) (incry 2) repeat the item 2 times,
* and coordinates are incremented by 2 on X direction, and 2 on Y direction
* Comments are allowed. they are inside (), and start by the keyword comment
* example:
* (comment rect around the title block)
*
* Lines and rect are defined by 2 coordinates start and end, and attributes.
* Attributes are linewidth and repeat parameters.
* example:
* (line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )
* (rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )
*
* Texts are defined by the text (between quotes), the position, and attributes
* example
* "(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )"
* the text can be rotated by (rotation <value>) with value = rot angle in degrees
* (font (size 1.3 1.3) bold italic) defines a specific size,
* with bold and italic options
* (justify <justif keyword>) controls the text justification (the default is left)
* justif keyword is center, left, right, top and bottom
* (justify center top) is a text centered on X axis and top aligned on vertical axis
* The text size can be constrained:
* (maxlen <value>) and (maxheight <value>) force the actual text x and/or y size to be
* reduced to limit the text height to the maxheight value,
* and the full text x size to the maxlen value.
* If the actual text size is smaller than limits, its size is not modified.
*
* Texts can include a format symbol, a la printf.
* At run time these format symbols will be replaced by their actual value.
*
* format symbols are:
*
* %% = replaced by %
* %K = Kicad version
* %Z = paper format name (A4, USLetter ...)
* %Y = company name
* %D = date
* %R = revision
* %S = sheet number
* %N = number of sheets
* %Cx = comment (x = 0 to 9 to identify the comment)
* %F = filename
* %P = sheet path (sheet full name)
* %T = title
*
* example:
* (tbtext \"Size: %Z\" ...) displays "Size A4" or Size USLetter"
*
* Poly Polygons
* Set of filled polygons are supported.
*
* The main purpose is to allow logos, or complex shapes
* They support the repeat and rotation options
* They are defined by
* (polygon (position ..) <rotation> <linewidth>
* the parameter linewidth defines the pen size used to draw/plot
* the polygon outlines (default = 0)
* example:
* (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254)
*
* and a list of corners like
* (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932)
* .... )
*
* each sequence like
* (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932)
* .... )
* defines a polygon.
* Each coordinate is relative to the polygon position.
* Therefore a "polygon" is in fact a set of polygons, of a poly polygon
*
*/
#include <worksheet.h> // defaultPageLayout
// height of the band reference grid 2.0 mm
// worksheet frame reference text size 1.3 mm
// default text size 1.5 mm
// default line width 0.15 mm
// frame ref pitch 50 mm
// export defaultPageLayout:
extern const char defaultPageLayout[];
// Default page layout (sizes are in mm)
const char defaultPageLayout[] = "( page_layout\n"
"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )"
"(rect (comment \"rect around the title block\") (linewidth 0.15) (start 110 34) (end 2 2) )\n"
"(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n"
"(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n"
"(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n"
"(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n"
"(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n"
"(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n"
"(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n"
"(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n"
"(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n"
"(tbtext \"Date: %D\" (pos 87 6.9) )\n"
"(line (start 110 5.5) end 2 5.5) )\n"
"(tbtext \"%K\" (pos 109 4.1) (comment \"Kicad version\" ) )\n"
"(line (start 110 8.5) end 2 8.5) )\n"
"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n"
"(tbtext \"Size: %Z\" (comment \"Paper format name\")(pos 109 6.9) )\n"
"(tbtext \"Id: %S/%N\" (comment \"Sheet id\")(pos 24 4.1) )\n"
"(line (start 110 12.5) end 2 12.5) )\n"
"(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n"
"(tbtext \"File: %F\" (pos 109 14.3) )\n"
"(line (start 110 18.5) end 2 18.5) )\n"
"(tbtext \"Sheet: %P\" (pos 109 17) )\n"
"(tbtext \"%Y\" (comment \"Company name\") (pos 109 20)(font bold) )\n"
"(tbtext \"%C0\" (comment \"Comment 0\") (pos 109 23) )\n"
"(tbtext \"%C1\" (comment \"Comment 1\") (pos 109 26) )\n"
"(tbtext \"%C2\" (comment \"Comment 2\") (pos 109 29) )\n"
"(tbtext \"%C3\" (comment \"Comment 3\") (pos 109 32) )\n"
"(line (start 90 8.5) end 90 5.5) )\n"
"(line (start 26 8.5) end 26 2) )\n"
")\n"
;

View File

@ -1,623 +0,0 @@
/**
* @file common/page_layout_reader.cpp
* @brief read an S expression of description of graphic items and texts
* to build a title block and page layout
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
* Copyright (C) 1992-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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <base_struct.h>
#include <worksheet.h>
#include <worksheet_shape_builder.h>
#include <math/vector2d.h>
#include <page_layout_reader_lexer.h>
using namespace TB_READER_T;
/**
* Class PAGE_LAYOUT_READER_PARSER
* holds data and functions pertinent to parsing a S-expression file
* for a WORKSHEET_LAYOUT.
*/
class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER
{
DSIZE m_defaultTextSize; // Default text size, when not defined inside a tbtext
double m_defaultLineWidth;
double m_defaulTextLineWidth;
public:
PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource );
void Parse( WORKSHEET_LAYOUT* aLayout )
throw( PARSE_ERROR, IO_ERROR );
private:
/**
* Function parseInt
* parses an integer and constrains it between two values.
* @param aMin is the smallest return value.
* @param aMax is the largest return value.
* @return int - the parsed integer.
*/
int parseInt( int aMin, int aMax );
/**
* Function parseDouble
* parses a double
* @return double - the parsed double.
*/
double parseDouble();
void parseSetup() throw( IO_ERROR, PARSE_ERROR );
void parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR );
void parseText( WORKSHEET_DATAITEM_TEXT * aItem ) throw( IO_ERROR, PARSE_ERROR );
void parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
throw( IO_ERROR, PARSE_ERROR );
void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
throw( IO_ERROR, PARSE_ERROR );
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR );
};
// PCB_PLOT_PARAMS_PARSER
PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ) :
PAGE_LAYOUT_READER_LEXER( aLine, aSource )
{
m_defaultTextSize.x = m_defaultTextSize.y = TB_DEFAULT_TEXTSIZE;
m_defaultLineWidth = 0.0;
m_defaulTextLineWidth = 0.0;
}
void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
throw( PARSE_ERROR, IO_ERROR )
{
T token;
WORKSHEET_DATAITEM * item;
LOCALE_IO toggle;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
if( token == T_page_layout )
continue;
switch( token )
{
case T_setup: // Defines default values for graphic items
parseSetup();
break;
case T_line:
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT );
parseGraphic( item );
aLayout->Append( item );
break;
case T_rect:
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT );
parseGraphic( item );
aLayout->Append( item );
break;
case T_polygon:
item = new WORKSHEET_DATAITEM_POLYPOLYGON();
parsePolygon( (WORKSHEET_DATAITEM_POLYPOLYGON*) item );
aLayout->Append( item );
break;
case T_tbtext:
NeedSYMBOLorNUMBER();
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() );
parseText( (WORKSHEET_DATAITEM_TEXT*) item );
aLayout->Append( item );
break;
default:
Unexpected( CurText() );
break;
}
}
}
void PAGE_LAYOUT_READER_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
switch( token )
{
case T_LEFT:
break;
case T_linewidth:
m_defaultLineWidth = parseDouble();
NeedRIGHT();
break;
case T_textsize:
m_defaultTextSize.x = parseDouble();
m_defaultTextSize.y = parseDouble();
NeedRIGHT();
break;
case T_textlinewidth:
m_defaulTextLineWidth = parseDouble();
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
}
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
aItem->m_LineWidth = 0;
T token;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_comment: // Comment, search the closing ')'
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
break;
case T_pos:
parseCoordinate( aItem->m_Pos );
break;
case T_pts:
parsePolyOutline( aItem );
aItem->CloseContour();
break;
case T_rotate:
aItem->m_Orient = parseDouble();
NeedRIGHT();
break;
case T_repeat:
aItem->m_RepeatCount = parseInt( -1, 100 );
NeedRIGHT();
break;
case T_incrx:
aItem->m_IncrementVector.x = parseDouble();
NeedRIGHT();
break;
case T_incry:
aItem->m_IncrementVector.y = parseDouble();
NeedRIGHT();
break;
case T_linewidth:
aItem->m_LineWidth = parseDouble();
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
aItem->SetBoundingBox();
}
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
DPOINT corner;
T token;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_xy:
corner.x = parseDouble();
corner.y = parseDouble();
aItem->AppendCorner( corner );
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
}
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
throw( IO_ERROR, PARSE_ERROR )
{
T token;
aItem->m_LineWidth = m_defaultLineWidth;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_comment: // Comment, search the closing ')'
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
break;
case T_start:
parseCoordinate( aItem->m_Pos );
break;
case T_end:
parseCoordinate( aItem->m_End );
break;
case T_repeat:
aItem->m_RepeatCount = parseInt( -1, 100 );
NeedRIGHT();
break;
case T_incrx:
aItem->m_IncrementVector.x = parseDouble();
NeedRIGHT();
break;
case T_incry:
aItem->m_IncrementVector.y = parseDouble();
NeedRIGHT();
break;
case T_linewidth:
aItem->m_LineWidth = parseDouble();
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
}
void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
throw( IO_ERROR, PARSE_ERROR )
{
T token;
aItem->m_TextSize = m_defaultTextSize;
aItem->m_LineWidth = m_defaulTextLineWidth;
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_comment: // Comment, search the closing ')'
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF );
break;
case T_pos:
parseCoordinate( aItem->m_Pos );
break;
case T_repeat:
aItem->m_RepeatCount = parseInt( -1, 100 );
NeedRIGHT();
break;
case T_incrx:
aItem->m_IncrementVector.x = parseDouble();
NeedRIGHT();
break;
case T_incry:
aItem->m_IncrementVector.y = parseDouble();
NeedRIGHT();
break;
case T_incrlabel:
aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
NeedRIGHT();
break;
case T_maxlen:
aItem->m_BoundingBoxSize.x = parseDouble();
NeedRIGHT();
break;
case T_maxheight:
aItem->m_BoundingBoxSize.y = parseDouble();
NeedRIGHT();
break;
case T_font:
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
switch( token )
{
case T_LEFT:
break;
case T_bold:
aItem->m_Flags |= USE_BOLD;
break;
case T_italic:
aItem->m_Flags |= USE_ITALIC;
break;
case T_size:
aItem->m_TextSize.x = parseDouble();
aItem->m_TextSize.y = parseDouble();
NeedRIGHT();
break;
case T_linewidth:
aItem->m_LineWidth = parseDouble();
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
break;
case T_justify:
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_EOF)
break;
switch( token )
{
case T_center:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER;
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
break;
case T_left:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
break;
case T_right:
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
break;
case T_top:
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP;
break;
case T_bottom:
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
break;
default:
Unexpected( CurText() );
break;
}
}
break;
case T_rotate:
aItem->m_Orient = parseDouble();
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
}
}
}
// parse an expression like " 25 1 ltcorner)"
void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
throw( IO_ERROR, PARSE_ERROR )
{
T token;
aCoord.m_Pos.x = parseDouble();
aCoord.m_Pos.y = parseDouble();
while( ( token = NextTok() ) != T_RIGHT )
{
switch( token )
{
case T_ltcorner:
aCoord.m_Anchor = LT_CORNER; // left top corner
break;
case T_lbcorner:
aCoord.m_Anchor = LB_CORNER; // left bottom corner
break;
case T_rbcorner:
aCoord.m_Anchor = RB_CORNER; // right bottom corner
break;
case T_rtcorner:
aCoord.m_Anchor = RT_CORNER; // right top corner
break;
default:
Unexpected( CurText() );
break;
}
}
}
int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax )
{
T token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
int val = atoi( CurText() );
if( val < aMin )
val = aMin;
else if( val > aMax )
val = aMax;
return val;
}
double PAGE_LAYOUT_READER_PARSER::parseDouble()
{
T token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
double val = strtod( CurText(), NULL );
return val;
}
// defaultPageLayout is the default page layout description
// using the S expr.
// see page_layout_default_shape.cpp
extern const char defaultPageLayout[];
void WORKSHEET_LAYOUT::SetDefaultLayout()
{
ClearList();
PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, wxT( "default page" ) );
try
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
{
wxLogMessage( ioe.errorText );
}
}
#include <wx/file.h>
// SetLayout() try to load a custom layout file,
// currently defined by the environment variable KICAD_WKSFILE
// (a *.kicad_wks file).
// if does not exists, loads the default page layout.
void WORKSHEET_LAYOUT::SetLayout()
{
wxString fullFileName;
wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName );
if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) )
{
#if 0
if( !fullFileName.IsEmpty() )
{
wxLogMessage( wxT("Page layout file <%s> not found"),
fullFileName.GetData() );
}
#endif
SetDefaultLayout();
return;
}
wxFile wksFile( fullFileName );
if( ! wksFile.IsOpened() )
{
SetDefaultLayout();
return;
}
int filelen = wksFile.Length();
char * buffer = new char[filelen+10];
if( wksFile.Read( buffer, filelen ) != filelen )
wxLogMessage( _("The file <%s> was not fully read"),
fullFileName.GetData() );
else
{
buffer[filelen]=0;
ClearList();
PAGE_LAYOUT_READER_PARSER lp_parser( buffer, fullFileName );
try
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
{
wxLogMessage( ioe.errorText );
}
}
delete[] buffer;
}

View File

@ -1,37 +0,0 @@
page_layout
setup
linewidth
textlinewidth
textsize
comment
line
rect
polygon
tbtext
ltcorner
lbcorner
rbcorner
rtcorner
name
pos
start
end
pts
xy
maxlen
maxheight
font
bold
italic
size
justify
left
center
right
top
bottom
rotate
repeat
incrx
incry
incrlabel

View File

@ -35,11 +35,64 @@
#endif
// This file defines 3 classes useful for working with DSN text files and is named
// "richio" after its author, Richard Hollenbeck, aka Dick Hollenbeck.
// This file defines 3 classes and some functions useful for working with text files
// and is named "richio" after its author, Richard Hollenbeck, aka Dick Hollenbeck.
static int vprint( std::string* result, const char* format, va_list ap )
{
char msg[512];
size_t len = vsnprintf( msg, sizeof(msg), format, ap );
if( len < sizeof(msg) ) // the output fit into msg
{
result->append( msg, msg + len );
}
else
{
// output was too big, so now incur the expense of allocating
// a buf for holding suffient characters.
std::vector<char> buf;
buf.reserve( len+1 ); // reserve(), not resize() which writes. +1 for trailing nul.
len = vsnprintf( &buf[0], len+1, format, ap );
result->append( &buf[0], &buf[0] + len );
}
return len;
}
int StrPrintf( std::string* result, const char* format, ... )
{
va_list args;
va_start( args, format );
int ret = vprint( result, format, args );
va_end( args );
return ret;
}
std::string StrPrintf( const char* format, ... )
{
std::string ret;
va_list args;
va_start( args, format );
int ignore = vprint( &ret, format, args );
(void) ignore;
va_end( args );
return ret;
}
void IO_ERROR::init( const char* aThrowersFile, const char* aThrowersLoc, const wxString& aMsg )
{
errorText.Printf( IO_FORMAT, aMsg.GetData(),

View File

@ -39,8 +39,6 @@
#include <protos.h>
const wxString traceFindReplace( wxT( "KicadFindReplace" ) );
const wxString traceFindItem( wxT( "KicadFindItem" ) );

View File

@ -9,6 +9,91 @@
#include <common.h>
#include <math_for_graphics.h>
// Returns true if the point P is on the segment S.
// faster than TestSegmentHit() because P should be exactly on S
// therefore works fine only for H, V and 45 deg segm (suitable for wires in eeschema)
bool IsPointOnSegment( const wxPoint& aSegStart, const wxPoint& aSegEnd,
const wxPoint& aTestPoint )
{
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
// Use long long here to avoid overflow in calculations
if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
return false; /* Cross product non-zero, vectors not parallel */
if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
return false; /* Point not on segment */
return true;
}
// Returns true if the segment 1 intersectd the segment 2.
bool SegmentIntersectsSegment( const wxPoint &a_p1_l1, const wxPoint &a_p2_l1,
const wxPoint &a_p1_l2, const wxPoint &a_p2_l2 )
{
//We are forced to use 64bit ints because the internal units can oveflow 32bit ints when
// multiplied with each other, the alternative would be to scale the units down (i.e. divide
// by a fixed number).
long long dX_a, dY_a, dX_b, dY_b, dX_ab, dY_ab;
long long num_a, num_b, den;
//Test for intersection within the bounds of both line segments using line equations of the
// form:
// x_k(u_k) = u_k * dX_k + x_k(0)
// y_k(u_k) = u_k * dY_k + y_k(0)
// with 0 <= u_k <= 1 and k = [ a, b ]
dX_a = a_p2_l1.x - a_p1_l1.x;
dY_a = a_p2_l1.y - a_p1_l1.y;
dX_b = a_p2_l2.x - a_p1_l2.x;
dY_b = a_p2_l2.y - a_p1_l2.y;
dX_ab = a_p1_l2.x - a_p1_l1.x;
dY_ab = a_p1_l2.y - a_p1_l1.y;
den = dY_a * dX_b - dY_b * dX_a ;
//Check if lines are parallel
if( den == 0 )
return false;
num_a = dY_ab * dX_b - dY_b * dX_ab;
num_b = dY_ab * dX_a - dY_a * dX_ab;
//We wont calculate directly the u_k of the intersection point to avoid floating point
// division but they could be calculated with:
// u_a = (float) num_a / (float) den;
// u_b = (float) num_b / (float) den;
if( den < 0 )
{
den = -den;
num_a = -num_a;
num_b = -num_b;
}
//Test sign( u_a ) and return false if negative
if( num_a < 0 )
return false;
//Test sign( u_b ) and return false if negative
if( num_b < 0 )
return false;
//Test to ensure (u_a <= 1)
if( num_a > den )
return false;
//Test to ensure (u_b <= 1)
if( num_b > den )
return false;
return true;
}
/* Function TestSegmentHit
* test for hit on line segment
* i.e. a reference point is within a given distance from segment

View File

@ -25,6 +25,8 @@ set( CVPCB_DIALOGS
dialogs/dialog_display_options_base.cpp
../pcbnew/dialogs/dialog_fp_lib_table.cpp
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
../pcbnew/dialogs/dialog_fp_plugin_options.cpp
../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp
)
set( CVPCB_SRCS
@ -119,6 +121,12 @@ target_link_libraries(cvpcb
)
endif(WIN32 AND MSYS)
if( BUILD_GITHUB_PLUGIN )
target_link_libraries( cvpcb github_plugin )
endif()
###
# Add cvpcb as install target
###

View File

@ -38,6 +38,7 @@
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
#include <class_DisplayFootprintsFrame.h>
#define GROUP wxT("/cvpcb")
@ -94,9 +95,17 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
// Attempt to load the project footprint library table if it exists.
m_footprintLibTable = new FP_LIB_TABLE();
if( m_DisplayFootprintFrame )
m_DisplayFootprintFrame->SetFootprintLibTable( m_footprintLibTable );
wxFileName projectFpLibTableFileName;
projectFpLibTableFileName = FP_LIB_TABLE::GetProjectFileName( fn );
try
{
m_footprintLibTable->Load( fn, m_globalFootprintTable );
m_footprintLibTable->Load( projectFpLibTableFileName, m_globalFootprintTable );
FP_LIB_TABLE::SetProjectPathEnvVariable( projectFpLibTableFileName );
}
catch( IO_ERROR ioe )
{

View File

@ -491,42 +491,13 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
return NULL;
}
wxString libName = FROM_UTF8( fpid.GetLibNickname().c_str() );
std::string nickname = fpid.GetLibNickname();
std::string fpname = fpid.GetFootprintName();
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
fpid.GetFootprintName().c_str(), fpid.GetLibNickname().c_str() );
fpname.c_str(), nickname.c_str() );
const FP_LIB_TABLE::ROW* row;
try
{
row = m_footprintLibTable->FindRow( libName );
if( row == NULL )
{
wxString msg;
msg.Printf( _( "No library named <%s> was found in the footprint library table." ),
fpid.GetLibNickname().c_str() );
DisplayInfoMessage( this, msg );
return NULL;
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() );
wxString libPath = row->GetFullURI();
libPath = FP_LIB_TABLE::ExpandSubstitutions( libPath );
wxLogDebug( wxT( "Loading footprint <%s> from library <%s>." ),
GetChars( footprintName ), GetChars( libPath ) );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
footprint = pi->FootprintLoad( libPath, footprintName );
footprint = m_footprintLibTable->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
#else
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();

View File

@ -43,6 +43,7 @@
#include <cvpcb_mainframe.h>
#include <cvpcb.h>
#include <cvstruct.h>
#include <invoke_pcb_dialog.h>
#include <dialog_cvpcb_config.h>
#include <class_DisplayFootprintsFrame.h>
#include <cvpcb_id.h>
@ -57,16 +58,6 @@ static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) );
static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
/**
* Function InvokePcbLibTableEditor
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
*
* @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal
* and/or the @a aProject table, respectively. If set, table was modified.
*/
int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject );
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
@ -317,7 +308,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_NO:
break;
case wxID_OK:
case wxID_YES:
diag = SaveCmpLinkFile( m_NetlistFileName.GetFullPath() );
@ -750,7 +740,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
m_footprints.ReadFootprintFiles( m_ModuleLibNames );
#else
if( m_footprintLibTable != NULL )
m_footprints.ReadFootprintFiles( *m_footprintLibTable );
m_footprints.ReadFootprintFiles( m_footprintLibTable );
#endif
// Display error messages, if any.

View File

@ -271,6 +271,35 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
if( !fn.HasExt() )
fn.SetExt( ComponentFileExtension );
#if defined( USE_FP_LIB_TABLE )
// Save the project specific footprint library table.
if( !m_footprintLibTable->IsEmpty( false ) )
{
wxFileName fpLibFileName = fn;
fpLibFileName.ClearExt();
fpLibFileName.SetName( FP_LIB_TABLE::GetFileName() );
if( fpLibFileName.FileExists()
&& IsOK( this, _( "A footprint library table already exists in this path.\n\nDo "
"you want to overwrite it?" ) ) )
{
try
{
m_footprintLibTable->Save( fpLibFileName );
}
catch( IO_ERROR& ioe )
{
DisplayError( this,
wxString::Format( _( "An error occurred attempting to save the "
"footprint library table <%s>\n\n%s" ),
GetChars( fpLibFileName.GetFullPath() ),
GetChars( ioe.errorText ) ) );
}
}
}
#endif
}
if( !IsWritable( fn.GetFullPath() ) )

View File

@ -71,7 +71,6 @@ set(EESCHEMA_SRCS
component_references_lister.cpp
controle.cpp
cross-probing.cpp
dangling_ends.cpp
database.cpp
${EESCHEMA_DLGS}
edit_component_in_schematic.cpp

View File

@ -186,31 +186,19 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
m_canvas->Refresh();
}
/*
* HandleBlockEnd is called when:
* a block is defined
* or a schematic iten should be dragged
* When the block is defined, all items inside the block should be collected
* When a schematic iten should be dragged, only this item should be collected
*
* In all cases, connected items are collected when a drag command is activated
*/
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{
bool nextcmd = false;
bool zoom_command = false;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
bool currItemOnly = false;
if ( block->GetCommand() == BLOCK_DRAG && GetScreen()->GetCurItem() != NULL )
currItemOnly = true;
if( block->GetCount() )
{
BLOCK_STATE_T state = block->GetState();
BLOCK_COMMAND_T command = block->GetCommand();
m_canvas->CallEndMouseCapture( DC );
m_canvas->CallEndMouseCapture( aDC );
block->SetState( state );
block->SetCommand( command );
@ -231,7 +219,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_ROTATE:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
@ -243,25 +231,28 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
RotateListOfItems( block->GetItems(), rotationPoint );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, DC );
GetScreen()->TestDanglingEnds( m_canvas, aDC );
m_canvas->Refresh();
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_DRAG:
GetScreen()->BreakSegmentsOnJunctions();
// fall through
case BLOCK_MOVE:
case BLOCK_COPY:
if( currItemOnly )
if( GetScreen()->GetCurItem() != NULL )
{
ITEM_PICKER picker;
picker.SetItem( GetScreen()->GetCurItem() );
block->PushItem( picker );
}
else
{
GetScreen()->UpdatePickList();
}
// fall through
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
@ -269,21 +260,21 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
nextcmd = true;
GetScreen()->SelectBlockItems();
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
block->SetState( STATE_BLOCK_MOVE );
}
else
{
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->SetMouseCapture( NULL, NULL );
}
break;
case BLOCK_DELETE: /* Delete */
case BLOCK_DELETE:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
@ -291,13 +282,13 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, DC );
GetScreen()->TestDanglingEnds( m_canvas, aDC );
m_canvas->Refresh();
break;
case BLOCK_SAVE: /* Save */
case BLOCK_SAVE:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
@ -313,10 +304,48 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
block->SetState( STATE_BLOCK_MOVE );
break;
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_ZOOM:
zoom_command = true;
break;
case BLOCK_MIRROR_X:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
MirrorX( block->GetItems(), mirrorPoint );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, aDC );
m_canvas->Refresh();
break;
case BLOCK_MIRROR_Y:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
MirrorY( block->GetItems(), mirrorPoint );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, aDC );
m_canvas->Refresh();
break;
default:
break;
}
@ -344,158 +373,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
}
void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
bool blockCmdFinished = true; /* set to false for block command which
* have a next step
* and true if the block command is finished here
*/
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
// can convert only a block move command to an other command
if( block->GetCommand() != BLOCK_MOVE )
return;
// Useless if the new command is block move because we are already in block move.
if( Command == BLOCK_MOVE )
return;
block->SetCommand( (BLOCK_COMMAND_T) Command );
block->SetMessageBlock( this );
switch( block->GetCommand() )
{
case BLOCK_COPY: /* move to copy */
block->SetState( STATE_BLOCK_MOVE );
blockCmdFinished = false;
break;
case BLOCK_DRAG: /* move to Drag */
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
// Clear list of items to move, and rebuild it with items to drag:
block->ClearItemsList();
GetScreen()->BreakSegmentsOnJunctions();
GetScreen()->UpdatePickList();
if( block->GetCount() )
{
blockCmdFinished = false;
GetScreen()->SelectBlockItems();
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
block->SetState( STATE_BLOCK_MOVE );
}
break;
case BLOCK_DELETE: /* move to Delete */
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
if( block->GetCount() )
{
DeleteItemsInList( m_canvas, block->GetItems() );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
break;
case BLOCK_SAVE: /* Save list in paste buffer*/
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
if( block->GetCount() )
{
wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
copyBlockItems( block->GetItems() );
MoveItemsInList( m_blockItems.GetItems(), move_vector );
}
break;
case BLOCK_ZOOM: /* Window Zoom */
m_canvas->CallEndMouseCapture( DC );
m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
Window_Zoom( GetScreen()->m_BlockLocate );
break;
case BLOCK_ROTATE:
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
if( block->GetCount() )
{
/* Compute the rotation center and put it on grid */
wxPoint rotationPoint = block->Centre();
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
RotateListOfItems( block->GetItems(), rotationPoint );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
break;
case BLOCK_MIRROR_X:
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
if( block->GetCount() )
{
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
MirrorX( block->GetItems(), mirrorPoint );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
break;
case BLOCK_MIRROR_Y:
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
if( block->GetCount() )
{
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
MirrorY( block->GetItems(), mirrorPoint );
OnModify();
}
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
break;
default:
break;
}
if( blockCmdFinished )
{
block->Clear();
GetScreen()->SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
false );
}
}
/* Traces the outline of the search block structures
* The entire block follows the cursor
*/

View File

@ -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 <stambaughw@verizon.net>
* 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 <stambaughw@verizon.net>
* 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
@ -32,8 +32,8 @@
#include <macros.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <sch_component.h>
#include <class_netlist_object.h>
#include <wx/regex.h>
@ -116,7 +116,7 @@ const char* ShowType( NETLIST_ITEM_T aType )
void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) const
{
wxString path = m_SheetList.PathHumanReadable();
wxString path = m_SheetPath.PathHumanReadable();
out << "<netItem ndx=\"" << ndx << '"' <<
" type=\"" << ShowType( m_Type ) << '"' <<
@ -129,13 +129,13 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) const
if( !m_Label.IsEmpty() )
out << " <label>" << m_Label.mb_str() << "</label>\n";
out << " <sheetpath>" << m_SheetList.PathHumanReadable().mb_str() << "</sheetpath>\n";
out << " <sheetpath>" << m_SheetPath.PathHumanReadable().mb_str() << "</sheetpath>\n";
switch( m_Type )
{
case NET_PIN:
/* GetRef() needs to be const
out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str()
out << " <refOfComp>" << GetComponentParent()->GetRef(&m_SheetPath).mb_str()
<< "</refOfComp>\n";
*/
@ -175,16 +175,16 @@ NETLIST_OBJECT::NETLIST_OBJECT()
m_Flag = 0; /* flag used in calculations */
m_ElectricalType = 0; /* Has meaning only for Pins and hierarchical pins: electrical
* type */
m_NetCode = 0; /* net code for all items except BUS labels because a BUS
m_netCode = 0; /* net code for all items except BUS labels because a BUS
* label has as many net codes as bus members
*/
m_BusNetCode = 0; /* Used for BUS connections */
m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created
* from the BUS label ) member number
*/
m_FlagOfConnection = UNCONNECTED;
m_ConnectionType = UNCONNECTED;
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_NetNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
* object used to give a name to the net
*/
}
@ -201,6 +201,15 @@ NETLIST_OBJECT::~NETLIST_OBJECT()
{
}
// return true if the object is a label of any type
bool NETLIST_OBJECT::IsLabelType() const
{
return m_Type == NET_LABEL
|| m_Type == NET_GLOBLABEL || m_Type == NET_HIERLABEL
|| m_Type == NET_BUSLABELMEMBER || m_Type == NET_GLOBBUSLABELMEMBER
|| m_Type == NET_HIERBUSLABELMEMBER
|| m_Type == NET_PINLABEL;
}
bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
{
@ -213,7 +222,7 @@ bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
{
if( m_SheetList == aNetItem->m_SheetListInclude )
if( m_SheetPath == aNetItem->m_SheetPathInclude )
{
return true; //connected!
}
@ -299,3 +308,82 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem
aNetListItems.push_back( item );
}
}
/*
* return the net name of the item
*/
wxString NETLIST_OBJECT::GetNetName() const
{
if( m_netNameCandidate == NULL )
return wxEmptyString;
wxString netName;
if( m_netNameCandidate->m_Type == NET_PIN )
return GetShortNetName();
if( !m_netNameCandidate->IsLabelGlobal() )
{
// usual net name, prefix it by the sheet path
netName = m_netNameCandidate->m_SheetPath.PathHumanReadable();
}
netName += m_netNameCandidate->m_Label;
return netName;
}
/**
* return the short net name of the item i.e. the net name
* from the "best" label without any prefix.
* 2 different nets can have the same short name
*/
wxString NETLIST_OBJECT::GetShortNetName() const
{
if( m_netNameCandidate == NULL )
return wxEmptyString;
wxString netName;
if( m_netNameCandidate->m_Type == NET_PIN )
{
SCH_COMPONENT* link = m_netNameCandidate->GetComponentParent();
if( link ) // Should be always true
{
netName = wxT("Net-(");
netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
netName << wxT("-Pad")
<< LIB_PIN::ReturnPinStringNum( m_netNameCandidate->m_PinNum )
<< wxT(")");
}
}
else
netName = m_netNameCandidate->m_Label;
return netName;
}
/**
* Set m_netNameCandidate to a connected item which will
* be used to calcule the net name of the item
* Obviously the candidate can be only a label
* when there is no label on the net a pad which will
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
* @param aCandidate = the connected item candidate
*/
void NETLIST_OBJECT::SetNetNameCandidate( NETLIST_OBJECT* aCandidate )
{
switch( aCandidate->m_Type )
{
case NET_HIERLABEL:
case NET_LABEL:
case NET_PINLABEL:
case NET_GLOBLABEL:
case NET_PIN:
m_netNameCandidate = aCandidate;
break;
default:
break;
}
}

View File

@ -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 <stambaughw@verizon.net>
* 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 <stambaughw@verizon.net>
* 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
@ -33,15 +33,10 @@
#include <sch_sheet_path.h>
#include <lib_pin.h> // LIB_PIN::ReturnPinStringNum( m_PinNum )
class NETLIST_OBJECT;
// Buffer to build the list of items used in netlist and erc calculations
typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST;
class NETLIST_OBJECT_LIST;
class SCH_COMPONENT;
/* Type of Net objects (wires, labels, pins...) */
@ -89,53 +84,46 @@ enum NET_CONNECTION_T {
};
/**
* Function IsBusLabel
* test if \a aLabel has a bus notation.
*
* @param aLabel A wxString object containing the label to test.
* @return true if text is a bus notation format otherwise false is returned.
*/
extern bool IsBusLabel( const wxString& aLabel );
class NETLIST_OBJECT
{
public:
NETLIST_ITEM_T m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
EDA_ITEM* m_Comp; /* Pointer on the library item that
EDA_ITEM* m_Comp; /* Pointer to the library item that
* created this net object (the parent)
*/
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
* Pointer to the hierarchy sheet that
* contains this SCH_SHEET_PIN
* For Pins: pointer to the component
* For Pins: pointer to the schematic component
* that contains this pin
*/
int m_Flag; /* flag used in calculations */
SCH_SHEET_PATH m_SheetList;
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label
int m_ElectricalType; /* Has meaning only for Pins and
* hierarchical pins: electrical type */
private:
int m_NetCode; /* net code for all items except BUS
* labels because a BUS label has
* as many net codes as bus members
*/
public:
int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
* created from the BUS label ) member number.
*/
NET_CONNECTION_T m_FlagOfConnection;
SCH_SHEET_PATH m_SheetListInclude; /* sheet that the hierarchical label connects to.*/
long m_PinNum; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
wxString m_Label; /* Label text. */
NET_CONNECTION_T m_ConnectionType; // Used to store the connection type
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
wxString m_Label; // Label text (for labels) or Pin name (for pins)
wxPoint m_Start; // Position of object or for segments: starting point
wxPoint m_End; // For segments (wire and buses): ending point
NETLIST_OBJECT* m_NetNameCandidate; /* a pointer to a label connected to the net,
* that can be used to give a name to the net
* NULL if no usable label
private:
int m_netCode; /* net code for all items except BUS
* labels because a BUS label has
* as many net codes as bus members
*/
NETLIST_OBJECT* m_netNameCandidate; /* a pointer to a label connected to the net,
* that can be used to give a name to the net
* or a pin if there is no label in net
* When no label, the pin is used to build
* default net name.
*/
public:
#if defined(DEBUG)
void Show( std::ostream& out, int ndx ) const; // override
@ -146,8 +134,42 @@ public:
~NETLIST_OBJECT();
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
int GetNet() const { return m_NetCode; }
// Accessors:
void SetNet( int aNetCode ) { m_netCode = aNetCode; }
int GetNet() const { return m_netCode; }
/**
* Set the item connection type:
* UNCONNECTED Pin or Label not connected (error)
* NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect
* symbol on it (no error)
* PAD_CONNECT Normal connection (no error)
*/
void SetConnectionType( NET_CONNECTION_T aFlg = UNCONNECTED )
{
m_ConnectionType = aFlg;
}
NET_CONNECTION_T GetConnectionType()
{
return m_ConnectionType;
}
/**
* Set m_netNameCandidate to a connected item which will
* be used to calcule the net name of the item
* Obviously the candidate can be only a label
* when there is no label on the net a pad which will
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
* @param aCandidate = the connected item candidate
*/
void SetNetNameCandidate( NETLIST_OBJECT* aCandidate );
/**
* @return true if an item has already a net name candidate
* and false if not ( m_netNameCandidate == NULL )
*/
bool HasNetNameCandidate() { return m_netNameCandidate != NULL; }
/**
* Function GetPinNum
@ -160,6 +182,19 @@ public:
return LIB_PIN::ReturnPinStringNum( m_PinNum );
}
/** For Pins (NET_PINS):
* @return the schematic component which contains this pin
* (Note: this is the schematic component, not the library component
* for others items: return NULL
*/
SCH_COMPONENT* GetComponentParent() const
{
if( m_Link && m_Link->Type() == SCH_COMPONENT_T )
return (SCH_COMPONENT*) m_Link;
return NULL;
}
/**
* Function IsLabelConnected
* tests if the net list object is a hierarchical label or sheet label and is
@ -171,6 +206,38 @@ public:
*/
bool IsLabelConnected( NETLIST_OBJECT* aNetItem );
/**
* Function IsLabelGlobal
* @return true if the object is a global label
* (i.e. an real global label or a pin label coming
* from a power pin invisible
*/
bool IsLabelGlobal() const
{
return ( m_Type == NET_PINLABEL ) || ( m_Type == NET_GLOBLABEL );
}
/**
* Function IsLabelType
* @return true if the object is a label of any type
*/
bool IsLabelType() const;
/**
* Function GetNetName
* @return the full net name of the item, i.e. the net name
* from the "best" label, prefixed by the sheet path
*/
wxString GetNetName() const;
/**
* Function GetShortNetName
* @return the short net name of the item i.e. the net name
* from the "best" label without any prefix.
* 2 different nets can have the same short name
*/
wxString GetShortNetName() const;
/**
* Function ConvertBusToNetListItems
* breaks the text of a bus label type net list object into as many members as
@ -184,4 +251,205 @@ public:
};
/**
* NETLIST_OBJECT_LIST is a class to handle the list of connected items
* in a full shematic hierarchy for netlist and erc calculations
*/
class NETLIST_OBJECT_LIST: public std::vector <NETLIST_OBJECT*>
{
bool m_isOwner; // = true if the objects in list are owned my me, and therefore
// the memory should be freed by the destructor and the list cleared
int m_lastNetCode; // Used in intermediate calculation: last net code created
int m_lastBusNetCode; // Used in intermediate calculation:
// last net code created for bus members
public:
/**
* Constructor.
* NETLIST_OBJECT_LIST handle a list of connected items.
* the instance can be owner of items or not.
* If it is the owner, the items are freeed by the destructor
* @param aIsOwner true if the instance is the owner of item list
* (default = false)
*/
NETLIST_OBJECT_LIST( bool aIsOwner = false ) { m_isOwner = aIsOwner; }
~NETLIST_OBJECT_LIST();
void SetOwner( bool aIsOwner ) { m_isOwner = aIsOwner; }
/**
* Function BuildNetListInfo
* the master function of tgis class.
* Build the list of connected objects (pins, labels ...) and
* all info to generate netlists or run ERC diags
* @param aSheets = the flattened sheet list
* @return true if OK, false is not item found
*/
bool BuildNetListInfo( SCH_SHEET_LIST& aSheets );
/*
* Acces to an item in list
*/
NETLIST_OBJECT* GetItem( unsigned aIdx ) const
{
return *( this->begin() + aIdx );
}
/*
* Acces to an item type
*/
NETLIST_ITEM_T GetItemType( unsigned aIdx ) const
{
return GetItem( aIdx )->m_Type;
}
/*
* Acces to an item net code
*/
int GetItemNet( unsigned aIdx ) const
{
return GetItem( aIdx )->GetNet();
}
NET_CONNECTION_T GetConnectionType( unsigned aIdx )
{
return GetItem( aIdx )->GetConnectionType();
}
/**
* Set the item connection type:
* UNCONNECTED Pin or Label not connected (error)
* NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect
* symbol on it (no error)
* PAD_CONNECT Normal connection (no error)
*/
void SetConnectionType( unsigned aIdx, NET_CONNECTION_T aFlg = UNCONNECTED )
{
GetItem( aIdx )->SetConnectionType( aFlg );
}
/*
* Delete all objects in list and clear list
* (delete NETLIST_OBJECT items)
*/
void FreeList();
/*
* Clear list but do not delete NETLIST_OBJECT items
* (they can be deleted only if the instance is owner of the items
*/
void Clear() { this->clear(); }
/**
* Reset the connection type of all items to UNCONNECTED type
*/
void ResetConnectionsType( )
{
for( unsigned ii = 0; ii < size(); ii++ )
GetItem( ii )->SetConnectionType( UNCONNECTED );
}
/*
* Sorts the list of connected items by net code
*/
void SortListbyNetcode();
/*
* Sorts the list of connected items by sheet.
* This sorting is used when searching "physical" connection between items
* because obviously only items inside the same sheet can be connected
*/
void SortListbySheet();
#if defined(DEBUG)
void DumpNetTable()
{
for( unsigned idx = 0; idx < size(); ++idx )
{
GetItem( idx )->Show( std::cout, idx );
}
}
#endif
private:
/*
* Propagate aNewNetCode to items having an internal netcode aOldNetCode
* used to interconnect group of items already physically connected,
* when a new connection is found between aOldNetCode and aNewNetCode
*/
void propageNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus );
/*
* 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 labelConnect( NETLIST_OBJECT* aLabelRef );
/* Comparison function to sort by increasing Netcode the list of connected items
*/
static bool sortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
{
return Objet1->GetNet() < Objet2->GetNet();
}
/* Comparison routine to sort items by Sheet Number
*/
static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
{
return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
}
/*
* Propagate net codes from a parent sheet to an include sheet,
* from a pin sheet connection
*/
void sheetLabelConnect( NETLIST_OBJECT* aSheetLabel );
void pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus, int start );
/*
* 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 list
*/
void segmentToPointConnect( NETLIST_OBJECT* aJonction, bool aIsBus, int aIdxStart );
void connectBusLabels();
/*
* Set the m_FlagOfConnection 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
*/
void setUnconnectedFlag();
/**
* 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.
* The "best" NETLIST_OBJECT is a NETLIST_OBJECT that have the type label
* and by priority order:
* the label is global or local
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
* alphabetic order.
*/
void findBestNetNameForEachNet();
};
/**
* Function IsBusLabel
* test if \a aLabel has a bus notation.
*
* @param aLabel A wxString object containing the label to test.
* @return true if text is a bus notation format otherwise false is returned.
*/
extern bool IsBusLabel( const wxString& aLabel );
#endif // _CLASS_NETLIST_OBJECT_H_

View File

@ -1,32 +0,0 @@
/**
* @file dangling_ends.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <sch_item_struct.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <protos.h>
#include <class_libentry.h>
#include <lib_pin.h>
#include <sch_component.h>
/* Returns true if the point P is on the segment S. */
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint )
{
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
// Use long long here to avoid overflow in calculations
if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
return false; /* Cross product non-zero, vectors not parallel */
if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
return false; /* Point not on segment */
return true;
}

View File

@ -940,9 +940,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Initialize fixed field values to default values found in library
// Note: the field texts are not modified because they are set in schematic,
// the text from libraries is most of time a dummy text
// Only VALUE and REFERENCE are re-initialized
// Perhaps the FOOTPRINT field should also be considered,
// but for most of components it is not set in library
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
LIB_FIELD& refField = entry->GetReferenceField();
m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( REFERENCE )->ImportValues( refField );
@ -951,6 +949,20 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( VALUE )->ImportValues( valField );
LIB_FIELD* field = entry->GetField(FOOTPRINT);
if( field && m_Cmp->GetField( FOOTPRINT ) )
{
m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
}
field = entry->GetField(DATASHEET);
if( field && m_Cmp->GetField( DATASHEET ) )
{
m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( DATASHEET )->ImportValues( *field );
}
m_Cmp->SetOrientation( CMP_NORMAL );
m_Parent->OnModify();

View File

@ -37,8 +37,8 @@
#include <wxEeschemaStruct.h>
#include <invoke_sch_dialog.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <sch_marker.h>
#include <sch_sheet.h>
#include <lib_pin.h>
@ -464,20 +464,20 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
*/
TestDuplicateSheetNames( true );
m_parent->BuildNetListBase();
NETLIST_OBJECT_LIST* objectsConnectedList = m_parent->BuildNetListBase();
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
// Reset the connection type indicator
objectsConnectedList->ResetConnectionsType();
unsigned lastNet;
unsigned nextNet = lastNet = 0;
int NetNbItems = 0;
int MinConn = NOC;
for( unsigned net = 0; net < g_NetObjectslist.size(); net++ )
for( unsigned net = 0; net < objectsConnectedList->size(); net++ )
{
if( g_NetObjectslist[lastNet]->GetNet() != g_NetObjectslist[net]->GetNet() )
if( objectsConnectedList->GetItemNet( lastNet ) !=
objectsConnectedList->GetItemNet( net ) )
{
// New net found:
MinConn = NOC;
@ -485,7 +485,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
nextNet = net;
}
switch( g_NetObjectslist[net]->m_Type )
switch( objectsConnectedList->GetItemType( net ) )
{
// These items do not create erc problems
case NET_ITEM_UNSPECIFIED:
@ -507,7 +507,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet
TestLabel( net, nextNet );
TestLabel( objectsConnectedList, net, nextNet );
break;
case NET_NOCONNECT:
@ -516,14 +516,14 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
MinConn = NET_NC;
if( NetNbItems != 0 )
Diagnose( g_NetObjectslist[net], NULL, MinConn, UNC );
Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC );
break;
case NET_PIN:
// Look for ERC problems between pins:
TestOthersItems( net, nextNet, &NetNbItems, &MinConn );
TestOthersItems( objectsConnectedList, net, nextNet, &NetNbItems, &MinConn );
break;
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -30,6 +30,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
bTextValueBoxSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TextValue->SetMaxLength( 0 );
m_TextValue->SetMinSize( wxSize( 200,-1 ) );
bTextValueBoxSizer->Add( m_TextValue, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
@ -45,6 +46,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
bTextSizeSizer->Add( m_TextSizeText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TextSize->SetMaxLength( 0 );
bTextSizeSizer->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
@ -75,28 +77,28 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
sOptionsSizer->Add( m_Invisible, 0, wxALL, 5 );
bBottomtBoxSizer->Add( sOptionsSizer, 0, wxALL|wxEXPAND, 5 );
bBottomtBoxSizer->Add( sOptionsSizer, 1, wxALL|wxEXPAND, 5 );
wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_TextShapeOptNChoices = sizeof( m_TextShapeOptChoices ) / sizeof( wxString );
m_TextShapeOpt = new wxRadioBox( this, wxID_ANY, _("Text Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeOptNChoices, m_TextShapeOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextShapeOpt->SetSelection( 0 );
bBottomtBoxSizer->Add( m_TextShapeOpt, 0, wxALL|wxEXPAND, 5 );
bBottomtBoxSizer->Add( m_TextShapeOpt, 1, wxALL|wxEXPAND, 5 );
wxString m_TextHJustificationOptChoices[] = { _("Align left"), _("Align center"), _("Align right") };
int m_TextHJustificationOptNChoices = sizeof( m_TextHJustificationOptChoices ) / sizeof( wxString );
m_TextHJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_TextHJustificationOptNChoices, m_TextHJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextHJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify:"), wxDefaultPosition, wxDefaultSize, m_TextHJustificationOptNChoices, m_TextHJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextHJustificationOpt->SetSelection( 1 );
bBottomtBoxSizer->Add( m_TextHJustificationOpt, 0, wxALL|wxEXPAND, 5 );
bBottomtBoxSizer->Add( m_TextHJustificationOpt, 1, wxALL|wxEXPAND, 5 );
wxString m_TextVJustificationOptChoices[] = { _("Align bottom"), _("Align center"), _("Align top") };
int m_TextVJustificationOptNChoices = sizeof( m_TextVJustificationOptChoices ) / sizeof( wxString );
m_TextVJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_TextVJustificationOptNChoices, m_TextVJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextVJustificationOpt = new wxRadioBox( this, wxID_ANY, _("Vert. Justify:"), wxDefaultPosition, wxDefaultSize, m_TextVJustificationOptNChoices, m_TextVJustificationOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextVJustificationOpt->SetSelection( 1 );
bBottomtBoxSizer->Add( m_TextVJustificationOpt, 0, wxALL|wxEXPAND, 5 );
bBottomtBoxSizer->Add( m_TextVJustificationOpt, 1, wxALL|wxEXPAND, 5 );
bPropertiesSizer->Add( bBottomtBoxSizer, 1, wxEXPAND, 5 );
bPropertiesSizer->Add( bBottomtBoxSizer, 1, wxALIGN_CENTER|wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );

View File

@ -483,7 +483,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxALIGN_CENTER|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -493,7 +493,7 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Text Options:</property>
@ -940,7 +940,7 @@
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -1030,7 +1030,7 @@
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -1060,7 +1060,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Horiz. Justify</property>
<property name="label">Horiz. Justify:</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -1120,7 +1120,7 @@
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -1150,7 +1150,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Vert. Justify</property>
<property name="label">Vert. Justify:</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 11 2012)
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>

View File

@ -727,8 +727,9 @@ Do you want to annotate schematic?" ) ) )
SCH_SCREENS screens;
screens.SchematicCleanUp();
BuildNetListBase();
bool success = WriteNetListFile( aFormat, aFullFileName, aNetlistOptions );
NETLIST_OBJECT_LIST * connectedItemsList = BuildNetListBase();
bool success = WriteNetListFile( connectedItemsList, aFormat,
aFullFileName, aNetlistOptions );
return success;
}

View File

@ -48,7 +48,7 @@
*/
enum SchematicFindReplaceFlags
{
// The last wxFindReplaceFlag enum is wxFR_MATCHCASE.
// The last wxFindReplaceFlag enum is wxFR_MATCHCASE = 0x4.
/// Search the current sheet only.
FR_CURRENT_SHEET_ONLY = wxFR_MATCHCASE << 1,

View File

@ -364,10 +364,10 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
LIB_COMPONENT::SubpartIdSeparatorPtr(),
IsGOST() ? '.' : 0, 0, 126 ) );
0, 0, 126 ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
LIB_COMPONENT::SubpartFirstIdPtr(),
IsGOST() ? '1' : 'A', '1', 'z' ) );
'A', '1', 'z' ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
&m_userLibraryPath ) );

View File

@ -33,8 +33,8 @@
#include <kicad_string.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <lib_pin.h>
#include <protos.h>
#include <erc.h>
@ -240,7 +240,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( WAR );
screen = aNetItemRef->m_SheetList.LastScreen();
screen = aNetItemRef->m_SheetPath.LastScreen();
screen->Append( marker );
wxString msg;
@ -277,7 +277,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
cmp_ref = wxT( "?" );
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( &aNetItemRef->m_SheetList );
cmp_ref = aNetItemRef->GetComponentParent()->GetRef( &aNetItemRef->m_SheetPath );
if( aNetItemTst == NULL )
{
@ -295,8 +295,8 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
if( aMinConn == NOD ) /* Nothing driving the net. */
{
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList );
cmp_ref = aNetItemRef->GetComponentParent()->GetRef(
&aNetItemRef->m_SheetPath );
msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ),
@ -336,7 +336,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
alt_cmp = wxT( "?" );
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList );
alt_cmp = aNetItemTst->GetComponentParent()->GetRef( &aNetItemTst->m_SheetPath );
msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) );
@ -349,40 +349,40 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
}
void TestOthersItems( unsigned NetItemRef, unsigned netstart,
int* NetNbItems, int* MinConnexion )
void TestOthersItems( NETLIST_OBJECT_LIST* aList,
unsigned aNetItemRef, unsigned aNetStart,
int* aNetNbItems, int* aMinConnexion )
{
unsigned NetItemTst;
int ref_elect_type, jj, erc = OK, local_minconn;
unsigned netItemTst = aNetStart;
int jj;
int erc = OK;
/* Analysis of the table of connections. */
ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType;
NetItemTst = netstart;
local_minconn = NOC;
int ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalType;
int local_minconn = NOC;
if( ref_elect_type == PIN_NC )
local_minconn = NPI;
/* Test pins connected to NetItemRef */
for( ; ; NetItemTst++ )
for( ; ; netItemTst++ )
{
if( NetItemRef == NetItemTst )
if( aNetItemRef == netItemTst )
continue;
// We examine only a given net. We stop the search if the net changes
if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
if( ( netItemTst >= aList->size() ) // End of list
|| ( aList->GetItemNet( aNetItemRef ) !=
aList->GetItemNet( netItemTst ) ) ) // End of net
{
/* End net code found: minimum connection test. */
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) )
if( ( *aMinConnexion < NET_NC ) && ( local_minconn < NET_NC ) )
{
/* Not connected or not driven pin. */
bool seterr = true;
if( local_minconn == NOC && g_NetObjectslist[NetItemRef]->m_Type == NET_PIN )
if( local_minconn == NOC &&
aList->GetItemType( aNetItemRef ) == NET_PIN )
{
/* This pin is not connected: for multiple part per
* package, and duplicated pin,
@ -392,49 +392,49 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
* TODO test also if instances connected are connected to
* the same net
*/
for( unsigned duplicate = 0; duplicate < g_NetObjectslist.size(); duplicate++ )
for( unsigned duplicate = 0; duplicate < aList->size(); duplicate++ )
{
if( g_NetObjectslist[duplicate]->m_Type != NET_PIN )
if( aList->GetItemType( duplicate ) != NET_PIN )
continue;
if( duplicate == NetItemRef )
if( duplicate == aNetItemRef )
continue;
if( g_NetObjectslist[NetItemRef]->m_PinNum !=
g_NetObjectslist[duplicate]->m_PinNum )
if( aList->GetItem( aNetItemRef )->m_PinNum !=
aList->GetItem( duplicate )->m_PinNum )
continue;
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]-> m_SheetList ) !=
( (SCH_COMPONENT*) g_NetObjectslist[duplicate]->m_Link )
->GetRef( &g_NetObjectslist[duplicate]->m_SheetList ) )
if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) !=
( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) )
continue;
// Same component and same pin. Do dot create error for this pin
// if the other pin is connected (i.e. if duplicate net has an other
// item)
if( (duplicate > 0)
&& ( g_NetObjectslist[duplicate]->GetNet() ==
g_NetObjectslist[duplicate - 1]->GetNet() ) )
&& ( aList->GetItemNet( duplicate ) ==
aList->GetItemNet( duplicate - 1 ) ) )
seterr = false;
if( (duplicate < g_NetObjectslist.size() - 1)
&& ( g_NetObjectslist[duplicate]->GetNet() ==
g_NetObjectslist[duplicate + 1]->GetNet() ) )
if( (duplicate < aList->size() - 1)
&& ( aList->GetItemNet( duplicate ) ==
aList->GetItemNet( duplicate + 1 ) ) )
seterr = false;
}
}
if( seterr )
Diagnose( g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR );
Diagnose( aList->GetItem( aNetItemRef ), NULL, local_minconn, WAR );
*MinConnexion = DRV; // inhibiting other messages of this
*aMinConnexion = DRV; // inhibiting other messages of this
// type for the net.
}
return;
}
switch( g_NetObjectslist[NetItemTst]->m_Type )
switch( aList->GetItemType( netItemTst ) )
{
case NET_ITEM_UNSPECIFIED:
case NET_SEGMENT:
@ -456,13 +456,13 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
break;
case NET_PIN:
jj = g_NetObjectslist[NetItemTst]->m_ElectricalType;
jj = aList->GetItem( netItemTst )->m_ElectricalType;
local_minconn = std::max( MinimalReq[ref_elect_type][jj], local_minconn );
if( NetItemTst <= NetItemRef )
if( netItemTst <= aNetItemRef )
break;
*NetNbItems += 1;
*aNetNbItems += 1;
if( erc == OK )
{
@ -470,14 +470,12 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
if( erc != OK )
{
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
if( aList->GetConnectionType( netItemTst ) == UNCONNECTED )
{
Diagnose( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst],
0,
erc );
g_NetObjectslist[NetItemTst]->m_FlagOfConnection =
NOCONNECT_SYMBOL_PRESENT;
Diagnose( aList->GetItem( aNetItemRef ),
aList->GetItem( netItemTst ),
0, erc );
aList->SetConnectionType( netItemTst, NOCONNECT_SYMBOL_PRESENT );
}
}
}
@ -538,38 +536,36 @@ bool WriteDiagnosticERC( const wxString& aFullFileName )
}
void TestLabel( unsigned NetItemRef, unsigned StartNet )
void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aStartNet )
{
unsigned NetItemTst;
unsigned netItemTst = aStartNet;
int erc = 1;
NetItemTst = StartNet;
/* Review the list of labels connected to NetItemRef. */
for( ; ; NetItemTst++ )
for( ; ; netItemTst++ )
{
if( NetItemTst == NetItemRef )
if( netItemTst == aNetItemRef )
continue;
/* Is always in the same net? */
if( ( NetItemTst == g_NetObjectslist.size() )
|| ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) )
if( ( netItemTst == aList->size() )
|| ( aList->GetItemNet( aNetItemRef ) != aList->GetItemNet( netItemTst ) ) )
{
/* End Netcode found. */
if( erc )
{
/* Glabel or SheetLabel orphaned. */
Diagnose( g_NetObjectslist[NetItemRef], NULL, -1, WAR );
Diagnose( aList->GetItem( aNetItemRef ), NULL, -1, WAR );
}
return;
}
if( g_NetObjectslist[NetItemRef]->IsLabelConnected( g_NetObjectslist[NetItemTst] ) )
if( aList->GetItem( aNetItemRef )->IsLabelConnected( aList->GetItem( netItemTst ) ) )
erc = 0;
//same thing, different order.
if( g_NetObjectslist[NetItemTst]->IsLabelConnected( g_NetObjectslist[NetItemRef] ) )
if( aList->GetItem( netItemTst )->IsLabelConnected( aList->GetItem( aNetItemRef ) ) )
erc = 0;
}
}

View File

@ -33,6 +33,7 @@
class EDA_DRAW_PANEL;
class NETLIST_OBJECT;
class NETLIST_OBJECT_LIST;
/* For ERC markers: error types (used in diags, and to set the color):
*/
@ -83,15 +84,16 @@ extern void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst,
* Perform ERC testing for electrical conflicts between \a NetItemRef and other items
* on the same net.
*/
extern void TestOthersItems( unsigned NetItemRef, unsigned NetStart,
int* NetNbItems, int* MinConnexion );
extern void TestOthersItems( NETLIST_OBJECT_LIST* aList,
unsigned aNetItemRef, unsigned aNetStart,
int* aNetNbItems, int* aMinConnexion );
/**
* Function TestLabel
* performs an ERC on a sheet labels to verify that it is connected to a corresponding
* sub sheet global label.
*/
extern void TestLabel( unsigned NetItemRef, unsigned StartNet );
extern void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aStartNet );
/**
* Function TestDuplicateSheetNames( )

View File

@ -35,12 +35,11 @@
#include <wxEeschemaStruct.h>
#include <appl_wxstruct.h>
#include <general.h>
#include <protos.h>
#include <eeschema_id.h>
#include <class_library.h>
#include <libeditframe.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <wildcards_and_files_ext.h>
@ -259,13 +258,25 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
if( screen )
{
if( !IsOK( this, _( "Discard changes to the current schematic?" ) ) )
int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do "
"you wish to save the changes?" ),
wxEmptyString,
_( "Save and Load" ), _( "Load Without Saving" ) );
if( response == wxID_CANCEL )
{
return false;
}
else if( response == wxID_YES )
{
wxCommandEvent dummy;
OnSaveProject( dummy );
}
}
FullFileName = aFileName;
if( ( FullFileName.IsEmpty() ) && !aIsNew )
if( FullFileName.IsEmpty() && !aIsNew )
{
wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
wxEmptyString, SchematicFileWildcard,

View File

@ -293,7 +293,6 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent )
SCH_SHEET_LIST schematic;
wxString msg;
SCH_FIND_REPLACE_DATA searchCriteria;
bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR );
SCH_FIND_COLLECTOR_DATA data;
searchCriteria.SetFlags( aEvent.GetFlags() );
@ -326,6 +325,88 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent )
m_foundItems.UpdateIndex();
}
updateFindReplaceView( aEvent );
}
void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent )
{
SCH_ITEM* item;
SCH_SHEET_PATH* sheet;
SCH_SHEET_LIST schematic;
SCH_FIND_COLLECTOR_DATA data;
if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL )
{
while( ( item = (SCH_ITEM*) m_foundItems.GetItem( data ) ) != NULL )
{
SCH_ITEM* undoItem = data.GetParent();
// Don't save child items in undo list.
if( undoItem == NULL )
undoItem = item;
SetUndoItem( undoItem );
sheet = schematic.GetSheet( data.GetSheetPath() );
wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() );
if( m_foundItems.ReplaceItem( sheet ) )
{
OnModify();
SaveUndoItemInUndoList( undoItem );
updateFindReplaceView( aEvent );
}
m_foundItems.IncrementIndex();
if( m_foundItems.PassedEnd() )
break;
}
}
else
{
SCH_ITEM* item = (SCH_ITEM*) m_foundItems.GetItem( data );
wxCHECK_RET( item != NULL, wxT( "Invalid replace item in find collector list." ) );
SCH_ITEM* undoItem = data.GetParent();
if( undoItem == NULL )
undoItem = item;
SetUndoItem( undoItem );
sheet = schematic.GetSheet( data.GetSheetPath() );
wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() );
if( m_foundItems.ReplaceItem( sheet ) )
{
OnModify();
SaveUndoItemInUndoList( undoItem );
updateFindReplaceView( aEvent );
}
m_foundItems.IncrementIndex();
}
// End the replace if we are at the end if the list. This prevents an infinite loop if
// wrap search is selected and all of the items have been replaced with a value that
// still satisfies the search criteria.
if( m_foundItems.PassedEnd() )
aEvent.SetFlags( aEvent.GetFlags() & ~FR_REPLACE_ITEM_FOUND );
}
void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent )
{
wxString msg;
SCH_SHEET_LIST schematic;
SCH_FIND_COLLECTOR_DATA data;
bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR );
if( m_foundItems.GetItem( data ) != NULL )
{
wxLogTrace( traceFindReplace, wxT( "Found " ) + m_foundItems.GetText() );
@ -335,13 +416,15 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent )
wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) +
data.GetSheetPath() );
SCH_ITEM* item = (SCH_ITEM*)m_foundItems.GetItem( data );
// Make the item temporarily visible just in case it's hide flag is set. This
// has no effect on objects that don't support hiding. If this is a close find
// dialog event, clear the temporary visibility flag.
if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE )
m_foundItems.GetItem( data )->SetForceVisible( false );
else
m_foundItems.GetItem( data )->SetForceVisible( true );
item->SetForceVisible( false );
else if( item->Type() == SCH_FIELD_T && !( (SCH_FIELD*) item )->IsVisible() )
item->SetForceVisible( true );
if( sheet->PathHumanReadable() != m_CurrentSheet->PathHumanReadable() )
{
@ -371,61 +454,3 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent )
SetStatusText( msg );
}
void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent )
{
SCH_FIND_COLLECTOR_DATA data;
bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR );
SCH_ITEM* item = (SCH_ITEM*) m_foundItems.GetItem( data );
wxCHECK_RET( item != NULL, wxT( "Invalid replace item in find collector list." ) );
wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ),
GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ),
GetChars( m_foundItems.GetText() ) );
SCH_ITEM* undoItem = data.GetParent();
if( undoItem == NULL )
undoItem = item;
SetUndoItem( undoItem );
if( m_foundItems.ReplaceItem() )
{
OnModify();
SaveUndoItemInUndoList( undoItem );
RedrawScreen( data.GetPosition(), warpCursor );
}
OnFindSchematicItem( aEvent );
if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL )
{
while( ( item = (SCH_ITEM*) m_foundItems.GetItem( data ) ) != NULL )
{
wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ),
GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ),
GetChars( m_foundItems.GetText() ) );
SCH_ITEM* undoItem = data.GetParent();
// Don't save child items in undo list.
if( undoItem == NULL )
undoItem = item;
SetUndoItem( undoItem );
if( m_foundItems.ReplaceItem() )
{
OnModify();
SaveUndoItemInUndoList( undoItem );
RedrawScreen( data.GetPosition(), warpCursor );
}
OnFindSchematicItem( aEvent );
}
}
}

View File

@ -5,26 +5,20 @@
#ifndef _GENERAL_H_
#define _GENERAL_H_
#include <wx/string.h>
#include <wx/gdicmn.h>
#include <colors.h> // for EDA_COLOR_T
#include <block_commande.h>
#include <class_netlist_object.h>
class SCH_SHEET;
class TRANSFORM;
class SCH_SHEET;
#define EESCHEMA_VERSION 2
#define SCHEMATIC_HEAD_STRING "Schematic File Version"
#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers
#define DEFAULT_TEXT_SIZE 50 // Default size for field texts
#define DANGLING_SYMBOL_SIZE 12
#define GR_DEFAULT_DRAWMODE GR_COPY
#define DANGLING_SYMBOL_SIZE 12
// this enum is for color management
typedef enum {
LAYER_WIRE,
@ -75,8 +69,6 @@ extern int g_RepeatDeltaLabel;
/* First and main (root) screen */
extern SCH_SHEET* g_RootSheet;
extern NETLIST_OBJECT_LIST g_NetObjectslist;
/**
* Default line thickness used to draw/plot items having a
* default thickness line value (i.e. = 0 ).

View File

@ -183,9 +183,9 @@ static EDA_HOTKEY HkCopyComponentOrText( wxT( "Copy Component or Label" ),
ID_POPUP_SCH_COPY_ITEM );
static EDA_HOTKEY HkDrag( wxT( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
static EDA_HOTKEY HkSaveBlock( wxT( "Save Block" ), HK_SAVE_BLOCK, 'C' + GR_KB_CTRL );
static EDA_HOTKEY HkSaveBlock( wxT( "Save Block" ), HK_SAVE_BLOCK, 'C' + GR_KB_CTRL, wxID_COPY );
static EDA_HOTKEY HkMove2Drag( wxT( "Move Block -> Drag Block" ),
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
@ -367,18 +367,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_ZOOM_AUTO:
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
case HK_SAVE_BLOCK: // Copy block to clip board.
cmd.SetId( hotKey->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp( BLOCK_DRAG, aDC );
break;
case HK_SAVE_BLOCK:
HandleBlockEndByPopUp( BLOCK_SAVE, aDC );
break;
case HK_DELETE:
if( notBusy )
DeleteItemAtCrossHair( aDC );

View File

@ -32,6 +32,7 @@
#include <base_struct.h>
#include <transform.h>
#include <gr_basic.h>
#include <boost/ptr_container/ptr_vector.hpp>

View File

@ -43,6 +43,7 @@
#include <libeditframe.h>
#include <class_library.h>
#include <lib_polyline.h>
#include <lib_pin.h>
#include <kicad_device_context.h>
#include <hotkeys.h>
@ -350,7 +351,6 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_NO:
break;
case wxID_OK:
case wxID_YES:
if ( this->SaveActiveLibrary( false ) )
break;

View File

@ -1,9 +1,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2013 jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-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
@ -35,8 +35,8 @@
#include <appl_wxstruct.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <class_library.h>
#include <lib_pin.h>
#include <sch_component.h>
@ -44,15 +44,12 @@
#include <sch_sheet.h>
#include <wx/tokenzr.h>
#include <xnode.h> // also nests: <wx/xml/xml.h>
#include <build_version.h>
#include <set>
#define INTERMEDIATE_NETLIST_EXT wxT("xml")
#include <set>
/**
* Class UNIQUE_STRINGS
* tracks unique wxStrings and is useful in telling if a string
@ -95,6 +92,8 @@ bool UNIQUE_STRINGS::Lookup( const wxString& aString )
*/
class NETLIST_EXPORT_TOOL
{
NETLIST_OBJECT_LIST * m_masterList; /// The main connected items flat list
/// Used to temporary store and filter the list of pins of a schematic component
/// when generating schematic component data in netlist (comp section)
NETLIST_OBJECT_LIST m_SortedComponentPinList;
@ -121,7 +120,8 @@ class NETLIST_EXPORT_TOOL
* <li> "/path/netname" for the usual nets
* </ul>
*/
static void sprintPinNetName( wxString* aResult, const wxString& aNetNameFormat, NETLIST_OBJECT* aPin );
static void sprintPinNetName( wxString& aResult, const wxString& aNetNameFormat,
NETLIST_OBJECT* aPin );
/**
* Function findNextComponentAndCreatePinList
@ -186,7 +186,7 @@ class NETLIST_EXPORT_TOOL
* - 6 CA
* </p>
*/
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<XNODE> 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 $<net number>
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;

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@
#include <class_libentry.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
#include <sch_text.h>
/// 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();
}
};

View File

@ -34,7 +34,6 @@
#include <wxEeschemaStruct.h>
#include <menus_helpers.h>
#include <general.h>
#include <sch_bus_entry.h>
#include <sch_text.h>
#include <sch_marker.h>
@ -43,6 +42,7 @@
#include <sch_no_connect.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_bitmap.h>

View File

@ -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 );

View File

@ -28,7 +28,7 @@
#include <macros.h>
#include <general.h>
#include <sch_sheet_path.h>
#include <transform.h>
#include <sch_collectors.h>
#include <sch_component.h>
@ -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;
}

View File

@ -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; }
};

View File

@ -1720,7 +1720,7 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
}
void SCH_COMPONENT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
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<NETLIST_OBJECT*>& 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<NETLIST_OBJECT*>& 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 )
{

View File

@ -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_FIELD> 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,7 +391,7 @@ public:
BITMAP_DEF GetMenuImage() const { return add_component_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;

View File

@ -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 );

View File

@ -36,6 +36,7 @@
#include <plot_common.h>
#include <sch_junction.h>
#include <class_netlist_object.h>
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<NETLIST_OBJECT*>& 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;

View File

@ -31,6 +31,7 @@
#include <sch_item_struct.h>
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<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }

View File

@ -516,7 +516,7 @@ BITMAP_DEF SCH_LINE::GetMenuImage() const
}
void SCH_LINE::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
// Net list item not required for graphic lines.
@ -524,8 +524,8 @@ void SCH_LINE::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
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;

View File

@ -32,6 +32,7 @@
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
/**
* Class SCH_LINE
@ -128,7 +129,7 @@ public:
BITMAP_DEF GetMenuImage() const;
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
bool operator <( const SCH_ITEM& aItem ) const;

View File

@ -188,13 +188,13 @@ void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
}
void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
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;

View File

@ -32,6 +32,7 @@
#include <sch_item_struct.h>
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<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath );
wxPoint GetPosition() const { return m_pos; }

View File

@ -40,9 +40,8 @@
#include <wxEeschemaStruct.h>
#include <plot_common.h>
#include <general.h>
#include <protos.h>
#include <netlist.h>
#include <class_netlist_object.h>
#include <class_library.h>
#include <sch_junction.h>
#include <sch_bus_entry.h>
@ -52,6 +51,7 @@
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_text.h>
#include <lib_pin.h>
#include <boost/foreach.hpp>
@ -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;

View File

@ -37,7 +37,6 @@
#include <kicad_string.h>
#include <msgpanel.h>
#include <general.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_component.h>
@ -1073,7 +1072,7 @@ wxPoint SCH_SHEET::GetResizePosition() const
}
void SCH_SHEET::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath )
{
SCH_SHEET_PATH sheetPath = *aSheetPath;
@ -1082,8 +1081,8 @@ void SCH_SHEET::GetNetListItem( vector<NETLIST_OBJECT*>& 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;

View File

@ -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,7 +542,7 @@ public:
BITMAP_DEF GetMenuImage() const { return add_hierarchical_subsheet_xpm; }
void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
SCH_SHEET_PATH* aSheetPath );
SCH_ITEM& operator=( const SCH_ITEM& aSheet );

View File

@ -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;
}

View File

@ -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:
/**

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