Commit 2f99ef29 authored by charras's avatar charras

eeschema: code cleaning

parent a178978c
......@@ -14,9 +14,11 @@ set(EESCHEMA_SRCS
bus-wire-junction.cpp
class_drawsheet.cpp
class_hierarchical_PIN_sheet.cpp
class_pin.cpp
class_schematic_items.cpp
class_screen.cpp
class_text-label.cpp
classes_body_items.cpp
cleanup.cpp
component_class.cpp
controle.cpp
......
......@@ -139,8 +139,8 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
pos.x = ptpoly[ii]; pos.y = -ptpoly[ii + 1];
......@@ -577,8 +577,8 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
ptpoly[ii] += offset.x;
......@@ -689,8 +689,8 @@ void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) item )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->PolyList;
int ii, imax = ( (LibDrawPolyline*) item )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) item )->m_PolyList;
for( ii = 0; ii < imax; ii += 2 )
{
SETMIRROR( ptpoly[ii] );
......
/****************************************************************/
/* Headers fo library definition and lib component definitions */
/****************************************************************/
#ifndef CLASS_LIBRARY_H
#define CLASS_LIBRARY_H
/* Types for components in libraries
* components can be a true component or an alias of a true component.
*/
enum LibrEntryType {
ROOT, /* This is a true component standard EDA_LibComponentStruct */
ALIAS /* This is an alias of a true component */
};
/* values for member .m_Options */
enum LibrEntryOptions {
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
ENTRY_POWER // Libentry is a power symbol
};
/******************************/
/* Classe to handle a library */
/******************************/
class LibraryStruct
{
public:
int m_Type; /* type indicator */
wxString m_Name; /* Short Name of the loaded library (without path). */
wxString m_FullFileName; /* Full File Name (with path) of library. */
wxString m_Header; /* first line of loaded library. */
int m_NumOfParts; /* Number of parts this library has. */
PriorQue* m_Entries; /* Parts themselves are saved here. */
LibraryStruct* m_Pnext; /* Point on next lib in chain. */
int m_Modified; /* flag indicateur d'edition */
int m_Size; // Size in bytes (for statistics)
unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions
bool m_IsLibCache; /* False for the "standard" libraries,
* True for the library cache */
public:
LibraryStruct( int type, const wxString& name, const wxString& fullname );
~LibraryStruct();
bool WriteHeader( FILE* file );
bool ReadHeader( FILE* file, int* LineNum );
};
#include "classes_body_items.h"
/* basic class to describe components in libraries (true component or alias), non used directly */
class LibCmpEntry : public EDA_BaseStruct
{
public:
LibrEntryType Type; /* Type = ROOT;
* = ALIAS pour struct LibraryAliasType */
LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE )
wxString m_Doc; /* documentation for info */
wxString m_KeyWord; /* keyword list (used to select a group of components by keyword) */
wxString m_DocFile; /* Associed doc filename */
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
public:
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName );
virtual ~LibCmpEntry();
virtual wxString GetClass() const
{
return wxT( "LibCmpEntry" );
}
bool WriteDescr( FILE* File );
};
/*********************************************/
/* class to handle an usual component in lib */
/*********************************************/
class EDA_LibComponentStruct : public LibCmpEntry
{
public:
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
wxArrayString m_AliasList; /* ALIAS list for the component */
wxArrayString m_FootprintList; /* list of suitable footprint names for the component (wildcard names accepted)*/
int m_UnitCount; /* Units (or sections) per package */
bool m_UnitSelectionLocked; // True if units are differents and their selection is locked
// (i.e. if part A cannot be automatically changed in part B
int m_TextInside; /* if 0: pin name drawn on the pin itself
* if > 0 pin name drawn inside the component,
* with a distance of m_TextInside in mils */
bool m_DrawPinNum;
bool m_DrawPinName;
LibDrawField* Fields; /* Auxiliairy Field list (id = 2 a 11) */
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date
public:
virtual wxString GetClass() const
{
return wxT( "EDA_LibComponentStruct" );
}
EDA_LibComponentStruct( const wxChar* CmpName );
EDA_Rect GetBoundaryBox( int Unit, int Convert ); /* return Box around the part. */
~EDA_LibComponentStruct();
void SortDrawItems();
};
/**************************************************************************/
/* class to handle an alias of an usual component in lib (root component) */
/**************************************************************************/
class EDA_LibCmpAliasStruct : public LibCmpEntry
{
public:
wxString m_RootName; /* Root component Part name */
public:
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName );
~EDA_LibCmpAliasStruct();
virtual wxString GetClass() const
{
return wxT( "EDA_LibCmpAliasStruct" );
}
};
#endif // CLASS_LIBRARY_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -66,8 +66,8 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
return NULL;
}
currentLibraryName = FullLibName;
currentLibraryName = FullLibName;
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName );
Entries = LoadLibraryAux( frame, NewLib, f, &NumOfParts );
......@@ -480,7 +480,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
/* End line or block analysis: test for an error */
if( !Res )
{ /* Something went wrong there. */
Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
*LineNum, currentLibraryName.GetData() );
DisplayError( frame, Msg );
SAFE_DELETE( LibEntry );
......@@ -734,24 +734,24 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
New = Polyl;
if( sscanf( &Line[2], "%d %d %d %d",
&Polyl->n, &Unit, &Convert,
&Polyl->m_CornersCount, &Unit, &Convert,
&Polyl->m_Width ) == 4
&& Polyl->n > 0 )
&& Polyl->m_CornersCount > 0 )
{
Polyl->m_Unit = Unit; Polyl->m_Convert = Convert;
Polyl->PolyList = (int*)
MyZMalloc( sizeof(int) * Polyl->n * 2 );
Polyl->m_PolyList = (int*)
MyZMalloc( sizeof(int) * Polyl->m_CornersCount * 2 );
p = strtok( &Line[2], " \t\n" );
p = strtok( NULL, " \t\n" );
p = strtok( NULL, " \t\n" );
p = strtok( NULL, " \t\n" );
for( i = 0; i < Polyl->n * 2 && !Error; i++ )
for( i = 0; i < Polyl->m_CornersCount * 2 && !Error; i++ )
{
p = strtok( NULL, " \t\n" );
Error = sscanf( p, "%d", &Polyl->PolyList[i] ) != 1;
Error = sscanf( p, "%d", &Polyl->m_PolyList[i] ) != 1;
}
Polyl->m_Fill = NO_FILL;
......
This diff is collapsed.
......@@ -256,7 +256,7 @@ eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au
eda_global LayerStruct g_LayerDescr; /* couleurs des couches */
eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */
#ifdef MAIN /* de l'edition simultan�e des pins de meme coordonn�es */
#ifdef MAIN /* de l'edition simultanee des pins de meme coordonnees */
= FALSE
#endif
;
......@@ -265,6 +265,13 @@ eda_global int g_LibSymbolDefaultLineWidth; /* default line width (in EESCHEMA
eda_global int g_DrawMinimunLineWidth; /* Minimum line (in EESCHEMA units) width used to draw items on screen; 0 = single pixel line width */
eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) width used to Plot items , postscript format */
eda_global int g_ItemSelectetColor // Color to draw selected items
#ifdef MAIN
= BROWN
#endif
;
/* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth")
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth")
......
......@@ -229,12 +229,12 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
DrawEntry = m_Drawings;
if( DrawEntry )
{
xmin = ymin = 0x7FFFFFFF;
xmin = ymin = 0x7FFFFFFF;
xmax = ymax = 0x80000000;
}
else
{
xmin = ymin = -50;
xmin = ymin = -50;
xmax = ymax = 50; // Min size in 1/1000 inch
}
......@@ -337,8 +337,8 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawEntry;
pt = polyline->PolyList;
for( ii = 0; ii < polyline->n; ii++ )
pt = polyline->m_PolyList;
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
{
if( xmin > *pt )
xmin = *pt;
......@@ -353,7 +353,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
}
}
break;
default:
;
}
......@@ -380,7 +380,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
/* a Field is a string linked to a component.
* Unlike a pure graphic text, fields can be used in netlist generation
* and other things.
*
*
* 4 fields have a special meaning:
* REFERENCE
* VALUE
......@@ -739,8 +739,8 @@ LibDrawSegment* LibDrawSegment::GenCopy()
LibDrawPolyline::LibDrawPolyline() : LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE )
{
n = 0;
PolyList = NULL;
m_CornersCount = 0;
m_PolyList = NULL;
m_Fill = NO_FILL;
m_Width = 0;
}
......@@ -754,12 +754,12 @@ LibDrawPolyline* LibDrawPolyline::GenCopy()
int size;
newitem->n = n;
size = sizeof(int) * 2 * n;
newitem->m_CornersCount = m_CornersCount;
size = sizeof(int) * 2 * m_CornersCount;
if( size )
{
newitem->PolyList = (int*) MyMalloc( size );
memcpy( newitem->PolyList, PolyList, size );
newitem->m_PolyList = (int*) MyMalloc( size );
memcpy( newitem->m_PolyList, m_PolyList, size );
}
newitem->m_Pos = m_Pos;
newitem->m_Width = m_Width;
......@@ -780,13 +780,13 @@ void LibDrawPolyline::AddPoint( const wxPoint& point )
{
int allocsize;
n++;
allocsize = 2 * sizeof(int) * n;
if( PolyList == NULL )
PolyList = (int*) MyMalloc( allocsize );
m_CornersCount++;
allocsize = 2 * sizeof(int) * m_CornersCount;
if( m_PolyList == NULL )
m_PolyList = (int*) MyMalloc( allocsize );
else
PolyList = (int*) realloc( PolyList, allocsize );
m_PolyList = (int*) realloc( m_PolyList, allocsize );
PolyList[(n * 2) - 2] = point.x;
PolyList[(n * 2) - 1] = -point.y;
m_PolyList[(m_CornersCount * 2) - 2] = point.x;
m_PolyList[(m_CornersCount * 2) - 1] = -point.y;
}
This diff is collapsed.
......@@ -153,7 +153,7 @@ bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE);
}
else if( (DrawEntry->m_Flags & IS_NEW) )
{
if( ((LibDrawPolyline*)DrawEntry)->n > 2 )
if( ((LibDrawPolyline*)DrawEntry)->m_CornersCount > 2 )
{
msg = AddHotkeyName( _( "Delete Segment " ), s_Libedit_Hokeys_Descr, HK_DELETE_PIN );
ADD_MENUITEM(PopMenu,
......
......@@ -880,8 +880,8 @@ LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
LibDrawPolyline* polyline = (LibDrawPolyline*) DrawItem;
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
break;
ptpoly = polyline->PolyList;
for( ii = polyline->n - 1; ii > 0; ii--, ptpoly += 2 )
ptpoly = polyline->m_PolyList;
for( ii = polyline->m_CornersCount - 1; ii > 0; ii--, ptpoly += 2 )
{
if( IsPointOnSegment( px, py,
ptpoly[0], -ptpoly[1], ptpoly[2], -ptpoly[3], seuil ) )
......
......@@ -20,7 +20,9 @@ OBJECTS = eeschema.o\
cross-probing.o\
setpage.o\
class_schematic_items.o\
classes_body_items.o\
class_drawsheet.o\
class_pin.o\
class_hierarchical_PIN_sheet.o\
class_text-label.o\
component_class.o\
......
......@@ -326,15 +326,15 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->n );
for( ii = 0; ii < polyline->n; ii++ )
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->m_CornersCount );
for( ii = 0; ii < polyline->m_CornersCount; ii++ )
{
Poly[ii * 2] = PartX +
TransMat[0][0] * polyline->PolyList[ii * 2] +
TransMat[0][1] * polyline->PolyList[ii * 2 + 1];
TransMat[0][0] * polyline->m_PolyList[ii * 2] +
TransMat[0][1] * polyline->m_PolyList[ii * 2 + 1];
Poly[ii * 2 + 1] = PartY +
TransMat[1][0] * polyline->PolyList[ii * 2] +
TransMat[1][1] * polyline->PolyList[ii * 2 + 1];
TransMat[1][0] * polyline->m_PolyList[ii * 2] +
TransMat[1][1] * polyline->m_PolyList[ii * 2 + 1];
}
if ( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
......
......@@ -36,7 +36,7 @@ void InstallCmpeditFrame(WinEDA_SchematicFrame * parent, wxPoint & pos,
/**************/
/* EELIBS2.CPP */
/* EELIBS_.CPP */
/**************/
/* Functions common to all EELibs?.c modules: */
......@@ -69,6 +69,14 @@ EDA_LibComponentStruct * Read_Component_Definition(WinEDA_DrawFrame * frame, cha
FILE *f, int *LineNum);
/* Routine to Read a DEF/ENDDEF part entry from given open file. */
/** Function TransformCoordinate
* Calculate the wew coordinate from the old one, according to the transform matrix.
* @param aTransformMatrix = rotation, mirror .. matrix
* @param aPosition = the position to transform
* @return the new coordinate
*/
wxPoint TransformCoordinate( int aTransformMatrix[2][2], wxPoint & aPosition );
LibraryStruct *FindLibrary(const wxString & Name);
int LoadDocLib(WinEDA_DrawFrame * frame, const wxString & FullDocLibName, const wxString & Libname);
PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * library,
......
......@@ -156,11 +156,11 @@ bool LibDrawPolyline::WriteDescr( FILE* ExportFile )
int ii, * ptpoly;
fprintf( ExportFile, "P %d %d %d %d",
n,
m_CornersCount,
m_Unit, m_Convert,
m_Width );
ptpoly = PolyList;
for( ii = n; ii > 0; ii-- )
ptpoly = m_PolyList;
for( ii = m_CornersCount; ii > 0; ii-- )
{
fprintf( ExportFile, " %d %d", *ptpoly, *(ptpoly + 1) );
ptpoly += 2;
......
......@@ -261,9 +261,9 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
LibDrawPolyline* polyline = new LibDrawPolyline();
CurrentDrawItem = polyline;
polyline->n = 2;
polyline->m_CornersCount = 2;
ptpoly = (int*) MyZMalloc( 4 * sizeof(int) );
polyline->PolyList = ptpoly;
polyline->m_PolyList = ptpoly;
ptpoly[0] = ptpoly[2] = GetScreen()->m_Curseur.x;
ptpoly[1] = ptpoly[3] = -( GetScreen()->m_Curseur.y );
polyline->m_Fill = FlSymbol_Fill;
......@@ -444,8 +444,8 @@ void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->n * 2;
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
int dx = mx - ptpoly[0];
int dy = -my - ptpoly[1];
for( ii = 0; ii < imax; ii += 2 )
......@@ -497,8 +497,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
InitPosition.y = *( ( (LibDrawPolyline*) CurrentDrawItem )->PolyList + 1 );
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
InitPosition.y = *( ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList + 1 );
break;
case COMPONENT_LINE_DRAW_TYPE:
......@@ -589,8 +589,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->PolyList;
ptpoly += 2 * ( ( (LibDrawPolyline*) CurrentDrawItem )->n - 1 );
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
ptpoly += 2 * ( ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount - 1 );
ptpoly[0] = mx;
ptpoly[1] = -my;
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
......@@ -827,10 +827,10 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode );
while( Poly->n > 2 ) // First segment is kept, only its end point is changed
while( Poly->m_CornersCount > 2 ) // First segment is kept, only its end point is changed
{
Poly->n--;
ptpoly = Poly->PolyList + ( 2 * (Poly->n - 1) );
Poly->m_CornersCount--;
ptpoly = Poly->m_PolyList + ( 2 * (Poly->m_CornersCount - 1) );
if( (ptpoly[0] != GetScreen()->m_Curseur.x)
|| (ptpoly[1] != -GetScreen()->m_Curseur.y) )
{
......@@ -840,8 +840,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
}
}
int allocsize = 2 * sizeof(int) * Poly->n;
Poly->PolyList = (int*) realloc( Poly->PolyList, allocsize );
int allocsize = 2 * sizeof(int) * Poly->m_CornersCount;
Poly->m_PolyList = (int*) realloc( Poly->m_PolyList, allocsize );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, 0, 0,
CurrentDrawItem, CurrentUnit, g_XorMode );
......
......@@ -398,11 +398,11 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
if( REFSTRUCT->n != CMPSTRUCT->n )
if( REFSTRUCT->m_CornersCount != CMPSTRUCT->m_CornersCount )
return FALSE;
ptref = REFSTRUCT->PolyList;
ptcomp = CMPSTRUCT->PolyList;
for( ii = 2 * REFSTRUCT->n; ii > 0; ii-- )
ptref = REFSTRUCT->m_PolyList;
ptcomp = CMPSTRUCT->m_PolyList;
for( ii = 2 * REFSTRUCT->m_CornersCount; ii > 0; ii-- )
{
if( *ptref != *ptcomp )
return FALSE;
......@@ -495,14 +495,14 @@ void WinEDA_LibeditFrame::PlaceAncre()
case COMPONENT_POLYLINE_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawPolyline*) DrawEntry )
ptsegm = STRUCT->PolyList;
for( ii = STRUCT->n; ii > 0; ii-- )
ptsegm = STRUCT->m_PolyList;
for( ii = STRUCT->m_CornersCount; ii > 0; ii-- )
{
*ptsegm += dx; ptsegm++;
*ptsegm += dy; ptsegm++;
}
break;
default:
;
}
......
......@@ -22,9 +22,9 @@ DEBUG = 0
#Define the wxWidget path (if not found in environment variables):
ifndef WXWIN
ifeq ($(DEBUG), 1)
WXWIN=f:/wxMSW-2.8.8-debug
WXWIN=f:/wxMSW-2.8.9-debug
else
WXWIN=f:/wxMSW-2.8.8
WXWIN=f:/wxMSW-2.8.9-rc1
endif
endif
LIBVERSION = 2.8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment