Upstream merged

This commit is contained in:
Maciej Suminski 2013-04-10 15:03:35 +02:00
commit 07cd3bcb56
409 changed files with 18253 additions and 21802 deletions

View File

@ -49,21 +49,21 @@
#include <3d_draw_basic_functions.h> #include <3d_draw_basic_functions.h>
// Imported function: // Imported function:
extern void SetGLColor( int color ); extern void SetGLColor( EDA_COLOR_T color );
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits ); extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
extern void CheckGLError(); extern void CheckGLError();
/* returns true if aLayer should be displayed, false otherwise /* returns true if aLayer should be displayed, false otherwise
*/ */
static bool Is3DLayerEnabled( int aLayer ); static bool Is3DLayerEnabled( LAYER_NUM aLayer );
/* returns the Z orientation parameter 1.0 or -1.0 for aLayer /* returns the Z orientation parameter 1.0 or -1.0 for aLayer
* Z orientation is 1.0 for all layers but "back" layers: * Z orientation is 1.0 for all layers but "back" layers:
* LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK * LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK
* used to calculate the Z orientation parameter for glNormal3f * used to calculate the Z orientation parameter for glNormal3f
*/ */
static GLfloat Get3DLayer_Z_Orientation( int aLayer ); static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
void EDA_3D_CANVAS::Redraw( bool finish ) void EDA_3D_CANVAS::Redraw( bool finish )
{ {
@ -163,7 +163,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
Draw3D_Via( (SEGVIA*) track ); Draw3D_Via( (SEGVIA*) track );
else else
{ {
int layer = track->GetLayer(); LAYER_NUM layer = track->GetLayer();
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
Draw3D_Track( track ); Draw3D_Track( track );
@ -174,7 +174,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
{ {
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{ {
int layer = pcb->GetArea( ii )->GetLayer(); LAYER_NUM layer = pcb->GetArea( ii )->GetLayer();
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
Draw3D_Zone( pcb->GetArea( ii ) ); Draw3D_Zone( pcb->GetArea( ii ) );
@ -236,8 +236,8 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
*/ */
void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone ) void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
{ {
int layer = aZone->GetLayer(); LAYER_NUM layer = aZone->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
if( layer == LAST_COPPER_LAYER ) if( layer == LAST_COPPER_LAYER )
@ -326,8 +326,8 @@ void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
{ {
double zpos = 0.0; double zpos = 0.0;
int gridcolor = DARKGRAY; // Color of grid lines EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines
int gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits; double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
glNormal3f( 0.0, 0.0, 1.0 ); glNormal3f( 0.0, 0.0, 1.0 );
@ -456,8 +456,8 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack ) void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
{ {
int layer = aTrack->GetLayer(); LAYER_NUM layer = aTrack->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU(); int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
if( layer == LAST_COPPER_LAYER ) if( layer == LAST_COPPER_LAYER )
@ -475,8 +475,8 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
{ {
int layer, top_layer, bottom_layer; LAYER_NUM layer, top_layer, bottom_layer;
int color; EDA_COLOR_T color;
double biu_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits ; double biu_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits ;
int outer_radius = via->GetWidth() / 2; int outer_radius = via->GetWidth() / 2;
@ -486,7 +486,7 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
via->ReturnLayerPair( &top_layer, &bottom_layer ); via->ReturnLayerPair( &top_layer, &bottom_layer );
// Drawing horizontal thick rings: // Drawing horizontal thick rings:
for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ ) for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{ {
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
@ -530,15 +530,15 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment ) void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
{ {
int layer = segment->GetLayer(); LAYER_NUM layer = segment->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer ); int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
SetGLColor( color ); SetGLColor( color );
if( layer == EDGE_N ) if( layer == EDGE_N )
{ {
for( layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ ) for( layer = FIRST_LAYER; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{ {
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(layer); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(layer);
@ -552,7 +552,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
break; break;
case S_CIRCLE: case S_CIRCLE:
{ {
int radius = KiROUND( hypot( double(segment->GetStart().x - segment->GetEnd().x), int radius = KiROUND( hypot( double(segment->GetStart().x - segment->GetEnd().x),
double(segment->GetStart().y - segment->GetEnd().y) ) double(segment->GetStart().y - segment->GetEnd().y) )
); );
@ -624,8 +624,8 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text ) void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
{ {
int layer = text->GetLayer(); LAYER_NUM layer = text->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color ); SetGLColor( color );
s_Text3DZPos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); s_Text3DZPos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
@ -754,7 +754,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false ) if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false )
return; return;
int color = g_ColorsSettings.GetLayerColor( m_Layer ); EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( m_Layer );
SetGLColor( color ); SetGLColor( color );
// for outline shape = S_POLYGON: // for outline shape = S_POLYGON:
@ -790,7 +790,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
if( m_Layer == EDGE_N ) if( m_Layer == EDGE_N )
{ {
for( int layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ ) for( LAYER_NUM layer = FIRST_LAYER; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{ {
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer ); int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
@ -948,7 +948,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
switch( GetShape() ) switch( GetShape() )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
for( int layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ ) for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{ {
if( layer && (layer == nlmax) ) if( layer && (layer == nlmax) )
layer = LAYER_N_FRONT; layer = LAYER_N_FRONT;
@ -998,16 +998,14 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(), polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(),
holecornersBuffer.end() ); holecornersBuffer.end() );
} }
break; break;
case PAD_RECT: case PAD_RECT:
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
{ {
wxPoint coord[5]; wxPoint coord[5];
BuildPadPolygon( coord, wxSize(0,0), m_Orient ); BuildPadPolygon( coord, wxSize(0,0), m_Orient );
for( int ii = 0; ii < 4; ii ++ ) for( int ii = 0; ii < 4; ii ++ )
{ {
CPolyPt pt( coord[ii].x + shape_pos.x, coord[ii].y+ shape_pos.y ); CPolyPt pt( coord[ii].x + shape_pos.x, coord[ii].y+ shape_pos.y );
polyPadShape.push_back( pt ); polyPadShape.push_back( pt );
@ -1019,7 +1017,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(), polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(),
holecornersBuffer.end() ); holecornersBuffer.end() );
} }
break; break;
default: default:
break; break;
@ -1027,7 +1025,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
if( polyPadShape.size() ) if( polyPadShape.size() )
{ {
for( int layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ ) for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{ {
if( layer && (layer == nlmax) ) if( layer && (layer == nlmax) )
layer = LAYER_N_FRONT; layer = LAYER_N_FRONT;
@ -1061,41 +1059,41 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
} }
bool Is3DLayerEnabled( int aLayer ) bool Is3DLayerEnabled( LAYER_NUM aLayer )
{ {
int flg = -1; int flg;
// see if layer needs to be shown // see if layer needs to be shown
// check the flags // check the flags
switch (aLayer) switch (aLayer)
{ {
case DRAW_N: case DRAW_N:
flg=g_Parm_3D_Visu.FL_DRAWINGS; flg = g_Parm_3D_Visu.FL_DRAWINGS;
break; break;
case COMMENT_N: case COMMENT_N:
flg=g_Parm_3D_Visu.FL_COMMENTS; flg = g_Parm_3D_Visu.FL_COMMENTS;
break; break;
case ECO1_N: case ECO1_N:
flg=g_Parm_3D_Visu.FL_ECO1; flg = g_Parm_3D_Visu.FL_ECO1;
break; break;
case ECO2_N: case ECO2_N:
flg=g_Parm_3D_Visu.FL_ECO2; flg = g_Parm_3D_Visu.FL_ECO2;
break; break;
}
// the layer was not a layer with a flag, so show it default:
if( flg < 0 ) // the layer was not a layer with a flag, so show it
return true; return true;
}
// if the layer has a flag, return the flag // if the layer has a flag, return the flag
return g_Parm_3D_Visu.m_DrawFlags[flg]; return g_Parm_3D_Visu.m_DrawFlags[flg];
} }
GLfloat Get3DLayer_Z_Orientation( int aLayer ) GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer )
{ {
double nZ; double nZ;

View File

@ -122,10 +122,10 @@ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolys
} }
void SetGLColor( int color ) void SetGLColor( EDA_COLOR_T color )
{ {
double red, green, blue; double red, green, blue;
StructColors colordata = ColorRefs[color & MASKCOLOR]; const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
red = colordata.m_Red / 255.0; red = colordata.m_Red / 255.0;
blue = colordata.m_Blue / 255.0; blue = colordata.m_Blue / 255.0;

View File

@ -35,20 +35,35 @@
#include <3d_viewer.h> #include <3d_viewer.h>
#include <info3d_visu.h> #include <info3d_visu.h>
#include "3d_struct.h"
#include "modelparsers.h"
// Imported function: // Imported function:
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits ); extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
// separator chars
static const char* sep_chars = " \t\n\r"; S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster,
const wxString aExtension )
{
if ( aExtension == wxT( "x3d" ) )
{
return new X3D_MODEL_PARSER( aMaster );
}
else if ( aExtension == wxT( "wrl" ) )
{
return new VRML_MODEL_PARSER( aMaster );
}
else
{
return NULL;
}
}
int S3D_MASTER::ReadData() int S3D_MASTER::ReadData()
{ {
char line[1024], * text;
wxFileName fn; wxFileName fn;
wxString FullFilename; wxString FullFilename;
FILE* file;
int LineNum = 0;
if( m_Shape3DName.IsEmpty() ) if( m_Shape3DName.IsEmpty() )
{ {
@ -56,15 +71,17 @@ int S3D_MASTER::ReadData()
} }
wxString shape3DNname = m_Shape3DName; wxString shape3DNname = m_Shape3DName;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
shape3DNname.Replace( wxT("/"), wxT("\\") ); shape3DNname.Replace( wxT( "/" ), wxT( "\\" ) );
#else #else
shape3DNname.Replace( wxT("\\"), wxT("/") ); shape3DNname.Replace( wxT( "\\" ), wxT( "/" ) );
#endif #endif
if( wxFileName::FileExists( shape3DNname ) ) if( wxFileName::FileExists( shape3DNname ) )
{ {
FullFilename = shape3DNname; FullFilename = shape3DNname;
fn.Assign( FullFilename );
} }
else else
{ {
@ -79,512 +96,24 @@ int S3D_MASTER::ReadData()
} }
} }
file = wxFopen( FullFilename, wxT( "rt" ) ); wxString extension = fn.GetExt();
S3D_MODEL_PARSER* parser = S3D_MODEL_PARSER::Create( this, extension );
if( file == NULL ) if( parser )
{ {
return -1; parser->Load( FullFilename );
} delete parser;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard();
while( GetLine( file, line, &LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( stricmp( text, "DEF" ) == 0 || stricmp( text, "Group" ) == 0)
{
while( GetLine( file, line, &LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( text == NULL )
continue;
if( *text == '}' )
break;
if( stricmp( text, "children" ) == 0 )
{
ReadChildren( file, &LineNum );
}
}
}
}
fclose( file );
SetLocaleTo_Default(); // revert to the current locale
return 0;
}
int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum )
{
char line[512], * text, * command;
wxString mat_name;
S3D_MATERIAL* material = NULL;
command = strtok( NULL, sep_chars );
text = strtok( NULL, sep_chars );
mat_name = FROM_UTF8( text );
if( stricmp( command, "USE" ) == 0 )
{
for( material = m_Materials; material; material = material->Next() )
{
if( material->m_Name == mat_name )
{
material->SetMaterial();
return 1;
}
}
D( printf( "ReadMaterial error: material not found\n" ) );
return 0; return 0;
} }
else
if( stricmp( command, "DEF" ) == 0 || stricmp( command, "Material") == 0)
{ {
material = new S3D_MATERIAL( this, mat_name ); wxLogDebug( wxT( "Unknown file type <%s>" ), GetChars( extension ) );
Insert( material );
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( text == NULL )
continue;
if( text[0] == '}' )
{
material->SetMaterial();
return 0;
}
if( stricmp( text, "diffuseColor" ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.z = atof( text );
}
else if( stricmp( text, "emissiveColor" ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.z = atof( text );
}
else if( strnicmp( text, "specularColor", 13 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_SpecularColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_SpecularColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_SpecularColor.z = atof( text );
}
else if( strnicmp( text, "ambientIntensity", 16 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_AmbientIntensity = atof( text );
}
else if( strnicmp( text, "transparency", 12 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_Transparency = atof( text );
}
else if( strnicmp( text, "shininess", 9 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_Shininess = atof( text );
}
}
} }
return -1; return -1;
} }
int S3D_MASTER::ReadChildren( FILE* file, int* LineNum )
{
char line[1024], * text;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == ']' )
return 0;
if( *text == ',' )
continue;
if( stricmp( text, "Shape" ) == 0 )
{
ReadShape( file, LineNum );
}
else
{
D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return 1;
}
int S3D_MASTER::ReadShape( FILE* file, int* LineNum )
{
char line[1024], * text;
int err = 1;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == '}' )
{
err = 0;
break;
}
if( stricmp( text, "appearance" ) == 0 )
{
ReadAppearance( file, LineNum );
}
else if( stricmp( text, "geometry" ) == 0 )
{
ReadGeometry( file, LineNum );
}
else
{
D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return err;
}
int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum )
{
char line[1024], * text;
int err = 1;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == '}' )
{
err = 0; break;
}
if( stricmp( text, "material" ) == 0 )
{
ReadMaterial( file, LineNum );
}
else
{
D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return err;
}
#define BUFSIZE 2000
/**
* Function ReadCoordList
* reads 3D coordinate lists like:
* coord Coordinate { point [
* -5.24489 6.57640e-3 -9.42129e-2,
* -5.11821 6.57421e-3 0.542654,
* -3.45868 0.256565 1.32000 ] }
* or:
* normal Normal { vector [
* 0.995171 -6.08102e-6 9.81541e-2,
* 0.923880 -4.09802e-6 0.382683,
* 0.707107 -9.38186e-7 0.707107]
* }
*
* text_buffer contains the first line of this node :
* "coord Coordinate { point ["
*/
void ReadCoordsList( FILE* file, char* text_buffer, std::vector< double >& aList, int* LineNum )
{
unsigned int ii = 0, jj = 0;
char* text;
bool HasData = false;
bool StartData = false;
bool EndNode = false;
char string_num[512];
text = text_buffer;
while( !EndNode )
{
if( *text == 0 ) // Needs data !
{
text = text_buffer;
GetLine( file, text_buffer, LineNum, 512 );
}
while( !EndNode && *text )
{
switch( *text )
{
case '[':
StartData = true;
jj = 0;
string_num[jj] = 0;
break;
case '}':
EndNode = true;
break;
case ']':
case '\t':
case ' ':
case ',':
jj = 0;
if( !StartData || !HasData )
break;
aList.push_back( atof( string_num ) );
string_num[jj] = 0;
ii++;
HasData = false;
if( *text == ']' )
{
StartData = false;
}
break;
default:
if( !StartData )
break;
if( jj >= sizeof( string_num ) )
break;
string_num[jj] = *text;
jj++;
string_num[jj] = 0;
HasData = true;
break;
}
text++;
}
}
}
int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum )
{
char line[1024], buffer[1024], * text;
int err = 1;
std::vector< double > points;
std::vector< double > list;
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
while( GetLine( file, line, LineNum, 512 ) )
{
strcpy( buffer, line );
text = strtok( buffer, sep_chars );
if( *text == '}' )
{
err = 0;
break;
}
if( stricmp( text, "normalPerVertex" ) == 0 )
{
text = strtok( NULL, " ,\t\n\r" );
if( stricmp( text, "true" ) == 0 )
{
}
else
{
}
continue;
}
if( stricmp( text, "colorPerVertex" ) == 0 )
{
text = strtok( NULL, " ,\t\n\r" );
if( stricmp( text, "true" ) == 0 )
{
}
else
{
}
continue;
}
if( stricmp( text, "normal" ) == 0 )
{
ReadCoordsList( file, line, list, LineNum );
list.clear();
continue;
}
if( stricmp( text, "normalIndex" ) == 0 )
{
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
continue;
}
if( stricmp( text, "color" ) == 0 )
{
ReadCoordsList( file, line, list, LineNum );
list.clear();
continue;
}
if( stricmp( text, "solid" ) == 0 )
{
// ignore solid
continue;
}
if( stricmp( text, "colorIndex" ) == 0 )
{
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
continue;
}
if( stricmp( text, "coord" ) == 0 )
{
ReadCoordsList( file, line, points, LineNum );
}
else if( stricmp( text, "coordIndex" ) == 0 )
{
if( points.size() < 3 || points.size() % 3 != 0 )
{
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
std::vector< int > coordIndex;
std::vector< S3D_VERTEX > vertices;
while( GetLine( file, line, LineNum, 512 ) )
{
int jj;
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
jj = atoi( text );
if( jj < 0 )
{
for( jj = 0; jj < (int) coordIndex.size(); jj++ )
{
int kk = coordIndex[jj] * 3;
if( (kk < 0) || ((kk + 3) > (int)points.size()) )
{
wxLogError( wxT( "3D geometry index read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
S3D_VERTEX vertex;
vertex.x = points[kk];
vertex.y = points[kk + 1];
vertex.z = points[kk + 2];
vertices.push_back( vertex );
}
Set_Object_Coords( vertices );
Set_Object_Data( vertices, vrmlunits_to_3Dunits );
vertices.clear();
coordIndex.clear();
}
else
{
coordIndex.push_back( jj );
}
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
}
else
{
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
}
return err;
}
int STRUCT_3D_SHAPE::ReadData( FILE* file, int* LineNum ) int STRUCT_3D_SHAPE::ReadData( FILE* file, int* LineNum )
{ {
char line[512]; char line[512];

View File

@ -115,26 +115,6 @@ public:
void Copy( S3D_MASTER* pattern ); void Copy( S3D_MASTER* pattern );
int ReadData(); int ReadData();
/**
* Function ReadMaterial
* read the description of a 3D material definition in the form:
* DEF yellow material Material (
* DiffuseColor 1.00000 1.00000 0.00000e 0
* EmissiveColor 0.00000e 0 0.00000e 0 0.00000e 0
* SpecularColor 1.00000 1.00000 1.00000
* AmbientIntensity 1.00000
* Transparency 0.00000e 0
* Shininess 1.00000
*)
* Or type:
* USE yellow material
*/
int ReadMaterial( FILE* file, int* LineNum );
int ReadChildren( FILE* file, int* LineNum );
int ReadShape( FILE* file, int* LineNum );
int ReadAppearance( FILE* file, int* LineNum );
int ReadGeometry( FILE* file, int* LineNum );
void Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices ); void Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices );
#if defined(DEBUG) #if defined(DEBUG)

View File

@ -105,16 +105,16 @@ void EDA_3D_FRAME::ReCreateHToolbar()
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_MOVE3D_LEFT, wxEmptyString, KiBitmap( left_xpm ), m_HToolBar->AddTool( ID_MOVE3D_LEFT, wxEmptyString, KiBitmap( left_xpm ),
_( "Move left <-" ) ); _( "Move left" ) );
m_HToolBar->AddTool( ID_MOVE3D_RIGHT, wxEmptyString, KiBitmap( right_xpm ), m_HToolBar->AddTool( ID_MOVE3D_RIGHT, wxEmptyString, KiBitmap( right_xpm ),
_( "Move right ->" ) ); _( "Move right" ) );
m_HToolBar->AddTool( ID_MOVE3D_UP, wxEmptyString, KiBitmap( up_xpm ), m_HToolBar->AddTool( ID_MOVE3D_UP, wxEmptyString, KiBitmap( up_xpm ),
_( "Move up ^" ) ); _( "Move up" ) );
m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, KiBitmap( down_xpm ), m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, KiBitmap( down_xpm ),
_( "Move down v" ) ); _( "Move down" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ORTHO, wxEmptyString, KiBitmap( ortho_xpm ), m_HToolBar->AddTool( ID_ORTHO, wxEmptyString, KiBitmap( ortho_xpm ),

View File

@ -19,6 +19,8 @@ set(3D-VIEWER_SRCS
3d_toolbar.cpp 3d_toolbar.cpp
info3d_visu.cpp info3d_visu.cpp
trackball.cpp trackball.cpp
x3dmodelparser.cpp
vrmlmodelparser.cpp
) )
add_library(3d-viewer STATIC ${3D-VIEWER_SRCS}) add_library(3d-viewer STATIC ${3D-VIEWER_SRCS})

View File

@ -135,7 +135,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
} }
// calculate z position for each non copper layer // calculate z position for each non copper layer
for( int layer_id = FIRST_NO_COPPER_LAYER; layer_id < NB_LAYERS; layer_id++ ) for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ )
{ {
double zpos; double zpos;
#define NonCopperLayerThicknessMargin 1.1 #define NonCopperLayerThicknessMargin 1.1
@ -184,7 +184,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
default: default:
zpos = zpos_copper_front + zpos = zpos_copper_front +
(layer_id - FIRST_NO_COPPER_LAYER + 5) * (layer_id - FIRST_NON_COPPER_LAYER + 5) *
m_NonCopperLayerThickness * NonCopperLayerThicknessMargin; m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break; break;
} }

View File

@ -93,7 +93,7 @@ public:
double m_CurrentZpos; // temporary storage of current value of Z position, double m_CurrentZpos; // temporary storage of current value of Z position,
// used in some calculation // used in some calculation
private: private:
double m_LayerZcoord[LAYER_COUNT]; // Z position of each layer (normalized) double m_LayerZcoord[NB_LAYERS]; // Z position of each layer (normalized)
double m_CopperThickness; // Copper thickness (normalized) double m_CopperThickness; // Copper thickness (normalized)
double m_EpoxyThickness; // Epoxy thickness (normalized) double m_EpoxyThickness; // Epoxy thickness (normalized)
double m_NonCopperLayerThickness; // Non copper layers thickness double m_NonCopperLayerThickness; // Non copper layers thickness
@ -173,7 +173,7 @@ public: INFO3D_VISU();
*/ */
int GetLayerObjectThicknessBIU( int aLayerId) const int GetLayerObjectThicknessBIU( int aLayerId) const
{ {
return aLayerId >= FIRST_NO_COPPER_LAYER ? return aLayerId >= FIRST_NON_COPPER_LAYER ?
GetNonCopperLayerThicknessBIU() : GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU(); GetCopperThicknessBIU();
} }

192
3d-viewer/modelparsers.h Normal file
View File

@ -0,0 +1,192 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com>
* 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 modelparsers.h
*/
#ifndef MODELPARSERS_H
#define MODELPARSERS_H
#include <map>
#include <vector>
#include <wx/string.h>
class S3D_MASTER;
class S3D_VERTEX;
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
class S3D_MODEL_PARSER;
class X3D_MODEL_PARSER;
/**
* abstract class S3D_MODEL_PARSER
* Base class for 3D model parsers.
*/
class S3D_MODEL_PARSER
{
public:
S3D_MODEL_PARSER(S3D_MASTER* aMaster) :
master( aMaster )
{}
virtual ~S3D_MODEL_PARSER()
{}
S3D_MASTER* GetMaster()
{
return master;
}
/**
* Function Create
* Factory method for creating concrete 3D model parsers
* Notice that the caller is responsible to delete created parser.
*
* @param aMaster is master object that the parser will fill.
* @param aExtension is file extension of the file you are going to parse.
*/
static S3D_MODEL_PARSER* Create( S3D_MASTER* aMaster, const wxString aExtension );
/**
* Function Load
*
* Concrete parsers should implement this function
*/
virtual void Load( const wxString aFilename ) = 0;
private:
S3D_MASTER* master;
};
class wxXmlNode;
/**
* class X3D_MODEL_PARSER
* Implements parser for X3D file format (VRML2.0 successor)
* X3D files can be exported from eg. Blender */
class X3D_MODEL_PARSER: public S3D_MODEL_PARSER
{
public:
X3D_MODEL_PARSER( S3D_MASTER* aMaster );
~X3D_MODEL_PARSER();
void Load( const wxString aFilename );
typedef std::map< wxString, wxString > PROPERTY_MAP;
typedef std::vector< wxXmlNode* > NODE_LIST;
/**
* Function GetChildsByName
* Searches all child nodes with aName.
*
* @param aParent is node to search from
* @param aName is the name of node you try to find
* @param aResult contains found nodes
*/
static void GetChildsByName( wxXmlNode* aParent, const wxString aName, NODE_LIST& aResult );
/**
* Function GetNodeProperties
* Collects all node properties to map.
*
* @param aProps contains map of found properties
*/
static void GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps );
/**
* Return string representing x3d file in vrml format
* Function Load must be called before this function, otherwise empty
* data set is returned.
*/
wxString VRML_representation();
private:
std::vector< wxString > vrml_materials;
std::vector< wxString > vrml_points;
std::vector< wxString > vrml_coord_indexes;
void readTransform( wxXmlNode* aTransformNode );
void readMaterial( wxXmlNode* aMatNode );
void readIndexedFaceSet( wxXmlNode* aFaceNode, PROPERTY_MAP& aTransfromProps );
bool parseDoubleTriplet( const wxString& aData, S3D_VERTEX& aResult );
void rotate( S3D_VERTEX& aCoordinate, S3D_VERTEX& aRotAxis, double angle );
};
/**
* class WRL_MODEL_PARSER
* Parses
*/
class VRML_MODEL_PARSER: public S3D_MODEL_PARSER
{
public:
VRML_MODEL_PARSER( S3D_MASTER* aMaster );
~VRML_MODEL_PARSER();
void Load( const wxString aFilename );
private:
/**
* Function ReadMaterial
* read the description of a 3D material definition in the form:
* DEF yellow material Material (
* DiffuseColor 1.00000 1.00000 0.00000e 0
* EmissiveColor 0.00000e 0 0.00000e 0 0.00000e 0
* SpecularColor 1.00000 1.00000 1.00000
* AmbientIntensity 1.00000
* Transparency 0.00000e 0
* Shininess 1.00000
*)
* Or type:
* USE yellow material
*/
int readMaterial( FILE* file, int* LineNum );
int readChildren( FILE* file, int* LineNum );
int readShape( FILE* file, int* LineNum );
int readAppearance( FILE* file, int* LineNum );
int readGeometry( FILE* file, int* LineNum );
/**
* Function ReadCoordList
* reads 3D coordinate lists like:
* coord Coordinate { point [
* -5.24489 6.57640e-3 -9.42129e-2,
* -5.11821 6.57421e-3 0.542654,
* -3.45868 0.256565 1.32000 ] }
* or:
* normal Normal { vector [
* 0.995171 -6.08102e-6 9.81541e-2,
* 0.923880 -4.09802e-6 0.382683,
* 0.707107 -9.38186e-7 0.707107]
* }
*
* text_buffer contains the first line of this node :
* "coord Coordinate { point ["
*/
void readCoordsList( FILE* file, char* text_buffer, std::vector< double >& aList,
int* LineNum );
};
#endif // MODELPARSERS_H

View File

@ -0,0 +1,546 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com>
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 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 vrmlmodelparser.cpp
*/
#include <fctsys.h>
#include <vector>
#include <macros.h>
#include <kicad_string.h>
#include <info3d_visu.h>
#include "3d_struct.h"
#include "modelparsers.h"
// separator chars
static const char* sep_chars = " \t\n\r";
VRML_MODEL_PARSER::VRML_MODEL_PARSER( S3D_MASTER* aMaster ) :
S3D_MODEL_PARSER( aMaster )
{}
VRML_MODEL_PARSER::~VRML_MODEL_PARSER()
{}
void VRML_MODEL_PARSER::Load( const wxString aFilename )
{
char line[1024], * text;
FILE* file;
int LineNum = 0;
file = wxFopen( aFilename, wxT( "rt" ) );
if( file == NULL )
{
return;
}
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard();
while( GetLine( file, line, &LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( stricmp( text, "DEF" ) == 0 || stricmp( text, "Group" ) == 0 )
{
while( GetLine( file, line, &LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( text == NULL )
continue;
if( *text == '}' )
break;
if( stricmp( text, "children" ) == 0 )
{
readChildren( file, &LineNum );
}
}
}
}
fclose( file );
SetLocaleTo_Default(); // revert to the current locale
}
int VRML_MODEL_PARSER::readMaterial( FILE* file, int* LineNum )
{
char line[512], * text, * command;
wxString mat_name;
S3D_MATERIAL* material = NULL;
command = strtok( NULL, sep_chars );
text = strtok( NULL, sep_chars );
mat_name = FROM_UTF8( text );
if( stricmp( command, "USE" ) == 0 )
{
for( material = GetMaster()->m_Materials; material; material = material->Next() )
{
if( material->m_Name == mat_name )
{
material->SetMaterial();
return 1;
}
}
D( printf( "ReadMaterial error: material not found\n" ) );
return 0;
}
if( stricmp( command, "DEF" ) == 0 || stricmp( command, "Material") == 0)
{
material = new S3D_MATERIAL( GetMaster(), mat_name );
GetMaster()->Insert( material );
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( text == NULL )
continue;
if( text[0] == '}' )
{
material->SetMaterial();
return 0;
}
if( stricmp( text, "diffuseColor" ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_DiffuseColor.z = atof( text );
}
else if( stricmp( text, "emissiveColor" ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_EmissiveColor.z = atof( text );
}
else if( strnicmp( text, "specularColor", 13 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_SpecularColor.x = atof( text );
text = strtok( NULL, sep_chars );
material->m_SpecularColor.y = atof( text );
text = strtok( NULL, sep_chars );
material->m_SpecularColor.z = atof( text );
}
else if( strnicmp( text, "ambientIntensity", 16 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_AmbientIntensity = atof( text );
}
else if( strnicmp( text, "transparency", 12 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_Transparency = atof( text );
}
else if( strnicmp( text, "shininess", 9 ) == 0 )
{
text = strtok( NULL, sep_chars );
material->m_Shininess = atof( text );
}
}
}
return -1;
}
int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum )
{
char line[1024], * text;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == ']' )
return 0;
if( *text == ',' )
continue;
if( stricmp( text, "Shape" ) == 0 )
{
readShape( file, LineNum );
}
else
{
D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return 1;
}
int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum )
{
char line[1024], * text;
int err = 1;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == '}' )
{
err = 0;
break;
}
if( stricmp( text, "appearance" ) == 0 )
{
readAppearance( file, LineNum );
}
else if( stricmp( text, "geometry" ) == 0 )
{
readGeometry( file, LineNum );
}
else
{
D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return err;
}
int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
{
char line[1024], * text;
int err = 1;
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, sep_chars );
if( *text == '}' )
{
err = 0;
break;
}
if( stricmp( text, "material" ) == 0 )
{
readMaterial( file, LineNum );
}
else
{
D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
break;
}
}
return err;
}
#define BUFSIZE 2000
void VRML_MODEL_PARSER::readCoordsList( FILE* file, char* text_buffer,
std::vector< double >& aList, int* LineNum )
{
unsigned int ii = 0, jj = 0;
char* text;
bool HasData = false;
bool StartData = false;
bool EndNode = false;
char string_num[512];
text = text_buffer;
while( !EndNode )
{
if( *text == 0 ) // Needs data !
{
text = text_buffer;
GetLine( file, text_buffer, LineNum, 512 );
}
while( !EndNode && *text )
{
switch( *text )
{
case '[':
StartData = true;
jj = 0;
string_num[jj] = 0;
break;
case '}':
EndNode = true;
break;
case ']':
case '\t':
case ' ':
case ',':
jj = 0;
if( !StartData || !HasData )
break;
aList.push_back( atof( string_num ) );
string_num[jj] = 0;
ii++;
HasData = false;
if( *text == ']' )
{
StartData = false;
}
break;
default:
if( !StartData )
break;
if( jj >= sizeof( string_num ) )
break;
string_num[jj] = *text;
jj++;
string_num[jj] = 0;
HasData = true;
break;
}
text++;
}
}
}
int VRML_MODEL_PARSER::readGeometry( FILE* file, int* LineNum )
{
char line[1024], buffer[1024], * text;
int err = 1;
std::vector< double > points;
std::vector< double > list;
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
while( GetLine( file, line, LineNum, 512 ) )
{
strcpy( buffer, line );
text = strtok( buffer, sep_chars );
if( *text == '}' )
{
err = 0;
break;
}
if( stricmp( text, "normalPerVertex" ) == 0 )
{
text = strtok( NULL, " ,\t\n\r" );
if( stricmp( text, "true" ) == 0 )
{
}
else
{
}
continue;
}
if( stricmp( text, "colorPerVertex" ) == 0 )
{
text = strtok( NULL, " ,\t\n\r" );
if( stricmp( text, "true" ) == 0 )
{
}
else
{
}
continue;
}
if( stricmp( text, "normal" ) == 0 )
{
readCoordsList( file, line, list, LineNum );
list.clear();
continue;
}
if( stricmp( text, "normalIndex" ) == 0 )
{
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
continue;
}
if( stricmp( text, "color" ) == 0 )
{
readCoordsList( file, line, list, LineNum );
list.clear();
continue;
}
if( stricmp( text, "solid" ) == 0 )
{
// ignore solid
continue;
}
if( stricmp( text, "colorIndex" ) == 0 )
{
while( GetLine( file, line, LineNum, 512 ) )
{
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
continue;
}
if( stricmp( text, "coord" ) == 0 )
{
readCoordsList( file, line, points, LineNum );
}
else if( stricmp( text, "coordIndex" ) == 0 )
{
if( points.size() < 3 || points.size() % 3 != 0 )
{
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
std::vector< int > coordIndex;
std::vector< S3D_VERTEX > vertices;
while( GetLine( file, line, LineNum, 512 ) )
{
int jj;
text = strtok( line, " ,\t\n\r" );
while( text )
{
if( *text == ']' )
break;
jj = atoi( text );
if( jj < 0 )
{
for( jj = 0; jj < (int) coordIndex.size(); jj++ )
{
int kk = coordIndex[jj] * 3;
if( (kk < 0) || ((kk + 3) > (int)points.size()) )
{
wxLogError( wxT( "3D geometry index read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
S3D_VERTEX vertex;
vertex.x = points[kk];
vertex.y = points[kk + 1];
vertex.z = points[kk + 2];
vertices.push_back( vertex );
}
GetMaster()->Set_Object_Coords( vertices );
Set_Object_Data( vertices, vrmlunits_to_3Dunits );
vertices.clear();
coordIndex.clear();
}
else
{
coordIndex.push_back( jj );
}
text = strtok( NULL, " ,\t\n\r" );
}
if( text && (*text == ']') )
break;
}
}
else
{
wxLogError( wxT( "3D geometry read error <%s> at line %d." ),
GetChars( FROM_UTF8( text ) ), *LineNum );
err = 1;
break;
}
}
return err;
}

View File

@ -0,0 +1,491 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Tuomas Vaherkoski <tuomasvaherkoski@gmail.com>
* 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 x3dmodelparser.cpp
*/
#include <fctsys.h>
#include <macros.h>
#include <info3d_visu.h>
#include <wx/xml/xml.h>
#include <wx/tokenzr.h>
#include <wx/string.h>
#include <map>
#include <queue>
#include <vector>
#include "3d_struct.h"
#include "modelparsers.h"
X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) :
S3D_MODEL_PARSER( aMaster )
{}
X3D_MODEL_PARSER::~X3D_MODEL_PARSER()
{}
void X3D_MODEL_PARSER::Load( const wxString aFilename )
{
wxXmlDocument doc;
if( !doc.Load( aFilename ) )
{
wxLogError( wxT( "Error while parsing file <%s>" ), GetChars( aFilename ) );
return;
}
if( doc.GetRoot()->GetName() != wxT( "X3D" ) )
{
wxLogError( wxT( "Filetype is not X3D <%s>" ), GetChars( aFilename ) );
return;
}
// Shapes are inside of Transform nodes
// Transform node contains information about
// transition, scale and rotation of the shape
NODE_LIST transforms;
GetChildsByName( doc.GetRoot(), wxT( "Transform" ), transforms );
for( NODE_LIST::iterator node_it = transforms.begin();
node_it != transforms.end();
node_it++ )
{
readTransform( *node_it );
}
}
wxString X3D_MODEL_PARSER::VRML_representation()
{
wxString output;
for( unsigned i = 0; i < vrml_points.size(); i++ )
{
output += wxT( "Shape {\n"
" appearance Appearance {\n"
" material Material {\n" ) +
vrml_materials[i] +
wxT( " }\n"
" }\n"
" geometry IndexedFaceSet {\n"
" solid TRUE\n"
" coord Coordinate {\n"
" point [\n") +
vrml_points[i] +
wxT( " ]\n"
" }\n"
" coordIndex [\n" ) +
vrml_coord_indexes[i] +
wxT( " ]\n"
" }\n"
"},\n" );
}
return output;
}
void X3D_MODEL_PARSER::GetChildsByName( wxXmlNode* aParent,
const wxString aName,
std::vector< wxXmlNode* >& aResult )
{
// Breadth-first search (BFS)
std::queue< wxXmlNode* > found;
found.push( aParent );
while( !found.empty() )
{
wxXmlNode *elem = found.front();
for( wxXmlNode *child = elem->GetChildren();
child != NULL;
child = child->GetNext() )
{
if( child->GetName() == aName )
{
aResult.push_back( child );
}
found.push( child );
}
found.pop();
}
}
void X3D_MODEL_PARSER::GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps )
{
wxXmlProperty *prop;
for( prop = aNode->GetAttributes();
prop != NULL;
prop = prop->GetNext() )
{
aProps[ prop->GetName() ] = prop->GetValue();
}
}
/* Private ----- */
void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode )
{
NODE_LIST childnodes;
GetChildsByName( aTransformNode, wxT( "Material" ), childnodes );
for( NODE_LIST::iterator node = childnodes.begin();
node != childnodes.end();
node++ )
{
readMaterial( *node );
}
childnodes.clear();
PROPERTY_MAP properties;
GetNodeProperties( aTransformNode, properties );
GetChildsByName( aTransformNode, wxT("IndexedFaceSet"), childnodes );
for( NODE_LIST::iterator node = childnodes.begin();
node != childnodes.end();
node++ )
{
readIndexedFaceSet( *node, properties );
}
childnodes.clear();
}
void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
{
PROPERTY_MAP properties;
GetNodeProperties( aMatNode, properties );
// DEFine new Material named as value of DEF
if( properties.find( wxT( "DEF" ) ) != properties.end() )
{
double amb, shine, transp;
S3D_MATERIAL* material = new S3D_MATERIAL( GetMaster(), properties[ wxT( "DEF" ) ] );
GetMaster()->Insert( material );
if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ],
material->m_DiffuseColor ) )
{
D( printf("diffuseColor parsing error") );
}
if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ],
material->m_SpecularColor ) )
{
D( printf("specularColor parsing error") );
}
if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ],
material->m_EmissiveColor ) )
{
D( printf("emissiveColor parsing error") );
}
wxStringTokenizer values;
values.SetString( properties[ wxT( "ambientIntensity" ) ] );
if( values.GetNextToken().ToDouble( &amb ) )
{
material->m_AmbientIntensity = amb;
}
else
{
D( printf( "ambienterror" ) );
}
values.SetString( properties[ wxT( "shininess" ) ] );
if( values.GetNextToken().ToDouble( &shine ) )
{
material->m_Shininess = shine;
}
else
{
D( printf( "shininess error" ) );
}
values.SetString( properties[ wxT( "transparency" ) ] );
if( values.GetNextToken().ToDouble( &transp ) )
{
material->m_Transparency = transp;
}
else
{
D( printf( "trans error") );
}
material->SetMaterial();
// VRML
wxString vrml_material;
PROPERTY_MAP::const_iterator p = ++properties.begin(); // skip DEF
for(;p != properties.end();p++)
{
vrml_material.Append( p->first + wxT( " " ) + p->second + wxT( "\n" ) );
}
vrml_materials.push_back( vrml_material );
}
// USE existing material named by value of USE
else if( properties.find( wxT( "USE" ) ) != properties.end() )
{
S3D_MATERIAL* material = NULL;
wxString mat_name = properties[ wxT( "USE" ) ];
for( material = GetMaster()->m_Materials; material; material = material->Next() )
{
if( material->m_Name == mat_name )
{
wxString vrml_material;
vrml_material.Append( wxString::Format( wxT( "specularColor %f %f %f\n" ),
material->m_SpecularColor.x,
material->m_SpecularColor.y,
material->m_SpecularColor.z ) );
vrml_material.Append( wxString::Format( wxT( "diffuseColor %f %f %f\n" ),
material->m_DiffuseColor.x,
material->m_DiffuseColor.y,
material->m_DiffuseColor.z ) );
vrml_material.Append( wxString::Format( wxT( "emissiveColor %f %f %f\n" ),
material->m_EmissiveColor.x,
material->m_EmissiveColor.y,
material->m_EmissiveColor.z ) );
vrml_material.Append( wxString::Format( wxT( "ambientIntensity %f\n"),
material->m_AmbientIntensity ) );
vrml_material.Append( wxString::Format( wxT( "shininess %f\n"),
material->m_Shininess ) );
vrml_material.Append( wxString::Format( wxT( "transparency %f\n"),
material->m_Transparency ) );
vrml_materials.push_back( vrml_material );
material->SetMaterial();
return;
}
}
D( printf( "ReadMaterial error: material not found\n" ) );
}
}
bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData,
S3D_VERTEX& aResult )
{
wxStringTokenizer tokens(aData);
return tokens.GetNextToken().ToDouble( &aResult.x ) &&
tokens.GetNextToken().ToDouble( &aResult.y ) &&
tokens.GetNextToken().ToDouble( &aResult.z );
}
void X3D_MODEL_PARSER::rotate( S3D_VERTEX& aV,
S3D_VERTEX& aU,
double angle )
{
S3D_VERTEX rotated;
double C = cos( angle );
double S = sin( angle );
double t = 1.0 - C;
rotated.x = ( t * aU.x * aU.x + C ) * aV.x +
( t * aU.x * aU.y - S * aU.z ) * aV.y +
( t * aU.x * aU.z + S * aU.y ) * aV.z;
rotated.y = ( t * aU.x * aU.y + S * aU.z ) * aV.x +
( t * aU.y * aU.y + C ) * aV.y +
( t * aU.y * aU.z - S * aU.x ) * aV.z;
rotated.z = ( t * aU.x * aU.z - S * aU.y ) * aV.x +
( t * aU.y * aU.z + S * aU.x ) * aV.y +
( t * aU.z * aU.z + C) * aV.z;
aV.x = rotated.x;
aV.y = rotated.y;
aV.z = rotated.z;
}
/* Steps:
* 1. Read transform data
* 2. Read vertex triplets
* 3. Read coordinate indexes
* 4. Apply geometry to Master object
*/
void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
PROPERTY_MAP& aTransformProps)
{
/* Step 1: Read transform data
* --------------------------- */
S3D_VERTEX translation;
parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation );
S3D_VERTEX scale;
parseDoubleTriplet( aTransformProps[ wxT( "scale" ) ], scale );
S3D_VERTEX rotation;
double angle = 0.0;
wxStringTokenizer tokens(aTransformProps[ wxT( "rotation" ) ]);
if( !(tokens.GetNextToken().ToDouble( &rotation.x ) &&
tokens.GetNextToken().ToDouble( &rotation.y ) &&
tokens.GetNextToken().ToDouble( &rotation.z ) &&
tokens.GetNextToken().ToDouble( &angle ) ) )
{
D( printf("rotation read error") );
}
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits *
UNITS3D_TO_UNITSPCB;
/* Step 2: Read all coordinate points
* ---------------------------- */
std::vector< double > points;
NODE_LIST coordinates;
GetChildsByName( aFaceNode, wxT( "Coordinate" ), coordinates);
PROPERTY_MAP coordinate_properties;
// IndexedFaceSet has one Coordinate child node
GetNodeProperties( coordinates[0], coordinate_properties );
// Save points to vector as doubles
wxStringTokenizer point_tokens( coordinate_properties[ wxT("point") ] );
double point = 0.0;
while( point_tokens.HasMoreTokens() )
{
if( point_tokens.GetNextToken().ToDouble( &point ) )
{
points.push_back( point );
}
else
{
wxLogError( wxT( "Error converting to double" ) );
}
}
if( points.size() % 3 != 0 )
{
D( printf( "Number of points is incorrect" ) );
return;
}
/* Create 3D vertex from 3 points and
* apply transforms in order of SCALE, ROTATION, TRANSLATION
*/
wxString vrml_pointlist;
std::vector< S3D_VERTEX > triplets;
for( unsigned id = 0; id < points.size() / 3; id++ )
{
int triplet_indx = id * 3;
S3D_VERTEX point( points[ triplet_indx ],
points[ triplet_indx + 1 ],
points[ triplet_indx + 2 ] );
point.x *= scale.x;
point.y *= scale.y;
point.z *= scale.z;
rotate( point, rotation, angle );
point.x += translation.x;
point.y += translation.y;
point.z += translation.z;
triplets.push_back(point);
// VRML
vrml_pointlist.Append( wxString::Format( wxT( "%f %f %f\n" ), point.x, point.y, point.z ) );
}
vrml_points.push_back( vrml_pointlist );
/* -- Read coordinate indexes -- */
PROPERTY_MAP faceset_properties;
GetNodeProperties( aFaceNode, faceset_properties );
std::vector< S3D_VERTEX > vertices;
std::vector< int > coordIndex;
wxString coordIndex_str = faceset_properties[ wxT( "coordIndex" ) ];
wxStringTokenizer index_tokens( coordIndex_str );
wxString vrml_coord_indx_list;
while( index_tokens.HasMoreTokens() )
{
long index = 0;
index_tokens.GetNextToken().ToLong( &index );
// -1 marks the end of polygon
if( index < 0 )
{
/* Step 4: Apply geometry to Master object
* --------------------------------------- */
std::vector<int>::const_iterator id;
for( id = coordIndex.begin();
id != coordIndex.end();
id++ )
{
vertices.push_back( triplets.at( *id ) );
}
GetMaster()->Set_Object_Coords( vertices );
Set_Object_Data( vertices, vrmlunits_to_3Dunits );
vertices.clear();
coordIndex.clear();
vrml_coord_indx_list.Append( wxT( "-1\n" ) );
}
else
{
coordIndex.push_back( index );
vrml_coord_indx_list.Append( wxString::Format( wxT( "%u " ), index ) );
}
}
vrml_coord_indexes.push_back( vrml_coord_indx_list );
}

View File

@ -42,7 +42,7 @@ option(KICAD_STABLE_VERSION
) )
option(KICAD_TESTING_VERSION option(KICAD_TESTING_VERSION
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)" "set this option to ON to build the testing version of KICAD. mainly used to set version ID (default OFF)"
) )
option(KICAD_SCRIPTING option(KICAD_SCRIPTING

View File

@ -24,18 +24,20 @@ Contribute to KiCad (under Linux)
cd kicad_john cd kicad_john
mkdir build; cd build mkdir build; cd build
cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug
to build a debug version
or
cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release
to build a release version
make -j 4 # this is for a 4 core machine make -j 4 # this is for a 4 core machine
7) Repeat step 5 and 6 until satisfied. 7) Repeat step 5 and 6 until satisfied.
8) Delete the "build" folder and create a patch: 8) Create a patch:
cd kicad_john in kicad_john:
rm -R ./build if some files are added: bzr add [FILE...]
bzr add . bzr diff > my_changes.patch
bzr status
bzr diff > gui_better_zoom.patch
9) Send the patch file "gui_better_zoom.patch" to the KiCad developers mailing list. 9) Send the patch file "my_changes.patch" to the KiCad developers mailing list.
in the subject of the e-mail include the keyword "[PATCH]". in the subject of the e-mail include the keyword "[PATCH]".
in the body of the e-mail clearly explain what you have done. in the body of the e-mail clearly explain what you have done.

View File

@ -5,16 +5,15 @@ Documentation subfolder.
Files Files
----- -----
AUTHORS.txt - The authors, contributors, document writers and translators list AUTHORS.txt - The authors, contributors, document writers and translators list
CHANGELOG.txt - This years changelog (see for previous years Documentation/changelogs) CHANGELOG.txt - This years changelog (see for previous years Documentation/changelogs)
CMakeList.txt - CMAKE build tool script CMakeList.txt - CMAKE build tool script
COPYRIGHT.txt - A copy of the GNU General Public License Version 2 COPYRIGHT.txt - A copy of the GNU General Public License Version 2
CTestConfig.txt - Support for CTest and CDash testing tools CTestConfig.cmake - Support for CTest and CDash testing tools
Doxyfile - Doxygen preferences Doxyfile - Doxygen config file for Kicad
INSTALL.txt - The release (binairy) installation instructions INSTALL.txt - The release (binairy) installation instructions
TODO.txt - Todo list TODO.txt - Todo list
uncrustify.cfg - Uncrustify code formatting tool preferences uncrustify.cfg - Uncrustify config file for uncrustify sorces formatting tool
version.txt - The current stable released version
Subdirectories Subdirectories
-------------- --------------
@ -37,6 +36,6 @@ packaging - Files for packaging on Windows and Mac OSX
pcbnew - Sourcecode of the printed circuit board editor pcbnew - Sourcecode of the printed circuit board editor
polygon - Sourcecode of the polygon library polygon - Sourcecode of the polygon library
resources - Resources for installation, freedesktop mime-types for linux resources - Resources for installation, freedesktop mime-types for linux
scripts - Helper scripts. For building, sourcecode packaging, font setting, pcb adjusting. scripts - Helper scripts. For building, sourcecode packaging.
template - Project template(s) template - Project template(s)

View File

@ -26,13 +26,14 @@
// For some unknown reasons, polygon.hpp shoul be included first // For some unknown reasons, polygon.hpp shoul be included first
#include <boost/polygon/polygon.hpp> #include <boost/polygon/polygon.hpp>
#include <wx/wx.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include <layers_id_colors_and_visibility.h>
#include <potracelib.h> #include <potracelib.h>
#include <auxiliary.h> #include <auxiliary.h>
@ -310,8 +311,7 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon )
case PCBNEW_FMT: case PCBNEW_FMT:
{ {
#define SILKSCREEN_N_FRONT 21 LAYER_NUM layer = SILKSCREEN_N_FRONT;
int layer = SILKSCREEN_N_FRONT;
int width = 1; int width = 1;
fprintf( m_Outfile, "DP %d %d %d %d %d %d %d\n", fprintf( m_Outfile, "DP %d %d %d %d %d %d %d\n",
0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -92,6 +92,7 @@ set(COMMON_SRCS
netlist_keywords.cpp netlist_keywords.cpp
newstroke_font.cpp newstroke_font.cpp
projet_config.cpp projet_config.cpp
ptree.cpp
richio.cpp richio.cpp
selcolor.cpp selcolor.cpp
string.cpp string.cpp
@ -135,7 +136,6 @@ set(PCB_COMMON_SRCS
../pcbnew/class_marker_pcb.cpp ../pcbnew/class_marker_pcb.cpp
../pcbnew/class_mire.cpp ../pcbnew/class_mire.cpp
../pcbnew/class_module.cpp ../pcbnew/class_module.cpp
../pcbnew/class_module_transform_functions.cpp
../pcbnew/class_pad.cpp ../pcbnew/class_pad.cpp
../pcbnew/class_pad_draw_functions.cpp ../pcbnew/class_pad_draw_functions.cpp
../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.cpp

View File

@ -90,7 +90,7 @@ void EDA_ITEM::InitVars()
void EDA_ITEM::SetModified() void EDA_ITEM::SetModified()
{ {
m_Flags |= IS_CHANGED; SetFlags( IS_CHANGED );
// If this a child object, then the parent modification state also needs to be set. // If this a child object, then the parent modification state also needs to be set.
if( m_Parent ) if( m_Parent )

View File

@ -1,9 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -289,7 +289,7 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
if( !wxFileName::FileExists( fn ) ) if( !wxFileName::FileExists( fn ) )
{ {
msg = type + _( " file <" ) + fn + _( "> was not found." ); msg.Printf( wxT( "file <%s> was not found." ), GetChars( fn ) );
wxMessageBox( msg ); wxMessageBox( msg );
fileHistory->RemoveFileFromHistory( i ); fileHistory->RemoveFileFromHistory( i );
fn = wxEmptyString; fn = wxEmptyString;
@ -388,7 +388,8 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
wildcard += wxT( ".exe" ); wildcard += wxT( ".exe" );
#endif #endif
wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard; wildcard.Printf( _( "Executable file (%s)|%s" ),
GetChars( wildcard ), GetChars( wildcard ) );
wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(), wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(),
fn.GetFullName(), wildcard, fn.GetFullName(), wildcard,
@ -644,7 +645,8 @@ edits you made?" ),
// Rename the old file to the backup file name. // Rename the old file to the backup file name.
if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) ) if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{ {
msg = _( "Could not create backup file " ) + backupFileName.GetFullPath(); msg.Printf( _( "Could not create backup file <%s>" ),
GetChars( backupFileName.GetFullPath() ) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
} }

View File

@ -108,7 +108,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
break; break;
default: default:
msg = wxT( "????" ); msg = wxT( "???" );
break; break;
} }

View File

@ -36,34 +36,27 @@ static const EDA_COLOR_T default_layer_color[LAYERSCOLORSBUFFERSIZE] =
static const EDA_COLOR_T default_items_color[LAYERSCOLORSBUFFERSIZE] = static const EDA_COLOR_T default_items_color[LAYERSCOLORSBUFFERSIZE] =
{ {
LIGHTGRAY, // unused LIGHTGRAY, // unused
CYAN, // VIA_MICROVIA_VISIBLE CYAN, // VIA_MICROVIA_VISIBLE
BROWN, // VIA_BBLIND_VISIBLE BROWN, // VIA_BBLIND_VISIBLE
LIGHTGRAY, // VIA_THROUGH_VISIBLE LIGHTGRAY, // VIA_THROUGH_VISIBLE
LIGHTGRAY, // MOD_TEXT_FR_VISIBLE YELLOW, // NON_PLATED_VISIBLE
LIGHTGRAY, // MOD_TEXT_FR_VISIBLE
BLUE, // MOD_TEXT_BK_VISIBLE BLUE, // MOD_TEXT_BK_VISIBLE
DARKGRAY, // MOD_TEXT_INVISIBLE DARKGRAY, // MOD_TEXT_INVISIBLE
BLUE, // ANCHOR_VISIBLE BLUE, // ANCHOR_VISIBLE
RED, // PAD_FR_VISIBLE RED, // PAD_FR_VISIBLE
GREEN, // PAD_BK_VISIBLE GREEN, // PAD_BK_VISIBLE
LIGHTGRAY, // RATSNEST_VISIBLE LIGHTGRAY, // RATSNEST_VISIBLE
DARKGRAY, //GRID_VISIBLE DARKGRAY, // GRID_VISIBLE
LIGHTRED, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTRED, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY,
LIGHTGRAY
}; };
COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS() COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
{ {
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ ) for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
m_LayersColors[ii] = default_layer_color[ii]; m_LayersColors[ii] = default_layer_color[ii];
@ -78,7 +71,7 @@ COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS()
* @return the color for aLayer which is one of the layer indices given * @return the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic * in pcbstruct.h or in schematic
*/ */
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) const EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
{ {
if( (unsigned) aLayer < DIM(m_LayersColors) ) if( (unsigned) aLayer < DIM(m_LayersColors) )
{ {
@ -93,7 +86,7 @@ EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) const
* sets the color for aLayer which is one of the layer indices given * sets the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic * in pcbstruct.h or in schematic
*/ */
void COLORS_DESIGN_SETTINGS::SetLayerColor( int aLayer, EDA_COLOR_T aColor ) void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{ {
if( (unsigned) aLayer < DIM(m_LayersColors) ) if( (unsigned) aLayer < DIM(m_LayersColors) )
{ {

View File

@ -65,14 +65,14 @@ int LAYER_BOX_SELECTOR::GetChoice()
// Get Current Layer // Get Current Layer
int LAYER_BOX_SELECTOR::GetLayerSelection() LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const
{ {
return (long) GetClientData( GetSelection() ); return (LAYER_NUM)((unsigned long) GetClientData( GetSelection() ) );
} }
// Set Layer # // Set Layer #
int LAYER_BOX_SELECTOR::SetLayerSelection( int layer ) int LAYER_BOX_SELECTOR::SetLayerSelection( LAYER_NUM layer )
{ {
int elements = GetCount(); int elements = GetCount();
@ -97,8 +97,8 @@ int LAYER_BOX_SELECTOR::SetLayerSelection( int layer )
void LAYER_BOX_SELECTOR::ResyncBitmapOnly() void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
{ {
int elements = GetCount(); LAYER_NUM elements = GetCount();
for( int i = 0; i < elements; i++ ) for( LAYER_NUM i = FIRST_LAYER; i < elements; ++i )
{ {
wxBitmap layerbmp( 14, 14 ); wxBitmap layerbmp( 14, 14 );
SetBitmapLayer( layerbmp, i ); SetBitmapLayer( layerbmp, i );
@ -106,14 +106,14 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
} }
void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, int aLayerIndex ) void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{ {
wxMemoryDC bmpDC; wxMemoryDC bmpDC;
wxBrush brush; wxBrush brush;
// Prepare Bitmap // Prepare Bitmap
bmpDC.SelectObject( aLayerbmp ); bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayerIndex ) ) ); brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID ); brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush ); bmpDC.SetBrush( brush );

View File

@ -330,7 +330,7 @@ void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aContro
GetCustomWidthMils() * 25.4 / 1000.0, GetCustomWidthMils() * 25.4 / 1000.0,
GetCustomHeightMils() * 25.4 / 1000.0 ); GetCustomHeightMils() * 25.4 / 1000.0 );
if( IsCustom() && IsPortrait() ) if( !IsCustom() && IsPortrait() )
aFormatter->Print( 0, " portrait" ); aFormatter->Print( 0, " portrait" );
aFormatter->Print( 0, ")\n" ); aFormatter->Print( 0, ")\n" );

View File

@ -195,7 +195,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
} }
int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetFlags(); return m_ItemsList[aIdx].GetFlags();
@ -253,7 +253,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx
} }
bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx ) bool PICKED_ITEMS_LIST::SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
{ {

View File

@ -52,14 +52,9 @@ wxString g_ProductName = wxT( "KiCad E.D.A. " );
bool g_ShowPageLimits = true; bool g_ShowPageLimits = true;
wxString g_UserLibDirBuffer; wxString g_UserLibDirBuffer;
wxString g_Prj_Default_Config_FullFilename;
wxString g_Prj_Config_LocalFilename;
EDA_UNITS_T g_UserUnit; EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor; EDA_COLOR_T g_GhostColor;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
static const bool s_gost = true; static const bool s_gost = true;
#else #else
@ -77,34 +72,40 @@ bool IsGOST()
* Please: if you change a value, remember these values are carefully chosen * Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors * to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects * when displaying superimposed objects
* This list must have exactly NBCOLOR items * This list must have exactly NBCOLORS items
*/ */
StructColors ColorRefs[NBCOLOR] = const StructColors g_ColorRefs[NBCOLORS] =
{ {
{ 0, 0, 0, BLACK, wxT( "BLACK" ), DARKDARKGRAY }, { 0, 0, 0, BLACK, wxT( "Black" ), DARKDARKGRAY },
{ 192, 0, 0, BLUE, wxT( "BLUE" ), LIGHTBLUE }, { 72, 72, 72, DARKDARKGRAY, wxT( "Gray 1" ), DARKGRAY },
{ 0, 160, 0, GREEN, wxT( "GREEN" ), LIGHTGREEN }, { 132, 132, 132, DARKGRAY, wxT( "Gray 2" ), LIGHTGRAY },
{ 160, 160, 0, CYAN, wxT( "CYAN" ), LIGHTCYAN }, { 194, 194, 194, LIGHTGRAY, wxT( "Gray 3" ), WHITE },
{ 0, 0, 160, RED, wxT( "RED" ), LIGHTRED }, { 255, 255, 255, WHITE, wxT( "White" ), WHITE },
{ 160, 0, 160, MAGENTA, wxT( "MAGENTA" ), LIGHTMAGENTA }, { 194, 255, 255, LIGHTYELLOW, wxT( "L.Yellow" ), WHITE },
{ 0, 128, 128, BROWN, wxT( "BROWN" ), YELLOW }, { 72, 0, 0, DARKBLUE, wxT( "Blue 1" ), BLUE },
{ 192, 192, 192, LIGHTGRAY, wxT( "GRAY" ), WHITE }, { 0, 72, 0, DARKGREEN, wxT( "Green 1" ), GREEN },
{ 128, 128, 128, DARKGRAY, wxT( "DARKGRAY" ), LIGHTGRAY }, { 72, 72, 0, DARKCYAN, wxT( "Cyan 1" ), CYAN },
{ 255, 0, 0, LIGHTBLUE, wxT( "LIGHTBLUE" ), LIGHTBLUE }, { 0, 0, 72, DARKRED, wxT( "Red 1" ), RED },
{ 0, 255, 0, LIGHTGREEN, wxT( "LIGHTGREEN" ), LIGHTGREEN }, { 72, 0, 72, DARKMAGENTA, wxT( "Magenta 1" ), MAGENTA },
{ 255, 255, 0, LIGHTCYAN, wxT( "LIGHTCYAN" ), LIGHTCYAN }, { 0, 72, 72, DARKBROWN, wxT( "Brown 1" ), BROWN },
{ 0, 0, 255, LIGHTRED, wxT( "LIGHTRED" ), LIGHTRED }, { 132, 0, 0, BLUE, wxT( "Blue 2" ), LIGHTBLUE },
{ 255, 0, 255, LIGHTMAGENTA, wxT( "LIGHTMAGENTA" ), LIGHTMAGENTA }, { 0, 132, 0, GREEN, wxT( "Green 2" ), LIGHTGREEN },
{ 0, 255, 255, YELLOW, wxT( "YELLOW" ), YELLOW }, { 132, 132, 0, CYAN, wxT( "Cyan 2" ), LIGHTCYAN },
{ 255, 255, 255, WHITE, wxT( "WHITE" ), WHITE }, { 0, 0, 132, RED, wxT( "Red 2" ), LIGHTRED },
{ 64, 64, 64, DARKDARKGRAY, wxT( "DARKDARKGRAY" ), DARKGRAY }, { 132, 0, 132, MAGENTA, wxT( "Magenta 2" ), LIGHTMAGENTA },
{ 64, 0, 0, DARKBLUE, wxT( "DARKBLUE" ), BLUE }, { 0, 132, 132, BROWN, wxT( "Brown 2" ), YELLOW },
{ 0, 64, 0, DARKGREEN, wxT( "DARKGREEN" ), GREEN }, { 194, 0, 0, LIGHTBLUE, wxT( "Blue 3" ), PUREBLUE, },
{ 64, 64, 0, DARKCYAN, wxT( "DARKCYAN" ), CYAN }, { 0, 194, 0, LIGHTGREEN, wxT( "Green 3" ), PUREGREEN },
{ 0, 0, 80, DARKRED, wxT( "DARKRED" ), RED }, { 194, 194, 0, LIGHTCYAN, wxT( "Cyan 3" ), PURECYAN },
{ 64, 0, 64, DARKMAGENTA, wxT( "DARKMAGENTA" ), MAGENTA }, { 0, 0, 194, LIGHTRED, wxT( "Red 3" ), PURERED },
{ 0, 64, 64, DARKBROWN, wxT( "DARKBROWN" ), BROWN }, { 194, 0, 194, LIGHTMAGENTA, wxT( "Magenta 3" ), PUREMAGENTA },
{ 128, 255, 255, LIGHTYELLOW, wxT( "LIGHTYELLOW" ), LIGHTYELLOW } { 0, 194, 194, YELLOW, wxT( "Yellow 3" ), PUREYELLOW },
{ 255, 0, 0, PUREBLUE, wxT( "Blue 4" ), WHITE },
{ 0, 255, 0, PUREGREEN, wxT( "Green 4" ), WHITE },
{ 255, 255, 0, PURECYAN, wxT( "Cyan 4" ), WHITE },
{ 0, 0, 255, PURERED, wxT( "Red 4" ), WHITE },
{ 255, 0, 255, PUREMAGENTA, wxT( "Magenta 4" ), WHITE },
{ 0, 255, 255, PUREYELLOW, wxT( "Yellow 4" ), WHITE },
}; };

View File

@ -45,7 +45,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
SetDefaultLineWidth( 0 ); // No line width on DXF SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF plotMirror = false; // No mirroring on DXF
currentColor = BLACK; m_currentColor = BLACK;
} }
/** /**
@ -151,7 +151,7 @@ bool DXF_PLOTTER::StartPlot()
" 2\n" " 2\n"
"LAYER\n" "LAYER\n"
" 70\n" " 70\n"
"%d\n", NBCOLOR ); "%d\n", NBCOLORS );
/* The layer/colors palette. The acad/DXF palette is divided in 3 zones: /* The layer/colors palette. The acad/DXF palette is divided in 3 zones:
@ -159,7 +159,7 @@ bool DXF_PLOTTER::StartPlot()
- An HSV zone (10-250, 5 values x 2 saturations x 10 hues - An HSV zone (10-250, 5 values x 2 saturations x 10 hues
- Greys (251 - 255) - Greys (251 - 255)
The is *no* black... the white does it on paper, usually, and There is *no* black... the white does it on paper, usually, and
anyway it depends on the plotter configuration, since DXF colors anyway it depends on the plotter configuration, since DXF colors
are meant to be logical only (they represent *both* line color and are meant to be logical only (they represent *both* line color and
width); later version with plot styles only complicate the matter! width); later version with plot styles only complicate the matter!
@ -170,36 +170,41 @@ bool DXF_PLOTTER::StartPlot()
static const struct { static const struct {
const char *name; const char *name;
int color; int color;
} dxf_layer[NBCOLOR] = { } dxf_layer[NBCOLORS] = {
{ "BLACK", 250 }, { "BLACK", 7 }, // In DXF, color 7 is *both* white and black!
{ "BLUE", 5 }, { "GRAY1", 251 },
{ "GREEN", 3 }, { "GRAY2", 8 },
{ "CYAN", 4 }, { "GRAY3", 9 },
{ "RED", 1 }, { "WHITE", 7 },
{ "MAGENTA", 6 }, { "LYELLOW", 51 },
{ "BROWN", 54 }, { "BLUE1", 178 },
{ "LIGHTGRAY", 9 }, { "GREEN1", 98 },
{ "DARKGRAY", 8 }, { "CYAN1", 138 },
{ "LIGHTBLUE", 171 }, { "RED1", 18 },
{ "LIGHTGREEN", 91 }, { "MAGENTA1", 228 },
{ "LIGHTCYAN", 131 }, { "BROWN1", 58 },
{ "LIGHTRED", 11 }, { "BLUE2", 5 },
{ "LIGHTMAGENTA", 221 }, { "GREEN2", 3 },
{ "YELLOW", 2 }, { "CYAN2", 4 },
{ "WHITE", 7 }, { "RED2", 1 },
{ "DARKDARKGRAY", 251 }, { "MAGENTA2", 6 },
{ "DARKBLUE", 178 }, { "BROWN2", 54 },
{ "DARKGREEN", 98 }, { "BLUE3", 171 },
{ "DARKCYAN", 138 }, { "GREEN3", 91 },
{ "DARKRED", 18 }, { "CYAN3", 131 },
{ "DARKMAGENTA", 228 }, { "RED3", 11 },
{ "DARKBROWN", 58 }, { "MAGENTA3", 221 },
{ "LIGHTYELLOW", 51 }, { "YELLOW3", 2 },
{ "BLUE4", 5 },
{ "GREEN4", 3 },
{ "CYAN4", 4 },
{ "RED4", 1 },
{ "MAGENTA4", 6 },
{ "YELLOW4", 2 }
}; };
for( int i = 0; i < NBCOLOR; i++ ) for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) )
{ {
wxString cname = ColorRefs[i].m_Name;
fprintf( outputFile, fprintf( outputFile,
" 0\n" " 0\n"
"LAYER\n" "LAYER\n"
@ -254,10 +259,10 @@ void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
|| ( color == BLACK ) || ( color == BLACK )
|| ( color == WHITE ) ) || ( color == WHITE ) )
{ {
currentColor = color; m_currentColor = color;
} }
else else
currentColor = BLACK; m_currentColor = BLACK;
} }
/** /**
@ -287,7 +292,7 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int
DPOINT centre_dev = userToDeviceCoordinates( centre ); DPOINT centre_dev = userToDeviceCoordinates( centre );
if( radius > 0 ) if( radius > 0 )
{ {
wxString cname = ColorRefs[currentColor].m_Name; wxString cname( ColorGetName( m_currentColor ) );
if (!fill) if (!fill)
{ {
fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n", fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
@ -349,7 +354,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
if( penLastpos != pos && plume == 'D' ) if( penLastpos != pos && plume == 'D' )
{ {
// DXF LINE // DXF LINE
wxString cname = ColorRefs[currentColor].m_Name; wxString cname( ColorGetName( m_currentColor ) );
fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n", fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
TO_UTF8( cname ), TO_UTF8( cname ),
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y ); pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
@ -396,7 +401,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad
double radius_dev = userToDeviceSize( radius ); double radius_dev = userToDeviceSize( radius );
// Emit a DXF ARC entity // Emit a DXF ARC entity
wxString cname = ColorRefs[currentColor].m_Name; wxString cname( ColorGetName( m_currentColor ) );
fprintf( outputFile, fprintf( outputFile,
"0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n", "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
TO_UTF8( cname ), TO_UTF8( cname ),
@ -570,7 +575,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
more useful as a CAD object */ more useful as a CAD object */
DPOINT origin_dev = userToDeviceCoordinates( aPos ); DPOINT origin_dev = userToDeviceCoordinates( aPos );
SetColor( aColor ); SetColor( aColor );
wxString cname = ColorRefs[currentColor].m_Name; wxString cname( ColorGetName( m_currentColor ) );
DPOINT size_dev = userToDeviceSize( aSize ); DPOINT size_dev = userToDeviceSize( aSize );
int h_code = 0, v_code = 0; int h_code = 0, v_code = 0;
switch( aH_justify ) switch( aH_justify )

View File

@ -39,9 +39,9 @@ void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
if( colorMode ) if( colorMode )
{ {
double r = ColorRefs[color].m_Red / 255.0; double r = g_ColorRefs[color].m_Red / 255.0;
double g = ColorRefs[color].m_Green / 255.0; double g = g_ColorRefs[color].m_Green / 255.0;
double b = ColorRefs[color].m_Blue / 255.0; double b = g_ColorRefs[color].m_Blue / 255.0;
if( negativeMode ) if( negativeMode )
emitSetRGBColor( 1 - r, 1 - g, 1 - b ); emitSetRGBColor( 1 - r, 1 - g, 1 - b );
else else

View File

@ -59,17 +59,16 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
int iusPerMil = plotter->GetIUsPerDecimil() * 10; int iusPerMil = plotter->GetIUsPerDecimil() * 10;
wxSize pageSize = aPageInfo.GetSizeMils(); // in mils wxSize pageSize = aPageInfo.GetSizeMils(); // in mils
int xg, yg; int xg, yg;
wxPoint pos, ref;
#if defined( KICAD_GOST )
int refx, refy;
#endif
wxPoint pos, end, ref;
wxString msg; wxString msg;
wxSize text_size; wxSize text_size;
#if defined(KICAD_GOST)
wxSize text_size2;
wxSize text_size3;
wxSize text_size1_5;
#else
int UpperLimit = VARIABLE_BLOCK_START_POSITION; int UpperLimit = VARIABLE_BLOCK_START_POSITION;
#endif
EDA_COLOR_T plotClr; EDA_COLOR_T plotClr;
plotClr = plotter->GetColorMode() ? RED : BLACK; plotClr = plotter->GetColorMode() ? RED : BLACK;
@ -84,6 +83,19 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() ) * iusPerMil; yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() ) * iusPerMil;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
int lnMsg, ln;
text_size.x = SIZETEXT * iusPerMil;
text_size.y = SIZETEXT * iusPerMil;
wxSize sz;
wxSize text_size0_8( SIZETEXT * iusPerMil * 0.8, SIZETEXT * iusPerMil * 1 );
wxSize text_size1_5( SIZETEXT * iusPerMil * 1.5, SIZETEXT * iusPerMil * 1.5 );
wxSize text_size2( SIZETEXT * iusPerMil * 2, SIZETEXT * iusPerMil * 2 );
wxSize text_size3( SIZETEXT * iusPerMil * 3, SIZETEXT * iusPerMil * 3 );
int lineOsn_widht = plotter->GetCurrentLineWidth() * 2;
int lineTonk_widht = plotter->GetCurrentLineWidth();
plotter->SetCurrentLineWidth( lineOsn_widht );
plotter->MoveTo( ref ); plotter->MoveTo( ref );
pos.x = xg; pos.x = xg;
pos.y = ref.y; pos.y = ref.y;
@ -95,6 +107,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
pos.y = yg; pos.y = yg;
plotter->LineTo( pos ); plotter->LineTo( pos );
plotter->FinishTo( ref ); plotter->FinishTo( ref );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
#else #else
@ -125,9 +138,6 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
#endif #endif
text_size.x = WSTEXTSIZE * iusPerMil;
text_size.y = WSTEXTSIZE * iusPerMil;
// upper left corner in mils // upper left corner in mils
ref.x = aPageInfo.GetLeftMarginMils(); ref.x = aPageInfo.GetLeftMarginMils();
ref.y = aPageInfo.GetTopMarginMils(); ref.y = aPageInfo.GetTopMarginMils();
@ -137,56 +147,516 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() ); yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() );
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU;
// Lower right corner
refx = xg;
refy = yg;
// First page
if( aSheetNumber == 1 )
{
for( Ki_WorkSheetData* WsItem = &WS_Osn1_Line1;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (refx - WsItem->m_Posx) * iusPerMil;
pos.y = (refy - WsItem->m_Posy) * iusPerMil;
end.x = (refx - WsItem->m_Endx) * iusPerMil;
end.y = (refy - WsItem->m_Endy) * iusPerMil;
msg = WsItem->m_Legende;
switch( WsItem->m_Type )
{
case WS_OSN:
plotter->SetCurrentLineWidth( lineOsn_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TONK:
plotter->SetCurrentLineWidth( lineTonk_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TEXT:
if( !msg.IsEmpty() )
{
if( WsItem == &WS_Osn1_Text1 )
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size0_8,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
else
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_TEXTL:
if( !msg.IsEmpty() )
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
}
}
// Sheet number
if( aNumberOfSheets > 1 )
{
pos.x = (refx - Mm2mils( 36 )) * iusPerMil;
pos.y = (refy - Mm2mils( 17.5 )) * iusPerMil;
msg.Empty();
msg << aSheetNumber;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
// Count of sheets
pos.x = (refx - Mm2mils( 10 )) * iusPerMil;
pos.y = (refy - Mm2mils( 17.5 )) * iusPerMil;
msg.Empty();
msg << aNumberOfSheets;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
// Company name
msg = aTitleBlock.GetCompany();
if( !msg.IsEmpty() )
{
sz = text_size1_5;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 49 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 25 )) * iusPerMil;
pos.y = (refy - Mm2mils( 7.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
// Title
msg = aTitleBlock.GetTitle();
if( !msg.IsEmpty() )
{
sz = text_size1_5;
wxArrayString lines;
int titleWidth = 0;
int titleHeight = (sz.y + sz.y * 0.5) / iusPerMil;
int titleFieldWidth = Mm2mils( 69 );
int titleFieldHeight = Mm2mils( 24 );
int index = 0;
wxString fullMsg = msg;
do // Reduce the height of wrapped title until the fit
{
do // Wrap the title
{
titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
if( titleWidth > titleFieldWidth )
{
index = 0;
do
{
msg = msg.Left( msg.Length() - 1 );
if( msg.Length() == 0 )
{
lines.Clear();
msg = fullMsg;
sz.x -= iusPerMil;
break;
}
else
{
index++;
titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
wxString ch = wxString( msg.Last() );
if( titleWidth < titleFieldWidth && ch == wxT( " " ) )
{
// New sentence on a new line
int dot = msg.Index( wxT( ". " ) );
if( dot != wxNOT_FOUND )
{
index += msg.Length() - dot - 2;
msg = msg.Left( dot + 1 );
lines.Add( msg );
msg = fullMsg.Right( index );
break;
}
else
{
msg = msg.Left( msg.Length() - 1 );
lines.Add( msg );
msg = fullMsg.Right( index );
break;
}
}
}
}while( 1 );
}
else
{
// New sentence on a new line
int dot = msg.Index( wxT( ". " ) );
if( dot != wxNOT_FOUND )
{
lines.Add( msg.Left( dot + 1 ) );
lines.Add( fullMsg.Right( msg.Length() - dot - 2 ) );
}
else
lines.Add( msg );
break;
}
}while( 1 );
if( titleFieldHeight < titleHeight * lines.Count() )
{
sz.y -= iusPerMil;
sz.x -= iusPerMil;
msg = fullMsg;
lines.Clear();
}
else
break;
}while( 1 );
pos.x = (refx - Mm2mils( 85 )) * iusPerMil;
pos.y = (refy - Mm2mils( 27.5 ) - (titleHeight * (lines.Count() - 1) / 2)) * iusPerMil;
for( int curLn = 0; curLn < lines.Count(); curLn++ )
{
msg = lines[curLn];
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
pos.y += titleHeight * iusPerMil;
}
}
// Decimal number
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
sz = text_size3;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 119 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 60 )) * iusPerMil;
pos.y = (refy - Mm2mils( 47.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
// Developer
msg = aTitleBlock.GetComment2();
if( !msg.IsEmpty() )
{
sz = text_size;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 22 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 167.5 )) * iusPerMil;
pos.y = (refy - Mm2mils( 27.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
// Verifier
msg = aTitleBlock.GetComment3();
if( !msg.IsEmpty() )
{
sz = text_size;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 22 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 167.5 )) * iusPerMil;
pos.y = (refy - Mm2mils( 22.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
// Approver
msg = aTitleBlock.GetComment4();
if( !msg.IsEmpty() )
{
sz = text_size;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 22 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 167.5 )) * iusPerMil;
pos.y = (refy - Mm2mils( 2.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
}
else // other pages
{
for( Ki_WorkSheetData* WsItem = &WS_Osn2a_Line1;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = (refx - WsItem->m_Posx) * iusPerMil;
pos.y = (refy - WsItem->m_Posy) * iusPerMil;
end.x = (refx - WsItem->m_Endx) * iusPerMil;
end.y = (refy - WsItem->m_Endy) * iusPerMil;
msg = WsItem->m_Legende;
switch( WsItem->m_Type )
{
case WS_OSN:
plotter->SetCurrentLineWidth( lineOsn_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TONK:
plotter->SetCurrentLineWidth( lineTonk_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TEXT:
if( !msg.IsEmpty() )
{
if( WsItem == &WS_Osn2a_Text1 )
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size0_8,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
else
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_TEXTL:
if( !msg.IsEmpty() )
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
}
}
// Sheet number
pos.x = (refx - Mm2mils( 5 )) * iusPerMil;
pos.y = (refy - Mm2mils( 4 )) * iusPerMil;
msg.Empty();
msg << aSheetNumber;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
// Decimal number
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
sz = text_size3;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 109 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 65 )) * iusPerMil;
pos.y = (refy - Mm2mils( 7.5 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
}
// Format
pos.x = (refx - Mm2mils( 23 )) * iusPerMil;
pos.y = (refy + Mm2mils( 2.5 )) * iusPerMil;
msg.Empty();
msg << aPageInfo.GetType();
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
// Lower left corner
refx = ref.x;
refy = yg;
for( Ki_WorkSheetData* WsItem = &WS_DopLeft_Line1;
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil; if( aSheetNumber > 1 && WsItem == &WS_DopLeft_Line9 ) // Some fields for first page only
pos.y = ( yg - WsItem->m_Posy ) * iusPerMil; break;
msg.Empty();
pos.x = (refx - WsItem->m_Posx) * iusPerMil;
pos.y = (refy - WsItem->m_Posy) * iusPerMil;
end.x = (refx - WsItem->m_Endx) * iusPerMil;
end.y = (refy - WsItem->m_Endy) * iusPerMil;
msg = WsItem->m_Legende;
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_CADRE: case WS_OSN:
break; plotter->SetCurrentLineWidth( lineOsn_widht );
case WS_PODPIS_LU:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_VERT, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_SEGMENT_LU:
plotter->MoveTo( pos ); plotter->MoveTo( pos );
pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil; plotter->FinishTo( end );
pos.y = ( yg - WsItem->m_Endy ) * iusPerMil; plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
plotter->FinishTo( pos ); break;
case WS_TONK:
plotter->SetCurrentLineWidth( lineTonk_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TEXT:
if( !msg.IsEmpty() )
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_VERT, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
} }
} }
for( Ki_WorkSheetData* WsItem = &WS_Segm1_LT; if( aPageInfo.GetType() == PAGE_INFO::A4 || !aPageInfo.IsPortrait() ) // A4 or Landscape
WsItem != NULL;
WsItem = WsItem->Pnext )
{ {
pos.x = ( ref.x + WsItem->m_Posx ) * iusPerMil; // Left Top corner
pos.y = ( ref.y + WsItem->m_Posy ) * iusPerMil; refx = ref.x;
msg.Empty(); refy = ref.y;
switch( WsItem->m_Type ) for( Ki_WorkSheetData* WsItem = &WS_DopTop_Line1;
WsItem != NULL;
WsItem = WsItem->Pnext )
{ {
case WS_SEGMENT_LT: if( aSheetNumber > 1 && WsItem == &WS_DopTop_Line3 )// Some fields for first page only
plotter->MoveTo( pos ); break;
pos.x = ( ref.x + WsItem->m_Endx ) * iusPerMil;
pos.y = ( ref.y + WsItem->m_Endy ) * iusPerMil; pos.x = (refx + WsItem->m_Posx) * iusPerMil;
plotter->FinishTo( pos ); pos.y = (refy + WsItem->m_Posy) * iusPerMil;
break; end.x = (refx + WsItem->m_Endx) * iusPerMil;
end.y = (refy + WsItem->m_Endy) * iusPerMil;
msg = WsItem->m_Legende;
switch( WsItem->m_Type )
{
case WS_OSN:
plotter->SetCurrentLineWidth( lineOsn_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TONK:
plotter->SetCurrentLineWidth( lineTonk_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
}
}
// Decimal number
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
sz = text_size2;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 69 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx + Mm2mils( 35 )) * iusPerMil;
pos.y = (refy + Mm2mils( 7 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, 1800, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
}
else // Portrait
{
// Right Top corner
// Lines are used from the upper left corner by the change of coordinates
refx = xg;
refy = ref.y;
for( Ki_WorkSheetData* WsItem = &WS_DopTop_Line1;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
if( aSheetNumber > 1 && WsItem == &WS_DopTop_Line3 )// Some fields for first page only
break;
pos.x = (refx - WsItem->m_Posy) * iusPerMil;
pos.y = (refy + WsItem->m_Posx) * iusPerMil;
end.x = (refx - WsItem->m_Endy) * iusPerMil;
end.y = (refy + WsItem->m_Endx) * iusPerMil;
msg = WsItem->m_Legende;
switch( WsItem->m_Type )
{
case WS_OSN:
plotter->SetCurrentLineWidth( lineOsn_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
case WS_TONK:
plotter->SetCurrentLineWidth( lineTonk_widht );
plotter->MoveTo( pos );
plotter->FinishTo( end );
plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
break;
}
}
// Decimal number
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
sz = text_size2;
lnMsg = ReturnGraphicTextWidth( msg, sz.x, false, false ) / iusPerMil;
ln = Mm2mils( 69 );
if( lnMsg > ln )
sz.x *= float( ln ) / lnMsg;
pos.x = (refx - Mm2mils( 7 )) * iusPerMil;
pos.y = (refy + Mm2mils( 35 )) * iusPerMil;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_VERT, sz,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
} }
#else #else
text_size.x = WSTEXTSIZE * iusPerMil;
text_size.y = WSTEXTSIZE * iusPerMil;
// Plot legend along the X axis. // Plot legend along the X axis.
int ipas = ( xg - ref.x ) / PAS_REF; int ipas = ( xg - ref.x ) / PAS_REF;
int gxpas = ( xg - ref.x ) / ipas; int gxpas = ( xg - ref.x ) / ipas;
@ -271,220 +741,10 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
PLOTTER::DEFAULT_LINE_WIDTH, false, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
#endif
// Plot the worksheet. // Plot the worksheet.
text_size.x = SIZETEXT * iusPerMil; text_size.x = SIZETEXT * iusPerMil;
text_size.y = SIZETEXT * iusPerMil; text_size.y = SIZETEXT * iusPerMil;
#if defined(KICAD_GOST)
text_size2.x = SIZETEXT * iusPerMil * 2;
text_size2.y = SIZETEXT * iusPerMil * 2;
text_size3.x = SIZETEXT * iusPerMil * 3;
text_size3.y = SIZETEXT * iusPerMil * 3;
text_size1_5.x = SIZETEXT * iusPerMil * 1.5;
text_size1_5.y = SIZETEXT * iusPerMil * 1.5;
ref.x = pageSize.x - aPageInfo.GetRightMarginMils();
ref.y = pageSize.y - aPageInfo.GetBottomMarginMils();
if( aSheetNumber == 1 )
{
for( Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
msg.Empty();
switch( WsItem->m_Type )
{
case WS_DATE:
break;
case WS_REV:
break;
case WS_KICAD_VERSION:
break;
case WS_PODPIS:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_SIZESHEET:
break;
case WS_IDENTSHEET:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
if( aNumberOfSheets > 1 )
msg << aSheetNumber;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_SHEETS:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg << aNumberOfSheets;
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_COMPANY_NAME:
msg = aTitleBlock.GetCompany();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size1_5,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_TITLE:
msg = aTitleBlock.GetTitle();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size1_5,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_COMMENT1:
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
pos.x = (aPageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
pos.y = (aPageInfo.GetTopMarginMils() + 270) * iusPerMil;
plotter->Text( pos, plotClr,
msg.GetData(), 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_COMMENT2:
msg = aTitleBlock.GetComment2();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_COMMENT3:
msg = aTitleBlock.GetComment3();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_COMMENT4:
msg = aTitleBlock.GetComment4();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_UPPER_SEGMENT:
case WS_LEFT_SEGMENT:
case WS_SEGMENT:
plotter->MoveTo( pos );
pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
pos.y = ( ref.y - WsItem->m_Endy ) * iusPerMil;
plotter->FinishTo( pos );
break;
}
}
}
else
{
for( Ki_WorkSheetData* WsItem = &WS_CADRE_D;
WsItem != NULL;
WsItem = WsItem->Pnext )
{
pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
msg.Empty();
switch( WsItem->m_Type )
{
case WS_CADRE:
// Begin list number > 1
msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() )
{
plotter->Text( pos, plotClr,
msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
pos.x = (aPageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
pos.y = (aPageInfo.GetTopMarginMils() + 270) * iusPerMil;
plotter->Text( pos, plotClr,
msg, 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
}
break;
case WS_PODPIS_D:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
plotter->Text( pos, plotClr, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_IDENTSHEET_D:
if( WsItem->m_Legende )
msg = WsItem->m_Legende;
msg << aSheetNumber;
plotter->Text( pos, plotClr, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break;
case WS_LEFT_SEGMENT_D:
case WS_SEGMENT_D:
plotter->MoveTo( pos );
pos.x = ( ref.x - WsItem->m_Endx ) * iusPerMil;
pos.y = ( ref.y - WsItem->m_Endy ) * iusPerMil;
plotter->FinishTo( pos );
break;
}
}
}
#else
ref.x = pageSize.x - GRID_REF_W - aPageInfo.GetRightMarginMils(); ref.x = pageSize.x - GRID_REF_W - aPageInfo.GetRightMarginMils();
ref.y = pageSize.y - GRID_REF_W - aPageInfo.GetBottomMarginMils(); ref.y = pageSize.y - GRID_REF_W - aPageInfo.GetBottomMarginMils();
@ -603,4 +863,5 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
} }
#endif #endif
} }

View File

@ -1,6 +1,6 @@
/* /**
* @file confirm.cpp * @file confirm.cpp
* utilities to display some error, warning and info short messges * @brief utilities to display some error, warning and info short messges
*/ */
#include <fctsys.h> #include <fctsys.h>

View File

@ -109,8 +109,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
dc.SetClippingRegion( DrawArea ); dc.SetClippingRegion( DrawArea );
} }
const int maskLayer = 0xFFFFFFFF; aFrame->PrintPage( &dc, FULL_LAYERS, false );
aFrame->PrintPage( &dc, maskLayer, false );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
aFrame->GetCanvas()->SetClipBox( tmp ); aFrame->GetCanvas()->SetClipBox( tmp );
wxMetafile* mf = dc.Close(); wxMetafile* mf = dc.Close();

View File

@ -63,9 +63,9 @@ const wxString pageFmts[] =
_("C 17x22in"), _("C 17x22in"),
_("D 22x34in"), _("D 22x34in"),
_("E 34x44in"), _("E 34x44in"),
_("USLetter 8.5x11in"), _("US Letter 8.5x11in"),
_("USLegal 8.5x14in"), _("US Legal 8.5x14in"),
_("USLedger 11x17in"), _("US Ledger 11x17in"),
_("User (Custom)"), _("User (Custom)"),
wxT("") // end of list wxT("") // end of list
}; };
@ -609,12 +609,20 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
wxPoint pointLeftTop( pageDUMMY.GetLeftMarginMils(), pageDUMMY.GetTopMarginMils() ); wxPoint pointLeftTop( pageDUMMY.GetLeftMarginMils(), pageDUMMY.GetTopMarginMils() );
wxPoint pointRightBottom( pageDUMMY.GetRightMarginMils(), pageDUMMY.GetBottomMarginMils() ); wxPoint pointRightBottom( pageDUMMY.GetRightMarginMils(), pageDUMMY.GetBottomMarginMils() );
// Get page type
int idx = m_paperSizeComboBox->GetSelection();
if( idx < 0 )
idx = 0;
wxString paperType = m_pageFmt[idx].Left( m_pageFmt[idx].Index( wxT( " " ) ) );
// Draw layout preview. // Draw layout preview.
wxString emptyString; wxString emptyString;
GRResetPenAndBrush( ( wxDC* ) &memDC ); GRResetPenAndBrush( ( wxDC* ) &memDC );
m_Parent->TraceWorkSheet( (wxDC*) &memDC, dummySize, pointLeftTop, pointRightBottom, m_Parent->TraceWorkSheet( (wxDC*) &memDC, dummySize, pointLeftTop, pointRightBottom,
emptyString, emptyString, m_tb, m_Screen->m_NumberOfScreens, paperType, emptyString, m_tb, m_Screen->m_NumberOfScreens,
m_Screen->m_ScreenNumber, 1, appScale, LIGHTGRAY, RED ); m_Screen->m_ScreenNumber, 1, appScale, LIGHTGRAY, RED );
memDC.SelectObject( wxNullBitmap ); memDC.SelectObject( wxNullBitmap );

View File

@ -166,9 +166,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ), m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
wxSize( m_FrameSize.x, m_MsgFrameHeight ) ); wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
m_messagePanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red, m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
ColorRefs[LIGHTGRAY].m_Green,
ColorRefs[LIGHTGRAY].m_Blue ) );
} }
@ -324,7 +322,7 @@ void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
} }
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, bool aPrintMirrorMode, void* aData ) void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData )
{ {
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
} }

View File

@ -40,16 +40,18 @@
#include <class_base_screen.h> #include <class_base_screen.h>
#define EDA_DRAWBASE
#include <newstroke_font.h> #include <newstroke_font.h>
#include <plot_common.h> #include <plot_common.h>
/* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name) /* factor used to calculate actual size of shapes from hershey fonts
* Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter * (could be adjusted depending on the font name)
* Of course some shapes can be bigger or smaller than the vertical char size parameter * Its value is choosen in order to have letters like M, P .. vertical size
* equal to the vertical char size parameter
* Of course some shapes can be bigger or smaller than the vertical char size
* parameter
*/ */
#define HERSHEY_SCALE_FACTOR 1 / 21.0 #define HERSHEY_SCALE_FACTOR 1 / 21.0
double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR; double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR;
/* Helper function for texts with over bar /* Helper function for texts with over bar
@ -59,6 +61,7 @@ int OverbarPositionY( int size_v, int thickness )
return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) ); return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) );
} }
/** /**
* Function GetPensizeForBold * Function GetPensizeForBold
* @return the "best" value for a pen size to draw/plot a bold text * @return the "best" value for a pen size to draw/plot a bold text
@ -84,12 +87,13 @@ int GetPenSizeForBold( int aTextSize )
*/ */
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold ) int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
{ {
int penSize = aPenSize; int penSize = aPenSize;
double scale = aBold ? 4.0 : 6.0; double scale = aBold ? 4.0 : 6.0;
int maxWidth = KiROUND( std::abs( aSize ) / scale ); int maxWidth = KiROUND( std::abs( aSize ) / scale );
if( penSize > maxWidth ) if( penSize > maxWidth )
penSize = maxWidth; penSize = maxWidth;
return penSize; return penSize;
} }
@ -112,17 +116,23 @@ int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold )
/** /**
* Function NegableTextLength * Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */ * Return the text length (char count) of a negable string,
* excluding the ~ markers
*/
int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText )
{ {
int char_count = aText.length(); int char_count = aText.length();
/* Fix the character count, removing the ~ found */ // Fix the character count, removing the ~ found
for( int i = char_count - 1; i >= 0; i-- ) for( int i = char_count - 1; i >= 0; i-- )
{ {
if( aText[i] == '~' ) if( aText[i] == '~' )
{ {
char_count--; // '~~' draw as '~' and count as two chars
if( i > 0 && aText[i - 1] == '~' )
i--;
else
char_count--;
} }
} }
@ -138,13 +148,15 @@ int NegableTextLength( const wxString& aText )
*/ */
static const char* GetHersheyShapeDescription( int AsciiCode ) static const char* GetHersheyShapeDescription( int AsciiCode )
{ {
/* calculate font length */ // calculate font length
int font_length_max = newstroke_font_bufsize; int font_length_max = newstroke_font_bufsize;
if( AsciiCode >= (32 + font_length_max) ) if( AsciiCode >= (32 + font_length_max) )
AsciiCode = '?'; AsciiCode = '?';
if( AsciiCode < 32 ) if( AsciiCode < 32 )
AsciiCode = 32; /* Clamp control chars */ AsciiCode = 32; /* Clamp control chars */
AsciiCode -= 32; AsciiCode -= 32;
return newstroke_font[AsciiCode]; return newstroke_font[AsciiCode];
@ -158,44 +170,50 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, boo
for( int i = 0; i < char_count; i++ ) for( int i = 0; i < char_count; i++ )
{ {
int AsciiCode = aText[i]; int asciiCode = aText[i];
if( AsciiCode == '~' ) /* Skip the negation marks */ /* Skip the negation marks
* and first '~' char of '~~'
* ('~~' draw as '~')
*/
if( asciiCode == '~' )
{ {
continue; if( i == 0 || aText[i - 1] != '~' )
continue;
} }
const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* shape_ptr = GetHersheyShapeDescription( asciiCode );
/* Get metrics */ // Get metrics
int xsta = *ptcar++ - 'R'; int xsta = *shape_ptr++ - 'R';
int xsto = *ptcar++ - 'R'; int xsto = *shape_ptr++ - 'R';
tally += KiROUND( aXSize * (xsto - xsta) * s_HerscheyScaleFactor ); tally += KiROUND( aXSize * (xsto - xsta) * s_HersheyScaleFactor );
} }
/* Italic correction, 1/8em */ // For italic correction, add 1/8 size
if( aItalic ) if( aItalic )
{ {
tally += KiROUND( aXSize * 0.125 ); tally += KiROUND( aXSize * 0.125 );
} }
return tally; return tally;
} }
/* Helper function for drawing character polygons */ // Helper function for drawing character polylines
static void DrawGraphicTextPline( static void DrawGraphicTextPline( EDA_RECT* aClipBox,
EDA_RECT* aClipBox, wxDC* aDC,
wxDC* aDC, EDA_COLOR_T aColor,
EDA_COLOR_T aColor, int aWidth,
int aWidth, bool aSketchMode,
bool aSketchMode, int point_count,
int point_count, wxPoint* coord,
wxPoint* coord, void (* aCallback)( int x0, int y0, int xf, int yf ),
void (* aCallback)(int x0, int y0, int xf, int yf ), PLOTTER* aPlotter )
PLOTTER* aPlotter )
{ {
if( aPlotter ) if( aPlotter )
{ {
aPlotter->MoveTo( coord[0] ); aPlotter->MoveTo( coord[0] );
for( int ik = 1; ik < point_count; ik++ ) for( int ik = 1; ik < point_count; ik++ )
{ {
aPlotter->LineTo( coord[ik] ); aPlotter->LineTo( coord[ik] );
@ -260,26 +278,26 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
void (* aCallback)( int x0, int y0, int xf, int yf ), void (* aCallback)( int x0, int y0, int xf, int yf ),
PLOTTER* aPlotter ) PLOTTER* aPlotter )
{ {
int AsciiCode; int AsciiCode;
int x0, y0; int x0, y0;
int size_h, size_v; int size_h, size_v;
unsigned ptr; unsigned ptr;
int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
wxPoint current_char_pos; // Draw coordinates for the current char wxPoint current_char_pos; // Draw coordinates for the current char
wxPoint overbar_pos; // Start point for the current overbar wxPoint overbar_pos; // Start point for the current overbar
int overbar_italic_comp; // Italic compensation for overbar int overbar_italic_comp; // Italic compensation for overbar
EDA_RECT* clipBox; // Clip box used in basic draw functions EDA_RECT* clipBox; // Clip box used in basic draw functions
clipBox = aPanel ? aPanel->GetClipBox() : NULL; clipBox = aPanel ? aPanel->GetClipBox() : NULL;
#define BUF_SIZE 100 #define BUF_SIZE 100
wxPoint coord[BUF_SIZE + 1]; // Buffer coordinate used to draw polylines (one char shape) wxPoint coord[BUF_SIZE + 1]; // Buffer coordinate used to draw polylines (one char shape)
bool sketch_mode = false; bool sketch_mode = false;
bool italic_reverse = false; // true for mirrored texts with m_Size.x < 0 bool italic_reverse = false; // true for mirrored texts with m_Size.x < 0
size_h = aSize.x; /* PLEASE NOTE: H is for HORIZONTAL not for HEIGHT */ size_h = aSize.x; /* PLEASE NOTE: H is for HORIZONTAL not for HEIGHT */
size_v = aSize.y; size_v = aSize.y;
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0 if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
if( aWidth < 0 ) if( aWidth < 0 )
@ -292,17 +310,18 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
aWidth = Clamp_Text_PenSize( aWidth, aSize, aBold ); aWidth = Clamp_Text_PenSize( aWidth, aSize, aBold );
#endif #endif
if( size_h < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis) if( size_h < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis)
italic_reverse = true; italic_reverse = true;
unsigned char_count = NegableTextLength( aText ); unsigned char_count = NegableTextLength( aText );
if( char_count == 0 ) if( char_count == 0 )
return; return;
current_char_pos = aPos; current_char_pos = aPos;
dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aWidth ); dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aWidth );
dy = size_v; dy = size_v;
/* Do not draw the text if out of draw area! */ /* Do not draw the text if out of draw area! */
if( aPanel ) if( aPanel )
@ -310,20 +329,23 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
int xm, ym, ll, xc, yc; int xm, ym, ll, xc, yc;
ll = std::abs( dx ); ll = std::abs( dx );
xc = current_char_pos.x; xc = current_char_pos.x;
yc = current_char_pos.y; yc = current_char_pos.y;
x0 = aPanel->GetClipBox()->GetX() - ll; x0 = aPanel->GetClipBox()->GetX() - ll;
y0 = aPanel->GetClipBox()->GetY() - ll; y0 = aPanel->GetClipBox()->GetY() - ll;
xm = aPanel->GetClipBox()->GetRight() + ll; xm = aPanel->GetClipBox()->GetRight() + ll;
ym = aPanel->GetClipBox()->GetBottom() + ll; ym = aPanel->GetClipBox()->GetBottom() + ll;
if( xc < x0 ) if( xc < x0 )
return; return;
if( yc < y0 ) if( yc < y0 )
return; return;
if( xc > xm ) if( xc > xm )
return; return;
if( yc > ym ) if( yc > ym )
return; return;
} }
@ -396,6 +418,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aItalic ) if( aItalic )
{ {
overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8; overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8;
if( italic_reverse ) if( italic_reverse )
{ {
overbar_italic_comp = -overbar_italic_comp; overbar_italic_comp = -overbar_italic_comp;
@ -404,53 +427,64 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
else else
{ {
overbar_italic_comp = 0; overbar_italic_comp = 0;
}; }
int overbars = 0; // Number of '~' seen (except '~~')
ptr = 0; // ptr = text index
int overbars = 0; // Number of ~ seen
ptr = 0; /* ptr = text index */
while( ptr < char_count ) while( ptr < char_count )
{ {
if( aText[ptr + overbars] == '~' ) if( aText[ptr + overbars] == '~' )
{ {
/* Found an overbar, adjust the pointers */ if( ptr + overbars + 1 < aText.length()
overbars++; && aText[ptr + overbars + 1] == '~' ) /* '~~' draw as '~' */
ptr++; // skip first '~' char and draw second
if( overbars & 1 ) // odd overbars count
{
/* Starting the overbar */
overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth );
RotatePoint( &overbar_pos, aPos, aOrient );
}
else else
{ {
/* Ending the overbar */ // Found an overbar, adjust the pointers
coord[0] = overbar_pos; overbars++;
overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp; if( overbars & 1 ) // odd overbars count
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); {
RotatePoint( &overbar_pos, aPos, aOrient ); // Starting the overbar
coord[1] = overbar_pos; overbar_pos = current_char_pos;
/* Plot the overbar segment */ overbar_pos.x += overbar_italic_comp;
DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, overbar_pos.y -= OverbarPositionY( size_v, aWidth );
sketch_mode, 2, coord, aCallback, aPlotter ); RotatePoint( &overbar_pos, aPos, aOrient );
}
else
{
// Ending the overbar
coord[0] = overbar_pos;
overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth );
RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos;
// Plot the overbar segment
DrawGraphicTextPline( clipBox, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback, aPlotter );
}
continue; // Skip ~ processing
} }
continue; /* Skip ~ processing */
} }
AsciiCode = aText.GetChar( ptr + overbars ); AsciiCode = aText.GetChar( ptr + overbars );
const char* ptcar = GetHersheyShapeDescription( AsciiCode ); const char* ptcar = GetHersheyShapeDescription( AsciiCode );
/* Get metrics */ // Get metrics
int xsta = *ptcar++ - 'R'; int xsta = *ptcar++ - 'R';
int xsto = *ptcar++ - 'R'; int xsto = *ptcar++ - 'R';
int point_count = 0; int point_count = 0;
bool endcar = false; bool endcar = false;
while( !endcar ) while( !endcar )
{ {
int hc1, hc2; int hc1, hc2;
hc1 = *ptcar++; hc1 = *ptcar++;
if( hc1 ) if( hc1 )
{ {
hc2 = *ptcar++; hc2 = *ptcar++;
@ -462,64 +496,103 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
hc2 = 'R'; hc2 = 'R';
endcar = true; endcar = true;
} }
// Do the Hershey decode thing: coordinates values are coded as <value> + 'R'
hc1 -= 'R'; hc2 -= 'R';
/* Pen up request */ // Do the Hershey decode thing:
// coordinates values are coded as <value> + 'R'
hc1 -= 'R';
hc2 -= 'R';
// Pen up request
if( hc1 == -50 && hc2 == 0 ) if( hc1 == -50 && hc2 == 0 )
{ {
if( point_count ) if( point_count )
{ {
if( aWidth <= 1 ) if( aWidth <= 1 )
aWidth = 0; aWidth = 0;
DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth,
sketch_mode, point_count, coord, sketch_mode, point_count, coord,
aCallback, aPlotter ); aCallback, aPlotter );
} }
point_count = 0; point_count = 0;
} }
else else
{ {
wxPoint currpoint; wxPoint currpoint;
hc1 -= xsta; hc2 -= 11; /* Align the midpoint */ hc1 -= xsta; hc2 -= 11; // Align the midpoint
hc1 = KiROUND( hc1 * size_h * s_HerscheyScaleFactor ); hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor );
hc2 = KiROUND( hc2 * size_v * s_HerscheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor );
// To simulate an italic font, add a x offset depending on the y offset // To simulate an italic font,
// add a x offset depending on the y offset
if( aItalic ) if( aItalic )
hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 ); hc1 -= KiROUND( italic_reverse ? -hc2 / 8.0 : hc2 / 8.0 );
currpoint.x = hc1 + current_char_pos.x; currpoint.x = hc1 + current_char_pos.x;
currpoint.y = hc2 + current_char_pos.y; currpoint.y = hc2 + current_char_pos.y;
RotatePoint( &currpoint, aPos, aOrient ); RotatePoint( &currpoint, aPos, aOrient );
coord[point_count] = currpoint; coord[point_count] = currpoint;
if( point_count < BUF_SIZE - 1 ) if( point_count < BUF_SIZE - 1 )
point_count++; point_count++;
} }
} } // end draw 1 char
/* end draw 1 char */
ptr++; ptr++;
// Apply the advance width // Apply the advance width
current_char_pos.x += KiROUND( size_h * (xsto - xsta) * s_HerscheyScaleFactor ); current_char_pos.x += KiROUND( size_h * (xsto - xsta) * s_HersheyScaleFactor );
} }
if( overbars % 2 ) if( overbars % 2 )
{ {
/* Close the last overbar */ // Close the last overbar
coord[0] = overbar_pos; coord[0] = overbar_pos;
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v, aWidth );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos; coord[1] = overbar_pos;
/* Plot the overbar segment */
// Plot the overbar segment
DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, DrawGraphicTextPline( clipBox, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback, aPlotter ); sketch_mode, 2, coord, aCallback, aPlotter );
} }
} }
void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel,
wxDC * aDC,
const wxPoint &aPos,
enum EDA_COLOR_T aBgColor,
enum EDA_COLOR_T aColor1,
enum EDA_COLOR_T aColor2,
const wxString &aText,
int aOrient,
const wxSize &aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify,
enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf ),
PLOTTER * aPlotter )
{
// Swap color if contrast would be better
if( ColorIsLight( aBgColor ) ) {
EDA_COLOR_T c = aColor1;
aColor1 = aColor2;
aColor2 = c;
}
DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth, aItalic, aBold,
aCallback, aPlotter );
DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize,
aH_justify, aV_justify, aWidth / 4, aItalic, aBold,
aCallback, aPlotter );
}
/** /**
* Function PlotGraphicText * Function PlotGraphicText
@ -550,7 +623,7 @@ void PLOTTER::Text( const wxPoint& aPos,
{ {
int textPensize = aWidth; int textPensize = aWidth;
if( textPensize == 0 && aBold ) // Use default values if aWidth == 0 if( textPensize == 0 && aBold ) // Use default values if aWidth == 0
textPensize = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); textPensize = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
if( textPensize >= 0 ) if( textPensize >= 0 )

View File

@ -29,7 +29,7 @@
#include <cstdlib> // bsearch() #include <cstdlib> // bsearch()
#include <cctype> #include <cctype>
#include <macros.h>
#include <dsnlexer.h> #include <dsnlexer.h>
//#include "fctsys.h" //#include "fctsys.h"
@ -280,24 +280,25 @@ bool DSNLEXER::IsSymbol( int aTok )
void DSNLEXER::Expecting( int aTok ) throw( IO_ERROR ) void DSNLEXER::Expecting( int aTok ) throw( IO_ERROR )
{ {
wxString errText( _("Expecting") ); wxString errText;
errText << wxT(" ") << GetTokenString( aTok ); errText.Printf( _("Expecting '%s'"), GetChars( GetTokenString( aTok ) ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
void DSNLEXER::Expecting( const char* text ) throw( IO_ERROR ) void DSNLEXER::Expecting( const char* text ) throw( IO_ERROR )
{ {
wxString errText( _("Expecting") ); wxString errText;
errText << wxT(" '") << wxString::FromUTF8( text ) << wxT("'"); errText.Printf( _("Expecting '%s'"),
GetChars( wxString::FromUTF8( text ) ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
void DSNLEXER::Unexpected( int aTok ) throw( IO_ERROR ) void DSNLEXER::Unexpected( int aTok ) throw( IO_ERROR )
{ {
wxString errText( _("Unexpected") ); wxString errText;
errText << wxT(" ") << GetTokenString( aTok ); errText.Printf( _("Unexpected '%s'"), GetChars( GetTokenString( aTok ) ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
@ -312,8 +313,9 @@ void DSNLEXER::Duplicate( int aTok ) throw( IO_ERROR )
void DSNLEXER::Unexpected( const char* text ) throw( IO_ERROR ) void DSNLEXER::Unexpected( const char* text ) throw( IO_ERROR )
{ {
wxString errText( _("Unexpected") ); wxString errText;
errText << wxT(" '") << wxString::FromUTF8( text ) << wxT("'"); errText.Printf( _("Unexpected '%s'"),
GetChars( wxString::FromUTF8( text ) ) );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }

View File

@ -122,8 +122,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( !wxFileExists( fullfilename ) ) if( !wxFileExists( fullfilename ) )
{ {
msg = _( "Doc File " ); msg.Printf( _( "Doc File <%s> not found" ), GetChars( aDocName ) );
msg << wxT("\"") << aDocName << wxT("\"") << _( " not found" );
DisplayError( aFrame, msg ); DisplayError( aFrame, msg );
return false; return false;
} }

View File

@ -269,22 +269,12 @@ void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aDrawMode != -1 ) if( aDrawMode != -1 )
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
/* Draw text anchor, if allowed */ // Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR ) if( aAnchor_color != UNSPECIFIED_COLOR )
{ {
GRDrawAnchor( aPanel->GetClipBox(), aDC,
int anchor_size = aDC->DeviceToLogicalXRel( 2 ); aPos.x + aOffset.x, aPos.y + aOffset.y,
DIM_ANCRE_TEXTE, aAnchor_color );
aAnchor_color = (EDA_COLOR_T) ( aAnchor_color & MASKCOLOR );
int cX = aPos.x + aOffset.x;
int cY = aPos.y + aOffset.y;
GRLine( aPanel->GetClipBox(), aDC, cX - anchor_size, cY,
cX + anchor_size, cY, 0, aAnchor_color );
GRLine( aPanel->GetClipBox(), aDC, cX, cY - anchor_size,
cX, cY + anchor_size, 0, aAnchor_color );
} }
if( aFillMode == SKETCH ) if( aFillMode == SKETCH )

View File

@ -652,15 +652,16 @@ bool OpenPDF( const wxString& file )
if( !success ) if( !success )
{ {
wxString msg = _( "Problem while running the PDF viewer" ); wxString msg;
msg << _( "\n command is " ) << command; msg.Printf( _( "Problem while running the PDF viewer\nCommand is '%s'" ),
GetChars( command ) );
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
} }
else else
{ {
wxString msg = _( "Unable to find a PDF viewer for" ); wxString msg;
msg << wxT( " " ) << filename; msg.Printf( _( "Unable to find a PDF viewer for <%s>" ), GetChars( filename ) );
DisplayError( NULL, msg ); DisplayError( NULL, msg );
success = false; success = false;
} }

View File

@ -1451,3 +1451,124 @@ void GRBezier( EDA_RECT* ClipBox,
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 ); std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color ); GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
} }
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( mixed );
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}
EDA_COLOR_T ColorByName( const wxChar *aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
bool ColorIsLight( EDA_COLOR_T aColor )
{
const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
int r = c.m_Red;
int g = c.m_Green;
int b = c.m_Blue;
return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
EDA_COLOR_T candidate = BLACK;
// These are ints because we will subtract them later
int r = aColor.Red();
int g = aColor.Green();
int b = aColor.Blue();
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (r - c.m_Red) * (r - c.m_Red) +
(g - c.m_Green) * (g - c.m_Green) +
(b - c.m_Blue) * (b - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= r &&
c.m_Green >= g && c.m_Blue >= b )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
int aSize, EDA_COLOR_T aColor )
{
int anchor_size = aDC->DeviceToLogicalXRel( aSize );
GRLine( aClipBox, aDC,
x - anchor_size, y,
x + anchor_size, y, 0, aColor );
GRLine( aClipBox, aDC,
x, y - anchor_size,
x, y + anchor_size, 0, aColor );
}

View File

@ -205,9 +205,7 @@ void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
if( color >= 0 ) if( color >= 0 )
{ {
color = ColorGetBase( color ); color = ColorGetBase( color );
aDC.SetTextForeground( wxColour( ColorRefs[color].m_Red, aDC.SetTextForeground( MakeColour( color ) );
ColorRefs[color].m_Green,
ColorRefs[color].m_Blue ) );
} }
if( !aItem.m_UpperText.IsEmpty() ) if( !aItem.m_UpperText.IsEmpty() )

View File

@ -123,7 +123,7 @@ const char* const newstroke_font[] =
"KYVcUcSbR`RVQTOSQRRPRFSDUCVC", "KYVcUcSbR`RVQTOSQRRPRFSDUCVC",
"H\\RbRD", "H\\RbRD",
"KYNcOcQbR`RVSTUSSRRPRFQDOCNC", "KYNcOcQbR`RVSTUSSRRPRFQDOCNC",
"KZMHNGPFTHVGWF", "KZMSNRPQTSVRWQ",
"F^K[KFYFY[K[", "F^K[KFYFY[K[",
/* // LATIN-1 SUPPLEMENT (0080-00FF) */ /* // LATIN-1 SUPPLEMENT (0080-00FF) */
"F^K[KFYFY[K[", /* U+80 */ "F^K[KFYFY[K[", /* U+80 */

View File

@ -46,12 +46,12 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_outlineWidth = 60000; m_outlineWidth = 60000;
// Store the predefined colors used in KiCad in format used by GAL // Store the predefined colors used in KiCad in format used by GAL
for( int i = 0; i < NBCOLOR; i++ ) for( int i = 0; i < NBCOLORS; i++ )
{ {
m_legacyColorMap[ColorRefs[i].m_Numcolor] = COLOR4D( (double) ColorRefs[i].m_Red / 255.0, m_legacyColorMap[g_ColorRefs[i].m_Numcolor] = COLOR4D( (double) g_ColorRefs[i].m_Red / 255.0,
(double) ColorRefs[i].m_Green / 255.0, (double) g_ColorRefs[i].m_Green / 255.0,
(double) ColorRefs[i].m_Blue / 255.0, (double) g_ColorRefs[i].m_Blue / 255.0,
m_layerOpacity ); m_layerOpacity );
} }
} }

View File

@ -34,6 +34,7 @@
#include <pcbcommon.h> #include <pcbcommon.h>
#include <plot_common.h> #include <plot_common.h>
#include <class_board.h>
#include <class_pad.h> #include <class_pad.h>
#include <class_zone_settings.h> #include <class_zone_settings.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
@ -42,36 +43,9 @@
class MODULE; class MODULE;
/* return a one bit layer mask from a layer number
* aLayerNumber = the layer number to convert (0 .. LAYER_COUNT-1)
*/
int GetLayerMask( int aLayerNumber )
{
wxASSERT( aLayerNumber < LAYER_COUNT && aLayerNumber >= 0 );
#if 0
// Look up Table for conversion one layer number -> one bit layer mask:
static int tabOneLayerMask[LAYER_COUNT] =
{
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,
0x00000100, 0x00000200, 0x00000400, 0x00000800,
0x00001000, 0x00002000, 0x00004000, 0x00008000,
0x00010000, 0x00020000, 0x00040000, 0x00080000,
0x00100000, 0x00200000, 0x00400000, 0x00800000,
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000
};
return( tabOneLayerMask[aLayerNumber] );
#else
return 1 << aLayerNumber;
#endif
}
/* Look up Table for conversion copper layer count -> general copper layer /* Look up Table for conversion copper layer count -> general copper layer
* mask: */ * mask: */
int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
0x0001, 0x8001, 0x8003, 0x8007, 0x0001, 0x8001, 0x8003, 0x8007,
0x800F, 0x801F, 0x803F, 0x807F, 0x800F, 0x801F, 0x803F, 0x807F,
0x80FF, 0x81FF, 0x83FF, 0x87FF, 0x80FF, 0x81FF, 0x83FF, 0x87FF,
@ -79,7 +53,7 @@ int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
}; };
DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */ DISPLAY_OPTIONS DisplayOpt; // Display options for board items
int g_RotationAngle; int g_RotationAngle;
@ -99,3 +73,156 @@ int g_PadCMPColor = RED;
*/ */
DLIST<TRACK> g_CurrentTrackList; DLIST<TRACK> g_CurrentTrackList;
LAYER_NUM FlipLayer( LAYER_NUM oldlayer )
{
switch( oldlayer )
{
case LAYER_N_BACK:
return LAYER_N_FRONT;
case LAYER_N_FRONT:
return LAYER_N_BACK;
case SILKSCREEN_N_BACK:
return SILKSCREEN_N_FRONT;
case SILKSCREEN_N_FRONT:
return SILKSCREEN_N_BACK;
case ADHESIVE_N_BACK:
return ADHESIVE_N_FRONT;
case ADHESIVE_N_FRONT:
return ADHESIVE_N_BACK;
case SOLDERMASK_N_BACK:
return SOLDERMASK_N_FRONT;
case SOLDERMASK_N_FRONT:
return SOLDERMASK_N_BACK;
case SOLDERPASTE_N_BACK:
return SOLDERPASTE_N_FRONT;
case SOLDERPASTE_N_FRONT:
return SOLDERPASTE_N_BACK;
// No change for the other layers
default:
return oldlayer;
}
}
LAYER_MSK FlipLayerMask( LAYER_MSK aMask )
{
LAYER_MSK newMask;
newMask = aMask & ~(LAYER_BACK | LAYER_FRONT |
SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT |
ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT |
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT |
SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT |
ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT);
if( aMask & LAYER_BACK )
newMask |= LAYER_FRONT;
if( aMask & LAYER_FRONT )
newMask |= LAYER_BACK;
if( aMask & SILKSCREEN_LAYER_BACK )
newMask |= SILKSCREEN_LAYER_FRONT;
if( aMask & SILKSCREEN_LAYER_FRONT )
newMask |= SILKSCREEN_LAYER_BACK;
if( aMask & ADHESIVE_LAYER_BACK )
newMask |= ADHESIVE_LAYER_FRONT;
if( aMask & ADHESIVE_LAYER_FRONT )
newMask |= ADHESIVE_LAYER_BACK;
if( aMask & SOLDERMASK_LAYER_BACK )
newMask |= SOLDERMASK_LAYER_FRONT;
if( aMask & SOLDERMASK_LAYER_FRONT )
newMask |= SOLDERMASK_LAYER_BACK;
if( aMask & SOLDERPASTE_LAYER_BACK )
newMask |= SOLDERPASTE_LAYER_FRONT;
if( aMask & SOLDERPASTE_LAYER_FRONT )
newMask |= SOLDERPASTE_LAYER_BACK;
if( aMask & ADHESIVE_LAYER_BACK )
newMask |= ADHESIVE_LAYER_FRONT;
if( aMask & ADHESIVE_LAYER_FRONT )
newMask |= ADHESIVE_LAYER_BACK;
return newMask;
}
LAYER_NUM ExtractLayer( LAYER_MSK aMask )
{
if( aMask == NO_LAYERS )
return UNSELECTED_LAYER;
LAYER_NUM candidate = UNDEFINED_LAYER;
// Scan all the layers and take note of the first set; if other are
// then found return UNDEFINED_LAYER
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
if( aMask & GetLayerMask( i ) )
{
if( candidate == UNDEFINED_LAYER )
candidate = i;
else
return UNDEFINED_LAYER;
}
}
return candidate;
}
wxString LayerMaskDescribe( const BOARD *aBoard, LAYER_MSK aMask )
{
// Try the single or no- layer case (easy)
LAYER_NUM layer = ExtractLayer( aMask );
switch( layer )
{
case UNSELECTED_LAYER:
return _( "No layers" );
case UNDEFINED_LAYER:
break;
default:
return aBoard->GetLayerName( layer );
}
// Try to be smart and useful, starting with outer copper
// (which are more important than internal ones)
wxString layerInfo;
if( aMask & LAYER_FRONT )
AccumulateDescription( layerInfo, aBoard->GetLayerName( LAYER_N_FRONT ) );
if( aMask & LAYER_BACK )
AccumulateDescription( layerInfo, aBoard->GetLayerName( LAYER_N_BACK ) );
if( aMask & INTERNAL_CU_LAYERS )
AccumulateDescription( layerInfo, _("Internal" ) );
if( aMask & ALL_NO_CU_LAYERS )
AccumulateDescription( layerInfo, _("Non-copper" ) );
return layerInfo;
}
void AccumulateDescription( wxString &aDesc, const wxString &aItem )
{
if( !aDesc.IsEmpty() )
aDesc << wxT(", ");
aDesc << aItem;
}

View File

@ -20,7 +20,6 @@
#define CONFIG_VERSION 1 #define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true #define FORCE_LOCAL_CONFIG true
@ -29,7 +28,6 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
bool ForceUseLocalConfig ) bool ForceUseLocalConfig )
{ {
wxFileName fn = fileName; wxFileName fn = fileName;
wxString defaultFileName;
// Free old config file. // Free old config file.
if( m_projectSettings ) if( m_projectSettings )
@ -38,9 +36,9 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
m_projectSettings = NULL; m_projectSettings = NULL;
} }
/* Check the file name does not a KiCad project extension. /* Force the file extension.
* This allows the user to enter a filename without extension * This allows the user to enter a filename without extension
* or use an existing name to create te project file * or use an existing name to create the project file
*/ */
if( fn.GetExt() != ProjectFileExtension ) if( fn.GetExt() != ProjectFileExtension )
{ {
@ -58,8 +56,9 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
// Init local config filename // Init local config filename
if( ForceUseLocalConfig || fn.FileExists() ) if( ForceUseLocalConfig || fn.FileExists() )
{ {
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString, m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
fn.GetFullPath(), wxEmptyString ); m_CurrentOptionFile, wxEmptyString );
m_projectSettings->DontCreateOnDemand(); m_projectSettings->DontCreateOnDemand();
if( ForceUseLocalConfig ) if( ForceUseLocalConfig )
@ -90,9 +89,10 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
} }
wxString defaultFileName;
defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) ); defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) );
if( !defaultFileName ) if( defaultFileName.IsEmpty() )
{ {
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) ); wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(), fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(),
@ -104,6 +104,7 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
// Create new project file using the default name. // Create new project file using the default name.
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString, m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
wxEmptyString, fn.GetFullPath() ); wxEmptyString, fn.GetFullPath() );
m_projectSettings->DontCreateOnDemand(); m_projectSettings->DontCreateOnDemand();
@ -112,63 +113,6 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
PARAM_CFG_BASE** List )
{
PARAM_CFG_BASE* pt_cfg;
wxString msg;
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write time (especially to avoid bug wxFileConfig that writes the
* wrong item if declaration [xx] in first line (If empty group)
*/
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
msg = DateAndTime();
m_projectSettings->Write( wxT( "update" ), msg );
msg = GetAppName();
m_projectSettings->Write( wxT( "last_client" ), msg );
/* Save parameters */
m_projectSettings->DeleteGroup( GroupName ); // Erase all data
m_projectSettings->Flush();
m_projectSettings->SetPath( GroupName );
m_projectSettings->Write( wxT( "version" ), CONFIG_VERSION );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
for( ; List != NULL && *List != NULL; List++ )
{
pt_cfg = *List;
if( pt_cfg->m_Group )
m_projectSettings->SetPath( pt_cfg->m_Group );
else
m_projectSettings->SetPath( GroupName );
if( pt_cfg->m_Setup )
continue;
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( pt_cfg->m_Ident )
m_projectSettings->DeleteGroup( pt_cfg->m_Ident );
}
else
{
pt_cfg->SaveParam( m_projectSettings );
}
}
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
delete m_projectSettings;
m_projectSettings = NULL;
}
void EDA_APP::WriteProjectConfig( const wxString& fileName, void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
const PARAM_CFG_ARRAY& params ) const PARAM_CFG_ARRAY& params )
@ -213,44 +157,18 @@ void EDA_APP::WriteProjectConfig( const wxString& fileName,
} }
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP ); m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
delete m_projectSettings; delete m_projectSettings;
m_projectSettings = NULL; m_projectSettings = NULL;
} }
void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
{
PARAM_CFG_BASE* pt_cfg;
if( m_settings == NULL )
return;
for( ; *aList != NULL; aList++ )
{
pt_cfg = *aList;
if( pt_cfg->m_Setup == false )
continue;
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( pt_cfg->m_Ident )
m_settings->DeleteGroup( pt_cfg->m_Ident );
}
else
{
pt_cfg->SaveParam( m_settings );
}
}
}
void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List ) void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
if( m_settings == NULL ) if( m_settings == NULL )
return; return;
unsigned count = List.size(); unsigned count = List.size();
for( unsigned i=0; i<count; ++i ) for( unsigned i=0; i<count; ++i )
{ {
const PARAM_CFG_BASE& param = List[i]; const PARAM_CFG_BASE& param = List[i];
@ -269,74 +187,15 @@ void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
} }
} }
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
PARAM_CFG_BASE** List,
bool Load_Only_if_New )
{
PARAM_CFG_BASE* pt_cfg;
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_projectSettings->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) )
{
return false;
}
m_CurrentOptionFileDateAndTime = timestamp;
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
{
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
}
else
{
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
for( ; List != NULL && *List != NULL; List++ )
{
pt_cfg = *List;
if( pt_cfg->m_Group )
m_projectSettings->SetPath( pt_cfg->m_Group );
else
m_projectSettings->SetPath( GroupName );
if( pt_cfg->m_Setup )
continue;
pt_cfg->ReadParam( m_projectSettings );
}
delete m_projectSettings;
m_projectSettings = NULL;
return true;
}
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
const PARAM_CFG_ARRAY& params, const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New ) bool Load_Only_if_New )
{ {
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false ); ReCreatePrjConfig( local_config_filename, GroupName, false );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR ); m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_projectSettings->Read( wxT( "update" ) ); wxString timestamp = m_projectSettings->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() ) if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) ) && (timestamp == m_CurrentOptionFileDateAndTime) )
@ -346,19 +205,6 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
m_CurrentOptionFileDateAndTime = timestamp; m_CurrentOptionFileDateAndTime = timestamp;
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
{
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
}
else
{
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
BOOST_FOREACH( const PARAM_CFG_BASE& param, params ) BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{ {
if( param.m_Group ) if( param.m_Group )
@ -379,22 +225,6 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
} }
void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
{
PARAM_CFG_BASE* pt_cfg;
for( ; *aList != NULL; aList++ )
{
pt_cfg = *aList;
if( pt_cfg->m_Setup == false )
continue;
pt_cfg->ReadParam( m_settings );
}
}
void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List ) void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
BOOST_FOREACH( const PARAM_CFG_BASE& param, List ) BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
@ -491,8 +321,8 @@ void PARAM_CFG_INT_WITH_SCALE::ReadParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
double default_value = m_Default * m_BIU_to_cfgunit; double dtmp = (double) m_Default * m_BIU_to_cfgunit;
double dtmp = aConfig->Read( m_Ident, default_value ); aConfig->Read( m_Ident, &dtmp );
int itmp = KiROUND( dtmp / m_BIU_to_cfgunit ); int itmp = KiROUND( dtmp / m_BIU_to_cfgunit );
@ -508,7 +338,11 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
aConfig->Write( m_Ident, *m_Pt_param * m_BIU_to_cfgunit ); // We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param * m_BIU_to_cfgunit );
} }
@ -524,8 +358,8 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptpara
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
const wxChar* ident, const wxChar* ident,
EDA_COLOR_T* ptparam, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val, EDA_COLOR_T default_val,
const wxChar* group ) : const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
{ {
@ -537,13 +371,11 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
{ {
static const int MAX_COLOR = 0x8001F;
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
EDA_COLOR_T itmp = ColorFromInt( aConfig->Read( m_Ident, m_Default ) ); EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
if( (itmp < 0) || (itmp > MAX_COLOR) ) if( itmp == UNSPECIFIED_COLOR )
itmp = m_Default; itmp = m_Default;
*m_Pt_param = itmp; *m_Pt_param = itmp;
} }
@ -554,7 +386,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
aConfig->Write( m_Ident, (long) *m_Pt_param ); aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
} }
@ -592,23 +424,13 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
double ftmp = 0; double dtmp = m_Default;
wxString msg; aConfig->Read( m_Ident, &dtmp );
msg = aConfig->Read( m_Ident, wxT( "" ) );
if( msg.IsEmpty() ) if( (dtmp < m_Min) || (dtmp > m_Max) )
{ dtmp = m_Default;
ftmp = m_Default;
}
else
{
msg.ToDouble( &ftmp );
if( (ftmp < m_Min) || (ftmp > m_Max) ) *m_Pt_param = dtmp;
ftmp = m_Default;
}
*m_Pt_param = ftmp;
} }
@ -617,7 +439,11 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
aConfig->Write( m_Ident, *m_Pt_param ); // We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param );
} }
@ -715,8 +541,9 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
wxString prm = aConfig->Read( m_Ident ); wxString prm = aConfig->Read( m_Ident );
// filesnames are stored using Unix notation // file names are stored using Unix notation
// under Window we must use \ instead of / // under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad) // mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -765,13 +592,13 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
libname = aConfig->Read( id_lib, wxT( "" ) ); libname = aConfig->Read( id_lib, wxT( "" ) );
if( libname.IsEmpty() ) if( libname.IsEmpty() )
break; break;
// filesnames are stored using Unix notation // file names are stored using Unix notation
// under Window we must use \ instead of / // under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad) // mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__ #ifdef __WINDOWS__
libname.Replace(wxT("/"), wxT("\\")); libname.Replace(wxT("/"), wxT("\\"));
#endif #endif
libname_list->Add( libname ); libname_list->Add( libname );
} }
} }

229
common/ptree.cpp Normal file
View File

@ -0,0 +1,229 @@
/*
* 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 CHANGELOG.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
*/
// Something in either <boost/property_tree/ptree.hpp> causes a bunch of compiler
// errors in <wx/msw/winundef.h> version 2.9 on MinGW.
#include <macros.h>
#include <boost/property_tree/ptree.hpp>
#include <assert.h>
#include <ptree.h>
typedef PTREE::const_iterator CITER;
typedef PTREE::iterator ITER;
#if defined(DEBUG)
#define D(x) x
#else
#define D(x)
#endif
#define CTL_OMIT_NL (1<<0)
#define CTL_IN_ATTRS (1<<1)
//-----<Scan>------------------------------------------------------------------
/**
* Function scanList
* reads a sexpr list from the input stream into a new node with key
* aLexer->CurText().
*/
inline void scanList( PTREE* aTree, DSNLEXER* aLexer )
{
assert( aLexer->CurTok() == DSN_LEFT );
int tok = aLexer->NextTok();
const char* key = aLexer->CurText();
//D(printf( "%s: '%s'\n", __func__, key );)
PTREE* list = &aTree->push_back( PTREE::value_type( key, PTREE() ) )->second;
if( tok != DSN_RIGHT )
{
while( ( tok = aLexer->NextTok() ) != DSN_RIGHT )
{
if( tok == DSN_EOF )
aLexer->Unexpected( DSN_EOF );
Scan( list, aLexer );
}
}
}
inline void scanAtom( PTREE* aTree, DSNLEXER* aLexer )
{
const char* key = aLexer->CurText();
//D(printf( "%s: '%s'\n", __func__, key );)
aTree->push_back( PTREE::value_type( key, PTREE() ) );
}
void Scan( PTREE* aTree, DSNLEXER* aLexer ) throw( IO_ERROR )
{
int tok = aLexer->CurTok();
// conditionally read first token.
if( tok == DSN_NONE )
tok = aLexer->NextTok();
if( tok == DSN_EOF )
{
aLexer->Unexpected( DSN_EOF );
}
if( tok == DSN_LEFT )
{
scanList( aTree, aLexer );
}
else
{
scanAtom( aTree, aLexer );
}
}
//-----<Format>------------------------------------------------------------------
inline bool isAtom( CPTREE& aTree )
{
return aTree.size()==0 && aTree.data().size()==0;
}
inline bool isLast( CPTREE& aTree, CITER it )
{
CITER next = it;
++next;
return next == aTree.end();
}
inline CITER next( CITER it )
{
CITER n = it;
return ++n;
}
static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
const std::string& aKey, CPTREE& aTree ) throw( IO_ERROR );
static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree )
throw( IO_ERROR )
{
for( CITER it = aTree.begin(); it != aTree.end(); ++it )
{
// Processing a tree which was read in with xml_parser?
if( it->first == "<xmlattr>" )
{
formatList( out, aNestLevel, aCtl | CTL_IN_ATTRS, it->second );
continue;
}
int ctl = 0;
#if defined(DEBUG)
if( it->first == "field" )
{
int breakhere = 1;
(void) breakhere;
}
#endif
if( isLast( aTree, it ) ) // is "it" the last one?
{
//if( !( aCtl & CTL_IN_ATTRS ) )
ctl = CTL_OMIT_NL;
}
else if( isAtom( next( it )->second ) )
{
/* if( !( aCtl & CTL_IN_ATTRS ) ) */
ctl = CTL_OMIT_NL;
}
formatNode( out, aNestLevel+1, ctl, it->first, it->second );
}
}
static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
const std::string& aKey, CPTREE& aTree )
throw( IO_ERROR )
{
if( !isAtom( aTree ) ) // is a list, not an atom
{
int ctl = CTL_OMIT_NL;
// aTree is list and its first child is a list
if( aTree.size() && !isAtom( aTree.begin()->second ) && !aTree.data().size() )
ctl = 0;
out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" );
if( aTree.data().size() ) // only xml typically uses "data()", not sexpr.
{
out->Print( 0, " %s%s",
out->Quotes( aTree.data() ).c_str(),
aTree.size() ? "\n" : ""
);
}
formatList( out, aNestLevel, aCtl, aTree );
out->Print( 0, ")%s", aCtl & CTL_OMIT_NL ? "" : "\n" );
}
else // is an atom, not a list
{
const char* atom = out->Quotes( aKey ).c_str();
out->Print( 0, " %s", atom );
}
}
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree ) throw( IO_ERROR )
{
if( aTree.size() == 1 && !aTree.data().size() )
{
// The topmost node is basically only a container for the document root.
// It anchors the paths which traverse the tree deeper.
CITER it = aTree.begin();
formatNode( out, aNestLevel, aCtl, it->first, it->second );
}
else
{
// This is not expected, neither for sexpr nor xml.
formatNode( out, aNestLevel, aCtl, "", aTree );
}
}

View File

@ -58,7 +58,7 @@ bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 )
SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) : SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType ) EDA_ITEM( aParent, aType )
{ {
m_Layer = 0; m_Layer = LAYER_WIRE; // It's only a default, in fact
} }

View File

@ -54,7 +54,7 @@ EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor )
framepos, OldColor ); framepos, OldColor );
color = static_cast<EDA_COLOR_T>( frame->ShowModal() ); color = static_cast<EDA_COLOR_T>( frame->ShowModal() );
frame->Destroy(); frame->Destroy();
if( color > NBCOLOR ) if( color > NBCOLORS )
color = UNSPECIFIED_COLOR; color = UNSPECIFIED_COLOR;
return color; return color;
} }
@ -125,7 +125,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
wxStdDialogButtonSizer* StdDialogButtonSizer = NULL; wxStdDialogButtonSizer* StdDialogButtonSizer = NULL;
wxButton* Button = NULL; wxButton* Button = NULL;
int ii, butt_ID, buttcolor; int ii, butt_ID;
int w = 20, h = 20; int w = 20, h = 20;
bool ColorFound = false; bool ColorFound = false;
@ -137,17 +137,17 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
for( ii = 0; ColorRefs[ii].m_Name != NULL && ii < NBCOLOR; ii++ ) for( ii = 0; ii < NBCOLORS; ++ii )
{ {
// Provide a separate column for every eight buttons (and their // Provide a separate column for every six buttons (and their
// associated text strings), so provide a FlexGrid Sizer with // associated text strings), so provide a FlexGrid Sizer with
// eight rows and two columns. // eight rows and two columns.
if( ii % 8 == 0 ) if( ii % 6 == 0 )
{ {
FlexColumnBoxSizer = new wxFlexGridSizer( 8, 2, 0, 0 ); FlexColumnBoxSizer = new wxFlexGridSizer( 6, 2, 0, 0 );
// Specify that all of the rows can be expanded. // Specify that all of the rows can be expanded.
for( int ii = 0; ii < 8; ii++ ) for( int ii = 0; ii < 6; ii++ )
{ {
FlexColumnBoxSizer->AddGrowableRow( ii ); FlexColumnBoxSizer->AddGrowableRow( ii );
} }
@ -163,11 +163,9 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
wxBitmap ButtBitmap( w, h ); wxBitmap ButtBitmap( w, h );
wxBrush Brush; wxBrush Brush;
iconDC.SelectObject( ButtBitmap ); iconDC.SelectObject( ButtBitmap );
buttcolor = ColorRefs[ii].m_Numcolor; EDA_COLOR_T buttcolor = g_ColorRefs[ii].m_Numcolor;
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour( ColorRefs[buttcolor].m_Red, ColorSetBrush( &Brush, buttcolor );
ColorRefs[buttcolor].m_Green,
ColorRefs[buttcolor].m_Blue );
Brush.SetStyle( wxSOLID ); Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush ); iconDC.SetBrush( Brush );
@ -190,7 +188,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
BitmapButton->SetFocus(); BitmapButton->SetFocus();
} }
Label = new wxStaticText( this, -1, ColorRefs[ii].m_Name, Label = new wxStaticText( this, -1, ColorGetName( buttcolor ),
wxDefaultPosition, wxDefaultSize, 0 ); wxDefaultPosition, wxDefaultSize, 0 );
FlexColumnBoxSizer->Add( Label, 1, FlexColumnBoxSizer->Add( Label, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |

View File

@ -95,4 +95,4 @@ const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf
const wxString PSFileWildcard( _( "PostScript files (.ps)|*.ps" ) ); const wxString PSFileWildcard( _( "PostScript files (.ps)|*.ps" ) );
const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" ); const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" );
const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" ); const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" );
const wxString VrmlFileWildcard( _( "Vrml files (*.wrl)|*.wrl" ) ); const wxString Shapes3DFileWildcard( _( "Vrml and x3d files (*.wrl *.x3d)|*.wrl;*.x3d" ) );

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,7 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <base_units.h> #include <base_units.h>
#include <macros.h>
/*******************************************************/ /*******************************************************/
@ -56,7 +57,8 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
if( !Title.IsEmpty() ) if( !Title.IsEmpty() )
{ {
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_UserUnit ); wxString msg;
msg.Printf( _( "Size%s" ), GetChars( ReturnUnitSymbol( m_UserUnit ) ) );
wxStaticText* text = new wxStaticText( parent, -1, msg ); wxStaticText* text = new wxStaticText( parent, -1, msg );
BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 );

View File

@ -27,7 +27,6 @@ const wxString RetroFileExtension( wxT( "stf" ) );
const wxString FootprintAliasFileExtension( wxT( "equ" ) ); const wxString FootprintAliasFileExtension( wxT( "equ" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic): // Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString RetroFileWildcard( _( "KiCad retroannotation files (*.stf)|*.stf" ) );
const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) ); const wxString FootprintAliasFileWildcard( _( "KiCad footprint alias files (*.equ)|*.equ" ) );
const wxString titleLibLoadError( _( "Library Load Error" ) ); const wxString titleLibLoadError( _( "Library Load Error" ) );

View File

@ -28,7 +28,6 @@ typedef boost::ptr_vector< COMPONENT_INFO > COMPONENT_LIST;
extern const wxString FootprintAliasFileExtension; extern const wxString FootprintAliasFileExtension;
extern const wxString RetroFileExtension; extern const wxString RetroFileExtension;
extern const wxString RetroFileWildcard;
extern const wxString FootprintAliasFileWildcard; extern const wxString FootprintAliasFileWildcard;
extern const wxString titleLibLoadError; extern const wxString titleLibLoadError;

View File

@ -54,7 +54,7 @@ DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( CVPCB_MAINFRAME* parent ) :
m_Config = wxGetApp().GetCommonSettings(); m_Config = wxGetApp().GetCommonSettings();
Init( ); Init( );
title = _( "Project file: " ) + fn.GetFullPath(); title.Format( _( "Project file: <%s>" ), GetChars( fn.GetFullPath() ) );
SetTitle( title ); SetTitle( title );
if( GetSizer() ) if( GetSizer() )

View File

@ -60,15 +60,16 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
if( !footprintName.IsEmpty() ) if( !footprintName.IsEmpty() )
{ {
msg = _( "Footprint: " ) + footprintName; msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) );
SetTitle( msg ); SetTitle( msg );
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName ); FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
msg = _( "Lib: " );
const wxChar *libname;
if( module_info ) if( module_info )
msg += module_info->m_LibName; libname = GetChars( module_info->m_LibName );
else else
msg += wxT( "???" ); libname = GetChars( wxT( "???" ) );
msg.Printf( _( "Lib: %s" ), libname );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );

View File

@ -132,7 +132,6 @@ set(EESCHEMA_SRCS
sch_line.cpp sch_line.cpp
sch_marker.cpp sch_marker.cpp
sch_no_connect.cpp sch_no_connect.cpp
sch_polyline.cpp
sch_screen.cpp sch_screen.cpp
sch_sheet.cpp sch_sheet.cpp
sch_sheet_path.cpp sch_sheet_path.cpp

View File

@ -122,10 +122,8 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename,
if( aForceFieldsVisibleAttribute ) if( aForceFieldsVisibleAttribute )
{ {
if( aFieldsVisibleAttributeState ) component->GetField( FOOTPRINT )
component->GetField( FOOTPRINT )->SetVisible( false ); ->SetVisible( aFieldsVisibleAttributeState );
else
component->GetField( FOOTPRINT )->SetVisible( true );
} }
} }
} }

View File

@ -41,7 +41,6 @@
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_polyline.h>
#include <sch_text.h> #include <sch_text.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_sheet.h> #include <sch_sheet.h>
@ -68,7 +67,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
return; return;
segment = (SCH_LINE*) s_wires.begin(); segment = (SCH_LINE*) s_wires.begin();
EDA_COLOR_T color = ReturnLayerColor( segment->GetLayer() ); EDA_COLOR_T color = GetLayerColor( segment->GetLayer() );
ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) ); ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) );
if( aErase ) if( aErase )
@ -346,33 +345,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() ) if( ( screen->GetCurItem() == NULL ) || !screen->GetCurItem()->IsNew() )
return; return;
/* Cancel trace in progress */ DrawSegment( m_canvas, DC, wxDefaultPosition, false );
if( screen->GetCurItem()->Type() == SCH_POLYLINE_T )
{
SCH_POLYLINE* polyLine = (SCH_POLYLINE*) screen->GetCurItem();
wxPoint endpos;
endpos = screen->GetCrossHairPosition();
int idx = polyLine->GetCornerCount() - 1;
wxPoint pt = (*polyLine)[idx];
if( GetForceHVLines() )
{
/* Coerce the line to vertical or horizontal one: */
if( std::abs( endpos.x - pt.x ) < std::abs( endpos.y - pt.y ) )
endpos.x = pt.x;
else
endpos.y = pt.y;
}
polyLine->SetPoint( idx, endpos );
polyLine->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
}
else
{
DrawSegment( m_canvas, DC, wxDefaultPosition, false );
}
screen->Remove( screen->GetCurItem() ); screen->Remove( screen->GetCurItem() );
m_canvas->SetMouseCaptureCallback( NULL ); m_canvas->SetMouseCaptureCallback( NULL );

View File

@ -43,33 +43,37 @@
static int s_LastShape = '\\'; static int s_LastShape = '\\';
SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* aDC, int aType ) SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
{ {
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position // Create and place a new bus entry at cursor position
SCH_BUS_ENTRY* busEntry = new SCH_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape, SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
aType );
busEntry->SetFlags( IS_NEW ); busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry ); GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC ); addCurrentItemToList( aDC );
return busEntry; return busEntry;
} }
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC )
{
SCH_SCREEN* screen = GetScreen();
// Create and place a new bus entry at cursor position
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToList( aDC );
return busEntry;
}
/* set the shape of BusEntry (shape = / or \ ) /* set the shape of BusEntry (shape = / or \ )
*/ */
void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_shape ) void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape )
{ {
if( BusEntry == NULL ) if( BusEntry == NULL )
return; return;
if( BusEntry->Type() != SCH_BUS_ENTRY_T )
{
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return;
}
/* Put old item in undo list if it is not currently in edit */ /* Put old item in undo list if it is not currently in edit */
if( BusEntry->GetFlags() == 0 ) if( BusEntry->GetFlags() == 0 )
SaveCopyInUndoList( BusEntry, UR_CHANGED ); SaveCopyInUndoList( BusEntry, UR_CHANGED );

View File

@ -391,7 +391,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) ) if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
continue; continue;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
bool fill = aPlotter->GetColorMode(); bool fill = aPlotter->GetColorMode();
item.Plot( aPlotter, aOffset, fill, aTransform ); item.Plot( aPlotter, aOffset, fill, aTransform );

View File

@ -155,7 +155,11 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
aStr.Append( wxT( "R" ) ); aStr.Append( wxT( "R" ) );
// Regular expression for a value string, e.g., 47k2 // Regular expression for a value string, e.g., 47k2
#if defined(KICAD_GOST)
static wxRegEx valueRegEx( wxT( "^([0-9]+)(мк|[pnumRkKMGT.,кнМГ])([0-9]*)(мк*|[pnumRkKMGTкнМГ]*)" ) );
#else
static wxRegEx valueRegEx( wxT( "^([0-9]+)([pnumRkKMGT.,])([0-9]*)([pnumRkKMGT]*)" ) ); static wxRegEx valueRegEx( wxT( "^([0-9]+)([pnumRkKMGT.,])([0-9]*)([pnumRkKMGT]*)" ) );
#endif
if( !valueRegEx.Matches( aStr ) ) if( !valueRegEx.Matches( aStr ) )
return false; return false;
@ -164,7 +168,31 @@ static bool engStrToDouble( wxString aStr, double* aDouble )
+ wxT( "." ) + wxT( "." )
+ valueRegEx.GetMatch( aStr, 3 ) ); + valueRegEx.GetMatch( aStr, 3 ) );
wxString multiplierString = valueRegEx.GetMatch( aStr, 2 ); wxString multiplierString = valueRegEx.GetMatch( aStr, 2 );
#if defined(KICAD_GOST)
if ( multiplierString == wxT( "мк" ) )
multiplierString = wxT( "u" );
else if ( multiplierString == wxT( "к" ) )
multiplierString = wxT( "k" );
else if ( multiplierString == wxT( "н" ) )
multiplierString = wxT( "n" );
else if ( multiplierString == wxT( "М" ) )
multiplierString = wxT( "M" );
else if ( multiplierString == wxT( "Г" ) )
multiplierString = wxT( "G" );
#endif
wxString post_multiplierString = valueRegEx.GetMatch( aStr, 4 ); wxString post_multiplierString = valueRegEx.GetMatch( aStr, 4 );
#if defined(KICAD_GOST)
if ( post_multiplierString == wxT( "мк" ) )
multiplierString = wxT( "u" );
else if ( post_multiplierString == wxT( "к" ) )
multiplierString = wxT( "k" );
else if ( post_multiplierString == wxT( "н" ) )
multiplierString = wxT( "n" );
else if ( post_multiplierString == wxT( "М" ) )
multiplierString = wxT( "M" );
else if ( post_multiplierString == wxT( "Г" ) )
multiplierString = wxT( "G" );
#endif
double multiplier; double multiplier;
switch( (wxChar)multiplierString[0] ) switch( (wxChar)multiplierString[0] )
@ -680,14 +708,20 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
else else
tmp = wxT( "?" ); tmp = wxT( "?" );
msg.Printf( _( "Item not annotated: %s%s" ),
GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) );
if( ( componentFlatList[ii].m_Unit > 0 ) if( ( componentFlatList[ii].m_Unit > 0 )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) ) && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{ {
tmp.Printf( _( " (unit %d)" ), componentFlatList[ii].m_Unit ); msg.Printf( _( "Item not annotated: %s%s (unit %d)\n" ),
msg << tmp; GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Item not annotated: %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
} }
if( aMessageList ) if( aMessageList )
@ -708,16 +742,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
else else
tmp = wxT( "?" ); tmp = wxT( "?" );
msg.Printf( _( "Error item %s%s" ), GetChars( componentFlatList[ii].GetRef() ), msg.Printf( _( "Error item %s%s unit %d and no more than %d parts\n" ),
GetChars( tmp ) ); GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
tmp.Printf( _( " unit %d and no more than %d parts" ),
componentFlatList[ii].m_Unit, componentFlatList[ii].m_Unit,
componentFlatList[ii].GetLibComponent()->GetPartCount() ); componentFlatList[ii].GetLibComponent()->GetPartCount() );
msg << tmp;
if( aMessageList ) if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ) ); aMessageList->Add( msg );
error++; error++;
break; break;
@ -747,18 +779,23 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
else else
tmp = wxT( "?" ); tmp = wxT( "?" );
msg.Printf( _( "Multiple item %s%s" ), if( ( componentFlatList[ii].m_Unit > 0 )
GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) ); && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
if( ( componentFlatList[ii].m_Unit > 0 )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{ {
tmp.Printf( _( " (unit %d)" ), componentFlatList[ii].m_Unit ); msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
msg << tmp; GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Multiple item %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
} }
if( aMessageList ) if( aMessageList )
aMessageList->Add( msg + wxT( "\n" ) ); aMessageList->Add( msg );
error++; error++;
continue; continue;
@ -774,18 +811,23 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
else else
tmp = wxT( "?" ); tmp = wxT( "?" );
msg.Printf( _( "Multiple item %s%s" ), if( ( componentFlatList[ii].m_Unit > 0 )
GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) ); && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
if( ( componentFlatList[ii].m_Unit > 0 )
&& ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) )
{ {
tmp.Printf( _( " (unit %d)" ), componentFlatList[ii].m_Unit ); msg.Printf( _( "Multiple item %s%s (unit %d)\n" ),
msg << tmp; GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ),
componentFlatList[ii].m_Unit );
}
else
{
msg.Printf( _( "Multiple item %s%s\n" ),
GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ) );
} }
if( aMessageList ) if( aMessageList )
aMessageList->Add( msg + wxT( "\n" )); aMessageList->Add( msg );
error++; error++;
} }

View File

@ -56,18 +56,31 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
if( nameList.empty() ) if( nameList.empty() )
{ {
msg = _( "No components found matching " );
if( !BufName.IsEmpty() ) if( !BufName.IsEmpty() )
{ {
msg += _( "name search criteria <" ) + BufName + wxT( "> " );
if( !Keys.IsEmpty() ) if( !Keys.IsEmpty() )
msg += _( "and " ); {
msg.Printf( _( "No components found matching name search criteria '%s' and key search criteria '%s'" ),
GetChars( BufName ), GetChars( Keys ) );
}
else
{
msg.Printf( _( "No components found matching name search criteria '%s'" ),
GetChars( BufName ) );
}
}
else
{
if( !Keys.IsEmpty() )
{
msg.Printf( _( "No components found matching key search criteria '%s'" ),
GetChars( Keys ) );
}
else
{
msg = _( "No components found matching" );
}
} }
if( !Keys.IsEmpty() )
msg += _( "key search criteria <" ) + Keys + wxT( "> " );
DisplayInfoMessage( frame, msg ); DisplayInfoMessage( frame, msg );

View File

@ -132,16 +132,19 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
if( GetResetItems() ) if( GetResetItems() )
{ {
message = _( "Clear and annotate all of the components " ); if( GetLevel() )
message += _( "Clear and annotate all of the components on the entire schematic?" );
else
message += _( "Clear and annotate all of the components on the current sheet?" );
promptUser = true; promptUser = true;
} }
else else
message = _( "Annotate only the unannotated components " ); {
if( GetLevel() )
if( GetLevel() ) message += _( "Annotate only the unannotated components on the entire schematic?" );
message += _( "on the entire schematic?" ); else
else message += _( "Annotate only the unannotated components on the current sheet?" );
message += _( "on the current sheet?" ); }
message += _( "\n\nThis operation will change the current annotation and cannot be undone." ); message += _( "\n\nThis operation will change the current annotation and cannot be undone." );
@ -179,11 +182,11 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event )
{ {
int response; int response;
wxString message = _( "Clear the existing annotation for " ); wxString message;
if( GetLevel() ) if( GetLevel() )
message += _( "the entire schematic?" ); message = _( "Clear the existing annotation for the entire schematic?" );
else else
message += _( "the current sheet?" ); message = _( "Clear the existing annotation for the current sheet?" );
message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." ); message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." );
response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL );

View File

@ -472,7 +472,7 @@ void DIALOG_BUILD_BOM::CreateSpreadSheetPartsShortList( )
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Failed to open file '%s'" ), GetChars(m_listFileName) ); msg.Printf( _( "Failed to open file <%s>" ), GetChars(m_listFileName) );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
@ -481,7 +481,7 @@ void DIALOG_BUILD_BOM::CreateSpreadSheetPartsShortList( )
bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol ); bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol );
// Set the list of fields to add to list // Set the list of fields to add to list
for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) ) if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii ); bom_lister.AddFieldIdToPrintList( ii );
// Write the list of components grouped by values: // Write the list of components grouped by values:
@ -509,8 +509,7 @@ void DIALOG_BUILD_BOM::CreateSpreadSheetPartsFullList( bool aIncludeSubComponent
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{ {
msg = _( "Failed to open file " ); msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) );
msg << m_listFileName;
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
@ -530,7 +529,7 @@ void DIALOG_BUILD_BOM::CreateSpreadSheetPartsFullList( bool aIncludeSubComponent
aIncludeSubComponents ); aIncludeSubComponents );
// Set the list of fields to add to list // Set the list of fields to add to list
for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) ) if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii ); bom_lister.AddFieldIdToPrintList( ii );
@ -553,8 +552,7 @@ void DIALOG_BUILD_BOM::CreatePartsAndLabelsFullList( bool aIncludeSubComponents
if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL )
{ {
msg = _( "Failed to open file " ); msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) );
msg << m_listFileName;
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
@ -564,7 +562,7 @@ void DIALOG_BUILD_BOM::CreatePartsAndLabelsFullList( bool aIncludeSubComponents
bom_lister.SetCvsFormOff(); bom_lister.SetCvsFormOff();
bom_lister.SetPrintLocation( s_Add_Location ); bom_lister.SetPrintLocation( s_Add_Location );
// Set the list of fields to add to list // Set the list of fields to add to list
for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) for( int ii = FOOTPRINT; ii <= FIELD8; ii++ )
if( IsFieldChecked( ii ) ) if( IsFieldChecked( ii ) )
bom_lister.AddFieldIdToPrintList( ii ); bom_lister.AddFieldIdToPrintList( ii );

View File

@ -11,6 +11,7 @@
#include <protos.h> #include <protos.h>
#include <dialog_color_config.h> #include <dialog_color_config.h>
#include <layers_id_colors_and_visibility.h>
#define ID_COLOR_SETUP 1800 #define ID_COLOR_SETUP 1800
@ -66,7 +67,7 @@ static ButtonIndex buttonGroups[] = {
}; };
static EDA_COLOR_T currentColors[ MAX_LAYER ]; static EDA_COLOR_T currentColors[ NB_SCH_LAYERS ];
IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog ) IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog )
@ -129,7 +130,6 @@ void DIALOG_COLOR_CONFIG::Init()
void DIALOG_COLOR_CONFIG::CreateControls() void DIALOG_COLOR_CONFIG::CreateControls()
{ {
wxStaticText* label; wxStaticText* label;
int color;
int buttonId = 1800; int buttonId = 1800;
ButtonIndex* groups = buttonGroups; ButtonIndex* groups = buttonGroups;
@ -167,12 +167,11 @@ void DIALOG_COLOR_CONFIG::CreateControls()
wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( bitmap ); iconDC.SelectObject( bitmap );
color = currentColors[ buttons->m_Layer ] = ReturnLayerColor( buttons->m_Layer ); EDA_COLOR_T color = GetLayerColor( LayerNumber( buttons->m_Layer ) );
currentColors[ buttons->m_Layer ] = color;
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
wxBrush brush; wxBrush brush;
brush.SetColour( ColorRefs[ color ].m_Red, ColorSetBrush( &brush, color );
ColorRefs[ color ].m_Green,
ColorRefs[ color ].m_Blue );
brush.SetStyle( wxSOLID ); brush.SetStyle( wxSOLID );
iconDC.SetBrush( brush ); iconDC.SetBrush( brush );
@ -266,9 +265,7 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event )
iconDC.SelectObject( bitmap ); iconDC.SelectObject( bitmap );
wxBrush brush; wxBrush brush;
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
brush.SetColour( ColorRefs[ color ].m_Red, ColorSetBrush( &brush, color);
ColorRefs[ color ].m_Green,
ColorRefs[ color ].m_Blue );
brush.SetStyle( wxSOLID ); brush.SetStyle( wxSOLID );
iconDC.SetBrush( brush ); iconDC.SetBrush( brush );
@ -290,17 +287,17 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
bool warning = false; bool warning = false;
for( int ii = 0; ii < MAX_LAYERS; ii++ ) for( LayerNumber ii = LAYER_WIRE; ii < NB_SCH_LAYERS; ++ii )
{ {
SetLayerColor( currentColors[ ii ], ii ); SetLayerColor( currentColors[ ii ], ii );
if( g_DrawBgColor == ReturnLayerColor( ii ) ) if( g_DrawBgColor == GetLayerColor( ii ) )
warning = true; warning = true;
} }
m_Parent->SetGridColor( ReturnLayerColor( LAYER_GRID ) ); m_Parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
if( g_DrawBgColor == ReturnLayerColor( LAYER_GRID ) ) if( g_DrawBgColor == GetLayerColor( LAYER_GRID ) )
warning = true; warning = true;
return warning; return warning;

View File

@ -49,18 +49,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
return; return;
} }
wxString title = _( "Properties for " ); wxString title;
bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0; bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0;
if( !isRoot ) if( !isRoot )
{ {
title += m_Parent->GetAliasName() + _( " (alias of " ) + component->GetName() + wxT( ")" ); title.Printf( _( "Properties for %s (alias of %s)" ),
GetChars( m_Parent->GetAliasName() ),
GetChars( component->GetName() ) );
} }
else else
{ title.Printf( _( "Properties for %s" ), GetChars( component->GetName() ) );
title += component->GetName();
}
SetTitle( title ); SetTitle( title );
InitPanelDoc(); InitPanelDoc();
@ -453,7 +452,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& event )
{ {
if( IsOK( this, _( "Ok to Delete FootprintFilter LIST" ) ) ) if( IsOK( this, _( "OK to delete the footprint filter list ?" ) ) )
{ {
m_FootprintFilterListBox->Clear(); m_FootprintFilterListBox->Clear();
m_ButtonDeleteAllFootprintFilter->Enable( false ); m_ButtonDeleteAllFootprintFilter->Enable( false );

View File

@ -1,3 +1,26 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2011 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
*/
/** /**
* @file dialog_edit_component_in_schematic.cpp * @file dialog_edit_component_in_schematic.cpp
*/ */
@ -79,18 +102,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
columnLabel.SetText( _( "Value" ) ); columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( 1, columnLabel ); fieldListCtrl->InsertColumn( 1, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit ); m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
textSizeLabel->SetLabel( label ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
label = _( "Pos " );
label += _( "X" );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
copySelectedFieldToPanel(); copySelectedFieldToPanel();
@ -142,8 +156,9 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
newname.Replace( wxT( " " ), wxT( "_" ) ); newname.Replace( wxT( " " ), wxT( "_" ) );
if( newname.IsEmpty() ) if( newname.IsEmpty() )
{
DisplayError( NULL, _( "No Component Name!" ) ); DisplayError( NULL, _( "No Component Name!" ) );
}
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{ {
if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL ) if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL )
@ -230,12 +245,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
copyPanelToOptions(); copyPanelToOptions();
// change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{
m_FieldsBuf[i].SetPosition( m_FieldsBuf[i].GetPosition() + m_Cmp->m_Pos );
}
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component. // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); ) for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
{ {
@ -251,9 +260,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
{ {
wxString msg; wxString msg;
msg.Printf( _( "The field name <%s> does not have a value and is not defined in \ msg.Printf( _( "The field name <%s> does not have a value and is not defined in "
the field template list. Empty field values are invalid an will be removed from the component. \ "the field template list. Empty field values are invalid an will "
Do you wish to remove this and all remaining undefined fields?" ), "be removed from the component. Do you wish to remove this and "
"all remaining undefined fields?" ),
GetChars( m_FieldsBuf[i].GetName( false ) ) ); GetChars( m_FieldsBuf[i].GetName( false ) ) );
wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT ); wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
@ -271,6 +281,12 @@ Do you wish to remove this and all remaining undefined fields?" ),
++i; ++i;
} }
// change all field positions from relative to absolute
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
}
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName ); LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry && entry->IsPower() ) if( entry && entry->IsPower() )
@ -440,8 +456,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
for( int i = 0; i<aComponent->GetFieldCount(); ++i ) for( int i = 0; i<aComponent->GetFieldCount(); ++i )
{ {
printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].m_Pos.x, printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x,
aComponent->m_Fields[i].m_Pos.y ); aComponent->m_Fields[i].GetTextPosition().y );
} }
#endif #endif
@ -458,7 +474,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( aComponent->m_Fields[i] ); m_FieldsBuf.push_back( aComponent->m_Fields[i] );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[i].SetPosition( m_FieldsBuf[i].GetPosition() - m_Cmp->m_Pos ); m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_Cmp->m_Pos );
} }
// Add template fieldnames: // Add template fieldnames:
@ -491,7 +507,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
fld = *schField; fld = *schField;
// make the editable field position relative to the component // make the editable field position relative to the component
fld.SetPosition( fld.GetPosition() - m_Cmp->m_Pos ); fld.SetTextPosition( fld.GetTextPosition() - m_Cmp->m_Pos );
} }
m_FieldsBuf.push_back( fld ); m_FieldsBuf.push_back( fld );
@ -510,7 +526,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf.push_back( *cmp ); m_FieldsBuf.push_back( *cmp );
// make the editable field position relative to the component // make the editable field position relative to the component
m_FieldsBuf[newNdx].SetPosition( m_FieldsBuf[newNdx].GetPosition() - m_Cmp->m_Pos ); m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
m_Cmp->m_Pos );
} }
} }
@ -606,18 +623,18 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// Select the right text justification // Select the right text justification
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ) if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
m_FieldHJustifyCtrl->SetSelection(0); m_FieldHJustifyCtrl->SetSelection( 0 );
else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
m_FieldHJustifyCtrl->SetSelection(2); m_FieldHJustifyCtrl->SetSelection( 2 );
else else
m_FieldHJustifyCtrl->SetSelection(1); m_FieldHJustifyCtrl->SetSelection( 1 );
if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM ) if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
m_FieldVJustifyCtrl->SetSelection(0); m_FieldVJustifyCtrl->SetSelection( 0 );
else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ) else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection(2); m_FieldVJustifyCtrl->SetSelection( 2 );
else else
m_FieldVJustifyCtrl->SetSelection(1); m_FieldVJustifyCtrl->SetSelection( 1 );
fieldNameTextCtrl->SetValue( field.GetName( false ) ); fieldNameTextCtrl->SetValue( field.GetName( false ) );
@ -644,7 +661,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
wxPoint coord = field.GetPosition(); wxPoint coord = field.GetTextPosition();
wxPoint zero = -m_Cmp->m_Pos; // relative zero wxPoint zero = -m_Cmp->m_Pos; // relative zero
// If the field value is empty and the position is at relative zero, we // If the field value is empty and the position is at relative zero, we
@ -655,10 +672,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetPosition().x coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetPosition().y coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y
+ ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100; + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
@ -728,7 +745,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
wxPoint pos; wxPoint pos;
pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() ); pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() ); pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
field.SetPosition( pos ); field.SetTextPosition( pos );
return true; return true;
} }
@ -844,11 +861,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Perhaps the FOOTPRINT field should also be considered, // Perhaps the FOOTPRINT field should also be considered,
// but for most of components it is not set in library // but for most of components it is not set in library
LIB_FIELD& refField = entry->GetReferenceField(); LIB_FIELD& refField = entry->GetReferenceField();
m_Cmp->GetField( REFERENCE )->SetPosition( refField.GetPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( REFERENCE )->ImportValues( refField ); m_Cmp->GetField( REFERENCE )->ImportValues( refField );
LIB_FIELD& valField = entry->GetValueField(); LIB_FIELD& valField = entry->GetValueField();
m_Cmp->GetField( VALUE )->SetPosition( valField.GetPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( VALUE )->ImportValues( valField ); m_Cmp->GetField( VALUE )->ImportValues( valField );
m_Cmp->SetOrientation( CMP_NORMAL ); m_Cmp->SetOrientation( CMP_NORMAL );

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -20,18 +20,17 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
upperSizer = new wxBoxSizer( wxHORIZONTAL ); upperSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* optionsSizer; wxStaticBoxSizer* optionsSizer;
optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component") ), wxVERTICAL );
wxStaticBoxSizer* unitSizer; m_staticTextUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 );
unitSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Unit") ), wxVERTICAL ); m_staticTextUnit->Wrap( -1 );
optionsSizer->Add( m_staticTextUnit, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxString unitChoiceChoices[] = { _("1"), _("2"), _("3"), _("4"), _("5"), _("6"), _("7"), _("8"), _("9"), _("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19"), _("20"), _("21"), _("22"), _("23"), _("24"), _("25"), _("26") }; wxString unitChoiceChoices[] = { _("1"), _("2"), _("3"), _("4"), _("5"), _("6"), _("7"), _("8"), _("9"), _("10"), _("11"), _("12"), _("13"), _("14"), _("15"), _("16"), _("17"), _("18"), _("19"), _("20"), _("21"), _("22"), _("23"), _("24"), _("25"), _("26") };
int unitChoiceNChoices = sizeof( unitChoiceChoices ) / sizeof( wxString ); int unitChoiceNChoices = sizeof( unitChoiceChoices ) / sizeof( wxString );
unitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, unitChoiceNChoices, unitChoiceChoices, 0 ); unitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, unitChoiceNChoices, unitChoiceChoices, 0 );
unitChoice->SetSelection( 0 ); unitChoice->SetSelection( 0 );
unitSizer->Add( unitChoice, 0, wxALL|wxEXPAND, 5 ); optionsSizer->Add( unitChoice, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
optionsSizer->Add( unitSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );
wxBoxSizer* orientationSizer; wxBoxSizer* orientationSizer;
orientationSizer = new wxBoxSizer( wxHORIZONTAL ); orientationSizer = new wxBoxSizer( wxHORIZONTAL );
@ -44,6 +43,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 ); orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 );
optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 );
wxBoxSizer* mirrorSizer; wxBoxSizer* mirrorSizer;
@ -57,18 +57,18 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 ); mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 );
optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 );
wxStaticBoxSizer* chipnameSizer; m_staticTextChipname = new wxStaticText( this, wxID_ANY, _("Chip Name"), wxDefaultPosition, wxDefaultSize, 0 );
chipnameSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Chip Name") ), wxHORIZONTAL ); m_staticTextChipname->Wrap( -1 );
optionsSizer->Add( m_staticTextChipname, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
chipnameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); chipnameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
chipnameTextCtrl->SetMaxLength( 32 ); chipnameTextCtrl->SetMaxLength( 32 );
chipnameTextCtrl->SetToolTip( _("The name of the symbol in the library from which this component came") ); chipnameTextCtrl->SetToolTip( _("The name of the symbol in the library from which this component came") );
chipnameSizer->Add( chipnameTextCtrl, 1, wxALL|wxEXPAND, 5 ); optionsSizer->Add( chipnameTextCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 );
convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 );
convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") ); convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") );
@ -84,6 +84,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
optionsSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 ); optionsSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 );
upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 ); upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* fieldsSizer; wxStaticBoxSizer* fieldsSizer;
@ -100,57 +101,60 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 );
addFieldButton->SetToolTip( _("Add a new custom field") ); addFieldButton->SetToolTip( _("Add a new custom field") );
gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); gridStaticBoxSizer->Add( addFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 );
deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); deleteFieldButton->SetToolTip( _("Delete one of the optional fields") );
gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); gridStaticBoxSizer->Add( deleteFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); moveUpButton->SetToolTip( _("Move the selected optional fields up one position") );
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
fieldsSizer->Add( gridStaticBoxSizer, 3, wxEXPAND|wxRIGHT|wxLEFT, 8 ); fieldsSizer->Add( gridStaticBoxSizer, 3, wxEXPAND|wxRIGHT|wxLEFT, 8 );
wxBoxSizer* fieldEditBoxSizer; wxBoxSizer* fieldEditBoxSizer;
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerOptions; wxBoxSizer* bSizerJustification;
sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Text Justification:") ), wxHORIZONTAL ); bSizerJustification = new wxBoxSizer( wxHORIZONTAL );
wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") }; wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") };
int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString );
m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldHJustifyCtrl->SetSelection( 0 ); m_FieldHJustifyCtrl->SetSelection( 0 );
sbSizerOptions->Add( m_FieldHJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); bSizerJustification->Add( m_FieldHJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 );
wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") }; wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") };
int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString );
m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_FieldVJustifyCtrl->SetSelection( 2 ); m_FieldVJustifyCtrl->SetSelection( 0 );
sbSizerOptions->Add( m_FieldVJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); bSizerJustification->Add( m_FieldVJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 );
fieldEditBoxSizer->Add( sbSizerOptions, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( bSizerJustification, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bSizerStyle;
bSizerStyle = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* visibilitySizer; wxStaticBoxSizer* visibilitySizer;
visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxVERTICAL );
wxBoxSizer* bShowRotateSizer;
bShowRotateSizer = new wxBoxSizer( wxVERTICAL );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
showCheckBox->SetToolTip( _("Check if you want this field visible") ); showCheckBox->SetToolTip( _("Check if you want this field visible") );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); visibilitySizer->Add( showCheckBox, 0, wxALL, 5 );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); visibilitySizer->Add( rotateCheckBox, 0, wxALL, 5 );
visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 );
bSizerStyle->Add( visibilitySizer, 1, wxEXPAND|wxALL, 5 );
wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString ); int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
@ -158,89 +162,101 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
m_StyleRadioBox->SetSelection( 3 ); m_StyleRadioBox->SetSelection( 3 );
m_StyleRadioBox->SetToolTip( _("The style of the currently selected field's text in the schemati") ); m_StyleRadioBox->SetToolTip( _("The style of the currently selected field's text in the schemati") );
visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerStyle->Add( m_StyleRadioBox, 1, wxEXPAND|wxALL, 5 );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND|wxTOP, 5 );
fieldEditBoxSizer->Add( bSizerStyle, 1, wxEXPAND, 5 );
wxBoxSizer* fieldNameBoxSizer; wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 ); fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameLabel->Wrap( -1 ); fieldNameLabel->Wrap( -1 );
fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); fieldNameBoxSizer->Add( fieldNameLabel, 0, wxTOP, 5 );
fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldNameTextCtrl->SetMaxLength( 0 );
fieldNameTextCtrl->SetToolTip( _("The name of the currently selected field\nSome fixed fields names are not editable") ); fieldNameTextCtrl->SetToolTip( _("The name of the currently selected field\nSome fixed fields names are not editable") );
fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 );
fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxEXPAND, 5 );
wxBoxSizer* fieldTextBoxSizer; wxBoxSizer* fieldTextBoxSizer;
fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL );
fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 ); fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldValueLabel->Wrap( -1 ); fieldValueLabel->Wrap( -1 );
fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); fieldTextBoxSizer->Add( fieldValueLabel, 0, wxTOP, 5 );
fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldValueTextCtrl->SetMaxLength( 0 );
fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* textSizeBoxSizer; fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxEXPAND, 5 );
textSizeBoxSizer = new wxBoxSizer( wxVERTICAL );
textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); wxFlexGridSizer* fgSizerPosSize;
fgSizerPosSize = new wxFlexGridSizer( 3, 3, 0, 0 );
fgSizerPosSize->AddGrowableCol( 1 );
fgSizerPosSize->SetFlexibleDirection( wxBOTH );
fgSizerPosSize->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
textSizeLabel->Wrap( -1 ); textSizeLabel->Wrap( -1 );
textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 ); fgSizerPosSize->Add( textSizeLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
textSizeTextCtrl->SetMaxLength( 0 );
textSizeTextCtrl->SetToolTip( _("The size of the currently selected field's text in the schematic") ); textSizeTextCtrl->SetToolTip( _("The size of the currently selected field's text in the schematic") );
textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( textSizeTextCtrl, 0, wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); m_staticTextUnitSize = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitSize->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* positionBoxSizer; posXLabel = new wxStaticText( this, wxID_ANY, _("PosX"), wxDefaultPosition, wxDefaultSize, 0 );
positionBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* posXBoxSizer;
posXBoxSizer = new wxBoxSizer( wxVERTICAL );
posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 );
posXLabel->Wrap( -1 ); posXLabel->Wrap( -1 );
posXBoxSizer->Add( posXLabel, 0, 0, 5 ); fgSizerPosSize->Add( posXLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posXTextCtrl->SetMaxLength( 0 );
posXTextCtrl->SetToolTip( _("The X coordinate of the text relative to the component") ); posXTextCtrl->SetToolTip( _("The X coordinate of the text relative to the component") );
posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( posXTextCtrl, 0, wxEXPAND|wxTOP|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); m_staticTextUnitPosX = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitPosX->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitPosX, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* posYBoxSizer; posYLabel = new wxStaticText( this, wxID_ANY, _("PosY"), wxDefaultPosition, wxDefaultSize, 0 );
posYBoxSizer = new wxBoxSizer( wxVERTICAL );
posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 );
posYLabel->Wrap( -1 ); posYLabel->Wrap( -1 );
posYBoxSizer->Add( posYLabel, 0, 0, 5 ); fgSizerPosSize->Add( posYLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYTextCtrl->SetMaxLength( 0 );
posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") );
posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( posYTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); m_staticTextUnitPosY = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitPosY->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitPosY, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
fieldEditBoxSizer->Add( fgSizerPosSize, 1, wxEXPAND|wxTOP, 5 );
fieldEditBoxSizer->Add( positionBoxSizer, 0, wxEXPAND, 5 );
fieldsSizer->Add( fieldEditBoxSizer, 2, wxEXPAND, 5 ); fieldsSizer->Add( fieldEditBoxSizer, 2, wxEXPAND, 5 );
upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 ); upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 );
mainSizer->Add( upperSizer, 1, wxEXPAND, 5 ); mainSizer->Add( upperSizer, 1, wxEXPAND, 5 );
stdDialogButtonSizer = new wxStdDialogButtonSizer(); stdDialogButtonSizer = new wxStdDialogButtonSizer();
@ -249,8 +265,10 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(
stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL ); stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel ); stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
stdDialogButtonSizer->Realize(); stdDialogButtonSizer->Realize();
mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 );
this->SetSizer( mainSizer ); this->SetSizer( mainSizer );
this->Layout(); this->Layout();

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -12,18 +12,18 @@
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/choice.h> #include <wx/stattext.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/sizer.h> #include <wx/choice.h>
#include <wx/statbox.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/sizer.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/statbox.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -38,9 +38,11 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
private: private:
protected: protected:
wxStaticText* m_staticTextUnit;
wxChoice* unitChoice; wxChoice* unitChoice;
wxRadioBox* orientationRadioBox; wxRadioBox* orientationRadioBox;
wxRadioBox* mirrorRadioBox; wxRadioBox* mirrorRadioBox;
wxStaticText* m_staticTextChipname;
wxTextCtrl* chipnameTextCtrl; wxTextCtrl* chipnameTextCtrl;
wxCheckBox* convertCheckBox; wxCheckBox* convertCheckBox;
wxStaticText* partsAreLockedLabel; wxStaticText* partsAreLockedLabel;
@ -60,10 +62,13 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
wxTextCtrl* fieldValueTextCtrl; wxTextCtrl* fieldValueTextCtrl;
wxStaticText* textSizeLabel; wxStaticText* textSizeLabel;
wxTextCtrl* textSizeTextCtrl; wxTextCtrl* textSizeTextCtrl;
wxStaticText* m_staticTextUnitSize;
wxStaticText* posXLabel; wxStaticText* posXLabel;
wxTextCtrl* posXTextCtrl; wxTextCtrl* posXTextCtrl;
wxStaticText* m_staticTextUnitPosX;
wxStaticText* posYLabel; wxStaticText* posYLabel;
wxTextCtrl* posYTextCtrl; wxTextCtrl* posYTextCtrl;
wxStaticText* m_staticTextUnitPosY;
wxStdDialogButtonSizer* stdDialogButtonSizer; wxStdDialogButtonSizer* stdDialogButtonSizer;
wxButton* stdDialogButtonSizerOK; wxButton* stdDialogButtonSizerOK;
wxButton* stdDialogButtonSizerCancel; wxButton* stdDialogButtonSizerCancel;
@ -81,7 +86,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
public: public:
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 700,521 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 700,496 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP();
}; };

View File

@ -140,7 +140,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
break; break;
} }
int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width const int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width
int max_len = 0; int max_len = 0;
@ -194,7 +194,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
m_TextStyle->SetSelection( style ); m_TextStyle->SetSelection( style );
wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) ); wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) );
msg = _( "H" ) + units + _( " x W" ) + units; msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) );
m_staticSizeUnits->SetLabel( msg ); m_staticSizeUnits->SetLabel( msg );
msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->GetSize().x ); msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->GetSize().x );

View File

@ -34,8 +34,8 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN
/*****************************************************************************************/ /*****************************************************************************************/
{ {
private: private:
LIB_EDIT_FRAME* m_Parent; LIB_EDIT_FRAME* m_parent;
LIB_COMPONENT* m_LibEntry; LIB_COMPONENT* m_libEntry;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
/// a copy of the edited component's LIB_FIELDs /// a copy of the edited component's LIB_FIELDs
@ -64,10 +64,10 @@ private:
int getSelectedFieldNdx(); int getSelectedFieldNdx();
/** /**
* Function InitBuffers * Function initBuffers
* sets up to edit the given component. * sets up to edit the given component.
*/ */
void InitBuffers(); void initBuffers();
/** /**
* Function findField * Function findField
@ -133,8 +133,8 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/ /***********************************************************************/
{ {
m_Parent = aParent; m_parent = aParent;
m_LibEntry = aLibEntry; m_libEntry = aLibEntry;
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
@ -163,20 +163,11 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event
columnLabel.SetText( _( "Value" ) ); columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel ); fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit ); m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
textSizeLabel->SetLabel( label ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
label = _( "Pos " ); initBuffers();
label += _( "X" );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
InitBuffers();
copySelectedFieldToPanel(); copySelectedFieldToPanel();
stdDialogButtonSizerOK->SetDefault(); stdDialogButtonSizerOK->SetDefault();
@ -237,7 +228,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
* or root alias of the component */ * or root alias of the component */
wxString newvalue = m_FieldsBuf[VALUE].GetText(); wxString newvalue = m_FieldsBuf[VALUE].GetText();
if( m_LibEntry->HasAlias( newvalue ) && !m_LibEntry->GetAlias( newvalue )->IsRoot() ) if( m_libEntry->HasAlias( newvalue ) && !m_libEntry->GetAlias( newvalue )->IsRoot() )
{ {
wxString msg; wxString msg;
msg.Printf( _( "A new name is entered for this component\n\ msg.Printf( _( "A new name is entered for this component\n\
@ -249,7 +240,7 @@ An alias %s already exists!\nCannot update this component" ),
/* End unused code */ /* End unused code */
/* save old cmp in undo list */ /* save old cmp in undo list */
m_Parent->SaveCopyInUndoList( m_LibEntry, IS_CHANGED ); m_parent->SaveCopyInUndoList( m_libEntry, IS_CHANGED );
// delete any fields with no name or no value before we copy all of m_FieldsBuf // delete any fields with no name or no value before we copy all of m_FieldsBuf
// back into the component // back into the component
@ -274,12 +265,12 @@ An alias %s already exists!\nCannot update this component" ),
#endif #endif
// copy all the fields back, fully replacing any previous fields // copy all the fields back, fully replacing any previous fields
m_LibEntry->SetFields( m_FieldsBuf ); m_libEntry->SetFields( m_FieldsBuf );
// We need to keep the name and the value the same at the moment! // We need to keep the name and the value the same at the moment!
SetName( m_LibEntry->GetValueField().GetText() ); SetName( m_libEntry->GetValueField().GetText() );
m_Parent->OnModify(); m_parent->OnModify();
EndModal( 0 ); EndModal( 0 );
} }
@ -445,13 +436,11 @@ LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aField
} }
/***********************************************************/ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers()
/***********************************************************/
{ {
LIB_FIELDS cmpFields; LIB_FIELDS cmpFields;
m_LibEntry->GetFields( cmpFields ); m_libEntry->GetFields( cmpFields );
#if defined(DEBUG) #if defined(DEBUG)
for( unsigned i=0; i<cmpFields.size(); ++i ) for( unsigned i=0; i<cmpFields.size(); ++i )
@ -492,7 +481,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers()
// Now copy in the template fields, in the order that they are present in the // Now copy in the template fields, in the order that they are present in the
// template field editor UI. // template field editor UI.
const TEMPLATE_FIELDNAMES& tfnames = const TEMPLATE_FIELDNAMES& tfnames =
((SCH_EDIT_FRAME*)m_Parent->GetParent())->GetTemplateFieldNames(); ((SCH_EDIT_FRAME*)m_parent->GetParent())->GetTemplateFieldNames();
for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it ) for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
{ {
@ -661,7 +650,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) ); textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
wxPoint coord = field.GetPosition(); wxPoint coord = field.GetTextPosition();
wxPoint zero; wxPoint zero;
// If the field value is empty and the position is at relative zero, we set the // If the field value is empty and the position is at relative zero, we set the
@ -672,8 +661,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
{ {
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT ); rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
coord.x = m_FieldsBuf[REFERENCE].GetPosition().x + (fieldNdx - MANDATORY_FIELDS + 1) * 100; coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x +
coord.y = m_FieldsBuf[REFERENCE].GetPosition().y + (fieldNdx - MANDATORY_FIELDS + 1) * 100; (fieldNdx - MANDATORY_FIELDS + 1) * 100;
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y +
(fieldNdx - MANDATORY_FIELDS + 1) * 100;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
// That is ok, we basically don't want all the new empty fields on // That is ok, we basically don't want all the new empty fields on
@ -761,7 +752,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
// and the screen axis is top to bottom: we must change the y coord sign for editing // and the screen axis is top to bottom: we must change the y coord sign for editing
NEGATE( pos.y ); NEGATE( pos.y );
field.SetPosition( pos ); field.SetTextPosition( pos );
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -16,39 +16,40 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL ); mainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* fieldsSizer; wxBoxSizer* bSizerFieldsSetup;
fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); bSizerFieldsSetup = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* gridStaticBoxSizer; wxBoxSizer* bSizerFiledsList;
gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); bSizerFiledsList = new wxBoxSizer( wxVERTICAL );
fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES ); fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
fieldListCtrl->SetMinSize( wxSize( 220,-1 ) ); fieldListCtrl->SetMinSize( wxSize( 220,-1 ) );
gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); bSizerFiledsList->Add( fieldListCtrl, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );
addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 );
addFieldButton->SetToolTip( _("Add a new custom field") ); addFieldButton->SetToolTip( _("Add a new custom field") );
gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( addFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 );
deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); deleteFieldButton->SetToolTip( _("Delete one of the optional fields") );
gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( deleteFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); moveUpButton->SetToolTip( _("Move the selected optional fields up one position") );
gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); bSizerFiledsList->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 );
fieldsSizer->Add( gridStaticBoxSizer, 5, wxEXPAND|wxRIGHT, 8 );
bSizerFieldsSetup->Add( bSizerFiledsList, 1, wxEXPAND, 5 );
wxBoxSizer* fieldEditBoxSizer; wxBoxSizer* fieldEditBoxSizer;
fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* optionsSizer; wxBoxSizer* bSizerJustify;
optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Text Justification:") ), wxHORIZONTAL ); bSizerJustify = new wxBoxSizer( wxHORIZONTAL );
wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") }; wxString m_FieldHJustifyCtrlChoices[] = { _("Left"), _("Center"), _("Right") };
int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString );
@ -56,7 +57,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
m_FieldHJustifyCtrl->SetSelection( 1 ); m_FieldHJustifyCtrl->SetSelection( 1 );
m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") );
optionsSizer->Add( m_FieldHJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT, 8 ); bSizerJustify->Add( m_FieldHJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") }; wxString m_FieldVJustifyCtrlChoices[] = { _("Bottom"), _("Center"), _("Top") };
int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString );
@ -64,35 +65,38 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
m_FieldVJustifyCtrl->SetSelection( 0 ); m_FieldVJustifyCtrl->SetSelection( 0 );
m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") );
optionsSizer->Add( m_FieldVJustifyCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 8 ); bSizerJustify->Add( m_FieldVJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
fieldEditBoxSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxEXPAND|wxBOTTOM, 5 );
fieldEditBoxSizer->Add( bSizerJustify, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bSizerAspect;
bSizerAspect = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* visibilitySizer; wxStaticBoxSizer* visibilitySizer;
visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxVERTICAL );
wxBoxSizer* bShowRotateSizer;
bShowRotateSizer = new wxBoxSizer( wxVERTICAL );
showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
showCheckBox->SetToolTip( _("Check if you want this field visible") ); showCheckBox->SetToolTip( _("Check if you want this field visible") );
bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); visibilitySizer->Add( showCheckBox, 0, wxALL, 5 );
rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 );
rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") );
bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); visibilitySizer->Add( rotateCheckBox, 0, wxALL, 5 );
visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 );
bSizerAspect->Add( visibilitySizer, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString ); int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString );
m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS );
m_StyleRadioBox->SetSelection( 1 ); m_StyleRadioBox->SetSelection( 0 );
visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerAspect->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( bSizerAspect, 0, wxEXPAND|wxTOP, 5 );
wxBoxSizer* fieldNameBoxSizer; wxBoxSizer* fieldNameBoxSizer;
fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL );
@ -102,10 +106,12 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 );
fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldNameTextCtrl->SetMaxLength( 0 );
fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* fieldTextBoxSizer; wxBoxSizer* fieldTextBoxSizer;
@ -116,60 +122,71 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 );
fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldValueTextCtrl->SetMaxLength( 0 );
fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") );
fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 );
fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 ); fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* textSizeBoxSizer; wxFlexGridSizer* fgSizerPosSize;
textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); fgSizerPosSize = new wxFlexGridSizer( 3, 3, 0, 0 );
fgSizerPosSize->AddGrowableCol( 1 );
fgSizerPosSize->SetFlexibleDirection( wxBOTH );
fgSizerPosSize->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
textSizeLabel->Wrap( -1 ); textSizeLabel->Wrap( -1 );
textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 ); fgSizerPosSize->Add( textSizeLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
textSizeTextCtrl->SetMaxLength( 0 );
textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") ); textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") );
textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( textSizeTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); m_staticTextUnitSize = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitSize->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* positionBoxSizer; posXLabel = new wxStaticText( this, wxID_ANY, _("PosX"), wxDefaultPosition, wxDefaultSize, 0 );
positionBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* posXBoxSizer;
posXBoxSizer = new wxBoxSizer( wxVERTICAL );
posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 );
posXLabel->Wrap( -1 ); posXLabel->Wrap( -1 );
posXBoxSizer->Add( posXLabel, 0, 0, 5 ); fgSizerPosSize->Add( posXLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); posXTextCtrl->SetMaxLength( 0 );
fgSizerPosSize->Add( posXTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); m_staticTextUnitPosX = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitPosX->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitPosX, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* posYBoxSizer; posYLabel = new wxStaticText( this, wxID_ANY, _("PosY"), wxDefaultPosition, wxDefaultSize, 0 );
posYBoxSizer = new wxBoxSizer( wxVERTICAL );
posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 );
posYLabel->Wrap( -1 ); posYLabel->Wrap( -1 );
posYBoxSizer->Add( posYLabel, 0, 0, 5 ); fgSizerPosSize->Add( posYLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
posYTextCtrl->SetMaxLength( 0 );
posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") );
posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); fgSizerPosSize->Add( posYTextCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); m_staticTextUnitPosY = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextUnitPosY->Wrap( -1 );
fgSizerPosSize->Add( m_staticTextUnitPosY, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 );
fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); fieldEditBoxSizer->Add( fgSizerPosSize, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
mainSizer->Add( fieldsSizer, 1, wxEXPAND|wxALL, 5 );
bSizerFieldsSetup->Add( fieldEditBoxSizer, 0, wxEXPAND, 5 );
mainSizer->Add( bSizerFieldsSetup, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
stdDialogButtonSizer = new wxStdDialogButtonSizer(); stdDialogButtonSizer = new wxStdDialogButtonSizer();
stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); stdDialogButtonSizerOK = new wxButton( this, wxID_OK );
@ -177,8 +194,10 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL ); stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL );
stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel ); stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel );
stdDialogButtonSizer->Realize(); stdDialogButtonSizer->Realize();
mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 );
this->SetSizer( mainSizer ); this->SetSizer( mainSizer );
this->Layout(); this->Layout();

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 30 2011) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -12,18 +12,19 @@
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/string.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/string.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/statbox.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -52,10 +53,14 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog
wxTextCtrl* fieldValueTextCtrl; wxTextCtrl* fieldValueTextCtrl;
wxStaticText* textSizeLabel; wxStaticText* textSizeLabel;
wxTextCtrl* textSizeTextCtrl; wxTextCtrl* textSizeTextCtrl;
wxStaticText* m_staticTextUnitSize;
wxStaticText* posXLabel; wxStaticText* posXLabel;
wxTextCtrl* posXTextCtrl; wxTextCtrl* posXTextCtrl;
wxStaticText* m_staticTextUnitPosX;
wxStaticText* posYLabel; wxStaticText* posYLabel;
wxTextCtrl* posYTextCtrl; wxTextCtrl* posYTextCtrl;
wxStaticText* m_staticTextUnitPosY;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* stdDialogButtonSizer; wxStdDialogButtonSizer* stdDialogButtonSizer;
wxButton* stdDialogButtonSizerOK; wxButton* stdDialogButtonSizerOK;
wxButton* stdDialogButtonSizerCancel; wxButton* stdDialogButtonSizerCancel;
@ -73,7 +78,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog
public: public:
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 615,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 615,456 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE(); ~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE();
}; };

View File

@ -54,7 +54,7 @@ DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* aSchFrame,
Init(); Init();
msg = _( "from " ) + wxGetApp().GetCurrentOptionFile(); msg.Printf( _( "from <%s>" ), GetChars( wxGetApp().GetCurrentOptionFile() ) );
SetTitle( msg ); SetTitle( msg );
if( GetSizer() ) if( GetSizer() )

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/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -16,14 +16,21 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
wxBoxSizer* bMainSizer; wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL ); bMainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbLibsChoiceSizer; wxBoxSizer* bSizerUpper;
sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component library files") ), wxHORIZONTAL ); bSizerUpper = new wxBoxSizer( wxVERTICAL );
m_staticTextLibsList = new wxStaticText( this, wxID_ANY, _("Component library files"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextLibsList->Wrap( -1 );
bSizerUpper->Add( m_staticTextLibsList, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerLibsChoice;
bSizerLibsChoice = new wxBoxSizer( wxHORIZONTAL );
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE ); m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Eeschema.\nThe order of this list is important:\nEeschema searchs for a given component using this list order priority.") ); m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Eeschema.\nThe order of this list is important:\nEeschema searchs for a given component using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 400,250 ) ); m_ListLibr->SetMinSize( wxSize( 400,250 ) );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerLibsChoice->Add( m_ListLibr, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bRightSizer; wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL ); bRightSizer = new wxBoxSizer( wxVERTICAL );
@ -49,18 +56,30 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
m_buttonDown = new wxButton( this, wxID_ANY, _("Down"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonDown = new wxButton( this, wxID_ANY, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonDown, 0, wxALL|wxEXPAND, 5 ); bRightSizer->Add( m_buttonDown, 0, wxALL|wxEXPAND, 5 );
sbLibsChoiceSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 2, wxALL|wxEXPAND, 5 ); bSizerLibsChoice->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User defined search path") ), wxHORIZONTAL ); bSizerUpper->Add( bSizerLibsChoice, 1, wxEXPAND, 5 );
bMainSizer->Add( bSizerUpper, 2, wxEXPAND, 5 );
wxBoxSizer* bSizerMiddle;
bSizerMiddle = new wxBoxSizer( wxVERTICAL );
m_staticTextPaths = new wxStaticText( this, wxID_ANY, _("User defined search path"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPaths->Wrap( -1 );
bSizerMiddle->Add( m_staticTextPaths, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerPathsChoice;
bSizerPathsChoice = new wxBoxSizer( wxHORIZONTAL );
m_listUserPaths = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE ); m_listUserPaths = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is higher than default KiCad paths.") ); m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is higher than default KiCad paths.") );
m_listUserPaths->SetMinSize( wxSize( 400,90 ) ); m_listUserPaths->SetMinSize( wxSize( 400,90 ) );
sbSizer4->Add( m_listUserPaths, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerPathsChoice->Add( m_listUserPaths, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bUserPathsButtonsSizer; wxBoxSizer* bUserPathsButtonsSizer;
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL ); bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
@ -74,19 +93,29 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
m_buttonRemovePath = new wxButton( this, wxID_REMOVE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonRemovePath = new wxButton( this, wxID_REMOVE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL|wxEXPAND, 5 ); bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL|wxEXPAND, 5 );
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bMainSizer->Add( sbSizer4, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerPathsChoice->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxStaticBoxSizer* sbLibPathSizer;
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Current search path list") ), wxVERTICAL ); bSizerMiddle->Add( bSizerPathsChoice, 1, wxEXPAND, 5 );
bMainSizer->Add( bSizerMiddle, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerLower;
bSizerLower = new wxBoxSizer( wxVERTICAL );
m_staticTextPathlist = new wxStaticText( this, wxID_ANY, _("Current search path list"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPathlist->Wrap( -1 );
bSizerLower->Add( m_staticTextPathlist, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB ); m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB );
m_DefaultLibraryPathslistBox->SetToolTip( _("System and user paths used to search and load library files and component doc files.\nSorted by decreasing priority order.") ); m_DefaultLibraryPathslistBox->SetToolTip( _("System and user paths used to search and load library files and component doc files.\nSorted by decreasing priority order.") );
sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 1, wxALL|wxEXPAND, 5 ); bSizerLower->Add( m_DefaultLibraryPathslistBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbLibPathSizer, 1, wxALL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
bMainSizer->Add( bSizerLower, 1, wxEXPAND, 5 );
m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline3, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bMainSizer->Add( m_staticline3, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
@ -97,8 +126,10 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize(); m_sdbSizer1->Realize();
bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
this->Layout(); this->Layout();
bMainSizer->Fit( this ); bMainSizer->Fit( this );

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,25 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_eeschema_config_fbp__ #ifndef __DIALOG_EESCHEMA_CONFIG_FBP_H__
#define __dialog_eeschema_config_fbp__ #define __DIALOG_EESCHEMA_CONFIG_FBP_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/listbox.h> #include <wx/stattext.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/listbox.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/statline.h> #include <wx/statline.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -38,19 +39,22 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
ID_REMOVE_LIB, ID_REMOVE_LIB,
ID_LIB_PATH_SEL, ID_LIB_PATH_SEL,
wxID_INSERT_PATH, wxID_INSERT_PATH,
wxID_REMOVE_PATH, wxID_REMOVE_PATH
}; };
wxStaticText* m_staticTextLibsList;
wxListBox* m_ListLibr; wxListBox* m_ListLibr;
wxButton* m_buttonAddLib; wxButton* m_buttonAddLib;
wxButton* m_buttonIns; wxButton* m_buttonIns;
wxButton* m_buttonRemoveLib; wxButton* m_buttonRemoveLib;
wxButton* m_buttonUp; wxButton* m_buttonUp;
wxButton* m_buttonDown; wxButton* m_buttonDown;
wxStaticText* m_staticTextPaths;
wxListBox* m_listUserPaths; wxListBox* m_listUserPaths;
wxButton* m_buttonAddPath; wxButton* m_buttonAddPath;
wxButton* m_buttonInsPath; wxButton* m_buttonInsPath;
wxButton* m_buttonRemovePath; wxButton* m_buttonRemovePath;
wxStaticText* m_staticTextPathlist;
wxListBox* m_DefaultLibraryPathslistBox; wxListBox* m_DefaultLibraryPathslistBox;
wxStaticLine* m_staticline3; wxStaticLine* m_staticline3;
@ -77,4 +81,4 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
}; };
#endif //__dialog_eeschema_config_fbp__ #endif //__DIALOG_EESCHEMA_CONFIG_FBP_H__

View File

@ -44,7 +44,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
m_plotOriginOpt->SetSelection( 0 ); m_plotOriginOpt->SetSelection( 0 );
m_paperHPGLSizer->Add( m_plotOriginOpt, 0, wxALL, 5 ); m_paperHPGLSizer->Add( m_plotOriginOpt, 0, wxALL, 5 );
m_penHPLGWidthTitle = new wxStaticText( this, wxID_ANY, _("Pen Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_penHPLGWidthTitle = new wxStaticText( this, wxID_ANY, _("Pen width"), wxDefaultPosition, wxDefaultSize, 0 );
m_penHPLGWidthTitle->Wrap( -1 ); m_penHPLGWidthTitle->Wrap( -1 );
m_paperHPGLSizer->Add( m_penHPLGWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_paperHPGLSizer->Add( m_penHPLGWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
@ -67,7 +67,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
wxStaticBoxSizer* sbSizerPlotFormat; wxStaticBoxSizer* sbSizerPlotFormat;
sbSizerPlotFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General Options") ), wxVERTICAL ); sbSizerPlotFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General Options") ), wxVERTICAL );
m_defaultLineWidthTitle = new wxStaticText( this, wxID_ANY, _("Default Line Thickness:"), wxDefaultPosition, wxDefaultSize, 0 ); m_defaultLineWidthTitle = new wxStaticText( this, wxID_ANY, _("Default line thickness"), wxDefaultPosition, wxDefaultSize, 0 );
m_defaultLineWidthTitle->Wrap( -1 ); m_defaultLineWidthTitle->Wrap( -1 );
sbSizerPlotFormat->Add( m_defaultLineWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbSizerPlotFormat->Add( m_defaultLineWidthTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );

View File

@ -45,7 +45,7 @@
<property name="size">-1,-1</property> <property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Plot</property> <property name="title">Plot Schematic</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
@ -507,7 +507,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Pen Width:</property> <property name="label">Pen width</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
@ -787,7 +787,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Default Line Thickness:</property> <property name="label">Default line thickness</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>

View File

@ -77,7 +77,7 @@ class DIALOG_PLOT_SCHEMATIC_BASE : public DIALOG_SHIM
public: public:
DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot Schematic"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PLOT_SCHEMATIC_BASE(); ~DIALOG_PLOT_SCHEMATIC_BASE();
}; };

View File

@ -85,7 +85,7 @@ static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosit
dirty.Inflate( 4 ); // Give a margin dirty.Inflate( 4 ); // Give a margin
aPanel->SetMouseCapture( NULL, NULL ); // Avoid loop in redraw panel aPanel->SetMouseCapture( NULL, NULL ); // Avoid loop in redraw panel
int flgs = image->GetFlags(); STATUS_FLAGS flgs = image->GetFlags();
image->ClearFlags(); image->ClearFlags();
aPanel->RefreshDrawingRect( dirty ); aPanel->RefreshDrawingRect( dirty );
image->SetFlags( flgs ); image->SetFlags( flgs );

View File

@ -68,12 +68,11 @@ void SCH_EDIT_FRAME::LoadLibraries( void )
} }
// Loaded library statusbar message // Loaded library statusbar message
msg = _( "Library " ) + tmp;
fn = tmp; fn = tmp;
if( CMP_LIBRARY::AddLibrary( fn, errMsg ) ) if( CMP_LIBRARY::AddLibrary( fn, errMsg ) )
{ {
msg += _( " loaded" ); msg.Printf( _( "Library <%s> loaded" ), GetChars( tmp ) );
sortOrder.Add( fn.GetName() ); sortOrder.Add( fn.GetName() );
} }
else else
@ -84,7 +83,7 @@ void SCH_EDIT_FRAME::LoadLibraries( void )
GetChars( fn.GetFullPath() ), GetChars( fn.GetFullPath() ),
GetChars( errMsg ) ); GetChars( errMsg ) );
DisplayError( this, prompt ); DisplayError( this, prompt );
msg += _( " error!" ); msg.Printf( _( "Library <%s> error!" ), GetChars( tmp ) );
} }
PrintMsg( msg ); PrintMsg( msg );

View File

@ -118,7 +118,7 @@ bool EDA_APP::OnInit()
// Give a default colour for all layers // Give a default colour for all layers
// (actual color will beinitialized by config) // (actual color will beinitialized by config)
for( int ii = 0; ii < MAX_LAYERS; ii++ ) for( int ii = 0; ii < NB_SCH_LAYERS; ii++ )
SetLayerColor( DARKGRAY, ii ); SetLayerColor( DARKGRAY, ii );
// read current setup and reopen last directory if no filename to open in // read current setup and reopen last directory if no filename to open in

View File

@ -53,7 +53,7 @@
#define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings. #define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
static EDA_COLOR_T s_layerColor[MAX_LAYERS]; static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS];
// The width to draw busses that do not have a specific width // The width to draw busses that do not have a specific width
static int s_defaultBusThickness; static int s_defaultBusThickness;
@ -65,7 +65,7 @@ int GetDefaultBusThickness()
void SetDefaultBusThickness( int aThickness) void SetDefaultBusThickness( int aThickness)
{ {
if( aThickness >=1 ) if( aThickness >= 1 )
s_defaultBusThickness = aThickness; s_defaultBusThickness = aThickness;
else else
s_defaultBusThickness = 1; s_defaultBusThickness = 1;
@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness)
s_drawDefaultLineThickness = 1; s_drawDefaultLineThickness = 1;
} }
EDA_COLOR_T ReturnLayerColor( int aLayer ) EDA_COLOR_T GetLayerColor( LayerNumber aLayer )
{ {
return s_layerColor[aLayer]; return s_layerColor[aLayer];
} }
@ -460,80 +460,77 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ), m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
(int*)&g_UserUnit, MILLIMETRES ) ); (int*)&g_UserUnit, MILLIMETRES ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorWireEx" ),
&s_layerColor[LAYER_WIRE], &s_layerColor[LAYER_WIRE],
GREEN ) ); GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBus" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBusEx" ),
&s_layerColor[LAYER_BUS], &s_layerColor[LAYER_BUS],
BLUE ) ); BLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConn" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConnEx" ),
&s_layerColor[LAYER_JUNCTION], &s_layerColor[LAYER_JUNCTION],
GREEN ) ); GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLlab" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLLabelEx" ),
&s_layerColor[LAYER_LOCLABEL], &s_layerColor[LAYER_LOCLABEL],
BLACK ) ); BLACK ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHlab" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHLabelEx" ),
&s_layerColor[LAYER_HIERLABEL], &s_layerColor[LAYER_HIERLABEL],
BROWN ) ); BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGbllab" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGLabelEx" ),
&s_layerColor[LAYER_GLOBLABEL], &s_layerColor[LAYER_GLOBLABEL],
RED ) ); RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinF" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNumEx" ),
&s_layerColor[LAYER_PINFUN],
MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColPinN" ),
&s_layerColor[LAYER_PINNUM], &s_layerColor[LAYER_PINNUM],
RED ) ); RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPNam" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNameEx" ),
&s_layerColor[LAYER_PINNAM], &s_layerColor[LAYER_PINNAM],
CYAN ) ); CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorField" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorFieldEx" ),
&s_layerColor[LAYER_FIELDS], &s_layerColor[LAYER_FIELDS],
MAGENTA ) ); MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorRef" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorReferenceEx" ),
&s_layerColor[LAYER_REFERENCEPART], &s_layerColor[LAYER_REFERENCEPART],
CYAN ) ); CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValue" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValueEx" ),
&s_layerColor[LAYER_VALUEPART], &s_layerColor[LAYER_VALUEPART],
CYAN ) ); CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNote" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoteEx" ),
&s_layerColor[LAYER_NOTES], &s_layerColor[LAYER_NOTES],
LIGHTBLUE ) ); LIGHTBLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBody" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyEx" ),
&s_layerColor[LAYER_DEVICE], &s_layerColor[LAYER_DEVICE],
RED ) ); RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBg" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBgEx" ),
&s_layerColor[LAYER_DEVICE_BACKGROUND], &s_layerColor[LAYER_DEVICE_BACKGROUND],
LIGHTYELLOW ) ); LIGHTYELLOW ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetN" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetNameEx" ),
&s_layerColor[LAYER_NETNAM], &s_layerColor[LAYER_NETNAM],
DARKGRAY ) ); DARKGRAY ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPin" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinEx" ),
&s_layerColor[LAYER_PIN], &s_layerColor[LAYER_PIN],
RED ) ); RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheet" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetEx" ),
&s_layerColor[LAYER_SHEET], &s_layerColor[LAYER_SHEET],
MAGENTA ) ); MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
wxT( "ColorSheetFileName" ), wxT( "ColorSheetFileNameEx" ),
&s_layerColor[LAYER_SHEETFILENAME], &s_layerColor[LAYER_SHEETFILENAME],
BROWN ) ); BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetName" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetNameEx" ),
&s_layerColor[LAYER_SHEETNAME], &s_layerColor[LAYER_SHEETNAME],
CYAN ) ); CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLab" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLabelEx" ),
&s_layerColor[LAYER_SHEETLABEL], &s_layerColor[LAYER_SHEETLABEL],
BROWN ) ); BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoCo" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoConnectEx" ),
&s_layerColor[LAYER_NOCONNECT], &s_layerColor[LAYER_NOCONNECT],
BLUE ) ); BLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcW" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcWEx" ),
&s_layerColor[LAYER_ERC_WARN], &s_layerColor[LAYER_ERC_WARN],
GREEN ) ); GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcE" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcEEx" ),
&s_layerColor[LAYER_ERC_ERR], &s_layerColor[LAYER_ERC_ERR],
RED ) ); RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGrid" ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGridEx" ),
&s_layerColor[LAYER_GRID], &s_layerColor[LAYER_GRID],
DARKGRAY ) ); DARKGRAY ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ), m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
@ -558,7 +555,7 @@ void SCH_EDIT_FRAME::LoadSettings()
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() ); wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
// This is required until someone gets rid of the global variable s_layerColor. // This is required until someone gets rid of the global variable s_layerColor.
m_GridColor = ReturnLayerColor( LAYER_GRID ); m_GridColor = GetLayerColor( LAYER_GRID );
SetDefaultBusThickness( cfg->Read( DefaultBusWidthEntry, 12l ) ); SetDefaultBusThickness( cfg->Read( DefaultBusWidthEntry, 12l ) );
SetDefaultLineThickness( cfg->Read( DefaultDrawLineWidthEntry, 6l ) ); SetDefaultLineThickness( cfg->Read( DefaultDrawLineWidthEntry, 6l ) );

View File

@ -336,7 +336,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
} }
// Reloading configuration. // Reloading configuration.
msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd(); msg.Printf( _( "Ready\nWorking dir: <%s>\n" ), GetChars( wxGetCwd() ) );
PrintMsg( msg ); PrintMsg( msg );
LoadProjectFile( wxEmptyString, false ); LoadProjectFile( wxEmptyString, false );

View File

@ -122,7 +122,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
wxPoint pos, curpos; wxPoint pos, curpos;
bool centerAndRedraw = false; bool centerAndRedraw = false;
bool notFound = true; bool notFound = true;
wxString msg;
LIB_PIN* pin; LIB_PIN* pin;
SCH_SHEET_LIST sheetList; SCH_SHEET_LIST sheetList;
@ -236,28 +235,29 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
/* Print diag */ /* Print diag */
wxString msg_item; wxString msg_item;
msg = aReference; wxString msg;
switch( aSearchType ) switch( aSearchType )
{ {
default: default:
case FIND_COMPONENT_ONLY: // Find component only case FIND_COMPONENT_ONLY: // Find component only
msg_item = _( "component" );
break; break;
case FIND_PIN: // find a pin case FIND_PIN: // find a pin
msg_item = _( "Pin " ) + aSearchText; msg_item.Printf( _( "pin %s" ), GetChars( aSearchText ) );
break; break;
case FIND_REFERENCE: // find reference case FIND_REFERENCE: // find reference
msg_item = _( "Ref " ) + aSearchText; msg_item.Printf( _( "reference %s" ), GetChars( aSearchText ) );
break; break;
case FIND_VALUE: // find value case FIND_VALUE: // find value
msg_item = _( "Value " ) + aSearchText; msg_item.Printf( _( "value" ), GetChars( aSearchText ) );
break; break;
case FIND_FIELD: // find field. todo case FIND_FIELD: // find field. todo
msg_item = _( "Field " ) + aSearchText; msg_item.Printf( _( "field" ), GetChars( aSearchText ) );
break; break;
} }
@ -265,27 +265,19 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
{ {
if( !notFound ) if( !notFound )
{ {
if( !msg_item.IsEmpty() ) msg.Printf( _( "%s %s found" ),
msg += wxT( " " ) + msg_item; GetChars( aReference ), GetChars( msg_item ) );
msg += _( " found" );
} }
else else
{ {
msg += _( " found" ); msg.Printf( _( "%s found but %s not found" ),
GetChars( aReference ), GetChars( msg_item ) );
if( !msg_item.IsEmpty() )
{
msg += wxT( " but " ) + msg_item + _( " not found" );
}
} }
} }
else else
{ {
if( !msg_item.IsEmpty() ) msg.Printf( _( "Component %s not found" ),
msg += wxT( " " ) + msg_item; GetChars( aReference ) );
msg += _( " not found" );
} }
SetStatusText( msg ); SetStatusText( msg );

View File

@ -18,8 +18,8 @@ class TRANSFORM;
#define SCHEMATIC_HEAD_STRING "Schematic File Version" #define SCHEMATIC_HEAD_STRING "Schematic File Version"
#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers. #define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers
#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */ #define DEFAULT_TEXT_SIZE 50 // Default size for field texts
#define GR_DEFAULT_DRAWMODE GR_COPY #define GR_DEFAULT_DRAWMODE GR_COPY
@ -33,7 +33,6 @@ typedef enum {
LAYER_LOCLABEL, LAYER_LOCLABEL,
LAYER_GLOBLABEL, LAYER_GLOBLABEL,
LAYER_HIERLABEL, LAYER_HIERLABEL,
LAYER_PINFUN,
LAYER_PINNUM, LAYER_PINNUM,
LAYER_PINNAM, LAYER_PINNAM,
LAYER_REFERENCEPART, LAYER_REFERENCEPART,
@ -52,12 +51,15 @@ typedef enum {
LAYER_ERC_ERR, LAYER_ERC_ERR,
LAYER_DEVICE_BACKGROUND, LAYER_DEVICE_BACKGROUND,
LAYER_GRID, LAYER_GRID,
LAYER_ITEM_SELECTED, NB_SCH_LAYERS
LAYER_INVISIBLE_ITEM,
MAX_LAYER // end of list
} LayerNumber; } LayerNumber;
inline LayerNumber operator++( LayerNumber& a )
{
a = LayerNumber( int( a ) + 1 );
return a;
}
/* Rotation, mirror of graphic items in components bodies are handled by a /* Rotation, mirror of graphic items in components bodies are handled by a
* transform matrix. The default matrix is useful to draw lib entries with * transform matrix. The default matrix is useful to draw lib entries with
@ -67,8 +69,6 @@ typedef enum {
*/ */
extern TRANSFORM DefaultTransform; extern TRANSFORM DefaultTransform;
#define MAX_LAYERS (int) MAX_LAYER
extern wxSize g_RepeatStep; extern wxSize g_RepeatStep;
extern int g_RepeatDeltaLabel; extern int g_RepeatDeltaLabel;
@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness);
int GetDefaultBusThickness(); int GetDefaultBusThickness();
void SetDefaultBusThickness( int aThickness ); void SetDefaultBusThickness( int aThickness );
EDA_COLOR_T ReturnLayerColor( int aLayer ); EDA_COLOR_T GetLayerColor( LayerNumber aLayer );
// Color to draw selected items // Color to draw selected items
EDA_COLOR_T GetItemSelectedColor(); EDA_COLOR_T GetItemSelectedColor();

View File

@ -117,8 +117,8 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
} }
} }
/* Ask for a component name or key words */ // Ask for a component name or key words
msg.Printf( _( "component selection (%d items loaded):" ), CmpCount ); msg.Printf( _( "Component selection (%d items loaded):" ), CmpCount );
DIALOG_GET_COMPONENT dlg( this, aHistoryList, msg, aUseLibBrowser ); DIALOG_GET_COMPONENT dlg( this, aHistoryList, msg, aUseLibBrowser );
@ -360,7 +360,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
if( unit > unitCount ) if( unit > unitCount )
unit = unitCount; unit = unitCount;
int flags = component->GetFlags(); STATUS_FLAGS flags = component->GetFlags();
if( !flags ) // No command in progress: save in undo list if( !flags ) // No command in progress: save in undo list
SaveCopyInUndoList( component, UR_CHANGED ); SaveCopyInUndoList( component, UR_CHANGED );
@ -405,7 +405,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC )
return; return;
} }
int flags = DrawComponent->GetFlags(); STATUS_FLAGS flags = DrawComponent->GetFlags();
if( DrawComponent->GetFlags() ) if( DrawComponent->GetFlags() )
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );

View File

@ -101,7 +101,7 @@ class HIERARCHY_NAVIG_DLG : public wxDialog
{ {
public: public:
SCH_EDIT_FRAME* m_Parent; SCH_EDIT_FRAME* m_Parent;
HIERARCHY_TREE* m_Tree; HIERARCHY_TREE* m_Tree;
int m_nbsheets; int m_nbsheets;
wxDC* m_DC; wxDC* m_DC;

View File

@ -131,7 +131,7 @@ bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
&m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy ); &m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy );
if( cnt < 8 ) if( cnt < 8 )
{ {
aErrorMsg.Printf( _( "arc only had %d parameters of the required 8" ), cnt ); aErrorMsg.Printf( _( "Arc only had %d parameters of the required 8" ), cnt );
return false; return false;
} }
@ -370,12 +370,12 @@ void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 ); aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 );
} }
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, GetPenSize() ); aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, GetPenSize() );
} }
@ -416,7 +416,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
return; return;
wxPoint pos1, pos2, posc; wxPoint pos1, pos2, posc;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color if( aColor < 0 ) // Used normal color or selected color
{ {
@ -452,8 +452,8 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
{ {
GRFilledArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2, GRFilledArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2,
m_Radius, GetPenSize( ), m_Radius, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
} }
else if( fill == FILLED_SHAPE && !aData ) else if( fill == FILLED_SHAPE && !aData )
{ {
@ -574,7 +574,7 @@ wxString LIB_ARC::GetSelectMenuText() const
} }
void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_ARC object." ) ); wxT( "Invalid edit mode for LIB_ARC object." ) );

View File

@ -110,7 +110,7 @@ public:
int GetPenSize() const; int GetPenSize() const;
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );

View File

@ -270,12 +270,12 @@ void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 ); aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 );
} }
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() ); aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
} }
@ -293,7 +293,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint pos1; wxPoint pos1;
std::vector<wxPoint> PolyPointsTraslated; std::vector<wxPoint> PolyPointsTraslated;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
m_PolyPoints = Bezier2Poly( m_BezierPoints[0], m_PolyPoints = Bezier2Poly( m_BezierPoints[0],
m_BezierPoints[1], m_BezierPoints[1],
@ -326,8 +326,8 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( fill == FILLED_WITH_BG_BODYCOLOR ) if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 1, GetPenSize(), &PolyPointsTraslated[0], 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE ) else if( fill == FILLED_SHAPE )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 1, GetPenSize(), color, color ); &PolyPointsTraslated[0], 1, GetPenSize(), color, color );

View File

@ -74,7 +74,7 @@ bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
if( cnt < 6 ) if( cnt < 6 )
{ {
aErrorMsg.Printf( _( "circle only had %d parameters of the required 6" ), cnt ); aErrorMsg.Printf( _( "Circle only had %d parameters of the required 6" ), cnt );
return false; return false;
} }
@ -194,12 +194,12 @@ void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->Circle( pos, m_Radius * 2, FILLED_SHAPE, 0 ); aPlotter->Circle( pos, m_Radius * 2, FILLED_SHAPE, 0 );
} }
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR; bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) ); aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->Circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() ); aPlotter->Circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() );
} }
@ -216,7 +216,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
{ {
wxPoint pos1; wxPoint pos1;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE ); EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color if( aColor < 0 ) // Used normal color or selected color
{ {
@ -237,8 +237,8 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( fill == FILLED_WITH_BG_BODYCOLOR ) if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(), GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE ) else if( fill == FILLED_SHAPE )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, 0, color, color ); GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, 0, color, color );
else else
@ -296,7 +296,7 @@ wxString LIB_CIRCLE::GetSelectMenuText() const
} }
void LIB_CIRCLE::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_CIRCLE object." ) ); wxT( "Invalid edit mode for LIB_CIRCLE object." ) );

View File

@ -71,7 +71,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ); void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );

View File

@ -156,5 +156,5 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
EDA_COLOR_T LIB_ITEM::GetDefaultColor() EDA_COLOR_T LIB_ITEM::GetDefaultColor()
{ {
return ReturnLayerColor( LAYER_DEVICE ); return GetLayerColor( LAYER_DEVICE );
} }

View File

@ -175,7 +175,7 @@ public:
* started. This may or may not be required depending on the item * started. This may or may not be required depending on the item
* being edited and the edit mode. * being edited and the edit mode.
*/ */
virtual void BeginEdit( int aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {} virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {}
/** /**
* Continue an edit in progress at \a aPosition. * Continue an edit in progress at \a aPosition.

View File

@ -149,19 +149,19 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
{ {
if( createLib ) if( createLib )
{ {
msg = fn.GetFullPath() + _( " - OK" ); msg.Printf( _( "<%s> - OK" ), GetChars( fn.GetFullPath() ) );
DisplayInfoMessage( this, _( "This library will not be available \ DisplayInfoMessage( this, _( "This library will not be available \
until it is loaded by Eeschema.\n\nModify the Eeschema library configuration \ until it is loaded by Eeschema.\n\nModify the Eeschema library configuration \
if you want to include it as part of this project." ) ); if you want to include it as part of this project." ) );
} }
else else
{ {
msg = fn.GetFullPath() + _( " - Export OK" ); msg.Printf( _( "<%s> - Export OK" ), GetChars( fn.GetFullPath() ) );
} }
} // Error } // Error
else else
{ {
msg = _( "Error creating " ) + fn.GetFullName(); msg.Printf( _( "Error creating <%s>" ), GetChars( fn.GetFullName() ) );
} }
SetStatusText( msg ); SetStatusText( msg );

View File

@ -523,15 +523,15 @@ EDA_COLOR_T LIB_FIELD::GetDefaultColor()
switch( m_id ) switch( m_id )
{ {
case REFERENCE: case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART ); color = GetLayerColor( LAYER_REFERENCEPART );
break; break;
case VALUE: case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART ); color = GetLayerColor( LAYER_VALUEPART );
break; break;
default: default:
color = ReturnLayerColor( LAYER_FIELDS ); color = GetLayerColor( LAYER_FIELDS );
break; break;
} }
@ -659,7 +659,7 @@ wxString LIB_FIELD::GetSelectMenuText() const
} }
void LIB_FIELD::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Invalid edit mode for LIB_FIELD object." ) ); wxT( "Invalid edit mode for LIB_FIELD object." ) );

View File

@ -207,7 +207,7 @@ public:
EDA_COLOR_T GetDefaultColor(); EDA_COLOR_T GetDefaultColor();
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );

View File

@ -179,7 +179,7 @@ const wxChar* MsgPinElectricType[] =
wxT( "openCol" ), wxT( "openCol" ),
wxT( "openEm" ), wxT( "openEm" ),
wxT( "NotConnected" ), wxT( "NotConnected" ),
wxT( "?????" ) wxT( "???" )
}; };
@ -262,9 +262,7 @@ void LIB_PIN::SetNumber( const wxString& number )
SetPinNumFromString( tmp ); SetPinNumFromString( tmp );
if( m_number != oldNumber ) if( m_number != oldNumber )
{ SetFlags( IS_CHANGED );
m_Flags |= IS_CHANGED;
}
/* Others pin numbers marked by EnableEditMode() are not modified /* Others pin numbers marked by EnableEditMode() are not modified
* because each pin has its own number * because each pin has its own number
@ -437,7 +435,7 @@ void LIB_PIN::SetConversion( int style )
return; return;
m_Convert = style; m_Convert = style;
m_Flags |= IS_CHANGED; SetFlags( IS_CHANGED );
if( style == 0 ) if( style == 0 )
{ {
@ -514,9 +512,9 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
&& !IsNew() && !IsNew()
&& editPinByPin == false && editPinByPin == false
&& enable ) && enable )
pinList[i]->m_Flags |= IS_LINKED | IN_EDIT; pinList[i]->SetFlags( IS_LINKED | IN_EDIT );
else else
pinList[i]->m_Flags &= ~( IS_LINKED | IN_EDIT ); pinList[i]->ClearFlags( IS_LINKED | IN_EDIT );
} }
} }
@ -650,7 +648,7 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
if( aFormatter.Print( 0, "\n" ) < 0 ) if( aFormatter.Print( 0, "\n" ) < 0 )
return false; return false;
m_Flags &= ~IS_CHANGED; ClearFlags( IS_CHANGED );
return true; return true;
} }
@ -862,7 +860,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
int posX = aPinPos.x, posY = aPinPos.y, len = m_length; int posX = aPinPos.x, posY = aPinPos.y, len = m_length;
EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
EDA_COLOR_T color = ReturnLayerColor( LAYER_PIN ); EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
if( aColor < 0 ) // Used normal color or selected color if( aColor < 0 ) // Used normal color or selected color
{ {
@ -1092,9 +1090,9 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
Color = GetItemSelectedColor(); Color = GetItemSelectedColor();
NameColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ? NameColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
ReturnLayerColor( LAYER_PINNAM ) : Color ); GetLayerColor( LAYER_PINNAM ) : Color );
NumColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ? NumColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
ReturnLayerColor( LAYER_PINNUM ) : Color ); GetLayerColor( LAYER_PINNUM ) : Color );
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum( StringPinNum ); ReturnPinStringNum( StringPinNum );
@ -1273,7 +1271,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation ) void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{ {
int MapX1, MapY1, x1, y1; int MapX1, MapY1, x1, y1;
EDA_COLOR_T color = ReturnLayerColor( LAYER_PIN ); EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
aPlotter->SetColor( color ); aPlotter->SetColor( color );
@ -1387,8 +1385,8 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter,
wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize ); wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
/* Get the num and name colors */ /* Get the num and name colors */
NameColor = ReturnLayerColor( LAYER_PINNAM ); NameColor = GetLayerColor( LAYER_PINNAM );
NumColor = ReturnLayerColor( LAYER_PINNUM ); NumColor = GetLayerColor( LAYER_PINNUM );
/* Create the pin num string */ /* Create the pin num string */
ReturnPinStringNum( StringPinNum ); ReturnPinStringNum( StringPinNum );
@ -1854,7 +1852,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), Text, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), Text, DARKGREEN ) );
/* Display pin length */ // Display pin length
Text = ReturnStringFromValue( g_UserUnit, m_length, true ); Text = ReturnStringFromValue( g_UserUnit, m_length, true );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), Text, MAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( _( "Length" ), Text, MAGENTA ) );

View File

@ -36,7 +36,7 @@
#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */ #define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
#define INVERT_PIN_RADIUS 20 /* Radius of inverted pin circle. */ #define INVERT_PIN_RADIUS 30 /* Radius of inverted pin circle. */
#else #else
#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */ #define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */
#endif #endif

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