diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index ac0a31c74d..857ce73a15 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -65,6 +65,8 @@ set(EESCHEMA_SRCS dialog_lib_new_component_base.cpp dialog_print_using_printer_base.cpp dialog_print_using_printer.cpp + dialog_sch_sheet_props.cpp + dialog_sch_sheet_props_base.cpp dialog_SVG_print.cpp dialog_SVG_print_base.cpp edit_component_in_lib.cpp diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 77f5583585..79022c04e5 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -75,7 +75,7 @@ void ReAnnotatePowerSymbolsOnly( void ) LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); - if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) + if( ( Entry == NULL ) || !Entry->isPower() ) continue; //DrawLibItem->ClearAnnotation(sheet); this clears all annotation :( diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index d31bbff2f8..244e766f8d 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -23,34 +23,26 @@ /* class CMP_LIB_ENTRY */ /*********************/ -/* Basic class for library component description - * Not directly used - * Used to create the 2 derived classes : - * - LIB_ALIAS - * - LIB_COMPONENT - */ - -/********************************************************************/ -CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType type, const wxString& name, - CMP_LIBRARY* lib ) : +CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, + CMP_LIBRARY* aLibrary ) : EDA_BaseStruct( LIBCOMPONENT_STRUCT_TYPE ) { - Type = type; - m_Name = name; - m_lib = lib; + type = aType; + name = aName; + library = aLibrary; } -CMP_LIB_ENTRY::CMP_LIB_ENTRY( CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib ) : - EDA_BaseStruct( entry ) +CMP_LIB_ENTRY::CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary ) : + EDA_BaseStruct( aEntry ) { - Type = entry.Type; - m_Name = entry.m_Name; - m_Doc = entry.m_Doc; - m_KeyWord = entry.m_KeyWord; - m_DocFile = entry.m_DocFile; - m_Options = entry.m_Options; - m_lib = lib; + type = aEntry.type; + name = aEntry.name; + description = aEntry.description; + keyWords = aEntry.keyWords; + docFileName = aEntry.docFileName; + options = aEntry.options; + library = aLibrary; } @@ -61,8 +53,8 @@ CMP_LIB_ENTRY::~CMP_LIB_ENTRY() wxString CMP_LIB_ENTRY::GetLibraryName() { - if( m_lib != NULL ) - return m_lib->GetName(); + if( library != NULL ) + return library->GetName(); return wxString( _( "none" ) ); } @@ -78,22 +70,22 @@ wxString CMP_LIB_ENTRY::GetLibraryName() */ bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile ) { - if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() ) + if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() ) return true; - if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name ) ) < 0 ) + if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( name ) ) < 0 ) return false; - if( ! m_Doc.IsEmpty() - && fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 ) + if( ! description.IsEmpty() + && fprintf( aFile, "D %s\n", CONV_TO_UTF8( description ) ) < 0 ) return false; - if( ! m_KeyWord.IsEmpty() - && fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ) < 0 ) + if( ! keyWords.IsEmpty() + && fprintf( aFile, "K %s\n", CONV_TO_UTF8( keyWords ) ) < 0 ) return false; - if( ! m_DocFile.IsEmpty() - && fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 ) + if( ! docFileName.IsEmpty() + && fprintf( aFile, "F %s\n", CONV_TO_UTF8( docFileName ) ) < 0 ) return false; if( fprintf( aFile, "$ENDCMP\n" ) < 0 ) @@ -103,21 +95,21 @@ bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile ) } -bool CMP_LIB_ENTRY::operator==( const wxChar* name ) const +bool CMP_LIB_ENTRY::operator==( const wxChar* aName ) const { - return m_Name.CmpNoCase( name ) == 0; + return name.CmpNoCase( aName ) == 0; } -bool operator<( const CMP_LIB_ENTRY& item1, const CMP_LIB_ENTRY& item2 ) +bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 ) { - return item1.GetName().CmpNoCase( item2.GetName() ) < 0; + return aItem1.GetName().CmpNoCase( aItem2.GetName() ) < 0; } -int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1, const CMP_LIB_ENTRY* LE2 ) +int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem2 ) { - return LE1->GetName().CmpNoCase( LE2->GetName() ); + return aItem1->GetName().CmpNoCase( aItem2->GetName() ); } @@ -134,20 +126,20 @@ int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1, const CMP_LIB_ENTRY* LE2 ) * (like 74LS00, 74HC00 ... and many op amps ) */ -LIB_ALIAS::LIB_ALIAS( const wxString& name, LIB_COMPONENT* root, - CMP_LIBRARY* lib ) : - CMP_LIB_ENTRY( ALIAS, name, lib ) +LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aComponent, + CMP_LIBRARY* aLibrary ) : + CMP_LIB_ENTRY( ALIAS, aName, aLibrary ) { - wxASSERT( root != NULL && root->Type == ROOT ); + wxASSERT( aComponent != NULL && aComponent->isComponent() ); - m_root = root; + root = aComponent; } -LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& alias, CMP_LIBRARY* lib ) : - CMP_LIB_ENTRY( alias ) +LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& aAlias, CMP_LIBRARY* aLibrary ) : + CMP_LIB_ENTRY( aAlias ) { - m_root = alias.m_root; + root = aAlias.root; } @@ -156,11 +148,11 @@ LIB_ALIAS::~LIB_ALIAS() } -void LIB_ALIAS::SetComponent( LIB_COMPONENT* root ) +void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent ) { - wxASSERT( root != NULL && root->Type == ROOT ); + wxASSERT( aComponent != NULL && aComponent->isComponent() ); - m_root = root; + root = aComponent; } @@ -170,13 +162,13 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* root ) /* This is a standard component (in library) */ -LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) : - CMP_LIB_ENTRY( ROOT, name, lib ) +LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : + CMP_LIB_ENTRY( ROOT, aName, aLibrary ) { m_LastDate = 0; - m_UnitCount = 1; + unitCount = 1; m_TextInside = 40; - m_Options = ENTRY_NORMAL; + options = ENTRY_NORMAL; m_UnitSelectionLocked = FALSE; m_DrawPinNum = 1; m_DrawPinName = 1; @@ -185,34 +177,34 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) : * designator field. */ LIB_FIELD* value = new LIB_FIELD( this, VALUE ); - value->m_Text = name; - m_Drawings.push_back( value ); - m_Drawings.push_back( new LIB_FIELD( this, REFERENCE ) ); + value->m_Text = aName; + drawings.push_back( value ); + drawings.push_back( new LIB_FIELD( this, REFERENCE ) ); } -LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib ) : - CMP_LIB_ENTRY( component, lib ) +LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) : + CMP_LIB_ENTRY( aComponent, aLibrary ) { LIB_DRAW_ITEM* newItem; - m_AliasList = component.m_AliasList; - m_FootprintList = component.m_FootprintList; - m_UnitCount = component.m_UnitCount; - m_UnitSelectionLocked = component.m_UnitSelectionLocked; - m_TextInside = component.m_TextInside; - m_DrawPinNum = component.m_DrawPinNum; - m_DrawPinName = component.m_DrawPinName; - m_LastDate = component.m_LastDate; + m_AliasList = aComponent.m_AliasList; + m_FootprintList = aComponent.m_FootprintList; + unitCount = aComponent.unitCount; + m_UnitSelectionLocked = aComponent.m_UnitSelectionLocked; + m_TextInside = aComponent.m_TextInside; + m_DrawPinNum = aComponent.m_DrawPinNum; + m_DrawPinName = aComponent.m_DrawPinName; + m_LastDate = aComponent.m_LastDate; - BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, component.GetDrawItemList() ) + BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, aComponent.GetDrawItemList() ) { if( ( oldItem.m_Flags & IS_NEW ) != 0 ) continue; newItem = oldItem.GenCopy(); newItem->SetParent( this ); - m_Drawings.push_back( newItem ); + drawings.push_back( newItem ); } } @@ -222,20 +214,20 @@ LIB_COMPONENT::~LIB_COMPONENT() } -void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, - const wxPoint& offset, int multi, - int convert, int drawMode, int color, - const int transformMatrix[2][2], - bool showPinText, bool drawFields, - bool onlySelected ) +void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, + const wxPoint& aOffset, int aMulti, + int aConvert, int aDrawMode, int aColor, + const int aTransformMatrix[2][2], + bool aShowPinText, bool aDrawFields, + bool aOnlySelected ) { - BASE_SCREEN* screen = panel->GetScreen(); + BASE_SCREEN* screen = aPanel->GetScreen(); - GRSetDrawMode( dc, drawMode ); + GRSetDrawMode( aDc, aDrawMode ); - BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, drawings ) { - if( onlySelected && drawItem.m_Selected == 0 ) + if( aOnlySelected && drawItem.m_Selected == 0 ) continue; // Do not draw an item while moving (the cursor handler does that) @@ -243,85 +235,85 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, continue; /* Do not draw items not attached to the current part */ - if( multi && drawItem.m_Unit && ( drawItem.m_Unit != multi ) ) + if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) ) continue; - if( convert && drawItem.m_Convert && ( drawItem.m_Convert != convert ) ) + if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) ) continue; - if( !drawFields && drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE ) + if( !aDrawFields && drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE ) continue; if( drawItem.Type() == COMPONENT_PIN_DRAW_TYPE ) { - drawItem.Draw( panel, dc, offset, color, drawMode, - (void*) showPinText, transformMatrix ); + drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, + (void*) aShowPinText, aTransformMatrix ); } else if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE ) { - drawItem.Draw( panel, dc, offset, color, drawMode, - (void*) NULL, transformMatrix ); + drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, + (void*) NULL, aTransformMatrix ); } else { bool forceNoFill = ( screen->m_IsPrinting && drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR && GetGRForceBlackPenState() ); - drawItem.Draw( panel, dc, offset, color, drawMode, - (void*) forceNoFill, transformMatrix ); + drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, + (void*) forceNoFill, aTransformMatrix ); } } /* Enable this to draw the anchor of the component. */ #if 0 - int len = panel->GetScreen()->Unscale( 3 ); - GRLine( &panel->m_ClipBox, dc, offset.x, offset.y - len, offset.x, - offset.y + len, 0, color ); - GRLine( &panel->m_ClipBox, dc, offset.x - len, offset.y, offset.x + len, - offset.y, 0, color ); + int len = aPanel->GetScreen()->Unscale( 3 ); + GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x, + aOffset.y + len, 0, aColor ); + GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len, + aOffset.y, 0, aColor ); #endif /* Enable this to draw the bounding box around the component to validate * the bounding box calculations. */ #if 0 - EDA_Rect bBox = GetBoundaryBox( multi, convert ); - GRRect( &panel->m_ClipBox, dc, bBox.GetOrigin().x, bBox.GetOrigin().y, + EDA_Rect bBox = GetBoundaryBox( aMulti, aConvert ); + GRRect( &aPanel->m_ClipBox, aDc, bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA ); #endif } -void LIB_COMPONENT::Plot( PLOTTER* plotter, int unit, int convert, - const wxPoint& offset, const int transform[2][2] ) +void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, + const wxPoint& aOffset, const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { - if( unit && item.m_Unit && ( item.m_Unit != unit ) ) + if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) ) continue; - if( convert && item.m_Convert && ( item.m_Convert != convert ) ) + if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) ) continue; - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - bool fill = plotter->get_color_mode(); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + bool fill = aPlotter->get_color_mode(); - item.Plot( plotter, offset, fill, transform ); + item.Plot( aPlotter, aOffset, fill, aTransform ); } } -void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item, - WinEDA_DrawPanel* panel, - wxDC* dc ) +void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* aItem, + WinEDA_DrawPanel* aPanel, + wxDC* aDc ) { - wxASSERT( item != NULL ); + wxASSERT( aItem != NULL ); /* Value and reference fields cannot be removed. */ - if( item->Type() == COMPONENT_FIELD_DRAW_TYPE ) + if( aItem->Type() == COMPONENT_FIELD_DRAW_TYPE ) { - LIB_FIELD* field = (LIB_FIELD*)item; + LIB_FIELD* field = (LIB_FIELD*)aItem; if( field->m_FieldId == VALUE || field->m_FieldId == REFERENCE ) { @@ -338,49 +330,49 @@ from component %s in library %s." ), LIB_DRAW_ITEM_LIST::iterator i; - if( dc != NULL ) - item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, + if( aDc != NULL ) + aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransformMatrix ); - for( i = m_Drawings.begin(); i < m_Drawings.end(); i++ ) + for( i = drawings.begin(); i < drawings.end(); i++ ) { - if( *i == item ) + if( *i == aItem ) { - m_Drawings.erase( i ); + drawings.erase( i ); break; } } } -void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* item ) +void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* aItem ) { - wxASSERT( item != NULL ); + wxASSERT( aItem != NULL ); - m_Drawings.push_back( item ); - m_Drawings.sort(); + drawings.push_back( aItem ); + drawings.sort(); } -LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item, - KICAD_T type ) +LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* aItem, + KICAD_T aType ) { /* Return the next draw object pointer. * If item is NULL return the first item of type in the list. */ - if( m_Drawings.empty() ) + if( drawings.empty() ) return NULL; - if( item == NULL && type == TYPE_NOT_INIT ) // type is unspecified - return &m_Drawings[0]; + if( aItem == NULL && aType == TYPE_NOT_INIT ) // type is unspecified + return &drawings[0]; // Search for last item size_t idx = 0; - if( item ) + if( aItem ) { - for( ; idx < m_Drawings.size(); idx++ ) + for( ; idx < drawings.size(); idx++ ) { - if( item == &m_Drawings[idx] ) + if( aItem == &drawings[idx] ) { idx++; // Prepare the next item search break; @@ -389,49 +381,48 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item, } // Search the next item - for( ; idx < m_Drawings.size(); idx++ ) + for( ; idx < drawings.size(); idx++ ) { - if( type == TYPE_NOT_INIT || m_Drawings[ idx ].Type() == type ) - return &m_Drawings[ idx ]; + if( aType == TYPE_NOT_INIT || drawings[ idx ].Type() == aType ) + return &drawings[ idx ]; } return NULL; } -/*************************************************************************/ -void LIB_COMPONENT::GetPins( LIB_PIN_LIST& pins, int unit, int convert ) -/*************************************************************************/ + +void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert ) { /* Notes: - * when unit == 0: no unit filtering - * when convert == 0: no convert (shape selection) filtering + * when aUnit == 0: no unit filtering + * when aConvert == 0: no convert (shape selection) filtering * when .m_Unit == 0, the body item is common to units * when .m_Convert == 0, the body item is common to shapes */ - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.Type() != COMPONENT_PIN_DRAW_TYPE ) // we search pins only continue; // Unit filtering: - if( unit && item.m_Unit && ( item.m_Unit != unit ) ) + if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) ) continue; // Shape filtering: - if( convert && item.m_Convert && ( item.m_Convert != convert ) ) + if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) ) continue; - pins.push_back( (LIB_PIN*) &item ); + aList.push_back( (LIB_PIN*) &item ); } } -LIB_PIN* LIB_COMPONENT::GetPin( const wxString& number, int unit, int convert ) +LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert ) { wxString pNumber; LIB_PIN_LIST pinList; - GetPins( pinList, unit, convert ); + GetPins( pinList, aUnit, aConvert ); for( size_t i = 0; i < pinList.size(); i++ ) { @@ -439,7 +430,7 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& number, int unit, int convert ) pinList[i]->ReturnPinStringNum( pNumber ); - if( number == pNumber ) + if( aNumber == pNumber ) return pinList[i]; } @@ -488,8 +479,8 @@ bool LIB_COMPONENT::Save( FILE* aFile ) 0, m_TextInside, m_DrawPinNum ? 'Y' : 'N', m_DrawPinName ? 'Y' : 'N', - m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F', - m_Options == ENTRY_POWER ? 'P' : 'N' ) < 0 ) + unitCount, m_UnitSelectionLocked ? 'L' : 'F', + options == ENTRY_POWER ? 'P' : 'N' ) < 0 ) return false; if( !SaveDateAndTime( aFile ) ) @@ -541,16 +532,16 @@ bool LIB_COMPONENT::Save( FILE* aFile ) } /* Save graphics items (including pins) */ - if( !m_Drawings.empty() ) + if( !drawings.empty() ) { /* we sort the draw items, in order to have an edition more easy, * when a file editing "by hand" is made */ - m_Drawings.sort(); + drawings.sort(); if( fprintf( aFile, "DRAW\n" ) < 0 ) return false; - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) continue; @@ -568,23 +559,23 @@ bool LIB_COMPONENT::Save( FILE* aFile ) return true; } -bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum, - wxString& errorMsg ) +bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, + wxString& aErrorMsg ) { int unused; char* p; - char* name; + char* componentName; char* prefix = NULL; bool Res; wxString Msg; - p = strtok( line, " \t\r\n" ); + p = strtok( aLine, " \t\r\n" ); if( strcmp( p, "DEF" ) != 0 ) { - errorMsg.Printf( wxT( "DEF command expected in line %d, aborted." ), - *lineNum ); + aErrorMsg.Printf( wxT( "DEF command expected in line %d, aborted." ), + *aLineNum ); return false; } @@ -592,24 +583,24 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum, char drawnum = 0; char drawname = 0; - if( ( name = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */ - || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ + if( ( componentName = strtok( NULL, " \t\n" ) ) == NULL /* Part name: */ + || ( prefix = strtok( NULL, " \t\n" ) ) == NULL /* Prefix name: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ || sscanf( p, "%d", &unused ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ || sscanf( p, "%d", &m_TextInside ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ || sscanf( p, "%c", &drawnum ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ || sscanf( p, "%c", &drawname ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_UnitCount: */ - || sscanf( p, "%d", &m_UnitCount ) != 1 ) + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* unitCount: */ + || sscanf( p, "%d", &unitCount ) != 1 ) { - errorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), - *lineNum ); - while( GetLine( file, line, lineNum, 1024 ) ) + aErrorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), + *aLineNum ); + while( GetLine( aFile, aLine, aLineNum, 1024 ) ) { - p = strtok( line, " \t\n" ); + p = strtok( aLine, " \t\n" ); if( stricmp( p, "ENDDEF" ) == 0 ) break; } @@ -617,20 +608,20 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum, return false; } - m_DrawPinNum = (drawnum == 'N') ? FALSE : true; - m_DrawPinName = (drawname == 'N') ? FALSE : true; + m_DrawPinNum = ( drawnum == 'N' ) ? FALSE : true; + m_DrawPinName = ( drawname == 'N' ) ? FALSE : true; /* Copy part name and prefix. */ LIB_FIELD& value = GetValueField(); - strupper( name ); - if( name[0] != '~' ) + strupper( componentName ); + if( componentName[0] != '~' ) { - m_Name = value.m_Text = CONV_FROM_UTF8( name ); + name = value.m_Text = CONV_FROM_UTF8( componentName ); } else { - m_Name = value.m_Text = CONV_FROM_UTF8( &name[1] ); + name = value.m_Text = CONV_FROM_UTF8( &componentName[1] ); value.m_Attributs |= TEXT_NO_VISIBLE; } @@ -650,70 +641,70 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum, if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' ) m_UnitSelectionLocked = true; if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' ) - m_Options = ENTRY_POWER; + options = ENTRY_POWER; /* Read next lines */ - while( GetLine( file, line, lineNum, 1024 ) ) + while( GetLine( aFile, aLine, aLineNum, 1024 ) ) { - p = strtok( line, " \t\n" ); + p = strtok( aLine, " \t\n" ); /* This is the error flag ( if an error occurs, Res = FALSE) */ Res = true; - if( (line[0] == 'T') && (line[1] == 'i') ) - Res = LoadDateAndTime( line ); - else if( line[0] == 'F' ) - Res = LoadField( line, Msg ); + if( (aLine[0] == 'T') && (aLine[1] == 'i') ) + Res = LoadDateAndTime( aLine ); + else if( aLine[0] == 'F' ) + Res = LoadField( aLine, Msg ); else if( strcmp( p, "ENDDEF" ) == 0 ) break; else if( strcmp( p, "DRAW" ) == 0 ) - Res = LoadDrawEntries( file, line, lineNum, Msg ); + Res = LoadDrawEntries( aFile, aLine, aLineNum, Msg ); else if( strncmp( p, "ALIAS", 5 ) == 0 ) { p = strtok( NULL, "\r\n" ); - Res = LoadAliases( p, errorMsg ); + Res = LoadAliases( p, aErrorMsg ); } else if( strncmp( p, "$FPLIST", 5 ) == 0 ) - Res = LoadFootprints( file, line, lineNum, Msg ); + Res = LoadFootprints( aFile, aLine, aLineNum, Msg ); /* End line or block analysis: test for an error */ if( !Res ) { if( Msg.IsEmpty() ) - errorMsg.Printf( wxT( "error occurred at line %d " ), *lineNum ); + aErrorMsg.Printf( wxT( "error occurred at line %d " ), *aLineNum ); else - errorMsg.Printf( wxT( "error <%s> occurred at line %d " ), - GetChars( Msg ), *lineNum ); + aErrorMsg.Printf( wxT( "error <%s> occurred at line %d " ), + GetChars( Msg ), *aLineNum ); return false; } } /* If we are here, this part is O.k. - put it in: */ - m_Drawings.sort(); + drawings.sort(); return true; } -bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line, - int* lineNum, wxString& errorMsg ) +bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine, + int* aLineNum, wxString& aErrorMsg ) { LIB_DRAW_ITEM* newEntry = NULL; while( true ) { - if( GetLine( f, line, lineNum, 1024 ) == NULL ) + if( GetLine( aFile, aLine, aLineNum, 1024 ) == NULL ) { - errorMsg = wxT( "file ended prematurely loading component draw element" ); + aErrorMsg = wxT( "file ended prematurely loading component draw element" ); return false; } - if( strncmp( line, "ENDDRAW", 7 ) == 0 ) + if( strncmp( aLine, "ENDDRAW", 7 ) == 0 ) break; newEntry = NULL; - switch( line[0] ) + switch( aLine[0] ) { case 'A': /* Arc */ newEntry = ( LIB_DRAW_ITEM* ) new LIB_ARC(this); @@ -744,32 +735,32 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line, break; default: - errorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] ); + aErrorMsg.Printf( wxT( "undefined DRAW command %c" ), aLine[0] ); return false; } - if( !newEntry->Load( line, errorMsg ) ) + if( !newEntry->Load( aLine, aErrorMsg ) ) { - errorMsg.Printf( wxT( "error <%s> in DRAW command %c" ), - GetChars( errorMsg ), line[0] ); + aErrorMsg.Printf( wxT( "error <%s> in DRAW command %c" ), + GetChars( aErrorMsg ), aLine[0] ); SAFE_DELETE( newEntry ); /* Flush till end of draw section */ do { - if( GetLine( f, line, lineNum, 1024 ) == NULL ) + if( GetLine( aFile, aLine, aLineNum, 1024 ) == NULL ) { - errorMsg = wxT( "file ended prematurely while attempting \ + aErrorMsg = wxT( "file ended prematurely while attempting \ to flush to end of drawing section." ); return false; } - } while( strncmp( line, "ENDDRAW", 7 ) != 0 ); + } while( strncmp( aLine, "ENDDRAW", 7 ) != 0 ); return false; } else { - m_Drawings.push_back( newEntry ); + drawings.push_back( newEntry ); } } @@ -777,9 +768,9 @@ to flush to end of drawing section." ); } -bool LIB_COMPONENT::LoadAliases( char* line, wxString& errorMsg ) +bool LIB_COMPONENT::LoadAliases( char* aLine, wxString& aErrorMsg ) { - char* text = strtok( line, " \t\r\n" ); + char* text = strtok( aLine, " \t\r\n" ); while( text ) { @@ -791,11 +782,11 @@ bool LIB_COMPONENT::LoadAliases( char* line, wxString& errorMsg ) } -bool LIB_COMPONENT::LoadField( char* line, wxString& errorMsg ) +bool LIB_COMPONENT::LoadField( char* aLine, wxString& aErrorMsg ) { LIB_FIELD* field = new LIB_FIELD( this ); - if ( !field->Load( line, errorMsg ) ) + if ( !field->Load( aLine, aErrorMsg ) ) { SAFE_DELETE( field ); return false; @@ -809,33 +800,33 @@ bool LIB_COMPONENT::LoadField( char* line, wxString& errorMsg ) else if ( field->m_FieldId == VALUE ) { GetValueField() = *field; - m_Name = field->m_Text; + name = field->m_Text; SAFE_DELETE( field ); } else { - m_Drawings.push_back( field ); + drawings.push_back( field ); } return true; } -bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line, - int* lineNum, wxString& errorMsg ) +bool LIB_COMPONENT::LoadFootprints( FILE* aFile, char* aLine, + int* aLineNum, wxString& aErrorMsg ) { while( true ) { - if( GetLine( file, line, lineNum, 1024 ) == NULL ) + if( GetLine( aFile, aLine, aLineNum, 1024 ) == NULL ) { - errorMsg = wxT( "file ended prematurely while loading footprints" ); + aErrorMsg = wxT( "file ended prematurely while loading footprints" ); return false; } - if( stricmp( line, "$ENDFPLIST" ) == 0 ) + if( stricmp( aLine, "$ENDFPLIST" ) == 0 ) break; - m_FootprintList.Add( CONV_FROM_UTF8( line + 1 ) ); + m_FootprintList.Add( CONV_FROM_UTF8( aLine + 1 ) ); } return true; @@ -844,30 +835,30 @@ bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line, /**********************************************************************/ /* Return the component boundary box ( in user coordinates ) - * The unit Unit, and the shape Convert are considered. - * If Unit == 0, Unit is not used - * if Convert == 0 Convert is non used + * The unit aUnit, and the shape aConvert are considered. + * If aUnit == 0, unit is not used + * if aConvert == 0 Convert is non used * Invisible fields are not take in account **/ /**********************************************************************/ -EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert ) +EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert ) { EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { - if( ( item.m_Unit > 0 ) && ( ( m_UnitCount > 1 ) && ( Unit > 0 ) - && ( Unit != item.m_Unit ) ) ) + if( ( item.m_Unit > 0 ) && ( ( unitCount > 1 ) && ( aUnit > 0 ) + && ( aUnit != item.m_Unit ) ) ) continue; if( item.m_Convert > 0 - && ( ( Convert > 0 ) && ( Convert != item.m_Convert ) ) ) + && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) ) continue; if ( ( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) - && ( ( ( LIB_TEXT& ) item ).m_Attributs & TEXT_NO_VISIBLE) ) + && ( ( ( LIB_TEXT& ) item ).m_Attributs & TEXT_NO_VISIBLE ) ) continue; - bBox.Merge( item.GetBoundingBox() ); + bBox.Merge( item.GetBoundingBox() ); } return bBox; @@ -891,7 +882,7 @@ void LIB_COMPONENT::SetFields( const std::vector aFields ) *field = aFields[i]; if( (int) i == VALUE ) - m_Name = field->m_Text; + name = field->m_Text; continue; } @@ -901,36 +892,36 @@ void LIB_COMPONENT::SetFields( const std::vector aFields ) continue; field = new LIB_FIELD( aFields[i] ); - m_Drawings.push_back( field ); + drawings.push_back( field ); } - m_Drawings.sort(); + drawings.sort(); } -void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& list ) +void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.Type() != COMPONENT_FIELD_DRAW_TYPE ) continue; LIB_FIELD* field = ( LIB_FIELD* ) &item; - list.push_back( *field ); + aList.push_back( *field ); } } -LIB_FIELD* LIB_COMPONENT::GetField( int id ) +LIB_FIELD* LIB_COMPONENT::GetField( int aId ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.Type() != COMPONENT_FIELD_DRAW_TYPE ) continue; LIB_FIELD* field = ( LIB_FIELD* ) &item; - if( field->m_FieldId == id ) + if( field->m_FieldId == aId ) return field; } @@ -938,7 +929,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int id ) } -LIB_FIELD& LIB_COMPONENT::GetValueField( void ) +LIB_FIELD& LIB_COMPONENT::GetValueField() { LIB_FIELD* field = GetField( VALUE ); wxASSERT( field != NULL ); @@ -946,7 +937,7 @@ LIB_FIELD& LIB_COMPONENT::GetValueField( void ) } -LIB_FIELD& LIB_COMPONENT::GetReferenceField( void ) +LIB_FIELD& LIB_COMPONENT::GetReferenceField() { LIB_FIELD* field = GetField( REFERENCE ); wxASSERT( field != NULL ); @@ -958,7 +949,7 @@ LIB_FIELD& LIB_COMPONENT::GetReferenceField( void ) * Read date and time of component in the format: * "Ti yy/mm/jj hh:mm:ss" */ -bool LIB_COMPONENT::SaveDateAndTime( FILE* file ) +bool LIB_COMPONENT::SaveDateAndTime( FILE* aFile ) { int year, mon, day, hour, min, sec; @@ -972,7 +963,7 @@ bool LIB_COMPONENT::SaveDateAndTime( FILE* file ) mon = ( m_LastDate >> 22 ) & 15; year = ( m_LastDate >> 26 ) + 1990; - if ( fprintf( file, "Ti %d/%d/%d %d:%d:%d\n", + if ( fprintf( aFile, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec ) < 0 ) return false; @@ -982,16 +973,16 @@ bool LIB_COMPONENT::SaveDateAndTime( FILE* file ) /* lit date et time de modif composant sous le format: * "Ti yy/mm/jj hh:mm:ss" */ -bool LIB_COMPONENT::LoadDateAndTime( char* Line ) +bool LIB_COMPONENT::LoadDateAndTime( char* aLine ) { int year, mon, day, hour, min, sec; char* text; year = mon = day = hour = min = sec = 0; - text = strtok( Line, " \r\t\n" ); + text = strtok( aLine, " \r\t\n" ); text = strtok( NULL, " \r\t\n" ); - if (sscanf( Line, "%d/%d/%d %d:%d:%d", + if (sscanf( aLine, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ) != 6 ) return false; @@ -1003,24 +994,24 @@ bool LIB_COMPONENT::LoadDateAndTime( char* Line ) } -void LIB_COMPONENT::SetOffset( const wxPoint& offset ) +void LIB_COMPONENT::SetOffset( const wxPoint& aOffset ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { - item.SetOffset( offset ); + item.SetOffset( aOffset ); } } void LIB_COMPONENT::RemoveDuplicateDrawItems() { - m_Drawings.unique(); + drawings.unique(); } bool LIB_COMPONENT::HasConversion() const { - BOOST_FOREACH( const LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( const LIB_DRAW_ITEM& item, drawings ) { if( item.m_Convert > 1 ) return true; @@ -1030,84 +1021,84 @@ bool LIB_COMPONENT::HasConversion() const } -void LIB_COMPONENT::ClearStatus( void ) +void LIB_COMPONENT::ClearStatus() { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) item.m_Flags = 0; } -int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert, - bool editPinByPin ) +int LIB_COMPONENT::SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, + bool aEditPinByPin ) { - int ItemsCount = 0; + int itemCount = 0; - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { item.m_Selected = 0; - if( ( item.m_Unit && item.m_Unit != unit ) - || ( item.m_Convert && item.m_Convert != convert ) ) + if( ( item.m_Unit && item.m_Unit != aUnit ) + || ( item.m_Convert && item.m_Convert != aConvert ) ) { if( item.Type() != COMPONENT_PIN_DRAW_TYPE ) continue; // Specific rules for pins. - if( editPinByPin || m_UnitSelectionLocked - || ( item.m_Convert && item.m_Convert != convert ) ) + if( aEditPinByPin || m_UnitSelectionLocked + || ( item.m_Convert && item.m_Convert != aConvert ) ) continue; } - if( item.Inside( rect ) ) + if( item.Inside( aRect ) ) { item.m_Selected = IS_SELECTED; - ItemsCount++; + itemCount++; } } - return ItemsCount; + return itemCount; } -void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset ) +void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.m_Selected == 0 ) continue; - item.SetOffset( offset ); + item.SetOffset( aOffset ); item.m_Flags = item.m_Selected = 0; } - m_Drawings.sort(); + drawings.sort(); } -void LIB_COMPONENT::ClearSelectedItems( void ) +void LIB_COMPONENT::ClearSelectedItems() { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) item.m_Flags = item.m_Selected = 0; } -void LIB_COMPONENT::DeleteSelectedItems( void ) +void LIB_COMPONENT::DeleteSelectedItems() { - LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin(); + LIB_DRAW_ITEM_LIST::iterator i = drawings.begin(); - while( i != m_Drawings.end() ) + while( i != drawings.end() ) { if( i->m_Selected == 0 ) i++; else - i = m_Drawings.erase( i ); + i = drawings.erase( i ); } } -void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset ) +void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.m_Selected == 0 ) continue; @@ -1115,25 +1106,26 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset ) item.m_Selected = 0; LIB_DRAW_ITEM* newItem = item.GenCopy(); newItem->m_Selected = IS_SELECTED; - m_Drawings.push_back( newItem ); + drawings.push_back( newItem ); } - MoveSelectedItems( offset ); - m_Drawings.sort(); + MoveSelectedItems( aOffset ); + drawings.sort(); } -void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center ) + +void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { if( item.m_Selected == 0 ) continue; - item.SetOffset( center ); + item.SetOffset( aCenter ); item.m_Flags = item.m_Selected = 0; } - m_Drawings.sort(); + drawings.sort(); } @@ -1141,25 +1133,25 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center ) /** * Locate a draw object. * - * @param unit - Unit number of draw item. - * @param convert - Body style of draw item. - * @param type - Draw object type, set to 0 to search for any type. - * @param pt - Coordinate for hit testing. + * @param aUnit - Unit number of draw item. + * @param aConvert - Body style of draw item. + * @param aType - Draw object type, set to 0 to search for any type. + * @param aPoint - Coordinate for hit testing. * * @return LIB_DRAW_ITEM - Pointer the the draw object if found. * Otherwise NULL. */ -LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, - KICAD_T type, const wxPoint& pt ) +LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, + KICAD_T aType, const wxPoint& aPoint ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { - if( ( unit && item.m_Unit && ( unit != item.m_Unit) ) - || ( convert && item.m_Convert && ( convert != item.m_Convert ) ) - || ( ( item.Type() != type ) && ( type != TYPE_NOT_INIT ) ) ) + if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) ) + || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) ) + || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) ) continue; - if( item.HitTest( pt ) ) + if( item.HitTest( aPoint ) ) return &item; } @@ -1171,16 +1163,15 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to this object (usually the half * thickness of a line) - * @param aTransMat = the transform matrix + * @param aTransform = the transform matrix * * @return LIB_DRAW_ITEM - Pointer the the draw object if found. * Otherwise NULL. */ -LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, - KICAD_T type, const wxPoint& pt, - const int aTransMat[2][2] ) +LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, + const wxPoint& aPoint, const int aTransform[2][2] ) { - /* we use LocateDrawItem( int unit, int convert, KICAD_T type, const + /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const * wxPoint& pt ) to search items. * because this function uses DefaultTransformMatrix as orient/mirror matrix * we temporary copy aTransMat in DefaultTransformMatrix @@ -1191,11 +1182,11 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, { for ( int jj = 0; jj < 2; jj++ ) { - matrix[ii][jj] = aTransMat[ii][jj]; + matrix[ii][jj] = aTransform[ii][jj]; EXCHG( matrix[ii][jj], DefaultTransformMatrix[ii][jj] ); } } - item = LocateDrawItem( unit, convert, type, pt ); + item = LocateDrawItem( aUnit, aConvert, aType, aPoint ); //Restore matrix for ( int ii = 0; ii < 2; ii++ ) { @@ -1209,58 +1200,59 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, } -void LIB_COMPONENT::SetPartCount( int count ) +void LIB_COMPONENT::SetPartCount( int aCount ) { LIB_DRAW_ITEM_LIST::iterator i; - if( m_UnitCount == count ) + if( unitCount == aCount ) return; - if( count < m_UnitCount ) + if( aCount < unitCount ) { - i = m_Drawings.begin(); + i = drawings.begin(); - while( i != m_Drawings.end() ) + while( i != drawings.end() ) { - if( i->m_Unit > count ) - i = m_Drawings.erase( i ); + if( i->m_Unit > aCount ) + i = drawings.erase( i ); else i++; } } else { - int prevCount = m_UnitCount; + int prevCount = unitCount; - for( i = m_Drawings.begin(); i != m_Drawings.end(); i++ ) + for( i = drawings.begin(); i != drawings.end(); i++ ) { if( i->m_Unit != 1 ) continue; - for( int j = prevCount + 1; j <= count; j++ ) + for( int j = prevCount + 1; j <= aCount; j++ ) { LIB_DRAW_ITEM* newItem = i->GenCopy(); newItem->m_Unit = j; - m_Drawings.push_back( newItem ); + drawings.push_back( newItem ); } } - m_Drawings.sort(); + drawings.sort(); } - m_UnitCount = count; + unitCount = aCount; } -void LIB_COMPONENT::SetConversion( bool asConvert ) +void LIB_COMPONENT::SetConversion( bool aSetConvert ) { - if( asConvert == HasConversion() ) + if( aSetConvert == HasConversion() ) return; + // Duplicate items to create the converted shape - if( asConvert ) + if( aSetConvert ) { - BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings ) + BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { /* Only pins are duplicated. */ if( item.Type() != COMPONENT_PIN_DRAW_TYPE ) @@ -1269,7 +1261,7 @@ void LIB_COMPONENT::SetConversion( bool asConvert ) { LIB_DRAW_ITEM* newItem = item.GenCopy(); newItem->m_Convert = 2; - m_Drawings.push_back( newItem ); + drawings.push_back( newItem ); } } } @@ -1277,12 +1269,12 @@ void LIB_COMPONENT::SetConversion( bool asConvert ) { // Delete converted shape items becuase the converted shape does // not exist - LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin(); + LIB_DRAW_ITEM_LIST::iterator i = drawings.begin(); - while( i != m_Drawings.end() ) + while( i != drawings.end() ) { if( i->m_Convert > 1 ) - i = m_Drawings.erase( i ); + i = drawings.erase( i ); else i++; } diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 8013cf4e5b..7c1b9f1cd8 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -38,19 +38,26 @@ enum LibrEntryOptions */ class CMP_LIB_ENTRY : public EDA_BaseStruct { -public: - LibrEntryType Type; /* Type = ROOT; - * = ALIAS pour struct LibraryAliasType */ - wxString m_Doc; /* documentation for info */ - wxString m_KeyWord; /* keyword list (used to select a group of - * components by keyword) */ - wxString m_DocFile; /* Associate doc file name */ - LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER) + +protected: + wxString name; + + /** Library object that entry is attached to. */ + CMP_LIBRARY* library; + + /** Entry type, either ROOT or ALIAS. */ + LibrEntryType type; + + wxString description; /* documentation for info */ + wxString keyWords; /* keyword list (used for search for + * components by keyword) */ + wxString docFileName; /* Associate doc file name */ + LibrEntryOptions options; // special features (i.e. Entry is a POWER) public: - CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name, - CMP_LIBRARY* lib = NULL ); - CMP_LIB_ENTRY( CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib = NULL ); + CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, + CMP_LIBRARY* aLibrary = NULL ); + CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL ); virtual ~CMP_LIB_ENTRY(); @@ -61,9 +68,42 @@ public: wxString GetLibraryName(); - virtual const wxString& GetName() const { return m_Name; } + virtual const wxString& GetName() const { return name; } - virtual void SetName( const wxString& name ) { m_Name = name; } + virtual void SetName( const wxString& aName ) { name = aName; } + + bool isComponent() { return type == ROOT; } + + bool isAlias() { return type == ALIAS; } + + int GetType() { return type; } + + bool isPower() { return options == ENTRY_POWER; } + bool isNormal() { return options == ENTRY_NORMAL; } + + void SetPower() { options = ENTRY_POWER; } + void SetNormal() { options = ENTRY_NORMAL; } + + void SetDescription( const wxString& aDescription ) + { + description = aDescription; + } + + wxString GetDescription() { return description; } + + void SetKeyWords( const wxString& aKeyWords ) + { + keyWords = aKeyWords; + } + + wxString GetKeyWords() { return keyWords; } + + void SetDocFileName( const wxString& aDocFileName ) + { + docFileName = aDocFileName; + } + + wxString GetDocFileName() { return docFileName; } /** * Write the entry document information to a FILE in "*.dcm" format. @@ -76,26 +116,19 @@ public: /** * Case insensitive comparison of the component entry name. */ - bool operator==( const wxChar* name ) const; - bool operator!=( const wxChar* name ) const + bool operator==( const wxChar* aName ) const; + bool operator!=( const wxChar* aName ) const { - return !( *this == name ); + return !( *this == aName ); } - -protected: - wxString m_Name; - - /** Library object that entry is attached to. */ - CMP_LIBRARY* m_lib; }; typedef boost::ptr_vector< CMP_LIB_ENTRY > LIB_ENTRY_LIST; -extern bool operator<( const CMP_LIB_ENTRY& item1, const CMP_LIB_ENTRY& item2 ); +extern bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 ); -extern int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1, - const CMP_LIB_ENTRY* LE2 ); +extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem2 ); /** @@ -126,8 +159,8 @@ public: long m_LastDate; // Last change Date protected: - int m_UnitCount; /* Units (or sections) per package */ - LIB_DRAW_ITEM_LIST m_Drawings; /* How to draw this part */ + int unitCount; /* Units (parts) per package */ + LIB_DRAW_ITEM_LIST drawings; /* How to draw this part */ public: virtual wxString GetClass() const @@ -136,21 +169,21 @@ public: } - virtual void SetName( const wxString& name ) + virtual void SetName( const wxString& aName ) { - CMP_LIB_ENTRY::SetName( name ); - GetValueField().m_Text = name; + CMP_LIB_ENTRY::SetName( aName ); + GetValueField().m_Text = aName; } - LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL ); - LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib = NULL ); + LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL ); + LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL ); ~LIB_COMPONENT(); - EDA_Rect GetBoundaryBox( int Unit, int Convert ); + EDA_Rect GetBoundaryBox( int aUnit, int aConvert ); - bool SaveDateAndTime( FILE* ExportFile ); - bool LoadDateAndTime( char* Line ); + bool SaveDateAndTime( FILE* aFile ); + bool LoadDateAndTime( char* aLine ); /** * Write the data structures out to a FILE in "*.lib" format. @@ -161,21 +194,21 @@ public: bool Save( FILE* aFile ); /** - * Load component definition from file. + * Load component definition from /a aFile. * - * @param file - File descriptor of file to load form. - * @param line - The first line of the component definition. - * @param lineNum - The current line number in the file. - * @param errorMsg - Description of error on load failure. + * @param aFile - File descriptor of file to load form. + * @param aLine - The first line of the component definition. + * @param aLineNum - The current line number in the file. + * @param aErrorMsg - Description of error on load failure. * @return True if the load was successful, false if there was an error. */ - bool Load( FILE* file, char* line, int* lineNum, wxString& errorMsg ); - bool LoadField( char* line, wxString& errorMsg ); - bool LoadDrawEntries( FILE* f, char* line, - int* lineNum, wxString& errorMsg ); - bool LoadAliases( char* line, wxString& Error ); - bool LoadFootprints( FILE* file, char* line, - int* lineNum, wxString& errorMsg ); + bool Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg ); + bool LoadField( char* aLine, wxString& aErrorMsg ); + bool LoadDrawEntries( FILE* aFile, char* aLine, + int* aLineNum, wxString& aErrorMsg ); + bool LoadAliases( char* aLine, wxString& aErrorMsg ); + bool LoadFootprints( FILE* aFile, char* aLine, + int* aLineNum, wxString& aErrorMsg ); /** * Initialize fields from a vector of fields. @@ -187,90 +220,90 @@ public: /** * Return list of field references of component. * - * @param list - List to add field references to. + * @param aList - List to add field references to. */ - void GetFields( LIB_FIELD_LIST& list ); + void GetFields( LIB_FIELD_LIST& aList ); /** * Return pointer to the requested field. * - * @param id - Id of field to return. + * @param aId - Id of field to return. * @return The field if found, otherwise NULL. */ - LIB_FIELD* GetField( int id ); + LIB_FIELD* GetField( int aId ); /** Return reference to the value field. */ - LIB_FIELD& GetValueField( void ); + LIB_FIELD& GetValueField(); /** Return reference to the reference designator field. */ - LIB_FIELD& GetReferenceField( void ); + LIB_FIELD& GetReferenceField(); /** * Draw component. * - * @param panel - Window to draw on. - * @param dc - Device context to draw on. - * @param offset - Position to component. - * @param multi - Component unit if multiple parts per component. - * @param convert - Component conversion (DeMorgan) if available. - * @param drawMode - Device context drawing mode, see wxDC. - * @param color - Color to draw component. - * @param transformMatrix - Coordinate adjustment settings. - * @param showPinText - Show pin text if true. - * @param drawFields - Draw field text if true otherwise just draw - * body items (useful to draw a body in schematic, - * because fields of schematic components replace - * the lib component fields). - * @param onlySelected - Draws only the body items that are selected. - * Used for block move redraws. + * @param aPanel - Window to draw on. + * @param aDc - Device context to draw on. + * @param aOffset - Position to component. + * @param aMulti - Component unit if multiple parts per component. + * @param aConvert - Component conversion (DeMorgan) if available. + * @param aDrawMode - Device context drawing mode, see wxDC. + * @param aColor - Color to draw component. + * @param aTransformMatrix - Coordinate adjustment settings. + * @param aShowPinText - Show pin text if true. + * @param aDrawFields - Draw field text if true otherwise just draw + * body items (useful to draw a body in schematic, + * because fields of schematic components replace + * the lib component fields). + * @param aOnlySelected - Draws only the body items that are selected. + * Used for block move redraws. */ - void Draw( WinEDA_DrawPanel* panel, wxDC* dc, const wxPoint& offset, - int multi, int convert, int drawMode, int color = -1, - const int transformMatrix[2][2] = DefaultTransformMatrix, - bool showPinText = true, bool drawFields = true, - bool onlySelected = false ); + void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, const wxPoint& aOffset, + int aMulti, int aConvert, int aDrawMode, int aColor = -1, + const int aTransform[2][2] = DefaultTransformMatrix, + bool aShowPinText = true, bool aDrawFields = true, + bool aOnlySelected = false ); /** * Plot component to plotter. * - * @param plotter - Plotter object to plot to. - * @param unit - Component part to plot. - * @param convert - Component alternate body style to plot. - * @param transform - Component plot transform matrix. + * @param aPlotter - Plotter object to plot to. + * @param aUnit - Component part to plot. + * @param aConvert - Component alternate body style to plot. + * @param aTransform - Component plot transform matrix. */ - void Plot( PLOTTER* plotter, int unit, int convert, const wxPoint& offset, - const int transform[2][2] ); + void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset, + const int aTransform[2][2] ); /** - * Add a new draw item to the draw object list. + * Add a new draw /a aItem to the draw object list. * * @param item - New draw object to add to component. */ - void AddDrawItem( LIB_DRAW_ITEM* item ); + void AddDrawItem( LIB_DRAW_ITEM* aItem ); /** - * Remove draw item from list. + * Remove draw /a aItem from list. * - * @param item - Draw item to remove from list. - * @param panel - Panel to remove part from. - * @param dc - Device context to remove part from. + * @param aItem - Draw item to remove from list. + * @param aPanel - Panel to remove part from. + * @param aDc - Device context to remove part from. */ - void RemoveDrawItem( LIB_DRAW_ITEM* item, - WinEDA_DrawPanel* panel = NULL, - wxDC* dc = NULL ); + void RemoveDrawItem( LIB_DRAW_ITEM* aItem, + WinEDA_DrawPanel* aPanel = NULL, + wxDC* aDc = NULL ); /** * Return the next draw object pointer. * - * @param item - Pointer to the current draw item. Setting item NULL - * with return the first item of type in the list. - * @param type - type of searched item (filter). - * if TYPE_NOT_INIT search for all items types + * @param aItem - Pointer to the current draw item. Setting item NULL + * with return the first item of type in the list. + * @param aType - type of searched item (filter). + * if TYPE_NOT_INIT search for all items types * @return - The next drawing object in the list if found, otherwise NULL. */ - LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* item = NULL, - KICAD_T type = TYPE_NOT_INIT ); + LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* aItem = NULL, + KICAD_T aType = TYPE_NOT_INIT ); /** * Return the next pin object from the draw list. @@ -281,9 +314,9 @@ public: * first pin in the draw object list. * @return - The next pin object in the list if found, otherwise NULL. */ - LIB_PIN* GetNextPin( LIB_PIN* item = NULL ) + LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL ) { - return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) item, + return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, COMPONENT_PIN_DRAW_TYPE ); } @@ -295,32 +328,32 @@ public: * Deleting any of the objects will leave list in a unstable state * and will likely segfault when the list is destroyed. * - * @param list - Pin list to place pin object pointers into. - * @param unit - Unit number of pin to add to list. Set to 0 to - * get pins from any component part. - * @param convert - Convert number of pin to add to list. Set to 0 to - * get pins from any convert of component. + * @param aList - Pin list to place pin object pointers into. + * @param aUnit - Unit number of pin to add to list. Set to 0 to + * get pins from any component part. + * @param aConvert - Convert number of pin to add to list. Set to 0 to + * get pins from any convert of component. */ - void GetPins( LIB_PIN_LIST& pins, int unit = 0, int convert = 0 ); + void GetPins( LIB_PIN_LIST& aList, int aUnit = 0, int aConvert = 0 ); /** - * Return pin object with the requested pin number. + * Return pin object with the requested pin /a aNumber. * - * @param number - Number of the pin to find. - * @param unit - Unit of the component to find. Set to 0 if a specific - * unit number is not required. - * @param convert - Alternate body style filter (DeMorgan). Set to 0 if - * no alternate body style is required. + * @param aNumber - Number of the pin to find. + * @param aUnit - Unit of the component to find. Set to 0 if a specific + * unit number is not required. + * @param aConvert - Alternate body style filter (DeMorgan). Set to 0 if + * no alternate body style is required. * @return The pin object if found. Otherwise NULL. */ - LIB_PIN* GetPin( const wxString& number, int unit = 0, int convert = 0 ); + LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ); /** - * Move the component offset. + * Move the component /a aOffset. * - * @param offset - Offset displacement. + * @param aOffset - Offset displacement. */ - void SetOffset( const wxPoint& offset ); + void SetOffset( const wxPoint& aOffset ); /** * Remove duplicate draw items from list. @@ -335,23 +368,23 @@ public: bool HasConversion() const; /** - * Test if alias name is in component alias list. + * Test if alias /a aName is in component alias list. * * Alias name comparisons are case insensitive. * - * @param name - Name of alias. + * @param aName - Name of alias. * @return True if alias name in alias list. */ - bool HasAlias( const wxChar* name ) + bool HasAlias( const wxChar* aName ) { - wxASSERT( name != NULL ); - return m_AliasList.Index( name ) != wxNOT_FOUND; + wxASSERT( aName != NULL ); + return m_AliasList.Index( aName ) != wxNOT_FOUND; } /** * Clears the status flag all draw objects in this component. */ - void ClearStatus( void ); + void ClearStatus(); /** * Checks all draw objects of component to see if they are with block. @@ -359,21 +392,21 @@ public: * Use this method to mark draw objects as selected during block * functions. * - * @param rect - The bounding rectangle to test in draw items are inside. - * @param unit - The current unit number to test against. - * @param convert - Are the draw items being selected a conversion. - * @param editPinByPin - Used to ignore pin selections when in edit pin - * by pin mode is enabled. + * @param aRect - The bounding rectangle to test in draw items are inside. + * @param aUnit - The current unit number to test against. + * @param aConvert - Are the draw items being selected a conversion. + * @param aEditPinByPin - Used to ignore pin selections when in edit pin + * by pin mode is enabled. * @return The number of draw objects found inside the block select * rectangle. */ - int SelectItems( EDA_Rect& rect, int unit, int convert, - bool editPinByPin ); + int SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, + bool aEditPinByPin ); /** * Clears all the draw items marked by a block select. */ - void ClearSelectedItems( void ); + void ClearSelectedItems(); /** * Deletes the select draw items marked by a block select. @@ -382,12 +415,12 @@ public: * minimum drawing items required for any component. Their properties * can be changed but the cannot be removed. */ - void DeleteSelectedItems( void ); + void DeleteSelectedItems(); /** * Move the selected draw items marked by a block select. */ - void MoveSelectedItems( const wxPoint& offset ); + void MoveSelectedItems( const wxPoint& aOffset ); /** * Make a copy of the selected draw items marked by a block select. @@ -396,47 +429,47 @@ public: * Copying fields would result in duplicate fields which does not * make sense in this context. */ - void CopySelectedItems( const wxPoint& offset ); + void CopySelectedItems( const wxPoint& aOffset ); /** * Horizontally (X axis) mirror selected draw items about a point. * - * @param center - Center point to mirror around. + * @param aCenter - Center point to mirror around. */ - void MirrorSelectedItemsH( const wxPoint& center ); + void MirrorSelectedItemsH( const wxPoint& aCenter ); /** * Locate a draw object. * - * @param unit - Unit number of draw item. - * @param convert - Body style of draw item. - * @param type - Draw object type, set to 0 to search for any type. - * @param pt - Coordinate for hit testing. + * @param aUnit - Unit number of draw item. + * @param aConvert - Body style of draw item. + * @param aType - Draw object type, set to 0 to search for any type. + * @param aPoint - Coordinate for hit testing. * @return The draw object if found. Otherwise NULL. */ - LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type, - const wxPoint& pt ); + LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, + const wxPoint& aPoint ); /** * Locate a draw object (overlaid) * - * @param unit - Unit number of draw item. - * @param convert - Body style of draw item. - * @param type - Draw object type, set to 0 to search for any type. - * @param pt - Coordinate for hit testing. - * @param aTransMat = the transform matrix + * @param aUnit - Unit number of draw item. + * @param aConvert - Body style of draw item. + * @param aType - Draw object type, set to 0 to search for any type. + * @param aPoint - Coordinate for hit testing. + * @param aTransform = the transform matrix * @return The draw object if found. Otherwise NULL. */ - LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type, - const wxPoint& pt, - const int aTransMat[2][2] ); + LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, + const wxPoint& aPoint, + const int aTransfrom[2][2] ); /** * Return a reference to the draw item list. * * @return LIB_DRAW_ITEM_LIST& - Reference to the draw item object list. */ - LIB_DRAW_ITEM_LIST& GetDrawItemList( void ) { return m_Drawings; } + LIB_DRAW_ITEM_LIST& GetDrawItemList() { return drawings; } /** * Set the part per package count. @@ -450,7 +483,7 @@ public: */ void SetPartCount( int count ); - int GetPartCount( void ) { return m_UnitCount; } + int GetPartCount() { return unitCount; } /** * Set or clear the alternate body style (DeMorgan) for the component. @@ -461,9 +494,9 @@ public: * asConvert is true, than the base draw items are duplicated and * added to the component. * - * @param asConvert - Set or clear the component alternate body style. + * @param aSetConvert - Set or clear the component alternate body style. */ - void SetConversion( bool asConvert ); + void SetConversion( bool aSetConvert ); }; @@ -476,12 +509,19 @@ public: class LIB_ALIAS : public CMP_LIB_ENTRY { protected: - LIB_COMPONENT* m_root; /* Root component of the alias. */ + /** + * The actual component of the alias. + * + * @note - Do not delete the root component. The root component is owned + * by library the component is part of. Deleting the root component + * will likely cause EESchema to crash. + */ + LIB_COMPONENT* root; public: - LIB_ALIAS( const wxString& name, LIB_COMPONENT* root, - CMP_LIBRARY* lib = NULL ); - LIB_ALIAS( LIB_ALIAS& alias, CMP_LIBRARY* lib = NULL ); + LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aComponent, + CMP_LIBRARY* aLibrary = NULL ); + LIB_ALIAS( LIB_ALIAS& aAlias, CMP_LIBRARY* aLibrary = NULL ); ~LIB_ALIAS(); virtual wxString GetClass() const @@ -492,15 +532,15 @@ public: /** * Get the alias root component. */ - LIB_COMPONENT* GetComponent( void ) const + LIB_COMPONENT* GetComponent() const { - return m_root; + return root; } /** * Set the alias root component. */ - void SetComponent( LIB_COMPONENT* component ); + void SetComponent( LIB_COMPONENT* aComponent ); }; diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 0e55af87fa..332d6eea4a 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -26,39 +26,39 @@ _( "Library <%s> has duplicate entry name <%s>.\n\ This may cause some unexpected behavior when loading components into a schematic." ); -static bool DuplicateEntryName( const CMP_LIB_ENTRY& item1, - const CMP_LIB_ENTRY& item2 ) +static bool DuplicateEntryName( const CMP_LIB_ENTRY& aItem1, + const CMP_LIB_ENTRY& aItem2 ) { - return item1.GetName().CmpNoCase( item2.GetName() ) == 0; + return aItem1.GetName().CmpNoCase( aItem2.GetName() ) == 0; } -bool operator==( const CMP_LIBRARY& lib, const wxChar* name ) +bool operator==( const CMP_LIBRARY& aLibrary, const wxChar* aName ) { - return lib.GetName().CmpNoCase( name ) == 0; + return aLibrary.GetName().CmpNoCase( aName ) == 0; } -bool operator!=( const CMP_LIBRARY& lib, const wxChar* name ) +bool operator!=( const CMP_LIBRARY& aLibrary, const wxChar* aName ) { - return !( lib == name ); + return !( aLibrary == aName ); } -bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 ) +bool operator<( const CMP_LIBRARY& aItem1, const CMP_LIBRARY& aItem2 ) { /* The cache library always is sorted to the end of the library list. */ - if( item1.IsCache() ) + if( aItem1.IsCache() ) return true; - if( item2.IsCache() ) + if( aItem2.IsCache() ) return false; /* If the sort order array isn't set, then sort alphabetically except. */ if( CMP_LIBRARY::GetSortOrder().IsEmpty() ) - return item1.GetName().CmpNoCase( item2.GetName() ) < 0; + return aItem1.GetName().CmpNoCase( aItem2.GetName() ) < 0; - int i1 = CMP_LIBRARY::GetSortOrder().Index( item1.GetName(), false ); - int i2 = CMP_LIBRARY::GetSortOrder().Index( item2.GetName(), false ); + int i1 = CMP_LIBRARY::GetSortOrder().Index( aItem1.GetName(), false ); + int i2 = CMP_LIBRARY::GetSortOrder().Index( aItem2.GetName(), false ); if( i1 == wxNOT_FOUND && i2 == wxNOT_FOUND ) return true; @@ -73,19 +73,19 @@ bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 ) } -CMP_LIBRARY::CMP_LIBRARY( int type, const wxFileName& fileName ) +CMP_LIBRARY::CMP_LIBRARY( int aType, const wxFileName& aFileName ) { - m_Type = type; /* type indicator */ - m_IsModified = false; /* modified indicator */ - m_TimeStamp = 0; - m_Flags = 0; - m_IsCache = false; - m_DateTime = wxDateTime::Now(); + m_Type = aType; + isModified = false; + timeStamp = 0; + m_Flags = 0; + isCache = false; + timeStamp = wxDateTime::Now(); - if( fileName.IsOk() ) - m_fileName = fileName; + if( aFileName.IsOk() ) + fileName = aFileName; else - m_fileName = wxFileName( wxT( "unnamed.lib" ) ); + fileName = wxFileName( wxT( "unnamed.lib" ) ); } @@ -94,70 +94,69 @@ CMP_LIBRARY::~CMP_LIBRARY() } -void CMP_LIBRARY::GetEntryNames( wxArrayString& names, bool sort, - bool makeUpperCase ) +void CMP_LIBRARY::GetEntryNames( wxArrayString& aNames, bool aSort, bool aMakeUpperCase ) { - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if( makeUpperCase ) + if( aMakeUpperCase ) { wxString tmp = entry.GetName(); tmp.MakeUpper(); - names.Add( tmp ); + aNames.Add( tmp ); } else { - names.Add( entry.GetName() ); + aNames.Add( entry.GetName() ); } } - if( sort ) - names.Sort(); + if( aSort ) + aNames.Sort(); } -void CMP_LIBRARY::SearchEntryNames( wxArrayString& names, - const wxString& nameSearch, - const wxString& keySearch, - bool sort ) +void CMP_LIBRARY::SearchEntryNames( wxArrayString& aNames, + const wxString& aNameSearch, + const wxString& aKeySearch, + bool aSort ) { - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if( !keySearch.IsEmpty() && KeyWordOk( keySearch, entry.m_KeyWord ) ) - names.Add( entry.GetName() ); - if( !nameSearch.IsEmpty() && WildCompareString( nameSearch, - entry.GetName(), - false ) ) - names.Add( entry.GetName() ); + if( !aKeySearch.IsEmpty() && KeyWordOk( aKeySearch, entry.GetKeyWords() ) ) + aNames.Add( entry.GetName() ); + if( !aNameSearch.IsEmpty() && WildCompareString( aNameSearch, + entry.GetName(), + false ) ) + aNames.Add( entry.GetName() ); } - if( sort ) - names.Sort(); + if( aSort ) + aNames.Sort(); } -void CMP_LIBRARY::SearchEntryNames( wxArrayString& names, const wxRegEx& re, - bool sort ) +void CMP_LIBRARY::SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe, + bool aSort ) { - if( !re.IsValid() ) + if( !aRe.IsValid() ) return; - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if( re.Matches( entry.m_KeyWord ) ) - names.Add( entry.GetName() ); + if( aRe.Matches( entry.GetKeyWords() ) ) + aNames.Add( entry.GetName() ); } - if( sort ) - names.Sort(); + if( aSort ) + aNames.Sort(); } -CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name ) +CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName ) { - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if( entry.GetName().CmpNoCase( name ) == 0 ) + if( entry.GetName().CmpNoCase( aName ) == 0 ) return &entry; } @@ -165,11 +164,11 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name ) } -CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name, LibrEntryType type ) +CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName, LibrEntryType aType ) { - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if( entry.GetName().CmpNoCase( name ) == 0 && entry.Type == type ) + if( entry.GetName().CmpNoCase( aName ) == 0 && entry.GetType() == aType ) return &entry; } @@ -177,12 +176,12 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name, LibrEntryType type ) } -LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* name ) +LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName ) { LIB_COMPONENT* component = NULL; - CMP_LIB_ENTRY* entry = FindEntry( name ); + CMP_LIB_ENTRY* entry = FindEntry( aName ); - if( entry != NULL && entry->Type == ALIAS ) + if( entry != NULL && entry->isAlias() ) { LIB_ALIAS* alias = (LIB_ALIAS*) entry; component = alias->GetComponent(); @@ -196,41 +195,41 @@ LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* name ) } -bool CMP_LIBRARY::AddAlias( LIB_ALIAS* alias ) +bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) { - wxASSERT( alias != NULL ); + wxASSERT( aAlias != NULL ); - if( FindEntry( alias->GetName() ) != NULL ) + if( FindEntry( aAlias->GetName() ) != NULL ) { wxString msg; msg.Printf( _( "Cannot add duplicate alias <%s> to library <%s>." ), - GetChars( alias->GetName() ), - GetChars( m_fileName.GetName() ) ); + GetChars( aAlias->GetName() ), + GetChars( fileName.GetName() ) ); return false; } - m_Entries.push_back( (CMP_LIB_ENTRY*) alias ); - m_IsModified = true; + entries.push_back( (CMP_LIB_ENTRY*) aAlias ); + isModified = true; return true; } -LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* cmp ) +LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) { - wxASSERT( cmp != NULL ); + wxASSERT( aComponent != NULL ); - LIB_COMPONENT* newCmp = new LIB_COMPONENT( *cmp, this ); + LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this ); if( newCmp == NULL ) return NULL; - m_Entries.push_back( (CMP_LIB_ENTRY*) newCmp ); - m_IsModified = true; + entries.push_back( (CMP_LIB_ENTRY*) newCmp ); + isModified = true; /* Cache libraries are component only libraries. Do not create alias * entries. */ - if( !m_IsCache ) + if( !isCache ) { for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) { @@ -239,255 +238,249 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* cmp ) if( alias == NULL ) { alias = new LIB_ALIAS( newCmp->m_AliasList[ i ], newCmp ); - m_Entries.push_back( alias ); + entries.push_back( alias ); } else if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) { - wxLogError( _( "Conflict in library <%s>: alias <%s> already \ -has root name <%s> and will not be assigned to root name <%s>." ), - GetChars( m_fileName.GetName() ), + wxLogError( _( "Conflict in library <%s>: alias <%s> already has root name \ +<%s> and will not be assigned to root name <%s>." ), + GetChars( fileName.GetName() ), GetChars( alias->GetComponent()->GetName() ), GetChars( newCmp->GetName() ) ); } } } - m_Entries.sort(); - m_Entries.unique( DuplicateEntryName ); + entries.sort(); + entries.unique( DuplicateEntryName ); return newCmp; } -void CMP_LIBRARY::RemoveEntry( const wxString& name ) +void CMP_LIBRARY::RemoveEntry( const wxString& aName ) { LIB_ENTRY_LIST::iterator i; - for( i = m_Entries.begin(); i < m_Entries.end(); i++ ) + for( i = entries.begin(); i < entries.end(); i++ ) { - if( i->GetName().CmpNoCase( name ) == 0 ) + if( i->GetName().CmpNoCase( aName ) == 0 ) { - m_Entries.erase( i ); + entries.erase( i ); return; } } } -void CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* entry ) +void CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* aEntry ) { - wxASSERT( entry != NULL ); + wxASSERT( aEntry != NULL ); - LIB_COMPONENT* Root; - LIB_ALIAS* Alias; + LIB_COMPONENT* root; + LIB_ALIAS* alias; - m_IsModified = true; + isModified = true; - if( entry->Type == ALIAS ) + if( aEntry->isAlias() ) { - Alias = (LIB_ALIAS*) entry; - Root = Alias->GetComponent(); + alias = (LIB_ALIAS*) aEntry; + root = alias->GetComponent(); /* Remove alias name from the root component alias list */ - if( Root == NULL ) + if( root == NULL ) { - wxLogWarning( wxT( "No root component found for alias <%s> in \ -library <%s>." ), - GetChars( entry->GetName() ), - GetChars( m_fileName.GetName() ) ); + wxLogWarning( wxT( "No root component found for alias <%s> in library <%s>." ), + GetChars( aEntry->GetName() ), + GetChars( fileName.GetName() ) ); } else { - int index = Root->m_AliasList.Index( entry->GetName(), false ); + int index = root->m_AliasList.Index( aEntry->GetName(), false ); if( index == wxNOT_FOUND ) - wxLogWarning( wxT( "Alias <%s> not found in component <%s> \ -alias list in library <%s>" ), - GetChars( entry->GetName() ), - GetChars( Root->GetName() ), - GetChars( m_fileName.GetName() ) ); + wxLogWarning( wxT( "Alias <%s> not found in component <%s> alias list in \ +library <%s>" ), + GetChars( aEntry->GetName() ), + GetChars( root->GetName() ), + GetChars( fileName.GetName() ) ); else - Root->m_AliasList.RemoveAt( index ); + root->m_AliasList.RemoveAt( index ); } - RemoveEntry( Alias->GetName() ); + RemoveEntry( alias->GetName() ); return; } - Root = ( LIB_COMPONENT* ) entry; + root = ( LIB_COMPONENT* ) aEntry; /* Entry is a component with no aliases so removal is simple. */ - if( Root->m_AliasList.GetCount() == 0 ) + if( root->m_AliasList.GetCount() == 0 ) { - RemoveEntry( Root->GetName() ); + RemoveEntry( root->GetName() ); return; } /* Entry is a component with one or more alias. */ - wxString AliasName = Root->m_AliasList[0]; + wxString aliasName = root->m_AliasList[0]; /* The root component is not really deleted, it is renamed with the first * alias name. */ - Alias = FindAlias( AliasName ); + alias = FindAlias( aliasName ); - if( Alias == NULL ) + if( alias == NULL ) { - wxLogWarning( wxT( "Alias <%s> for component <%s> not found in \ -library <%s>" ), - GetChars( AliasName ), - GetChars( Root->GetName() ), - GetChars( m_fileName.GetName() ) ); + wxLogWarning( wxT( "Alias <%s> for component <%s> not found in library <%s>" ), + GetChars( aliasName ), + GetChars( root->GetName() ), + GetChars( fileName.GetName() ) ); return; } /* Remove the first alias name from the component alias list. */ - Root->m_AliasList.RemoveAt( 0 ); + root->m_AliasList.RemoveAt( 0 ); /* Rename the component to the name of the first alias. */ - Root->m_Doc = Alias->m_Doc; - Root->m_KeyWord = Alias->m_KeyWord; + root->SetDescription( alias->GetDescription() ); + root->SetKeyWords( alias->GetKeyWords() ); /* Remove the first alias from library. */ - RemoveEntry( AliasName ); + RemoveEntry( aliasName ); /* Change the root name. */ - Root->SetName( AliasName ); + root->SetName( aliasName ); } -LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* oldComponent, - LIB_COMPONENT* newComponent ) +LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, + LIB_COMPONENT* aNewComponent ) { - wxASSERT( oldComponent != NULL && newComponent != NULL - && oldComponent->GetName().CmpNoCase( newComponent->GetName() )== 0 ); + wxASSERT( aOldComponent != NULL && aNewComponent != NULL + && aOldComponent->GetName().CmpNoCase( aNewComponent->GetName() )== 0 ); size_t i; int index; LIB_ALIAS* alias; - if( oldComponent->m_AliasList != newComponent->m_AliasList ) + if( aOldComponent->m_AliasList != aNewComponent->m_AliasList ) { /* Remove extra aliases. */ - for( i = 0; i < oldComponent->m_AliasList.GetCount(); i++ ) + for( i = 0; i < aOldComponent->m_AliasList.GetCount(); i++ ) { index = - newComponent->m_AliasList.Index( oldComponent->m_AliasList[ i ] ); + aNewComponent->m_AliasList.Index( aOldComponent->m_AliasList[ i ] ); if( index != wxNOT_FOUND ) continue; - wxLogDebug( wxT( "Removing extra alias <%s> from component <%s> \ -in library <%s>." ), - GetChars( oldComponent->m_AliasList[ i ] ), - GetChars( oldComponent->GetName() ), - GetChars( m_fileName.GetName() ) ); + wxLogDebug( wxT( "Removing extra alias <%s> from component <%s> in library <%s>." ), + GetChars( aOldComponent->m_AliasList[ i ] ), + GetChars( aOldComponent->GetName() ), + GetChars( fileName.GetName() ) ); - RemoveEntry( oldComponent->m_AliasList[ i ] ); + RemoveEntry( aOldComponent->m_AliasList[ i ] ); } /* Add new aliases. */ - for( i = 0; i < newComponent->m_AliasList.GetCount(); i++ ) + for( i = 0; i < aNewComponent->m_AliasList.GetCount(); i++ ) { - index = - oldComponent->m_AliasList.Index( newComponent->m_AliasList[ i ] ); + index = aOldComponent->m_AliasList.Index( aNewComponent->m_AliasList[ i ] ); if( index != wxNOT_FOUND - || FindEntry( newComponent->m_AliasList[ i ] ) != NULL ) + || FindEntry( aNewComponent->m_AliasList[ i ] ) != NULL ) continue; - wxLogDebug( wxT( "Adding extra alias <%s> from component <%s> \ -in library <%s>." ), - GetChars( newComponent->m_AliasList[ i ] ), - GetChars( newComponent->GetName() ), - GetChars( m_fileName.GetName() ) ); + wxLogDebug( wxT( "Adding extra alias <%s> from component <%s> in library <%s>." ), + GetChars( aNewComponent->m_AliasList[ i ] ), + GetChars( aNewComponent->GetName() ), + GetChars( fileName.GetName() ) ); - alias = new LIB_ALIAS( newComponent->m_AliasList[ i ], - newComponent ); - m_Entries.push_back( alias ); + alias = new LIB_ALIAS( aNewComponent->m_AliasList[ i ], aNewComponent ); + entries.push_back( alias ); } } - RemoveEntry( oldComponent->GetName() ); + RemoveEntry( aOldComponent->GetName() ); - LIB_COMPONENT* newCmp = new LIB_COMPONENT( *newComponent, this ); + LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aNewComponent, this ); if( newCmp == NULL ) return NULL; - m_Entries.push_back( (CMP_LIB_ENTRY*) newCmp ); - m_Entries.sort(); - m_IsModified = true; + entries.push_back( (CMP_LIB_ENTRY*) newCmp ); + entries.sort(); + isModified = true; return newCmp; } -CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* name ) +CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) { size_t i; CMP_LIB_ENTRY* entry = NULL; - for( i = 0; i < m_Entries.size(); i++ ) + for( i = 0; i < entries.size(); i++ ) { - if( m_Entries[i].GetName().CmpNoCase( name ) == 0 ) + if( entries[i].GetName().CmpNoCase( aName ) == 0 ) { - if( i < m_Entries.size() - 1 ) + if( i < entries.size() - 1 ) { - entry = &m_Entries[ i + 1 ]; + entry = &entries[ i + 1 ]; break; } } } if( entry == NULL ) - entry = &m_Entries.front(); + entry = &entries.front(); return entry; } -CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* name ) +CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) { size_t i; CMP_LIB_ENTRY* entry = NULL; - for( i = 0; i < m_Entries.size(); i++ ) + for( i = 0; i < entries.size(); i++ ) { - if( m_Entries[i].GetName().CmpNoCase( name ) == 0 && entry ) + if( entries[i].GetName().CmpNoCase( aName ) == 0 && entry ) break; - entry = &m_Entries[i]; + entry = &entries[i]; } return entry; } -bool CMP_LIBRARY::Load( wxString& errMsg ) +bool CMP_LIBRARY::Load( wxString& aErrorMsg ) { - FILE* f; - int LineNum = 0; - char Line[1024]; - LIB_COMPONENT* LibEntry; + FILE* file; + int lineNumber = 0; + char line[1024]; + LIB_COMPONENT* libEntry; wxString msg; - if( m_fileName.GetFullPath().IsEmpty() ) + if( fileName.GetFullPath().IsEmpty() ) { - errMsg = _( "The component library file name is not set." ); + aErrorMsg = _( "The component library file name is not set." ); return false; } - f = wxFopen( m_fileName.GetFullPath(), wxT( "rt" ) ); + file = wxFopen( fileName.GetFullPath(), wxT( "rt" ) ); - if( f == NULL ) + if( file == NULL ) { - errMsg = _( "The file could not be opened." ); + aErrorMsg = _( "The file could not be opened." ); return false; } - if( GetLine( f, Line, &LineNum, sizeof( Line ) ) == NULL ) + if( GetLine( file, line, &lineNumber, sizeof( line ) ) == NULL ) { - errMsg = _( "The file is empty!" ); + aErrorMsg = _( "The file is empty!" ); return false; } @@ -496,9 +489,9 @@ bool CMP_LIBRARY::Load( wxString& errMsg ) { wxString tmp; - m_Header = CONV_FROM_UTF8( Line ); + header = CONV_FROM_UTF8( line ); - wxStringTokenizer tkn( m_Header ); + wxStringTokenizer tkn( header ); /* * The file header (first line) in library versions 2.0 and lower @@ -510,20 +503,19 @@ bool CMP_LIBRARY::Load( wxString& errMsg ) if( !tkn.HasMoreTokens() || !tkn.GetNextToken().Upper().StartsWith(wxT( "EESCHEMA-LIB" ) ) ) { - errMsg = _( "The file is NOT an EESCHEMA library!" ); + aErrorMsg = _( "The file is NOT an EESCHEMA library!" ); return false; } if( !tkn.HasMoreTokens() ) { - errMsg = wxT( - "The file header is missing version and time stamp information." ); + aErrorMsg = _( "The file header is missing version and time stamp information." ); return false; } if( tkn.GetNextToken() != wxT( "Version" ) || !tkn.HasMoreTokens() ) { - errMsg = wxT( "The file header version information is invalid." ); + aErrorMsg = wxT( "The file header version information is invalid." ); return false; } @@ -544,62 +536,62 @@ the current schematic." ), } else { - m_verMajor = (int) major; - m_verMinor = (int) minor; + versionMajor = (int) major; + versionMinor = (int) minor; wxLogDebug( wxT( "Component library <%s> is version %d.%d." ), - GetChars( GetName() ), m_verMajor, m_verMinor ); + GetChars( GetName() ), versionMajor, versionMinor ); } } - while( GetLine( f, Line, &LineNum, sizeof( Line ) ) ) + while( GetLine( file, line, &lineNumber, sizeof( line ) ) ) { if( m_Type == LIBRARY_TYPE_EESCHEMA - && strnicmp( Line, "$HEADER", 7 ) == 0 ) + && strnicmp( line, "$HEADER", 7 ) == 0 ) { - if( !LoadHeader( f, &LineNum ) ) + if( !LoadHeader( file, &lineNumber ) ) { - errMsg = _( "An error occurred attempting to read the header." ); + aErrorMsg = _( "An error occurred attempting to read the header." ); return false; } continue; } - if( strnicmp( Line, "DEF", 3 ) == 0 ) + if( strnicmp( line, "DEF", 3 ) == 0 ) { /* Read one DEF/ENDDEF part entry from library: */ - LibEntry = new LIB_COMPONENT( wxEmptyString, this ); + libEntry = new LIB_COMPONENT( wxEmptyString, this ); - if( LibEntry->Load( f, Line, &LineNum, msg ) ) + if( libEntry->Load( file, line, &lineNumber, msg ) ) { /* Check for duplicate entry names and warn the user about * the potential conflict. */ - if( FindEntry( LibEntry->GetName() ) != NULL ) + if( FindEntry( libEntry->GetName() ) != NULL ) { wxString msg( wxGetTranslation(duplicate_name_msg)); wxLogWarning( msg, - GetChars( m_fileName.GetName() ), - GetChars( LibEntry->GetName() ) ); + GetChars( fileName.GetName() ), + GetChars( libEntry->GetName() ) ); } /* If we are here, this part is O.k. - put it in: */ - m_Entries.push_back( LibEntry ); - LoadAliases( LibEntry ); + entries.push_back( libEntry ); + LoadAliases( libEntry ); } else { wxLogWarning( _( "Library <%s> component load error %s." ), - GetChars( m_fileName.GetName() ), + GetChars( fileName.GetName() ), GetChars( msg ) ); msg.Clear(); - delete LibEntry; + delete libEntry; } } } - m_Entries.sort(); + entries.sort(); return true; } @@ -607,7 +599,7 @@ the current schematic." ), void CMP_LIBRARY::LoadAliases( LIB_COMPONENT* component ) { - wxASSERT( component != NULL && component->Type == ROOT ); + wxASSERT( component != NULL && component->isComponent() ); LIB_ALIAS* alias; unsigned ii; @@ -618,12 +610,12 @@ void CMP_LIBRARY::LoadAliases( LIB_COMPONENT* component ) { wxString msg( wxGetTranslation(duplicate_name_msg)); wxLogError( msg, - GetChars( m_fileName.GetName() ), + GetChars( fileName.GetName() ), GetChars( component->m_AliasList[ii] ) ); } alias = new LIB_ALIAS( component->m_AliasList[ii], component, this ); - m_Entries.push_back( alias ); + entries.push_back( alias ); } } @@ -637,7 +629,7 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum ) text = strtok( Line, " \t\r\n" ); data = strtok( NULL, " \t\r\n" ); if( stricmp( text, "TimeStamp" ) == 0 ) - m_TimeStamp = atol( data ); + timeStamp = atol( data ); if( stricmp( text, "$ENDHEADER" ) == 0 ) return TRUE; } @@ -646,97 +638,96 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum ) } -bool CMP_LIBRARY::LoadDocs( wxString& errMsg ) +bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg ) { - int LineNum = 0; - char Line[1024], * Name, * Text; - CMP_LIB_ENTRY* Entry; - FILE* f; + int lineNumber = 0; + char line[1024], * name, * text; + CMP_LIB_ENTRY* entry; + FILE* file; wxString msg; - wxFileName fn = m_fileName; + wxFileName fn = fileName; fn.SetExt( DOC_EXT ); - f = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); + file = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); - if( f == NULL ) + if( file == NULL ) { - errMsg.Printf( _( "Could not open component document library file <%s>." ), - GetChars( fn.GetFullPath() ) ); + aErrorMsg.Printf( _( "Could not open component document library file <%s>." ), + GetChars( fn.GetFullPath() ) ); return false; } - if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL ) + if( GetLine( file, line, &lineNumber, sizeof(line) ) == NULL ) { - errMsg.Printf( _( "Component document library file <%s> is empty." ), - GetChars( fn.GetFullPath() ) ); - fclose( f ); + aErrorMsg.Printf( _( "Component document library file <%s> is empty." ), + GetChars( fn.GetFullPath() ) ); + fclose( file ); return false; } - if( strnicmp( Line, DOCFILE_IDENT, 10 ) != 0 ) + if( strnicmp( line, DOCFILE_IDENT, 10 ) != 0 ) { - errMsg.Printf( _( "File <%s> is not a valid component library \ -document file." ), - GetChars( fn.GetFullPath() ) ); - fclose( f ); + aErrorMsg.Printf( _( "File <%s> is not a valid component library document file." ), + GetChars( fn.GetFullPath() ) ); + fclose( file ); return false; } - while( GetLine( f, Line, &LineNum, sizeof(Line) ) ) + while( GetLine( file, line, &lineNumber, sizeof(line) ) ) { - if( strncmp( Line, "$CMP", 4 ) != 0 ) + if( strncmp( line, "$CMP", 4 ) != 0 ) { - errMsg.Printf( wxT( "$CMP command expected in line %d, aborted." ), - LineNum ); - fclose( f ); + aErrorMsg.Printf( wxT( "$CMP command expected in line %d, aborted." ), + lineNumber ); + fclose( file ); return false; } /* Read one $CMP/$ENDCMP part entry from library: */ - Name = strtok( Line + 5, "\n\r" ); + name = strtok( line + 5, "\n\r" ); - wxString cmpname = CONV_FROM_UTF8( Name ); + wxString cmpname = CONV_FROM_UTF8( name ); - Entry = FindEntry( cmpname ); + entry = FindEntry( cmpname ); - while( GetLine( f, Line, &LineNum, sizeof(Line) ) ) + while( GetLine( file, line, &lineNumber, sizeof(line) ) ) { - if( strncmp( Line, "$ENDCMP", 7 ) == 0 ) + if( strncmp( line, "$ENDCMP", 7 ) == 0 ) break; - Text = strtok( Line + 2, "\n\r" ); + text = strtok( line + 2, "\n\r" ); - switch( Line[0] ) + switch( line[0] ) { case 'D': - if( Entry ) - Entry->m_Doc = CONV_FROM_UTF8( Text ); + if( entry ) + entry->SetDescription( CONV_FROM_UTF8( text ) ); break; case 'K': - if( Entry ) - Entry->m_KeyWord = CONV_FROM_UTF8( Text ); + if( entry ) + entry->SetKeyWords( CONV_FROM_UTF8( text ) ); break; case 'F': - if( Entry ) - Entry->m_DocFile = CONV_FROM_UTF8( Text ); + if( entry ) + entry->SetDocFileName( CONV_FROM_UTF8( text ) ); break; } } } - fclose( f ); + fclose( file ); return true; } -bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat ) +bool CMP_LIBRARY::Save( const wxString& aFullFileName, bool aOldDocFormat ) { FILE* libfile; wxString msg; - wxFileName libFileName = FullFileName; - wxFileName backupFileName = FullFileName; + wxFileName libFileName = aFullFileName; + wxFileName backupFileName = aFullFileName; /* the old .lib file is renamed .bak */ if( libFileName.FileExists() ) @@ -765,9 +756,9 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat ) return false; } - m_IsModified = false; + isModified = false; - m_TimeStamp = GetTimeStamp(); + timeStamp = GetTimeStamp(); if( !SaveHeader( libfile ) ) { fclose( libfile ); @@ -776,9 +767,9 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat ) bool success = true; - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { - if ( entry.Type == ROOT ) + if ( entry.isComponent() ) { LIB_COMPONENT* component = ( LIB_COMPONENT* ) &entry; if ( !component->Save( libfile ) ) @@ -791,19 +782,19 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat ) fclose( libfile ); - if( USE_OLD_DOC_FILE_FORMAT( m_verMajor, m_verMinor ) && oldDocFormat ) - success = SaveDocFile( FullFileName ); + if( USE_OLD_DOC_FILE_FORMAT( versionMajor, versionMinor ) && aOldDocFormat ) + success = SaveDocFile( aFullFileName ); return success; } -bool CMP_LIBRARY::SaveDocFile( const wxString& FullFileName ) +bool CMP_LIBRARY::SaveDocFile( const wxString& aFullFileName ) { FILE* docfile; wxString msg; - wxFileName backupFileName = FullFileName; - wxFileName docFileName = FullFileName; + wxFileName backupFileName = aFullFileName; + wxFileName docFileName = aFullFileName; docFileName.SetExt( DOC_EXT ); @@ -834,9 +825,9 @@ bool CMP_LIBRARY::SaveDocFile( const wxString& FullFileName ) return false; } - char Line[256]; + char line[256]; if( fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, - DateAndTime( Line ) ) < 0 ) + DateAndTime( line ) ) < 0 ) { fclose( docfile ); return false; @@ -844,7 +835,7 @@ bool CMP_LIBRARY::SaveDocFile( const wxString& FullFileName ) bool success = true; - BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries ) + BOOST_FOREACH( CMP_LIB_ENTRY& entry, entries ) { if ( !entry.SaveDoc( docfile ) ) success = false; @@ -859,20 +850,20 @@ bool CMP_LIBRARY::SaveDocFile( const wxString& FullFileName ) } -bool CMP_LIBRARY::SaveHeader( FILE* file ) +bool CMP_LIBRARY::SaveHeader( FILE* aFile ) { char BufLine[1024]; bool succes = true; DateAndTime( BufLine ); - if( fprintf( file, "%s %d.%d Date: %s\n", LIBFILE_IDENT, + if( fprintf( aFile, "%s %d.%d Date: %s\n", LIBFILE_IDENT, LIB_VERSION_MAJOR, LIB_VERSION_MINOR, BufLine ) < 0 ) succes = false; #if 0 - if( ( fprintf( file, "$HEADER\n" ) < 0 ) - || ( fprintf( file, "TimeStamp %8.8lX\n", m_TimeStamp ) < 0 ) - || ( fprintf( file, "Parts %d\n", m_Entries.size() ) != 2 ) - || ( fprintf( file, "$ENDHEADER\n" ) != 1 ) ) + if( ( fprintf( aFile, "$HEADER\n" ) < 0 ) + || ( fprintf( aFile, "TimeStamp %8.8lX\n", m_TimeStamp ) < 0 ) + || ( fprintf( aFile, "Parts %d\n", entries.size() ) != 2 ) + || ( fprintf( aFile, "$ENDHEADER\n" ) != 1 ) ) succes = false; #endif return succes; @@ -882,122 +873,122 @@ bool CMP_LIBRARY::SaveHeader( FILE* file ) /* * The static library list and list management methods. */ -CMP_LIBRARY_LIST CMP_LIBRARY::m_LibraryList; -wxArrayString CMP_LIBRARY::m_LibraryListSortOrder; +CMP_LIBRARY_LIST CMP_LIBRARY::libraryList; +wxArrayString CMP_LIBRARY::libraryListSortOrder; -CMP_LIBRARY* CMP_LIBRARY::LoadLibrary( const wxFileName& fileName, - wxString& errMsg ) +CMP_LIBRARY* CMP_LIBRARY::LoadLibrary( const wxFileName& aFileName, wxString& aErrorMsg ) { CMP_LIBRARY* lib = NULL; - lib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fileName ); + lib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, aFileName ); wxBusyCursor ShowWait; - if( !lib->Load( errMsg ) ) + if( !lib->Load( aErrorMsg ) ) { delete lib; return NULL; } - if( USE_OLD_DOC_FILE_FORMAT( lib->m_verMajor, lib->m_verMinor ) ) - lib->LoadDocs( errMsg ); + if( USE_OLD_DOC_FILE_FORMAT( lib->versionMajor, lib->versionMinor ) ) + lib->LoadDocs( aErrorMsg ); return lib; } -bool CMP_LIBRARY::AddLibrary( const wxFileName& fileName, wxString& errMsg ) +bool CMP_LIBRARY::AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg ) { CMP_LIBRARY* lib; /* Don't reload the library if it is already loaded. */ - lib = FindLibrary( fileName.GetName() ); + lib = FindLibrary( aFileName.GetName() ); if( lib != NULL ) return true; - lib = LoadLibrary( fileName, errMsg ); + lib = LoadLibrary( aFileName, aErrorMsg ); if( lib == NULL ) return false; - m_LibraryList.push_back( lib ); + libraryList.push_back( lib ); return true; } -bool CMP_LIBRARY::AddLibrary( const wxFileName& fileName, wxString& errMsg, - CMP_LIBRARY_LIST::iterator& i ) +bool CMP_LIBRARY::AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg, + CMP_LIBRARY_LIST::iterator& aIterator ) { CMP_LIBRARY* lib; /* Don't reload the library if it is already loaded. */ - lib = FindLibrary( fileName.GetName() ); + lib = FindLibrary( aFileName.GetName() ); if( lib != NULL ) return true; - lib = LoadLibrary( fileName, errMsg ); + lib = LoadLibrary( aFileName, aErrorMsg ); if( lib == NULL ) return false; - if( i >= m_LibraryList.begin() && i < m_LibraryList.end() ) - m_LibraryList.insert( i, lib ); + if( aIterator >= libraryList.begin() && aIterator < libraryList.end() ) + libraryList.insert( aIterator, lib ); else - m_LibraryList.push_back( lib ); + libraryList.push_back( lib ); return true; } -void CMP_LIBRARY::RemoveLibrary( const wxString& name ) +void CMP_LIBRARY::RemoveLibrary( const wxString& aName ) { - if( name.IsEmpty() ) + if( aName.IsEmpty() ) return; CMP_LIBRARY_LIST::iterator i; - for ( i = m_LibraryList.begin(); i < m_LibraryList.end(); i++ ) + for ( i = libraryList.begin(); i < libraryList.end(); i++ ) { - if( i->GetName().CmpNoCase( name ) == 0 ) + if( i->GetName().CmpNoCase( aName ) == 0 ) { - CMP_LIBRARY::m_LibraryList.erase( i ); + CMP_LIBRARY::libraryList.erase( i ); return; } } } -CMP_LIBRARY* CMP_LIBRARY::FindLibrary( const wxString& name ) +CMP_LIBRARY* CMP_LIBRARY::FindLibrary( const wxString& aName ) { - BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList ) + BOOST_FOREACH( CMP_LIBRARY& lib, libraryList ) { - if( lib == name ) + if( lib == aName ) return &lib; } return NULL; } -wxArrayString CMP_LIBRARY::GetLibraryNames( bool sorted ) + +wxArrayString CMP_LIBRARY::GetLibraryNames( bool aSorted ) { wxString cacheName; wxArrayString names; - BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::m_LibraryList ) + BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::libraryList ) { - if( lib.m_IsCache && sorted ) + if( lib.isCache && aSorted ) cacheName = lib.GetName(); else names.Add( lib.GetName() ); } /* Even sorted, the cache library is always at the end of the list. */ - if( sorted ) + if( aSorted ) names.Sort(); if( !cacheName.IsEmpty() ) @@ -1007,17 +998,17 @@ wxArrayString CMP_LIBRARY::GetLibraryNames( bool sorted ) } -LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& name, - const wxString& libName ) +LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& aName, + const wxString& aLibraryName ) { LIB_COMPONENT* component = NULL; - BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList ) + BOOST_FOREACH( CMP_LIBRARY& lib, libraryList ) { - if( !libName.IsEmpty() && lib.GetName() != libName ) + if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName ) continue; - component = lib.FindComponent( name ); + component = lib.FindComponent( aName ); if( component != NULL ) break; @@ -1027,17 +1018,17 @@ LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& name, } -CMP_LIB_ENTRY* CMP_LIBRARY::FindLibraryEntry( const wxString& name, - const wxString& libName ) +CMP_LIB_ENTRY* CMP_LIBRARY::FindLibraryEntry( const wxString& aName, + const wxString& aLibraryName ) { CMP_LIB_ENTRY* entry = NULL; - BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList ) + BOOST_FOREACH( CMP_LIBRARY& lib, libraryList ) { - if( !libName.IsEmpty() && lib.GetName() != libName ) + if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName ) continue; - entry = lib.FindEntry( name ); + entry = lib.FindEntry( aName ); if( entry != NULL ) break; @@ -1047,13 +1038,13 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindLibraryEntry( const wxString& name, } -void CMP_LIBRARY::RemoveCacheLibrary( void ) +void CMP_LIBRARY::RemoveCacheLibrary() { CMP_LIBRARY_LIST::iterator i; - for ( i = m_LibraryList.begin(); i < m_LibraryList.end(); i++ ) + for ( i = libraryList.begin(); i < libraryList.end(); i++ ) { - if( i->m_IsCache ) - m_LibraryList.erase( i-- ); + if( i->isCache ) + libraryList.erase( i-- ); } } diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 7ef46f5019..6b2bee4e1d 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -61,15 +61,13 @@ class CMP_LIBRARY { public: int m_Type; /* type indicator */ - wxString m_Header; /* first line of loaded library. */ - unsigned long m_TimeStamp; // Signature temporelle - int m_Flags; // variable used in some functions + int m_Flags; public: - CMP_LIBRARY( int type, const wxFileName& fullname ); - CMP_LIBRARY( int type, const wxString& fullname ) + CMP_LIBRARY( int aType, const wxFileName& aFileName ); + CMP_LIBRARY( int aType, const wxString& aFileName ) { - CMP_LIBRARY( type, wxFileName( fullname ) ); + CMP_LIBRARY( aType, wxFileName( aFileName ) ); } ~CMP_LIBRARY(); @@ -86,12 +84,12 @@ public: * component library already exists, it is backup up in file *.bak. * * @param aFullFileName - The library filename with path. - * @param oldDocFormat - Save the document information in a separate - * file if true. The default is to save as the - * current library file format. + * @param aOldDocFormat - Save the document information in a separate + * file if true. The default is to save as the + * current library file format. * @return True if success writing else false. */ - bool Save( const wxString& aFullFileName, bool oldDocFormat = false ); + bool Save( const wxString& aFullFileName, bool aOldDocFormat = false ); /** * Save library document information to file. @@ -102,25 +100,25 @@ public: * @param aFullFileName - The library filename with path. * @return True if success writing else false. */ - bool SaveDocFile( const wxString& FullFileName ); + bool SaveDocFile( const wxString& aFullFileName ); /** * Load library from file. * - * @param errMsg - Error message if load fails. + * @param aErrorMsg - Error message if load fails. * @return True if load was successful otherwise false. */ - bool Load( wxString& errMsg ); + bool Load( wxString& aErrorMsg ); - bool LoadDocs( wxString& errMsg ); + bool LoadDocs( wxString& aErrorMsg ); private: - bool SaveHeader( FILE* file ); + bool SaveHeader( FILE* aFile ); - bool LoadHeader( FILE* file, int* LineNum ); - void LoadAliases( LIB_COMPONENT* component ); + bool LoadHeader( FILE* aFile, int* aLineNum ); + void LoadAliases( LIB_COMPONENT* aComponent ); - void RemoveEntry( const wxString& name ); + void RemoveEntry( const wxString& aName ); public: /** @@ -130,7 +128,7 @@ public: */ bool IsEmpty() const { - return m_Entries.empty(); + return entries.empty(); } /** @@ -140,29 +138,29 @@ public: */ int GetCount() const { - return m_Entries.size(); + return entries.size(); } bool IsModified() const { - return m_IsModified; + return isModified; } - bool IsCache() const { return m_IsCache; } + bool IsCache() const { return isCache; } - void SetModified( void ) { m_IsModified = true; } + void SetModified( void ) { isModified = true; } - void SetCache( void ) { m_IsCache = true; } + void SetCache( void ) { isCache = true; } /** * Load a string array with the names of all the entries in this library. * - * @param names - String array to place entry names into. - * @param sort - Sort names if true. - * @param makeUpperCase - Force entry names to upper case. + * @param aNames - String array to place entry names into. + * @param aSort - Sort names if true. + * @param aMakeUpperCase - Force entry names to upper case. */ - void GetEntryNames( wxArrayString& names, bool sort = true, - bool makeUpperCase = true ); + void GetEntryNames( wxArrayString& aNames, bool aSort = true, + bool aMakeUpperCase = true ); /** * Load string array with entry names matching name and/or key word. @@ -171,72 +169,70 @@ public: * WildCompareString(). The names array will be populated with the * library entry names that meat the search criteria on exit. * - * @param names - String array to place entry names into. - * @param nameSearch - Name wild card search criteria. - * @param keySearch - Key word search criteria. - * @param sort - Sort names if true. + * @param aNames - String array to place entry names into. + * @param aNameSearch - Name wild card search criteria. + * @param aKeySearch - Key word search criteria. + * @param aSort - Sort names if true. */ - void SearchEntryNames( wxArrayString& names, - const wxString& nameSearch = wxEmptyString, - const wxString& keySearch = wxEmptyString, - bool sort = true ); + void SearchEntryNames( wxArrayString& aNames, + const wxString& aNameSearch = wxEmptyString, + const wxString& aKeySearch = wxEmptyString, + bool aSort = true ); /** * Find components in library by key word regular expression search. * - * @param names - String array to place found component names into. - * @param re - Regular expression used to seach component key words. - * @param sort - Sort component name list. + * @param aNames - String array to place found component names into. + * @param aRe - Regular expression used to seach component key words. + * @param aSort - Sort component name list. */ - void SearchEntryNames( wxArrayString& names, const wxRegEx& re, - bool sort = true ); + void SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe, + bool aSort = true ); /** * Find entry by name. * - * @param name - Name of entry, case insensitive. - * @return Pointer to entry if found. NULL if not found. + * @param aName - Name of entry, case insensitive. + * @return Entry if found. NULL if not found. */ - CMP_LIB_ENTRY* FindEntry( const wxChar* name ); + CMP_LIB_ENTRY* FindEntry( const wxChar* aName ); /** - * Find entry by name and type. + * Find entry by /a aName and /a aType. * - * @param name - Name of entry, case insensitive. - * @param type - Type of entry, root or alias. - * @return Pointer to entry if found. NULL if not found. + * @param aName - Name of entry, case insensitive. + * @param aType - Type of entry, root or alias. + * @return Entry if found. NULL if not found. */ - CMP_LIB_ENTRY* FindEntry( const wxChar* name, LibrEntryType type ); + CMP_LIB_ENTRY* FindEntry( const wxChar* aName, LibrEntryType aType ); /** - * Find component by name. + * Find component by /a aName. * * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to * a LIB_COMPONENT pointer is not required. * - * @param name - Name of component, case insensitive. - * @param searchAliases - Searches for component by alias name as well as - * component name if true. - * @return Pointer to component if found. NULL if not found. + * @param aName - Name of component, case insensitive. + * @return Component if found. NULL if not found. */ - LIB_COMPONENT* FindComponent( const wxChar* name ); + LIB_COMPONENT* FindComponent( const wxChar* aName ); /** - * Find alias by name. + * Find alias by /a nName. * * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to * a LIB_ALIAS pointer is not required. * - * @param name - Name of alias, case insensitive. - * @return Pointer to alias if found. NULL if not found. + * @param aName - Name of alias, case insensitive. + * @return Alias if found. NULL if not found. */ - LIB_ALIAS* FindAlias( const wxChar* name ) + LIB_ALIAS* FindAlias( const wxChar* aName ) { - return (LIB_ALIAS*) FindEntry( name, ALIAS ); + return (LIB_ALIAS*) FindEntry( aName, ALIAS ); } /** - * Add a new alias entry to the library. + * Add a new /a aAlias entry to the library. * * First check if a component or alias with the same name already exists * in the library and add alias if no conflict occurs. Once the alias @@ -244,21 +240,21 @@ public: * alias pointer will render the library unstable. Use RemoveEntry to * remove the alias from the library. * - * @param alias - Alias to add to library. - * @return True if alias added to library. False if conflict exists. + * @param aAlias - Alias to add to library. + * @return True if alias added to library. False if a conflict exists. */ - bool AddAlias( LIB_ALIAS* alias ); + bool AddAlias( LIB_ALIAS* aAlias ); /** - * Add component entry to library. + * Add /a aComponent entry to library. * - * @param cmp - Component to add. - * @return Pointer to added component if successful. + * @param aComponent - Component to add. + * @return Added component if successful. */ - LIB_COMPONENT* AddComponent( LIB_COMPONENT* cmp ); + LIB_COMPONENT* AddComponent( LIB_COMPONENT* aComponent ); /** - * Remove an entry from the library. + * Remove an /a aEntry from the library. * * If the entry is an alias, the alias is removed from the library and from * the alias list of the root component. If the entry is a root component @@ -267,18 +263,18 @@ public: * the first alias and the root name for all remaining aliases are updated * to reflect the new root name. * - * @param entry - Entry to remove from library. + * @param aEntry - Entry to remove from library. */ - void RemoveEntry( CMP_LIB_ENTRY* entry ); + void RemoveEntry( CMP_LIB_ENTRY* aEntry ); /** * Replace an existing component entry in the library. * - * @param oldComponent - The component to replace. - * @param newComponent - The new component. + * @param aOldComponent - The component to replace. + * @param aNewComponent - The new component. */ - LIB_COMPONENT* ReplaceComponent( LIB_COMPONENT* oldComponent, - LIB_COMPONENT* newComponent ); + LIB_COMPONENT* ReplaceComponent( LIB_COMPONENT* aOldComponent, + LIB_COMPONENT* aNewComponent ); /** * Return the first entry in the library. @@ -287,55 +283,55 @@ public: */ CMP_LIB_ENTRY* GetFirstEntry() { - return &m_Entries.front(); + return &entries.front(); } /** - * Find next library entry by name. + * Find next library entry by /a aName. * * If the name of the entry is the last entry in the library, the first * entry in the list is returned. * - * @param name - Name of current entry. - * @return Pointer to next entry if entry name is found. Otherwise NULL. + * @param aName - Name of current entry. + * @return Next entry if entry name is found. Otherwise NULL. */ - CMP_LIB_ENTRY* GetNextEntry( const wxChar* name ); + CMP_LIB_ENTRY* GetNextEntry( const wxChar* aName ); /** - * Find previous library entry by name. + * Find previous library entry by /a aName. * * If the name of the entry is the first entry in the library, the last * entry in the list is returned. * - * @param name - Name of current entry. + * @param aName - Name of current entry. * @return Previous entry if entry name is found, otherwise NULL. */ - CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* name ); + CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* aName ); /** * Return the file name without path or extension. * * @return Name of library file. */ - wxString GetName() const { return m_fileName.GetName(); } + wxString GetName() const { return fileName.GetName(); } /** * Return the full file library name with path and extension. * * @return Full library file name with path and extension. */ - wxString GetFullFileName() { return m_fileName.GetFullPath(); } + wxString GetFullFileName() { return fileName.GetFullPath(); } /** * Set the component library file name. * - * @param fileName - New library file name. + * @param aFileName - New library file name. */ - void SetFileName( const wxFileName fileName ) + void SetFileName( const wxFileName aFileName ) { - if( fileName != m_fileName ) - m_fileName = fileName; + if( aFileName != fileName ) + fileName = aFileName; } /* @@ -348,57 +344,57 @@ public: /** * Load a component library file. * - * @param fileName - File name of the component library to load. - * @param errMsg - Error message if the component library failed to load. + * @param aFileName - File name of the component library to load. + * @param aErrorMsg - Error message if the component library failed to load. * @return Library object if library file loaded successfully, * otherwise NULL. */ - static CMP_LIBRARY* LoadLibrary( const wxFileName& fileName, - wxString& errMsg ); + static CMP_LIBRARY* LoadLibrary( const wxFileName& aFileName, + wxString& aErrorMsg ); /** * Add a compnent library to the library list. * - * @param fileName - File name object of component library. - * @param errMsg - Error message if the component library failed to load. + * @param aFileName - File name object of component library. + * @param aErrorMsg - Error message if the component library failed to load. * @return True if library loaded properly otherwise false. */ - static bool AddLibrary( const wxFileName& fileName, wxString& errMsg ); + static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg ); /** * Insert a compnent library to the library list. * - * @param fileName - File name object of component library. - * @param errMsg - Error message if the component library failed to load. - * @param i - Iterator to insert library in front of. + * @param aFileName - File name object of component library. + * @param aErrerMsg - Error message if the component library failed to load. + * @param aIteratir - Iterator to insert library in front of. * @return True if library loaded properly otherwise false. */ - static bool AddLibrary( const wxFileName& fileName, wxString& errMsg, - CMP_LIBRARY_LIST::iterator& i ); + static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg, + CMP_LIBRARY_LIST::iterator& aIterator ); /** * Remove component library from the library list. * - * @param name - Name of component library to remove. + * @param aName - Name of component library to remove. */ - static void RemoveLibrary( const wxString& name ); + static void RemoveLibrary( const wxString& aName ); /** - * Find component library by name. + * Find component library by /a aName. * - * @param name - Library file name without path or extension to find. - * @return Pointer to component library if found, otherwise NULL. + * @param aName - Library file name without path or extension to find. + * @return Component library if found, otherwise NULL. */ - static CMP_LIBRARY* FindLibrary( const wxString& name ); + static CMP_LIBRARY* FindLibrary( const wxString& aName ); /** * Get the list of component library file names without path and extension. * - * @param sorted - Sort the list of name if true. Otherwise use the - * library load order. + * @param aSorted - Sort the list of name if true. Otherwise use the + * library load order. * @return The list of library names. */ - static wxArrayString GetLibraryNames( bool sorted = true ); + static wxArrayString GetLibraryNames( bool aSorted = true ); /** * Search all libraries in the list for a component. @@ -406,60 +402,60 @@ public: * A component object will always be returned. If the entry found * is an alias. The root component will be found and returned. * - * @param name - Name of component to search for. - * @param libNaem - Name of the library to search for component. + * @param aCompoentName - Name of component to search for. + * @param aLibraryName - Name of the library to search for component. * @return The component object if found, otherwise NULL. */ - static LIB_COMPONENT* FindLibraryComponent( - const wxString& name, const wxString& libName = wxEmptyString ); + static LIB_COMPONENT* FindLibraryComponent( const wxString& aComponentName, + const wxString& aLibraryName = wxEmptyString ); /** * Search all libraries in the list for an entry. * * The object can be either a component or an alias. * - * @param name - Name of component to search for. - * @param libNaem - Name of the library to search for entry. + * @param aEntryName - Name of entry to search for. + * @param aLibraryName - Name of the library to search. * @return The entry object if found, otherwise NULL. */ - static CMP_LIB_ENTRY* FindLibraryEntry( - const wxString& name, - const wxString& libName = wxEmptyString ); + static CMP_LIB_ENTRY* FindLibraryEntry( const wxString& aEntryName, + const wxString& aLibraryName = wxEmptyString ); /** * Remove all cache libraries from library list. */ - static void RemoveCacheLibrary( void ); + static void RemoveCacheLibrary(); - static int GetLibraryCount( void ) { return m_LibraryList.size(); } + static int GetLibraryCount() { return libraryList.size(); } - static CMP_LIBRARY_LIST& GetLibraryList( void ) + static CMP_LIBRARY_LIST& GetLibraryList() { - return m_LibraryList; + return libraryList; } - static void SetSortOrder( const wxArrayString& sortOrder ) + static void SetSortOrder( const wxArrayString& aSortOrder ) { - m_LibraryListSortOrder = sortOrder; + libraryListSortOrder = aSortOrder; } static wxArrayString& GetSortOrder( void ) { - return m_LibraryListSortOrder; + return libraryListSortOrder; } protected: - wxFileName m_fileName; /* Library file name. */ - wxDateTime m_DateTime; /* Library save time and date. */ - int m_verMajor; /* Library major version number. */ - int m_verMinor; /* Library minor version number. */ - LIB_ENTRY_LIST m_Entries; /* Parts themselves are saved here. */ - bool m_IsModified; /* Library modification status. */ - bool m_IsCache; /* False for the "standard" libraries, + wxFileName fileName; /* Library file name. */ + wxDateTime timeStamp; /* Library save time and date. */ + int versionMajor; /* Library major version number. */ + int versionMinor; /* Library minor version number. */ + LIB_ENTRY_LIST entries; /* Parts themselves are saved here. */ + bool isModified; /* Library modification status. */ + bool isCache; /* False for the "standard" libraries, * True for the library cache */ + wxString header; /* first line of loaded library. */ - static CMP_LIBRARY_LIST m_LibraryList; - static wxArrayString m_LibraryListSortOrder; + static CMP_LIBRARY_LIST libraryList; + static wxArrayString libraryListSortOrder; friend class CMP_LIB_ENTRY; }; @@ -468,7 +464,7 @@ protected: /** * Case insensitive library name comparison. */ -extern bool operator==( const CMP_LIBRARY& lib, const wxChar* name ); -extern bool operator!=( const CMP_LIBRARY& lib, const wxChar* name ); +extern bool operator==( const CMP_LIBRARY& aLibrary, const wxChar* aName ); +extern bool operator!=( const CMP_LIBRARY& aLibrary, const wxChar* aName ); #endif // CLASS_LIBRARY_H diff --git a/eeschema/class_sch_component.cpp b/eeschema/class_sch_component.cpp index 353a66cd09..939fb0f038 100644 --- a/eeschema/class_sch_component.cpp +++ b/eeschema/class_sch_component.cpp @@ -525,7 +525,7 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) if( Entry == NULL ) return NULL; - wxASSERT( Entry->Type == ROOT ); + wxASSERT( Entry->isComponent() ); return Entry->GetPin( number, m_Multi, m_Convert ); } @@ -1099,7 +1099,7 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), DARKCYAN ); - if( Entry->m_Options == ENTRY_POWER ) + if( Entry->isPower() ) msg = _( "Power symbol" ); else msg = _( "Name" ); @@ -1110,8 +1110,8 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) msg = Entry->GetLibraryName(); frame->AppendMsgPanel( _( "Library" ), msg, DARKRED ); - frame->AppendMsgPanel( _( "Description" ), Entry->m_Doc, DARKCYAN ); - frame->AppendMsgPanel( _( "Key words" ), Entry->m_KeyWord, DARKCYAN ); + frame->AppendMsgPanel( _( "Description" ), Entry->GetDescription(), DARKCYAN ); + frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN ); } /** virtual function Mirror_Y diff --git a/eeschema/classes_body_items.cpp b/eeschema/classes_body_items.cpp index ac5d09f5b0..12329934e7 100644 --- a/eeschema/classes_body_items.cpp +++ b/eeschema/classes_body_items.cpp @@ -10,6 +10,7 @@ #include "drawtxt.h" #include "trigo.h" #include "bezier_curves.h" +#include "confirm.h" #include "program.h" #include "general.h" @@ -23,8 +24,8 @@ static int fill_tab[3] = { 'N', 'F', 'f' }; /* Base class (abstract) for components bodies items */ -LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT* aParent ) : - EDA_BaseStruct( struct_type ) +LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T aType, LIB_COMPONENT* aParent ) : + EDA_BaseStruct( aType ) { m_Unit = 0; /* Unit identification (for multi part per package) * 0 if the item is common to all units */ @@ -37,15 +38,15 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT* aParent ) : } -LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ) : - EDA_BaseStruct( item ) +LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ) : + EDA_BaseStruct( aItem ) { - m_Unit = item.m_Unit; - m_Convert = item.m_Convert; - m_Fill = item.m_Fill; - m_Parent = item.m_Parent; - m_typeName = item.m_typeName; - m_isFillable = item.m_isFillable; + m_Unit = aItem.m_Unit; + m_Convert = aItem.m_Convert; + m_Fill = aItem.m_Fill; + m_Parent = aItem.m_Parent; + m_typeName = aItem.m_typeName; + m_isFillable = aItem.m_isFillable; } @@ -56,18 +57,18 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ) : * all library items. Call the base class from the derived class or the * common information will not be updated in the message panel. */ -void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; - frame->ClearMsgPanel(); - frame->AppendMsgPanel( _( "Type" ), m_typeName, CYAN ); + aFrame->ClearMsgPanel(); + aFrame->AppendMsgPanel( _( "Type" ), m_typeName, CYAN ); if( m_Unit == 0 ) msg = _( "All" ); else msg.Printf( wxT( "%d" ), m_Unit ); - frame->AppendMsgPanel( _( "Unit" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Unit" ), msg, BROWN ); if( m_Convert == 0 ) msg = _( "All" ); @@ -77,37 +78,37 @@ void LIB_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame ) msg = _( "yes" ); else msg = wxT( "?" ); - frame->AppendMsgPanel( _( "Convert" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Convert" ), msg, BROWN ); } -bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& other ) const +bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& aOther ) const { - return ( ( Type() == other.Type() ) - && ( m_Unit == other.m_Unit ) - && ( m_Convert == other.m_Convert ) - && DoCompare( other ) == 0 ); + return ( ( Type() == aOther.Type() ) + && ( m_Unit == aOther.m_Unit ) + && ( m_Convert == aOther.m_Convert ) + && DoCompare( aOther ) == 0 ); } -bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& other ) const +bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& aOther ) const { - int result = m_Convert - other.m_Convert; + int result = m_Convert - aOther.m_Convert; if( result != 0 ) return result < 0; - result = m_Unit - other.m_Unit; + result = m_Unit - aOther.m_Unit; if( result != 0 ) return result < 0; - result = Type() - other.Type(); + result = Type() - aOther.Type(); if( result != 0 ) return result < 0; - return ( DoCompare( other ) < 0 ); + return ( DoCompare( aOther ) < 0 ); } @@ -128,16 +129,16 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : } -LIB_ARC::LIB_ARC( const LIB_ARC& arc ) : LIB_DRAW_ITEM( arc ) +LIB_ARC::LIB_ARC( const LIB_ARC& aArc ) : LIB_DRAW_ITEM( aArc ) { - m_Radius = arc.m_Radius; - m_t1 = arc.m_t1; - m_t2 = arc.m_t2; - m_Width = arc.m_Width; - m_Fill = arc.m_Fill; - m_Pos = arc.m_Pos; - m_ArcStart = arc.m_ArcStart; - m_ArcEnd = arc.m_ArcEnd; + m_Radius = aArc.m_Radius; + m_t1 = aArc.m_t1; + m_t2 = aArc.m_t2; + m_Width = aArc.m_Width; + m_Fill = aArc.m_Fill; + m_Pos = aArc.m_Pos; + m_ArcStart = aArc.m_ArcStart; + m_ArcEnd = aArc.m_ArcEnd; } @@ -146,7 +147,7 @@ LIB_ARC::LIB_ARC( const LIB_ARC& arc ) : LIB_DRAW_ITEM( arc ) * A centre_posx centre_posy rayon start_angle end_angle unit convert * fill('N', 'F' ou 'f') startx starty endx endy */ -bool LIB_ARC::Save( FILE* ExportFile ) +bool LIB_ARC::Save( FILE* aFile ) { int x1 = m_t1; @@ -158,7 +159,7 @@ bool LIB_ARC::Save( FILE* ExportFile ) if( x2 > 1800 ) x2 -= 3600; - if( fprintf( ExportFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", + if( fprintf( aFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", m_Pos.x, m_Pos.y, m_Radius, x1, x2, m_Unit, m_Convert, m_Width, fill_tab[m_Fill], m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x, m_ArcEnd.y ) < 0 ) @@ -168,17 +169,17 @@ bool LIB_ARC::Save( FILE* ExportFile ) } -bool LIB_ARC::Load( char* line, wxString& errorMsg ) +bool LIB_ARC::Load( char* aLine, wxString& aErrorMsg ) { int startx, starty, endx, endy, cnt; char tmp[256]; - cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d", + cnt = sscanf( &aLine[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d", &m_Pos.x, &m_Pos.y, &m_Radius, &m_t1, &m_t2, &m_Unit, &m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy ); if( cnt < 8 ) { - errorMsg.Printf( _( "arc only had %d parameters of the required 8" ), + aErrorMsg.Printf( _( "arc only had %d parameters of the required 8" ), cnt ); return false; } @@ -299,11 +300,11 @@ LIB_DRAW_ITEM* LIB_ARC::DoGenCopy() } -int LIB_ARC::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_ARC::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_ARC_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_ARC_DRAW_TYPE ); - const LIB_ARC* tmp = ( LIB_ARC* ) &other; + const LIB_ARC* tmp = ( LIB_ARC* ) &aOther; if( m_Pos.x != tmp->m_Pos.x ) return m_Pos.x - tmp->m_Pos.x; @@ -321,64 +322,64 @@ int LIB_ARC::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_ARC::DoOffset( const wxPoint& offset ) +void LIB_ARC::DoOffset( const wxPoint& aOffset ) { - m_Pos += offset; - m_ArcStart += offset; - m_ArcEnd += offset; + m_Pos += aOffset; + m_ArcStart += aOffset; + m_ArcEnd += aOffset; } -bool LIB_ARC::DoTestInside( EDA_Rect& rect ) +bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) { - return rect.Inside( m_ArcStart.x, -m_ArcStart.y ) - || rect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); + return aRect.Inside( m_ArcStart.x, -m_ArcStart.y ) + || aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); } -void LIB_ARC::DoMove( const wxPoint& newPosition ) +void LIB_ARC::DoMove( const wxPoint& aPosition ) { - wxPoint offset = newPosition - m_Pos; - m_Pos = newPosition; + wxPoint offset = aPosition - m_Pos; + m_Pos = aPosition; m_ArcStart += offset; m_ArcEnd += offset; } -void LIB_ARC::DoMirrorHorizontal( const wxPoint& center ) +void LIB_ARC::DoMirrorHorizontal( const wxPoint& aCenter ) { - m_Pos.x -= center.x; + m_Pos.x -= aCenter.x; m_Pos.x *= -1; - m_Pos.x += center.x; - m_ArcStart.x -= center.x; + m_Pos.x += aCenter.x; + m_ArcStart.x -= aCenter.x; m_ArcStart.x *= -1; - m_ArcStart.x += center.x; - m_ArcEnd.x -= center.x; + m_ArcStart.x += aCenter.x; + m_ArcEnd.x -= aCenter.x; m_ArcEnd.x *= -1; - m_ArcEnd.x += center.x; + m_ArcEnd.x += aCenter.x; EXCHG( m_ArcStart, m_ArcEnd ); } -void LIB_ARC::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_ARC::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); int t1 = m_t1; int t2 = m_t2; - wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset; + wxPoint pos = TransformCoordinate( aTransform, m_Pos ) + aOffset; - MapAngles( &t1, &t2, transform ); + MapAngles( &t1, &t2, aTransform ); - if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) + if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - plotter->arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 ); } - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->arc( pos, -t2, -t1, m_Radius, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->arc( pos, -t2, -t1, m_Radius, m_Fill, GetPenSize() ); } @@ -516,22 +517,22 @@ start(%d, %d), end(%d, %d), radius %d" ), } -void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; EDA_Rect bBox = GetBoundingBox(); - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); } @@ -549,18 +550,18 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) : } -LIB_CIRCLE::LIB_CIRCLE( const LIB_CIRCLE& circle ) : - LIB_DRAW_ITEM( circle ) +LIB_CIRCLE::LIB_CIRCLE( const LIB_CIRCLE& aCircle ) : + LIB_DRAW_ITEM( aCircle ) { - m_Pos = circle.m_Pos; - m_Radius = circle.m_Radius; - m_Fill = circle.m_Fill; + m_Pos = aCircle.m_Pos; + m_Radius = aCircle.m_Radius; + m_Fill = aCircle.m_Fill; } -bool LIB_CIRCLE::Save( FILE* ExportFile ) +bool LIB_CIRCLE::Save( FILE* aFile ) { - if( fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, + if( fprintf( aFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, m_Radius, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ) < 0 ) return false; @@ -568,16 +569,16 @@ bool LIB_CIRCLE::Save( FILE* ExportFile ) } -bool LIB_CIRCLE::Load( char* line, wxString& errorMsg ) +bool LIB_CIRCLE::Load( char* aLine, wxString& aErrorMsg ) { char tmp[256]; - int cnt = sscanf( &line[2], "%d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, + int cnt = sscanf( &aLine[2], "%d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, &m_Radius, &m_Unit, &m_Convert, &m_Width, tmp ); if( cnt < 6 ) { - errorMsg.Printf( _( "circle only had %d parameters of the required 6" ), + aErrorMsg.Printf( _( "circle only had %d parameters of the required 6" ), cnt ); return false; } @@ -595,7 +596,7 @@ bool LIB_CIRCLE::Load( char* line, wxString& errorMsg ) * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param aRefPos A wxPoint to test in eeschema space - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) { @@ -616,8 +617,7 @@ bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef ) * thickness of a line) * @param aTransMat = the transform matrix */ -bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, - const int aTransMat[2][2] ) +bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) { wxPoint relpos = aPosRef - TransformCoordinate( aTransMat, m_Pos ); @@ -647,11 +647,11 @@ LIB_DRAW_ITEM* LIB_CIRCLE::DoGenCopy() } -int LIB_CIRCLE::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_CIRCLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_CIRCLE_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_CIRCLE_DRAW_TYPE ); - const LIB_CIRCLE* tmp = ( LIB_CIRCLE* ) &other; + const LIB_CIRCLE* tmp = ( LIB_CIRCLE* ) &aOther; if( m_Pos.x != tmp->m_Pos.x ) return m_Pos.x - tmp->m_Pos.x; @@ -666,49 +666,49 @@ int LIB_CIRCLE::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_CIRCLE::DoOffset( const wxPoint& offset ) +void LIB_CIRCLE::DoOffset( const wxPoint& aOffset ) { - m_Pos += offset; + m_Pos += aOffset; } -bool LIB_CIRCLE::DoTestInside( EDA_Rect& rect ) +bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) { /* * FIXME: This fails to take into acount the radius around the center * point. */ - return rect.Inside( m_Pos.x, -m_Pos.y ); + return aRect.Inside( m_Pos.x, -m_Pos.y ); } -void LIB_CIRCLE::DoMove( const wxPoint& newPosition ) +void LIB_CIRCLE::DoMove( const wxPoint& aPosition ) { - m_Pos = newPosition; + m_Pos = aPosition; } -void LIB_CIRCLE::DoMirrorHorizontal( const wxPoint& center ) +void LIB_CIRCLE::DoMirrorHorizontal( const wxPoint& aCenter ) { - m_Pos.x -= center.x; + m_Pos.x -= aCenter.x; m_Pos.x *= -1; - m_Pos.x += center.x; + m_Pos.x += aCenter.x; } -void LIB_CIRCLE::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_CIRCLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset; + wxPoint pos = TransformCoordinate( aTransform, m_Pos ) + aOffset; - if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) + if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - plotter->circle( pos, m_Radius * 2, FILLED_SHAPE, 0 ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->circle( pos, m_Radius * 2, FILLED_SHAPE, 0 ); } - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->circle( pos, m_Radius * 2, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->circle( pos, m_Radius * 2, m_Fill, GetPenSize() ); } @@ -777,26 +777,26 @@ EDA_Rect LIB_CIRCLE::GetBoundingBox() } -void LIB_CIRCLE::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_CIRCLE::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; EDA_Rect bBox = GetBoundingBox(); - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); msg = ReturnStringFromValue( g_UnitMetric, m_Radius, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Radius" ), msg, RED ); + aFrame->AppendMsgPanel( _( "Radius" ), msg, RED ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); } @@ -814,19 +814,19 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) : } -LIB_RECTANGLE::LIB_RECTANGLE( const LIB_RECTANGLE& rect ) : - LIB_DRAW_ITEM( rect ) +LIB_RECTANGLE::LIB_RECTANGLE( const LIB_RECTANGLE& aRect ) : + LIB_DRAW_ITEM( aRect ) { - m_Pos = rect.m_Pos; - m_End = rect.m_End; - m_Width = rect.m_Width; - m_Fill = rect.m_Fill; + m_Pos = aRect.m_Pos; + m_End = aRect.m_End; + m_Width = aRect.m_Width; + m_Fill = aRect.m_Fill; } -bool LIB_RECTANGLE::Save( FILE* ExportFile ) +bool LIB_RECTANGLE::Save( FILE* aFile ) { - if( fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, + if( fprintf( aFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, m_End.x, m_End.y, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ) < 0 ) return false; @@ -835,17 +835,17 @@ bool LIB_RECTANGLE::Save( FILE* ExportFile ) } -bool LIB_RECTANGLE::Load( char* line, wxString& errorMsg ) +bool LIB_RECTANGLE::Load( char* aLine, wxString& aErrorMsg ) { int cnt; char tmp[256]; - cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, + cnt = sscanf( &aLine[2], "%d %d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y, &m_End.x, &m_End.y, &m_Unit, &m_Convert, &m_Width, tmp ); if( cnt < 7 ) { - errorMsg.Printf( _( "rectangle only had %d parameters of the required 7" ), + aErrorMsg.Printf( _( "rectangle only had %d parameters of the required 7" ), cnt ); return false; } @@ -875,11 +875,11 @@ LIB_DRAW_ITEM* LIB_RECTANGLE::DoGenCopy() } -int LIB_RECTANGLE::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_RECTANGLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_RECT_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_RECT_DRAW_TYPE ); - const LIB_RECTANGLE* tmp = ( LIB_RECTANGLE* ) &other; + const LIB_RECTANGLE* tmp = ( LIB_RECTANGLE* ) &aOther; if( m_Pos.x != tmp->m_Pos.x ) return m_Pos.x - tmp->m_Pos.x; @@ -897,54 +897,54 @@ int LIB_RECTANGLE::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_RECTANGLE::DoOffset( const wxPoint& offset ) +void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset ) { - m_Pos += offset; - m_End += offset; + m_Pos += aOffset; + m_End += aOffset; } -bool LIB_RECTANGLE::DoTestInside( EDA_Rect& rect ) +bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) { - return rect.Inside( m_Pos.x, -m_Pos.y ) || rect.Inside( m_End.x, -m_End.y ); + return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y ); } -void LIB_RECTANGLE::DoMove( const wxPoint& newPosition ) +void LIB_RECTANGLE::DoMove( const wxPoint& aPosition ) { wxPoint size = m_End - m_Pos; - m_Pos = newPosition; - m_End = newPosition + size; + m_Pos = aPosition; + m_End = aPosition + size; } -void LIB_RECTANGLE::DoMirrorHorizontal( const wxPoint& center ) +void LIB_RECTANGLE::DoMirrorHorizontal( const wxPoint& aCenter ) { - m_Pos.x -= center.x; + m_Pos.x -= aCenter.x; m_Pos.x *= -1; - m_Pos.x += center.x; - m_End.x -= center.x; + m_Pos.x += aCenter.x; + m_End.x -= aCenter.x; m_End.x *= -1; - m_End.x += center.x; + m_End.x += aCenter.x; } -void LIB_RECTANGLE::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_RECTANGLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); - wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset; - wxPoint end = TransformCoordinate( transform, m_End ) + offset; + wxPoint pos = TransformCoordinate( aTransform, m_Pos ) + aOffset; + wxPoint end = TransformCoordinate( aTransform, m_End ) + aOffset; - if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) + if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - plotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 ); } - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->rect( pos, end, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->rect( pos, end, m_Fill, GetPenSize() ); } @@ -1003,16 +1003,15 @@ void LIB_RECTANGLE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, } -void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UnitMetric, m_Width, - EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); } @@ -1031,7 +1030,7 @@ EDA_Rect LIB_RECTANGLE::GetBoundingBox() * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param aRefPoint A wxPoint to test in eeschema space - * @return bool - true if a hit, else false + * @return true if a hit, else false */ bool LIB_RECTANGLE::HitTest( const wxPoint& aRefPoint ) { @@ -1100,25 +1099,25 @@ LIB_SEGMENT::LIB_SEGMENT( LIB_COMPONENT* aParent ) : } -LIB_SEGMENT::LIB_SEGMENT( const LIB_SEGMENT& segment ) : - LIB_DRAW_ITEM( segment ) +LIB_SEGMENT::LIB_SEGMENT( const LIB_SEGMENT& aSegment ) : + LIB_DRAW_ITEM( aSegment ) { - m_Pos = segment.m_Pos; - m_End = segment.m_End; - m_Width = segment.m_Width; + m_Pos = aSegment.m_Pos; + m_End = aSegment.m_End; + m_Width = aSegment.m_Width; } -bool LIB_SEGMENT::Save( FILE* ExportFile ) +bool LIB_SEGMENT::Save( FILE* aFile ) { - if( fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width ) ) + if( fprintf( aFile, "L %d %d %d", m_Unit, m_Convert, m_Width ) ) return false; return true; } -bool LIB_SEGMENT::Load( char* line, wxString& errorMsg ) +bool LIB_SEGMENT::Load( char* aLine, wxString& aErrorMsg ) { return true; } @@ -1139,11 +1138,11 @@ LIB_DRAW_ITEM* LIB_SEGMENT::DoGenCopy() } -int LIB_SEGMENT::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_SEGMENT::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_LINE_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_LINE_DRAW_TYPE ); - const LIB_SEGMENT* tmp = ( LIB_SEGMENT* ) &other; + const LIB_SEGMENT* tmp = ( LIB_SEGMENT* ) &aOther; if( m_Pos.x != tmp->m_Pos.x ) return m_Pos.x - tmp->m_Pos.x; @@ -1161,52 +1160,52 @@ int LIB_SEGMENT::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_SEGMENT::DoOffset( const wxPoint& offset ) +void LIB_SEGMENT::DoOffset( const wxPoint& aOffset ) { + m_Pos += aOffset; + m_End += aOffset; +} + + +bool LIB_SEGMENT::DoTestInside( EDA_Rect& aRect ) +{ + return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y ); +} + + +void LIB_SEGMENT::DoMove( const wxPoint& aPosition ) +{ + wxPoint offset = aPosition - m_Pos; m_Pos += offset; m_End += offset; } -bool LIB_SEGMENT::DoTestInside( EDA_Rect& rect ) +void LIB_SEGMENT::DoMirrorHorizontal( const wxPoint& aCenter ) { - return rect.Inside( m_Pos.x, -m_Pos.y ) || rect.Inside( m_End.x, -m_End.y ); -} - - -void LIB_SEGMENT::DoMove( const wxPoint& newPosition ) -{ - wxPoint offset = newPosition - m_Pos; - m_Pos += offset; - m_End += offset; -} - - -void LIB_SEGMENT::DoMirrorHorizontal( const wxPoint& center ) -{ - m_Pos.x -= center.x; + m_Pos.x -= aCenter.x; m_Pos.x *= -1; - m_Pos.x += center.x; - m_End.x -= center.x; + m_Pos.x += aCenter.x; + m_End.x -= aCenter.x; m_End.x *= -1; - m_End.x += center.x; + m_End.x += aCenter.x; } -void LIB_SEGMENT::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_SEGMENT::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); int points[4]; - wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset; - wxPoint end = TransformCoordinate( transform, m_End ) + offset; + wxPoint pos = TransformCoordinate( aTransform, m_Pos ) + aOffset; + wxPoint end = TransformCoordinate( aTransform, m_End ) + aOffset; points[0] = pos.x; points[1] = pos.y; points[2] = end.x; points[3] = end.y; - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->poly( 2, points, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->poly( 2, points, m_Fill, GetPenSize() ); } @@ -1253,22 +1252,22 @@ void LIB_SEGMENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, } -void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; EDA_Rect bBox = GetBoundingBox(); - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); } @@ -1276,7 +1275,7 @@ void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* frame ) * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param aRefPos A wxPoint to test - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ bool LIB_SEGMENT::HitTest( const wxPoint& aPosRef ) { @@ -1329,50 +1328,47 @@ LIB_POLYLINE::LIB_POLYLINE( const LIB_POLYLINE& polyline ) : } -bool LIB_POLYLINE::Save( FILE* ExportFile ) +bool LIB_POLYLINE::Save( FILE* aFile ) { int ccount = GetCornerCount(); - if( fprintf( ExportFile, "P %d %d %d %d", - ccount, m_Unit, m_Convert, m_Width ) < 0 ) + if( fprintf( aFile, "P %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ) < 0 ) return false; for( unsigned i = 0; i < GetCornerCount(); i++ ) { - if( fprintf( ExportFile, " %d %d", - m_PolyPoints[i].x, m_PolyPoints[i].y ) < 0 ) + if( fprintf( aFile, " %d %d", m_PolyPoints[i].x, m_PolyPoints[i].y ) < 0 ) return false; } - if( fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ) < 0 ) + if( fprintf( aFile, " %c\n", fill_tab[m_Fill] ) < 0 ) return false; return true; } -bool LIB_POLYLINE::Load( char* line, wxString& errorMsg ) +bool LIB_POLYLINE::Load( char* aLine, wxString& aErrorMsg ) { char* p; int i, ccount = 0; wxPoint pt; - i = sscanf( &line[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, + i = sscanf( &aLine[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, &m_Width ); if( i < 4 ) { - errorMsg.Printf( _( "polyline only had %d parameters of the required 4" ), i ); + aErrorMsg.Printf( _( "polyline only had %d parameters of the required 4" ), i ); return false; } if( ccount <= 0 ) { - errorMsg.Printf( _( "polyline count parameter %d is invalid" ), - ccount ); + aErrorMsg.Printf( _( "polyline count parameter %d is invalid" ), ccount ); return false; } - p = strtok( &line[2], " \t\n" ); + p = strtok( &aLine[2], " \t\n" ); p = strtok( NULL, " \t\n" ); p = strtok( NULL, " \t\n" ); p = strtok( NULL, " \t\n" ); @@ -1383,15 +1379,13 @@ bool LIB_POLYLINE::Load( char* line, wxString& errorMsg ) p = strtok( NULL, " \t\n" ); if( sscanf( p, "%d", &pt.x ) != 1 ) { - errorMsg.Printf( _( "polyline point %d X position not defined" ), - i ); + aErrorMsg.Printf( _( "polyline point %d X position not defined" ), i ); return false; } p = strtok( NULL, " \t\n" ); if( sscanf( p, "%d", &pt.y ) != 1 ) { - errorMsg.Printf( _( "polyline point %d Y position not defined" ), - i ); + aErrorMsg.Printf( _( "polyline point %d Y position not defined" ), i ); return false; } AddPoint( pt ); @@ -1426,11 +1420,11 @@ LIB_DRAW_ITEM* LIB_POLYLINE::DoGenCopy() } -int LIB_POLYLINE::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_POLYLINE::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_POLYLINE_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_POLYLINE_DRAW_TYPE ); - const LIB_POLYLINE* tmp = ( LIB_POLYLINE* ) &other; + const LIB_POLYLINE* tmp = ( LIB_POLYLINE* ) &aOther; if( m_PolyPoints.size() != tmp->m_PolyPoints.size() ) return m_PolyPoints.size() - tmp->m_PolyPoints.size(); @@ -1447,18 +1441,18 @@ int LIB_POLYLINE::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_POLYLINE::DoOffset( const wxPoint& offset ) +void LIB_POLYLINE::DoOffset( const wxPoint& aOffset ) { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) - m_PolyPoints[i] += offset; + m_PolyPoints[i] += aOffset; } -bool LIB_POLYLINE::DoTestInside( EDA_Rect& rect ) +bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { - if( rect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) + if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) return true; } @@ -1466,50 +1460,53 @@ bool LIB_POLYLINE::DoTestInside( EDA_Rect& rect ) } -void LIB_POLYLINE::DoMove( const wxPoint& newPosition ) +void LIB_POLYLINE::DoMove( const wxPoint& aPosition ) { - DoOffset( newPosition - m_PolyPoints[0] ); + DoOffset( aPosition - m_PolyPoints[0] ); } -void LIB_POLYLINE::DoMirrorHorizontal( const wxPoint& center ) +void LIB_POLYLINE::DoMirrorHorizontal( const wxPoint& aCenter ) { size_t i, imax = m_PolyPoints.size(); for( i = 0; i < imax; i++ ) { - m_PolyPoints[i].x -= center.x; + m_PolyPoints[i].x -= aCenter.x; m_PolyPoints[i].x *= -1; - m_PolyPoints[i].x += center.x; + m_PolyPoints[i].x += aCenter.x; } } -void LIB_POLYLINE::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_POLYLINE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); size_t i; int* Poly = (int*) MyMalloc( sizeof(int) * 2 * GetCornerCount() ); + if( Poly == NULL ) + return; + for( i = 0; i < m_PolyPoints.size(); i++ ) { wxPoint pos = m_PolyPoints[i]; - pos = TransformCoordinate( transform, pos ) + offset; + pos = TransformCoordinate( aTransform, pos ) + aOffset; Poly[i * 2] = pos.x; Poly[i * 2 + 1] = pos.y; } - if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) + if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - plotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 ); } - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->poly( i, Poly, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->poly( i, Poly, m_Fill, GetPenSize() ); MyFree( Poly ); } @@ -1528,6 +1525,7 @@ int LIB_POLYLINE::GetPenSize() return ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; } + void LIB_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ) @@ -1560,8 +1558,16 @@ void LIB_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, Buf_Poly_Drawings = (wxPoint*) realloc( Buf_Poly_Drawings, sizeof(wxPoint) * Buf_Poly_Size ); + + if( Buf_Poly_Drawings == NULL ) + { + DisplayError( NULL, _( "Cannot allocate memory to draw polylines." ) ); + } } + if( Buf_Poly_Drawings == NULL ) + return; + for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { Buf_Poly_Drawings[ii] = @@ -1600,7 +1606,7 @@ void LIB_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param aRefPos A wxPoint to test - * @return bool - true if a hit, else false + * @return true if a hit, else false */ bool LIB_POLYLINE::HitTest( const wxPoint& aRefPos ) { @@ -1619,8 +1625,7 @@ bool LIB_POLYLINE::HitTest( const wxPoint& aRefPos ) * @param aThreshold = max distance to a segment * @param aTransMat = the transform matrix */ -bool LIB_POLYLINE::HitTest( wxPoint aPosRef, int aThreshold, - const int aTransMat[2][2] ) +bool LIB_POLYLINE::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) { wxPoint ref, start, end; @@ -1664,24 +1669,25 @@ EDA_Rect LIB_POLYLINE::GetBoundingBox() } -void LIB_POLYLINE::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_POLYLINE::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; EDA_Rect bBox = GetBoundingBox(); - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel(_( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel(_( "Line width" ), msg, BLUE ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); } + /***************************/ /** class LIB_BEZIER **/ /***************************/ @@ -1695,60 +1701,57 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) : } -LIB_BEZIER::LIB_BEZIER( const LIB_BEZIER& bezier ) : LIB_DRAW_ITEM( bezier ) +LIB_BEZIER::LIB_BEZIER( const LIB_BEZIER& aBezier ) : LIB_DRAW_ITEM( aBezier ) { - m_PolyPoints = bezier.m_PolyPoints; - m_BezierPoints = bezier.m_BezierPoints; // Vector copy - m_Width = bezier.m_Width; - m_Fill = bezier.m_Fill; + m_PolyPoints = aBezier.m_PolyPoints; + m_BezierPoints = aBezier.m_BezierPoints; // Vector copy + m_Width = aBezier.m_Width; + m_Fill = aBezier.m_Fill; } -bool LIB_BEZIER::Save( FILE* ExportFile ) +bool LIB_BEZIER::Save( FILE* aFile ) { int ccount = GetCornerCount(); - if( fprintf( ExportFile, "B %d %d %d %d", + if( fprintf( aFile, "B %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ) < 0 ) return false; for( unsigned i = 0; i < GetCornerCount(); i++ ) { - if( fprintf( ExportFile, " %d %d", m_BezierPoints[i].x, + if( fprintf( aFile, " %d %d", m_BezierPoints[i].x, m_BezierPoints[i].y ) < 0 ) return false; } - if( fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ) < 0 ) + if( fprintf( aFile, " %c\n", fill_tab[m_Fill] ) < 0 ) return false; return true; } -bool LIB_BEZIER::Load( char* line, wxString& errorMsg ) +bool LIB_BEZIER::Load( char* aLine, wxString& aErrorMsg ) { char* p; int i, ccount = 0; wxPoint pt; - i = sscanf( &line[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, - &m_Width ); + i = sscanf( &aLine[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, &m_Width ); if( i !=4 ) { - errorMsg.Printf( _( "Bezier only had %d parameters of the required 4" ), - i ); + aErrorMsg.Printf( _( "Bezier only had %d parameters of the required 4" ), i ); return false; } if( ccount <= 0 ) { - errorMsg.Printf( _( "Bezier count parameter %d is invalid" ), - ccount ); + aErrorMsg.Printf( _( "Bezier count parameter %d is invalid" ), ccount ); return false; } - p = strtok( &line[2], " \t\n" ); + p = strtok( &aLine[2], " \t\n" ); p = strtok( NULL, " \t\n" ); p = strtok( NULL, " \t\n" ); p = strtok( NULL, " \t\n" ); @@ -1759,13 +1762,13 @@ bool LIB_BEZIER::Load( char* line, wxString& errorMsg ) p = strtok( NULL, " \t\n" ); if( sscanf( p, "%d", &pt.x ) != 1 ) { - errorMsg.Printf( _( "Bezier point %d X position not defined" ), i ); + aErrorMsg.Printf( _( "Bezier point %d X position not defined" ), i ); return false; } p = strtok( NULL, " \t\n" ); if( sscanf( p, "%d", &pt.y ) != 1 ) { - errorMsg.Printf( _( "Bezier point %d Y position not defined" ), i ); + aErrorMsg.Printf( _( "Bezier point %d Y position not defined" ), i ); return false; } m_BezierPoints.push_back( pt ); @@ -1799,11 +1802,11 @@ LIB_DRAW_ITEM* LIB_BEZIER::DoGenCopy() } -int LIB_BEZIER::DoCompare( const LIB_DRAW_ITEM& other ) const +int LIB_BEZIER::DoCompare( const LIB_DRAW_ITEM& aOther ) const { - wxASSERT( other.Type() == COMPONENT_BEZIER_DRAW_TYPE ); + wxASSERT( aOther.Type() == COMPONENT_BEZIER_DRAW_TYPE ); - const LIB_BEZIER* tmp = ( LIB_BEZIER* ) &other; + const LIB_BEZIER* tmp = ( LIB_BEZIER* ) &aOther; if( m_BezierPoints.size() != tmp->m_BezierPoints.size() ) return m_BezierPoints.size() - tmp->m_BezierPoints.size(); @@ -1820,23 +1823,23 @@ int LIB_BEZIER::DoCompare( const LIB_DRAW_ITEM& other ) const } -void LIB_BEZIER::DoOffset( const wxPoint& offset ) +void LIB_BEZIER::DoOffset( const wxPoint& aOffset ) { size_t i; for( i = 0; i < m_BezierPoints.size(); i++ ) - m_BezierPoints[i] += offset; + m_BezierPoints[i] += aOffset; for( i = 0; i < m_PolyPoints.size(); i++ ) - m_PolyPoints[i] += offset; + m_PolyPoints[i] += aOffset; } -bool LIB_BEZIER::DoTestInside( EDA_Rect& rect ) +bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { - if( rect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) + if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) return true; } @@ -1844,58 +1847,61 @@ bool LIB_BEZIER::DoTestInside( EDA_Rect& rect ) } -void LIB_BEZIER::DoMove( const wxPoint& newPosition ) +void LIB_BEZIER::DoMove( const wxPoint& aPosition ) { - DoOffset( newPosition - m_PolyPoints[0] ); + DoOffset( aPosition - m_PolyPoints[0] ); } -void LIB_BEZIER::DoMirrorHorizontal( const wxPoint& center ) +void LIB_BEZIER::DoMirrorHorizontal( const wxPoint& aCenter ) { size_t i, imax = m_PolyPoints.size(); for( i = 0; i < imax; i++ ) { - m_PolyPoints[i].x -= center.x; + m_PolyPoints[i].x -= aCenter.x; m_PolyPoints[i].x *= -1; - m_PolyPoints[i].x += center.x; + m_PolyPoints[i].x += aCenter.x; } imax = m_BezierPoints.size(); for( i = 0; i < imax; i++ ) { - m_BezierPoints[i].x -= center.x; + m_BezierPoints[i].x -= aCenter.x; m_BezierPoints[i].x *= -1; - m_BezierPoints[i].x += center.x; + m_BezierPoints[i].x += aCenter.x; } } -void LIB_BEZIER::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) +void LIB_BEZIER::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - wxASSERT( plotter != NULL ); + wxASSERT( aPlotter != NULL ); size_t i; int* Poly = (int*) MyMalloc( sizeof(int) * 2 * GetCornerCount() ); + if( Poly == NULL ) + return; + for( i = 0; i < m_PolyPoints.size(); i++ ) { wxPoint pos = m_PolyPoints[i]; - pos = TransformCoordinate( transform, pos ) + offset; + pos = TransformCoordinate( aTransform, pos ) + aOffset; Poly[i * 2] = pos.x; Poly[i * 2 + 1] = pos.y; } - if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) + if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR ) { - plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); - plotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); + aPlotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 ); } - plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); - plotter->poly( i, Poly, m_Fill, GetPenSize() ); + aPlotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); + aPlotter->poly( i, Poly, m_Fill, GetPenSize() ); MyFree( Poly ); } @@ -1968,7 +1974,7 @@ void LIB_BEZIER::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param aRefPos A wxPoint to test - * @return bool - true if a hit, else false + * @return true if a hit, else false */ bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) { @@ -1980,7 +1986,7 @@ bool LIB_BEZIER::HitTest( const wxPoint& aRefPos ) } /** Function HitTest - * @return true if the point aPosRef is near a segment + * @return if the point aPosRef is near a segment * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to a segment * @param aTransMat = the transform matrix @@ -2033,20 +2039,20 @@ EDA_Rect LIB_BEZIER::GetBoundingBox() } -void LIB_BEZIER::DisplayInfo( WinEDA_DrawFrame* frame ) +void LIB_BEZIER::DisplayInfo( WinEDA_DrawFrame* aFrame ) { wxString msg; EDA_Rect bBox = GetBoundingBox(); - LIB_DRAW_ITEM::DisplayInfo( frame ); + LIB_DRAW_ITEM::DisplayInfo( aFrame ); msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true ); - frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); + aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - frame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); + aFrame->AppendMsgPanel( _( "Bounding box" ), msg, BROWN ); } diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index 842687ded6..7fe05fd308 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -37,8 +37,7 @@ class LIB_PIN; /** * The component library pin object electrical types used in ERC tests. */ -enum ElectricPinType -{ +enum ElectricPinType { PIN_INPUT, PIN_OUTPUT, PIN_BIDI, @@ -63,8 +62,7 @@ extern const wxChar* MsgPinElectricType[]; /** * The component library pin object drawing shapes. */ -enum DrawPinShape -{ +enum DrawPinShape { NONE = 0, INVERT = 1, CLOCK = 2, @@ -76,8 +74,7 @@ enum DrawPinShape /** * The component library pin object orientations. */ -enum DrawPinOrient -{ +enum DrawPinOrient { PIN_RIGHT = 'R', PIN_LEFT = 'L', PIN_UP = 'U', @@ -137,12 +134,12 @@ public: } - LIB_DRAW_ITEM( KICAD_T struct_type, LIB_COMPONENT * aParent ); - LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ); + LIB_DRAW_ITEM( KICAD_T aType, LIB_COMPONENT * aParent ); + LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ); virtual ~LIB_DRAW_ITEM() { } /** - * Draw A body item + * Draw a body item * * @param aPanel - DrawPanel to use (can be null) mainly used for clipping * purposes @@ -165,18 +162,19 @@ public: /** * @return the size of the "pen" that be used to draw or plot this item */ - virtual int GetPenSize( ) = 0; + virtual int GetPenSize() = 0; /** - * Write draw item object to a FILE in "*.lib" format. + * Write draw item object to /a aFile in "*.lib" format. * - * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @param aFile - The file to write to. + * @param aErrorMsg - Error message if write fails. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ) = 0; - virtual bool Load( char* line, wxString& errorMsg ) = 0; + virtual bool Load( char* aLine, wxString& aErrorMsg ) = 0; - LIB_COMPONENT * GetParent() + LIB_COMPONENT* GetParent() { return (LIB_COMPONENT *)m_Parent; } @@ -184,12 +182,14 @@ public: /** * Tests if the given point is within the bounds of this object. * - * @param refPos A wxPoint to test - * @return bool - true if a hit, else false + * Derived classes should override this function. + * + * @param aPosition - The coordinats to test. + * @return - true if a hit, else false */ - virtual bool HitTest( const wxPoint& refPos ) + virtual bool HitTest( const wxPoint& aPosition ) { - return false; // derived classes should override this function + return false; } /** @@ -197,7 +197,7 @@ public: * @param aThreshold - max distance to this object (usually the half * thickness of a line) * @param aTransMat - the transform matrix - * @return true if the point aPosRef is near this object + * @return - true if the point aPosRef is near this object */ virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) = 0; @@ -210,7 +210,7 @@ public: return EDA_BaseStruct::GetBoundingBox(); } - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); /** * Make a copy of this draw item. @@ -225,29 +225,29 @@ public: /** * Test LIB_DRAW_ITEM objects for equivalence. * - * @param other - Object to test against. - * @return bool - True if object is identical to this object. + * @param aOther - Object to test against. + * @return - True if object is identical to this object. */ - bool operator==( const LIB_DRAW_ITEM& other ) const; - bool operator==( const LIB_DRAW_ITEM* other ) const + bool operator==( const LIB_DRAW_ITEM& aOther ) const; + bool operator==( const LIB_DRAW_ITEM* aOther ) const { - return *this == *other; + return *this == *aOther; } /** * Test if another draw item is less than this draw object. * - * @param other - Draw item to compare against. - * @return bool - True if object is less than this object. + * @param aOther - Draw item to compare against. + * @return - True if object is less than this object. */ - bool operator<( const LIB_DRAW_ITEM& other) const; + bool operator<( const LIB_DRAW_ITEM& aOther) const; /** * Set drawing object offset from the current position. * - * @param offset - Cooridinates to offset position. + * @param aOffset - Cooridinates to offset position. */ - void SetOffset( const wxPoint& offset ) { DoOffset( offset ); } + void SetOffset( const wxPoint& aOffset ) { DoOffset( aOffset ); } /** * Test if any part of the draw object is inside rectangle bounds. @@ -255,53 +255,56 @@ public: * This is used for block selection. The real work is done by the * DoTestInside method for each derived object type. * - * @param rect - Rectangle to check against. - * @return bool - True if object is inside rectangle. + * @param aRect - Rectangle to check against. + * @return - True if object is inside rectangle. */ - bool Inside( EDA_Rect& rect ) { return DoTestInside( rect ); } + bool Inside( EDA_Rect& aRect ) { return DoTestInside( aRect ); } /** - * Move a draw object to a new position. + * Move a draw object to a new /a aPosition. * * The real work is done by the DoMove method for each derived object type. * - * @param newPosition - Position to move draw item to. + * @param aPosition - Position to move draw item to. */ - void Move( const wxPoint& newPosition ) { DoMove( newPosition ); } + void Move( const wxPoint& aPosition ) { DoMove( aPosition ); } /** * Return the current draw object start position. */ - wxPoint GetPosition( void ) { return DoGetPosition(); } + wxPoint GetPosition() { return DoGetPosition(); } /** * Mirror the draw object along the horizontal (X) axis about a point. * - * @param center - Point to mirror around. + * @param aCenter - Point to mirror around. */ - void MirrorHorizontal( const wxPoint& center ) + void MirrorHorizontal( const wxPoint& aCenter ) { - DoMirrorHorizontal( center ); + DoMirrorHorizontal( aCenter ); } /** * Plot the draw item using the plot object. * - * @param plotter - The plot object to plot to. + * @param aPlotter - The plot object to plot to. + * @param aOffset - Plot offset position. + * @param aFill - Flag to indicate whether or not the object is filled. + * @param aTransform - The plot transform. */ - void Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) + void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) { - DoPlot( plotter, offset, fill, transform ); + DoPlot( aPlotter, aOffset, aFill, aTransform ); } /** * Return the width of the draw item. * - * @return int - Width of draw object. + * @return Width of draw object. */ - int GetWidth( void ) { return DoGetWidth(); } - void SetWidth( int width ) { DoSetWidth( width ); } + int GetWidth() { return DoGetWidth(); } + void SetWidth( int aWidth ) { DoSetWidth( aWidth ); } /** * Check if draw object can be filled. @@ -309,24 +312,23 @@ public: * The default setting is false. If the derived object support filling, * set the m_isFillable member to true. * - * @return bool - True if draw object can be fill. Default is false. + * @return - True if draw object can be fill. Default is false. */ - bool IsFillable( void ) { return m_isFillable; } + bool IsFillable() { return m_isFillable; } /** * Return the modified status of the draw object. * - * @return bool - True if the draw object has been modified. + * @return - True if the draw object has been modified. */ - bool IsModified( void ) { return ( m_Flags & IS_CHANGED ) != 0; } + bool IsModified() { return ( m_Flags & IS_CHANGED ) != 0; } /** * Return the new item status of the draw object. * - * @return bool - True if the draw item has been added to the - * parent component. + * @return - True if the draw item has been added to the parent component. */ - bool IsNew( void ) { return ( m_Flags & IS_NEW ) != 0; } + bool IsNew() { return ( m_Flags & IS_NEW ) != 0; } protected: virtual LIB_DRAW_ITEM* DoGenCopy() = 0; @@ -342,16 +344,16 @@ protected: * - KICAD_T enum value. * - Result of derived classes comparison. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const = 0; - virtual void DoOffset( const wxPoint& offset ) = 0; - virtual bool DoTestInside( EDA_Rect& rect ) = 0; - virtual void DoMove( const wxPoint& newPosition ) = 0; - virtual wxPoint DoGetPosition( void ) = 0; - virtual void DoMirrorHorizontal( const wxPoint& center ) = 0; - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ) = 0; - virtual int DoGetWidth( void ) = 0; - virtual void DoSetWidth( int width ) = 0; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0; + virtual void DoOffset( const wxPoint& aOffset ) = 0; + virtual bool DoTestInside( EDA_Rect& aRect ) = 0; + virtual void DoMove( const wxPoint& aPosition ) = 0; + virtual wxPoint DoGetPosition() = 0; + virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0; + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ) = 0; + virtual int DoGetWidth() = 0; + virtual void DoSetWidth( int aWidth ) = 0; /** Flag to indicate if draw item is fillable. Default is false. */ bool m_isFillable; @@ -390,7 +392,7 @@ public: public: LIB_PIN(LIB_COMPONENT * aParent); - LIB_PIN( const LIB_PIN& pin ); + LIB_PIN( const LIB_PIN& aPin ); ~LIB_PIN() { } LIB_PIN* Next() const { return (LIB_PIN*) Pnext; } @@ -406,17 +408,17 @@ public: * Write pin object to a FILE in "*.lib" format. * * @param aFile The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Test if the given point is within the bounds of this object. * * @param aRefPos A wxPoint to test - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ virtual bool HitTest( const wxPoint& aRefPos ); @@ -425,10 +427,9 @@ public: * @param aThreshold - max distance to this object (usually the half * thickness of a line) * @param aTransMat - the transform matrix - * @return true if the point aPosRef is near this object + * @return - true if the point aPosRef is near this object */ - virtual bool HitTest( wxPoint aPosRef, int aThreshold, - const int aTransMat[2][2] ); + virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual EDA_Rect GetBoundingBox(); @@ -447,7 +448,7 @@ public: */ void ReturnPinStringNum( wxString& aStringBuffer ) const; - wxString GetNumber( void ); + wxString GetNumber(); /** Function ReturnPinStringNum (static function) * Pin num is coded as a long or 4 ascii chars @@ -457,7 +458,7 @@ public: */ static wxString ReturnPinStringNum( long aPinNum ); - void SetPinNumFromString( wxString& buffer ); + void SetPinNumFromString( wxString& aBuffer ); /** * Set the pin name. @@ -466,26 +467,26 @@ public: * * @param name - New pin name. */ - void SetName( const wxString& name ); + void SetName( const wxString& aName ); /** - * Set the size of the pin name text. + * Set the /a aSize of the pin name text. * * This will also update the text size of the name of the pins marked * by EnableEditMode(). * - * @param size - The text size of the pin name in schematic units ( mils ). + * @param aSize - The text size of the pin name in schematic units ( mils ). */ - void SetNameTextSize( int size ); + void SetNameTextSize( int aSize ); /** * Set the pin number. * * This will also all of the pin numbers marked by EnableEditMode(). * - * @param number - New pin number. + * @param aNumber - New pin number. */ - void SetNumber( const wxString& number ); + void SetNumber( const wxString& aNumber ); /** * Set the size of the pin number text. @@ -493,10 +494,10 @@ public: * This will also update the text size of the number of the pins marked * by EnableEditMode(). * - * @param size - The text size of the pin number in schematic - * units ( mils ). + * @param aSize - The text size of the pin number in schematic + * units ( mils ). */ - void SetNumberTextSize( int size ); + void SetNumberTextSize( int aSize ); /** * Set orientation on the pin. @@ -504,9 +505,9 @@ public: * This will also update the orientation of the pins marked by * EnableEditMode(). * - * @param orientation - The orientation of the pin. + * @param aOrientation - The orientation of the pin. */ - void SetOrientation( int orientation ); + void SetOrientation( int aOrientation ); /** * Set the draw style of the pin. @@ -514,9 +515,9 @@ public: * This will also update the draw style of the pins marked by * EnableEditMode(). * - * @param style - The draw style of the pin. + * @param aStyle - The draw style of the pin. */ - void SetDrawStyle( int style ); + void SetDrawStyle( int aStyle ); /** * Set the electrical type of the pin. @@ -524,18 +525,18 @@ public: * This will also update the electrical type of the pins marked by * EnableEditMode(). * - * @param type - The electrical type of the pin. + * @param aType - The electrical type of the pin. */ - void SetElectricalType( int style ); + void SetElectricalType( int aType ); /** * Set the pin length. * * This will also update the length of the pins marked by EnableEditMode(). * - * @param size - The length of the pin in mils. + * @param aLength - The length of the pin in mils. */ - void SetLength( int length ); + void SetLength( int aLength ); /** * Set the pin part number. @@ -543,10 +544,10 @@ public: * If the pin is changed from not common to common to all parts, any * linked pins will be removed from the parent component. * - * @param part - Number of the part the pin belongs to. Set to zero to - * make pin common to all parts in a multi-part component. + * @param aPart - Number of the part the pin belongs to. Set to zero to + * make pin common to all parts in a multi-part component. */ - void SetPartNumber( int part ); + void SetPartNumber( int aPart ); /** * Set the body style (conversion) of the pin. @@ -557,7 +558,7 @@ public: * @param conversion - Body style of the pin. Set to zero to make pin * common to all body styles. */ - void SetConversion( int conversion ); + void SetConversion( int aConversion ); /** * Set or clear the visibility flag for the pin. @@ -565,9 +566,9 @@ public: * This will also update the visibility of the pins marked by * EnableEditMode(). * - * @param visible - True to make the pin visible or false to hide the pin. + * @param aVisible - True to make the pin visible or false to hide the pin. */ - void SetVisible( bool visible ); + void SetVisible( bool aVisible ); /** * Enable or clear pin editing mode. @@ -580,18 +581,18 @@ public: * parts or body styles in the component. See SetCommonToAllParts() * and SetCommonToAllBodyStyles() for more information. * - * @params enable - True marks all common pins for editing mode. False - * clears the editing mode. - * @params editpinByPin - Enables the edit pin by pin mode. + * @params aEnable - True marks all common pins for editing mode. False + * clears the editing mode. + * @params aEditpinByPin - Enables the edit pin by pin mode. */ - void EnableEditMode( bool enable, bool pinByPin = false ); + void EnableEditMode( bool aEnable, bool aEditPinByPin = false ); /** * Return the visibility status of the draw object. * - * @return bool - True if draw object is visible otherwise false. + * @return True if draw object is visible otherwise false. */ - bool IsVisible( void ) { return ( m_Attributs & PINNOTDRAW ) == 0; } + bool IsVisible() { return ( m_Attributs & PINNOTDRAW ) == 0; } /** * @return the size of the "pen" that be used to draw or plot this item. @@ -599,81 +600,79 @@ public: virtual int GetPenSize(); void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, - int aColor, int aDrawMode, void* aData, - const int aTransformMatrix[2][2] ); + int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); - void DrawPinSymbol( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& pin_pos, int orient, - int DrawMode, int Color = -1 ); + void DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aPosition, + int aOrientation, int aDrawMode, int aColor = -1 ); - void DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC, - wxPoint& pin_pos, int orient, - int TextInside, bool DrawPinNum, - bool DrawPinName, int Color, int DrawMode ); + void DrawPinTexts( WinEDA_DrawPanel* aPanel, wxDC* aDC, wxPoint& aPosition, + int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName, + int aColor, int aDrawMode ); - void PlotPinTexts( PLOTTER *plotter, - wxPoint& pin_pos, - int orient, - int TextInside, - bool DrawPinNum, - bool DrawPinNameint, + void PlotPinTexts( PLOTTER *aPlotter, + wxPoint& aPosition, + int aOrientation, + int aTextInside, + bool aDrawPinNum, + bool aDrawPinName, int aWidth ); /** * Get a list of pin orientation names. * - * @return wxArrayString - List of valid pin orientation names. + * @return List of valid pin orientation names. */ - static wxArrayString GetOrientationNames( void ); + static wxArrayString GetOrientationNames(); /** * Get the orientation code by index used to set the pin orientation. * - * @param index - The index of the orientation code to look up. - * @return int - Orientation code if index is valid. Returns right - * orientation on index error. + * @param aIndex - The index of the orientation code to look up. + * @return Orientation code if index is valid. Returns right + * orientation on index error. */ - static int GetOrientationCode( int index ); + static int GetOrientationCode( int aIndex ); /** * Get the index of the orientation code. * - * @param code - The orientation code to look up. - * @return int - The index of the orientation code if found. Otherwise, - * return wxNOT_FOUND. + * @param aCode - The orientation code to look up. + * @return The index of the orientation code if found. Otherwise, + * return wxNOT_FOUND. */ - static int GetOrientationCodeIndex( int code ); + static int GetOrientationCodeIndex( int aCode ); /** * Get a list of pin draw style names. * - * @return wxArrayString - List of valid pin draw style names. + * @return List of valid pin draw style names. */ - static wxArrayString GetStyleNames( void ); + static wxArrayString GetStyleNames(); /** * Get the pin draw style code by index used to set the pin draw style. * - * @param index - The index of the pin draw style code to look up. - * @return int - Pin draw style code if index is valid. Returns NONE - * style on index error. + * @param aIndex - The index of the pin draw style code to look up. + * @return Pin draw style code if index is valid. Returns NONE + * style on index error. */ - static int GetStyleCode( int index ); + static int GetStyleCode( int aIndex ); /** * Get the index of the pin draw style code. * - * @param code - The pin draw style code to look up. - * @return int - The index of the pin draw style code if found. Otherwise, - * return wxNOT_FOUND. + * @param aCode - The pin draw style code to look up. + * @return The index of the pin draw style code if found. Otherwise, + * return wxNOT_FOUND. */ - static int GetStyleCodeIndex( int code ); + static int GetStyleCodeIndex( int aCode ); /** * Get a list of pin electrical type names. - * @return wxArrayString - List of valid pin electrical type names. + * + * @return List of valid pin electrical type names. */ - static wxArrayString GetElectricalTypeNames( void ); + static wxArrayString GetElectricalTypeNames(); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -687,16 +686,16 @@ protected: * - Pin horizontal (X) position. * - Pin vertical (Y) position. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; @@ -717,7 +716,7 @@ public: public: LIB_ARC(LIB_COMPONENT * aParent); - LIB_ARC( const LIB_ARC& arc ); + LIB_ARC( const LIB_ARC& aArc ); ~LIB_ARC() { } virtual wxString GetClass() const { @@ -729,16 +728,16 @@ public: * Save arc object to a FILE in "*.lib" format. * * @param aFile The FILE to write to. - * @return bool - true if success writing else false. + * @return - True if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Tests if the given wxPoint is within the bounds of this object. * - * @param aRefPos A wxPoint to test - * @return bool - true if a hit, else false + * @param aRefPos - Coordinates to test + * @return - True if a hit, else false */ virtual bool HitTest( const wxPoint& aRefPos ); @@ -747,7 +746,7 @@ public: * @param aThreshold - max distance to this object (usually the half * thickness of a line) * @param aTransMat - the transform matrix - * @return true if the point aPosRef is near this object + * @return - True if the point aPosRef is near this object */ virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); @@ -775,16 +774,16 @@ protected: * - Arc start angle. * - Arc end angle. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; @@ -801,7 +800,7 @@ public: public: LIB_CIRCLE(LIB_COMPONENT * aParent); - LIB_CIRCLE( const LIB_CIRCLE& circle ); + LIB_CIRCLE( const LIB_CIRCLE& aCircle ); ~LIB_CIRCLE() { } virtual wxString GetClass() const { @@ -813,10 +812,10 @@ public: * Write circle object to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Test if the given point is within the bounds of this object. @@ -841,12 +840,12 @@ public: */ virtual int GetPenSize( ); - void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset, + void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint &aOffset, int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); virtual EDA_Rect GetBoundingBox(); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -859,17 +858,17 @@ protected: * - Circle vertical (Y) position. * - Circle radius. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; @@ -883,7 +882,7 @@ class LIB_TEXT : public LIB_DRAW_ITEM, public EDA_TextStruct { public: LIB_TEXT(LIB_COMPONENT * aParent); - LIB_TEXT( const LIB_TEXT& text ); + LIB_TEXT( const LIB_TEXT& aText ); ~LIB_TEXT() { } virtual wxString GetClass() const { @@ -895,16 +894,16 @@ public: * Write text object out to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Test if the given point is within the bounds of this object. * * @param refPos - A wxPoint to test - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ virtual bool HitTest( const wxPoint& refPos ); @@ -922,12 +921,12 @@ public: * * For now, an ending point must be inside this rect. * - * @param refArea - the given EDA_Rect - * @return bool - true if a hit, else false + * @param aRect - the given EDA_Rect + * @return - true if a hit, else false */ - virtual bool HitTest( EDA_Rect& refArea ) + virtual bool HitTest( EDA_Rect& aRect ) { - return TextHitTest( refArea ); + return TextHitTest( aRect ); } /** @@ -939,7 +938,7 @@ public: int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); virtual EDA_Rect GetBoundingBox(); @@ -956,17 +955,17 @@ protected: * - Text width. * - Text height. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; @@ -982,7 +981,7 @@ public: public: LIB_RECTANGLE(LIB_COMPONENT * aParent); - LIB_RECTANGLE( const LIB_RECTANGLE& rect ); + LIB_RECTANGLE( const LIB_RECTANGLE& aRect ); ~LIB_RECTANGLE() { } virtual wxString GetClass() const { @@ -994,16 +993,16 @@ public: * Write rectangle object out to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Test if the given point is within the bounds of this object. * * @param aRefPos - A wxPoint to test - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ virtual bool HitTest( const wxPoint& aRefPos ); @@ -1027,7 +1026,7 @@ public: const int aTransformMatrix[2][2] ); virtual EDA_Rect GetBoundingBox(); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -1041,19 +1040,20 @@ protected: * - Rectangle horizontal (X) end position. * - Rectangle vertical (Y) end position. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; + /**********************************/ /* Graphic Body Item: single line */ /**********************************/ @@ -1066,7 +1066,7 @@ public: public: LIB_SEGMENT(LIB_COMPONENT * aParent); - LIB_SEGMENT( const LIB_SEGMENT& segment ); + LIB_SEGMENT( const LIB_SEGMENT& aSegment ); ~LIB_SEGMENT() { } virtual wxString GetClass() const { @@ -1078,10 +1078,10 @@ public: * Writes segment object out to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); /** * Test if the given point is within the bounds of this object. @@ -1110,7 +1110,7 @@ public: int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -1124,17 +1124,17 @@ protected: * - Line segment horizontal (X) end position. * - Line segment vertical (Y) end position. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_Pos; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; @@ -1149,7 +1149,7 @@ public: public: LIB_POLYLINE(LIB_COMPONENT * aParent); - LIB_POLYLINE( const LIB_POLYLINE& polyline ); + LIB_POLYLINE( const LIB_POLYLINE& aPolyline ); ~LIB_POLYLINE() { } virtual wxString GetClass() const @@ -1162,12 +1162,12 @@ public: * Write polyline object out to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return - true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); - void AddPoint( const wxPoint& point ); + void AddPoint( const wxPoint& aPoint ); /** * @return the number of corners @@ -1178,7 +1178,7 @@ public: * Test if the given point is within the bounds of this object. * * @param aRefPos - A wxPoint to test - * @return bool - true if a hit, else false + * @return - true if a hit, else false */ virtual bool HitTest( const wxPoint& aRefPos ); @@ -1205,7 +1205,7 @@ public: int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -1217,19 +1217,20 @@ protected: * - Line segment point horizontal (X) position. * - Line segment point vertical (Y) position. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; + /**********************************************************/ /* Graphic Body Item: Bezier Curve (set of lines) */ /**********************************************************/ @@ -1242,7 +1243,7 @@ public: public: LIB_BEZIER( LIB_COMPONENT * aParent ); - LIB_BEZIER( const LIB_BEZIER& bezier ); + LIB_BEZIER( const LIB_BEZIER& aBezier ); ~LIB_BEZIER() { } virtual wxString GetClass() const @@ -1255,12 +1256,12 @@ public: * Write bezier curve object out to a FILE in "*.lib" format. * * @param aFile - The FILE to write to. - * @return bool - true if success writing else false. + * @return true if success writing else false. */ virtual bool Save( FILE* aFile ); - virtual bool Load( char* line, wxString& errorMsg ); + virtual bool Load( char* aLine, wxString& aErrorMsg ); - void AddPoint( const wxPoint& point ); + void AddPoint( const wxPoint& aPoint ); /** * @return the number of corners @@ -1271,7 +1272,7 @@ public: * Test if the given point is within the bounds of this object. * * @param aRefPos - A wxPoint to test - * @return bool - true if a hit, else false + * @return true if a hit, else false */ virtual bool HitTest( const wxPoint& aRefPos ); @@ -1298,7 +1299,7 @@ public: int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] ); - virtual void DisplayInfo( WinEDA_DrawFrame* frame ); + virtual void DisplayInfo( WinEDA_DrawFrame* aFrame ); protected: virtual LIB_DRAW_ITEM* DoGenCopy(); @@ -1310,17 +1311,17 @@ protected: * - Bezier point horizontal (X) point position. * - Bezier point vertical (Y) point position. */ - virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; + virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; - virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); - virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; } - virtual void DoMirrorHorizontal( const wxPoint& center ); - virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, - const int transform[2][2] ); - virtual int DoGetWidth( void ) { return m_Width; } - virtual void DoSetWidth( int width ) { m_Width = width; } + virtual void DoOffset( const wxPoint& aOffset ); + virtual bool DoTestInside( EDA_Rect& aRect ); + virtual void DoMove( const wxPoint& aPosition ); + virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; } + virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, + const int aTransform[2][2] ); + virtual int DoGetWidth() { return m_Width; } + virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; #endif // CLASSES_BODY_ITEMS_H diff --git a/eeschema/database.cpp b/eeschema/database.cpp index 3ce1986bc5..0e656b34aa 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -82,9 +82,9 @@ void DisplayCmpDoc( wxString& Name ) return; wxLogDebug( wxT( "Selected component <%s>, m_Doc: <%s>, m_KeyWord: <%s>." ), - GetChars( Name ), GetChars( CmpEntry->m_Doc ), - GetChars( CmpEntry->m_KeyWord ) ); + GetChars( Name ), GetChars( CmpEntry->GetDescription() ), + GetChars( CmpEntry->GetKeyWords() ) ); - Name = wxT( "Description: " ) + CmpEntry->m_Doc; - Name += wxT( "\nKey Words: " ) + CmpEntry->m_KeyWord; + Name = wxT( "Description: " ) + CmpEntry->GetDescription(); + Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords(); } diff --git a/eeschema/dialog_create_component.cpp b/eeschema/dialog_create_component.cpp index bd86492844..817d64f52d 100644 --- a/eeschema/dialog_create_component.cpp +++ b/eeschema/dialog_create_component.cpp @@ -114,10 +114,10 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) else component.m_TextInside = m_SetSkew->GetValue(); - if ( m_IsPowerSymbol->GetValue() == TRUE) - component.m_Options = ENTRY_POWER; + if ( m_IsPowerSymbol->GetValue() == TRUE ) + component.SetPower(); else - component.m_Options = ENTRY_NORMAL; + component.SetNormal(); /* Set the option "Units locked". Obviously, cannot be TRUE if there is only one part */ diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index 3863c8603e..1430e54a7d 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -267,7 +267,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName ); - if( entry && entry->m_Options == ENTRY_POWER ) + if( entry && entry->isPower() ) m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName; // copy all the fields back, and change the length of m_Fields. @@ -527,7 +527,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() // For power symbols, the value is NOR editable, because value and pin // name must be same and can be edited only in library editor - if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) + if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->isPower() ) fieldValueTextCtrl->Enable( false ); else fieldValueTextCtrl->Enable( true ); diff --git a/eeschema/dialog_sch_sheet_props.cpp b/eeschema/dialog_sch_sheet_props.cpp new file mode 100644 index 0000000000..655d409e9a --- /dev/null +++ b/eeschema/dialog_sch_sheet_props.cpp @@ -0,0 +1,7 @@ +#include "dialog_sch_sheet_props.h" + +DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : + DIALOG_SCH_SHEET_PROPS_BASE( parent ) +{ + m_textFileName->SetFocus(); +} diff --git a/eeschema/dialog_sch_sheet_props.fbp b/eeschema/dialog_sch_sheet_props.fbp new file mode 100644 index 0000000000..0cd537b0b2 --- /dev/null +++ b/eeschema/dialog_sch_sheet_props.fbp @@ -0,0 +1,681 @@ + + + + + + C++ + 1 + UTF-8 + table + dialog_sch_sheet_props_base + 1000 + none + 1 + dialog_sch_sheet_props + + . + + 1 + 1 + 0 + + + wxBOTH + + 1 + + + + 0 + wxID_ANY + + + DIALOG_SCH_SHEET_PROPS_BASE + + + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + Schematic Sheet Properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mainSizer + wxVERTICAL + none + + 12 + wxALL|wxEXPAND + 1 + + 6 + wxBOTH + 1 + + 0 + + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + &File name: + + + m_staticText1 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 5 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_textFileName + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_HORIZONTAL|wxALL + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + Te&xt size: + + + m_staticText2 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_textFileNameSize + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + units + + + m_staticFileNameSizeUnits + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + &Sheet name: + + + m_staticText4 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 5 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_textSheetName + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + &Text size: + + + m_staticText5 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_textSheetNameSize + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + units + + + m_staticSheetNameSizeUnits + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + protected + 0 + + + + 12 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + + + + + + + + + + + + + diff --git a/eeschema/dialog_sch_sheet_props.h b/eeschema/dialog_sch_sheet_props.h new file mode 100644 index 0000000000..873c57981b --- /dev/null +++ b/eeschema/dialog_sch_sheet_props.h @@ -0,0 +1,53 @@ +#ifndef __dialog_sch_sheet_props__ +#define __dialog_sch_sheet_props__ + +/** + * @file + * Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder. + */ + +#include "dialog_sch_sheet_props_base.h" + +/** Implementing DIALOG_SCH_SHEET_PROPS_BASE */ +class DIALOG_SCH_SHEET_PROPS : public DIALOG_SCH_SHEET_PROPS_BASE +{ +public: + /** Constructor */ + DIALOG_SCH_SHEET_PROPS( wxWindow* parent ); + + void SetFileName( const wxString& aFileName ) + { + m_textFileName->SetValue( aFileName ); + } + wxString GetFileName() { return m_textFileName->GetValue(); } + + void SetSheetName( const wxString& aSheetName ) + { + m_textSheetName->SetValue( aSheetName ); + } + wxString GetSheetName() { return m_textSheetName->GetValue(); } + + void SetFileNameTextSize( const wxString& aTextSize ) + { + m_textFileNameSize->SetValue( aTextSize ); + } + wxString GetFileNameTextSize() { return m_textFileNameSize->GetValue(); } + + void SetSheetNameTextSize( const wxString& aTextSize ) + { + m_textSheetNameSize->SetValue( aTextSize ); + } + wxString GetSheetNameTextSize() { return m_textSheetNameSize->GetValue(); } + + void SetFileNameTextSizeUnits(const wxString& aUnits) + { + m_staticFileNameSizeUnits->SetLabel( aUnits ); + } + + void SetSheetNameTextSizeUnits(const wxString& aUnits) + { + m_staticSheetNameSizeUnits->SetLabel( aUnits ); + } +}; + +#endif // __dialog_sch_sheet_props__ diff --git a/eeschema/dialog_sch_sheet_props_base.cpp b/eeschema/dialog_sch_sheet_props_base.cpp new file mode 100644 index 0000000000..de560e080e --- /dev/null +++ b/eeschema/dialog_sch_sheet_props_base.cpp @@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_sch_sheet_props_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* mainSizer; + mainSizer = new wxBoxSizer( wxVERTICAL ); + + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 2, 6, 0, 0 ); + fgSizer1->AddGrowableCol( 1 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText1 = new wxStaticText( this, wxID_ANY, _("&File name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_textFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_textFileName, 5, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); + + + fgSizer1->Add( 0, 0, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("Te&xt size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_textFileNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_textFileNameSize, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_staticFileNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticFileNameSizeUnits->Wrap( -1 ); + fgSizer1->Add( m_staticFileNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_staticText4 = new wxStaticText( this, wxID_ANY, _("&Sheet name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText4->Wrap( -1 ); + fgSizer1->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_textSheetName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_textSheetName, 5, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); + + + fgSizer1->Add( 0, 0, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); + + m_staticText5 = new wxStaticText( this, wxID_ANY, _("&Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + fgSizer1->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_textSheetNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer1->Add( m_textSheetNameSize, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + m_staticSheetNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticSheetNameSizeUnits->Wrap( -1 ); + fgSizer1->Add( m_staticSheetNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + + mainSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 12 ); + + + mainSizer->Add( 0, 0, 0, wxALL|wxEXPAND, 5 ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + mainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 12 ); + + this->SetSizer( mainSizer ); + this->Layout(); + mainSizer->Fit( this ); + + this->Centre( wxBOTH ); +} + +DIALOG_SCH_SHEET_PROPS_BASE::~DIALOG_SCH_SHEET_PROPS_BASE() +{ +} diff --git a/eeschema/dialog_sch_sheet_props_base.h b/eeschema/dialog_sch_sheet_props_base.h new file mode 100644 index 0000000000..a7fd258ae3 --- /dev/null +++ b/eeschema/dialog_sch_sheet_props_base.h @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_sch_sheet_props_base__ +#define __dialog_sch_sheet_props_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_SCH_SHEET_PROPS_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_SCH_SHEET_PROPS_BASE : public wxDialog +{ + private: + + protected: + wxStaticText* m_staticText1; + wxTextCtrl* m_textFileName; + + wxStaticText* m_staticText2; + wxTextCtrl* m_textFileNameSize; + wxStaticText* m_staticFileNameSizeUnits; + wxStaticText* m_staticText4; + wxTextCtrl* m_textSheetName; + + wxStaticText* m_staticText5; + wxTextCtrl* m_textSheetNameSize; + wxStaticText* m_staticSheetNameSizeUnits; + + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Cancel; + + public: + DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_SCH_SHEET_PROPS_BASE(); + +}; + +#endif //__dialog_sch_sheet_props_base__ diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index 82b8a7ad85..2133d50389 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -75,9 +75,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() return; } - m_Doc->SetValue( entry->m_Doc ); - m_Keywords->SetValue( entry->m_KeyWord ); - m_Docfile->SetValue( entry->m_DocFile ); + m_Doc->SetValue( entry->GetDescription() ); + m_Keywords->SetValue( entry->GetKeyWords() ); + m_Docfile->SetValue( entry->GetDocFileName() ); } @@ -109,7 +109,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 ); m_SelNumberOfUnits->SetValue( component->GetPartCount() ); m_SetSkew->SetValue( component->m_TextInside ); - m_OptionPower->SetValue( component->m_Options == ENTRY_POWER ); + m_OptionPower->SetValue( component->isPower() ); m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked ); } @@ -152,9 +152,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) } else { - entry->m_Doc = m_Doc->GetValue(); - entry->m_KeyWord = m_Keywords->GetValue(); - entry->m_DocFile = m_Docfile->GetValue(); + entry->SetDescription( m_Doc->GetValue() ); + entry->SetKeyWords( m_Keywords->GetValue() ); + entry->SetDocFileName( m_Docfile->GetValue() ); } if( m_PartAliasList->GetStrings() != component->m_AliasList ) @@ -230,9 +230,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) } if( m_OptionPower->GetValue() == true ) - component->m_Options = ENTRY_POWER; + component->SetPower(); else - component->m_Options = ENTRY_NORMAL; + component->SetNormal(); /* Set the option "Units locked". * Obviously, cannot be true if there is only one part */ @@ -257,9 +257,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED if( component == NULL || m_Parent->GetAliasName().IsEmpty() ) return; - m_Doc->SetValue( component->m_Doc ); - m_Docfile->SetValue( component->m_DocFile ); - m_Keywords->SetValue( component->m_KeyWord ); + m_Doc->SetValue( component->GetDescription() ); + m_Docfile->SetValue( component->GetDocFileName() ); + m_Keywords->SetValue( component->GetKeyWords() ); } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 22380077f6..67e7f9533d 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -102,7 +102,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_FIELD* Field, wxDC* DC ) { Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName ); - if( Entry && (Entry->m_Options == ENTRY_POWER) ) + if( Entry && Entry->isPower() ) { DisplayInfoMessage( this, _( "Part is a POWER, value cannot be \ modified!\nYou must create a new power" ) ); diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index c52112276c..4c49dbc699 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -138,12 +138,12 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, cmpName = LibEntry->GetName(); m_aliasName.Empty(); - if( LibEntry->Type != ROOT ) + if( LibEntry->isAlias() ) { LIB_ALIAS* alias = (LIB_ALIAS*) LibEntry; component = alias->GetComponent(); - wxASSERT( component != NULL && component->Type == ROOT ); + wxASSERT( component != NULL && component->isComponent() ); wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ), GetChars( cmpName ), @@ -326,7 +326,7 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() AppendMsgPanel( _( "Body" ), msg, GREEN, 8 ); - if( m_component->m_Options == ENTRY_POWER ) + if( m_component->isPower() ) msg = _( "Power Symbol" ); else msg = _( "Component" ); @@ -334,16 +334,16 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 ); if( alias != NULL ) - msg = alias->m_Doc; + msg = alias->GetDescription(); else - msg = m_component->m_Doc; + msg = m_component->GetDescription(); AppendMsgPanel( _( "Description" ), msg, CYAN, 8 ); if( alias != NULL ) - msg = alias->m_KeyWord; + msg = alias->GetKeyWords(); else - msg = m_component->m_KeyWord; + msg = m_component->GetKeyWords(); AppendMsgPanel( _( "Key words" ), msg, DARKDARKGRAY ); } @@ -542,8 +542,11 @@ created. Aborted" ) ); component->m_TextInside = 1; } else + { component->m_TextInside = 0; - component->m_Options = ( dlg.GetPowerSymbol() ) ? ENTRY_POWER : ENTRY_NORMAL; + } + + ( dlg.GetPowerSymbol() ) ? component->SetPower() : component->SetNormal(); component->m_DrawPinNum = dlg.GetShowPinNumber(); component->m_DrawPinName = dlg.GetShowPinName(); component->m_UnitSelectionLocked = dlg.GetLockItems(); @@ -612,7 +615,7 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory() m_drawItem = m_lastDrawItem = NULL; - wxASSERT( m_component->Type == ROOT ); + wxASSERT( m_component->isComponent() ); if( oldComponent != NULL ) Component = m_library->ReplaceComponent( oldComponent, m_component ); diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index 9be705a754..1b6644b453 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -457,9 +457,9 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event ) CMP_LIB_ENTRY* entry = m_library->FindEntry( m_aliasName ); if( entry != NULL ) - enable = !entry->m_DocFile.IsEmpty(); + enable = !entry->GetDocFileName().IsEmpty(); } - else if( !m_component->m_DocFile.IsEmpty() ) + else if( !m_component->GetDocFileName().IsEmpty() ) { enable = true; } @@ -572,11 +572,11 @@ void WinEDA_LibeditFrame::OnViewEntryDoc( wxCommandEvent& event ) m_library->FindEntry( m_aliasName ); if( entry != NULL ) - fileName = entry->m_DocFile; + fileName = entry->GetDocFileName(); } else { - fileName = m_component->m_DocFile; + fileName = m_component->GetDocFileName(); } if( !fileName.IsEmpty() ) diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 0a5822b890..2306fc7868 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -255,7 +255,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) if( libEntry ) { - if( libEntry->Type == ALIAS ) + if( libEntry->isAlias() ) libComponent = ( (LIB_ALIAS*) libEntry )->GetComponent(); else libComponent = (LIB_COMPONENT*) libEntry; @@ -300,7 +300,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, msg, edit_component_xpm ); - if( libEntry && libEntry->m_Options != ENTRY_POWER ) + if( libEntry && libEntry->isNormal() ) { msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_VALUE ); @@ -348,7 +348,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) _( "Delete Component" ), delete_xpm ); } - if( libEntry && !libEntry->m_DocFile.IsEmpty() ) + if( libEntry && !libEntry->GetDocFileName().IsEmpty() ) ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), datasheet_xpm ); } diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 6431fecb41..0fdd2d0b08 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -379,7 +379,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_SCH_EDIT_SHEET: - EditSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ); + if( EditSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ) ) + screen->SetModify(); break; case ID_POPUP_IMPORT_GLABEL: @@ -645,10 +646,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) LibEntry = CMP_LIBRARY::FindLibraryEntry( ( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName ); - if( LibEntry && LibEntry->m_DocFile != wxEmptyString ) + if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString ) { - GetAssociatedDocument( this, LibEntry->m_DocFile , - & wxGetApp().GetLibraryPathList() ); + GetAssociatedDocument( this, LibEntry->GetDocFileName(), + &wxGetApp().GetLibraryPathList() ); } } break; diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index 2f88ef1485..3cc774a493 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -69,6 +69,9 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ListNames = (const wxChar**) MyZMalloc( ( nameList.GetCount() + 1 ) * sizeof( wxChar* ) ); + if( ListNames == NULL ) + return 0; + for( i = 0; i < nameList.GetCount(); i++ ) ListNames[i] = (const wxChar*) nameList[i]; diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index c8892b4466..f74140f676 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -1,24 +1,14 @@ ///////////////////////////////////////////////////////////////////////////// - // Name: sheet.cpp // Purpose: // Author: jean-pierre Charras -// Modified by: +// Modified by: Wayne Stambaugh // Created: 08/02/2006 18:37:02 // RCS-ID: // Copyright: License GNU // License: ///////////////////////////////////////////////////////////////////////////// -// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02 - -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "sheet.h" -#endif - -////@begin includes -////@end includes - #include "fctsys.h" #include "gr_basic.h" #include "common.h" @@ -30,407 +20,240 @@ #include "general.h" #include "protos.h" - -static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); -static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); +#include "dialog_sch_sheet_props.h" -static int s_SheetMindx, s_SheetMindy; +static int s_PreviousSheetWidth; +static int s_PreviousSheetHeight; static wxPoint s_OldPos; /* Former position for cancellation or move ReSize */ -#include "sheet.h" - -////@begin XPM images -////@end XPM images - -/*! - * WinEDA_SheetPropertiesFrame type definition - */ - -IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog ) - -/*! - * WinEDA_SheetPropertiesFrame event table definition - */ - -BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog ) - -////@begin WinEDA_SheetPropertiesFrame event table entries -EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick ) - -EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick ) - -////@end WinEDA_SheetPropertiesFrame event table entries - -END_EVENT_TABLE() -/*! - * WinEDA_SheetPropertiesFrame constructors - */ - -WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame() -{ -} - - -WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( - WinEDA_SchematicFrame* parent, - SCH_SHEET* currentsheet, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ - m_Parent = parent; - m_CurrentSheet = currentsheet; - Create( parent, id, caption, pos, size, style ); - - AddUnitSymbol( *m_SheetNameTextSize ); - PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize, - m_Parent->m_InternalUnits ); - - AddUnitSymbol( *m_FileNameTextSize ); - PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize, - m_Parent->m_InternalUnits ); -} - - -/*! - * WinEDA_SheetPropertiesFrame creator - */ - -bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ -////@begin WinEDA_SheetPropertiesFrame member initialisation - m_FileNameWin = NULL; - m_SheetNameWin = NULL; - m_FileNameTextSize = NULL; - m_FileNameSize = NULL; - m_SheetNameTextSize = NULL; - m_SheetNameSize = NULL; - m_btClose = NULL; - -////@end WinEDA_SheetPropertiesFrame member initialisation - -////@begin WinEDA_SheetPropertiesFrame creation - SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); - wxDialog::Create( parent, id, caption, pos, size, style ); - - CreateControls(); - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } - Centre(); - -////@end WinEDA_SheetPropertiesFrame creation - return true; -} - - -/*! - * Control creation for WinEDA_SheetPropertiesFrame - */ - -void WinEDA_SheetPropertiesFrame::CreateControls() -{ -////@begin WinEDA_SheetPropertiesFrame content construction - // Generated by DialogBlocks, 24/04/2009 14:25:43 (unregistered) - - WinEDA_SheetPropertiesFrame* itemDialog1 = this; - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL ); - - itemDialog1->SetSizer( itemBoxSizer2 ); - - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL ); - itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 ); - - wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, - wxID_STATIC, - _( "Filename:" ), - wxDefaultPosition, - wxDefaultSize, - 0 ); - itemBoxSizer4->Add( itemStaticText5, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | - wxADJUST_MINSIZE, - 5 ); - - m_FileNameWin = - new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, - wxSize( 300, - 1 ), wxTE_PROCESS_ENTER ); - itemBoxSizer4->Add( m_FileNameWin, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); - - wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, - wxID_STATIC, - _( "Sheetname:" ), - wxDefaultPosition, - wxDefaultSize, - 0 ); - itemBoxSizer4->Add( itemStaticText7, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | - wxADJUST_MINSIZE, - 5 ); - - m_SheetNameWin = - new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, - wxSize( 300, -1 ), 0 ); - itemBoxSizer4->Add( m_SheetNameWin, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); - - wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL ); - itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, - _( "Size" ), wxDefaultPosition, - wxDefaultSize, 0 ); - itemBoxSizer9->Add( m_FileNameTextSize, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | - wxADJUST_MINSIZE, - 5 ); - - m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T( "" ), - wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer9->Add( m_FileNameSize, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); - - m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, - _( "Size" ), wxDefaultPosition, - wxDefaultSize, 0 ); - itemBoxSizer9->Add( m_SheetNameTextSize, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | - wxADJUST_MINSIZE, - 5 ); - - m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T( "" ), - wxDefaultPosition, - wxDefaultSize, 0 ); - itemBoxSizer9->Add( m_SheetNameSize, - 0, - wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); - - itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 ); - - wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL ); - itemBoxSizer2->Add( itemBoxSizer15, - 0, - wxALIGN_CENTER_HORIZONTAL | wxALL, - 5 ); - - m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _( "&Cancel" ), - wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer15->Add( m_btClose, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, - _( "&OK" ), wxDefaultPosition, - wxDefaultSize, 0 ); - itemButton17->SetDefault(); - itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - - // Set validators - m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, - &m_CurrentSheet->m_SheetName ) ); - -////@end WinEDA_SheetPropertiesFrame content construction - - m_btClose->SetFocus(); - m_FileNameWin->SetValue( m_CurrentSheet->GetFileName() ); -} - - -/*! - * Should we show tooltips? - */ - -bool WinEDA_SheetPropertiesFrame::ShowToolTips() -{ - return true; -} - - -/*! - * Get bitmap resources - */ - -wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name ) -{ - // Bitmap retrieval -////@begin WinEDA_SheetPropertiesFrame bitmap retrieval - wxUnusedVar( name ); - return wxNullBitmap; - -////@end WinEDA_SheetPropertiesFrame bitmap retrieval -} - - -/*! - * Get icon resources - */ - -wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name ) -{ - // Icon retrieval -////@begin WinEDA_SheetPropertiesFrame icon retrieval - wxUnusedVar( name ); - return wxNullIcon; - -////@end WinEDA_SheetPropertiesFrame icon retrieval -} - - -/** Function SheetPropertiesAccept - * Set the new sheets properties: - * sheetname and filename (text and size) - */ -void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) -{ - wxFileName fn; - wxString msg; - - fn = m_FileNameWin->GetValue(); - - if( !fn.IsOk() ) - { - DisplayError( this, _( "No Filename! Aborted" ) ); - EndModal( FALSE ); - return; - } - - fn.SetExt( SchematicFileExtension ); - - /* m_CurrentSheet->m_AssociatedScreen must be a valide screen, and the - * sheet must have a valid associated filename, - * so we must call m_CurrentSheet->ChangeFileName to set a filename, - * AND always when a new sheet is created ( when - * m_CurrentSheet->m_AssociatedScreen is null ), - * to create or set an Associated Screen - */ - if( ( fn.GetFullPath() != m_CurrentSheet->GetFileName() ) - || ( m_CurrentSheet->m_AssociatedScreen == NULL) ) - { - msg = _( "Changing a Filename can change all the schematic \ -structures and cannot be undone.\nOk to continue renaming?" ); - - if( m_CurrentSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) ) - { - // do not prompt on a new sheet. in fact, we should not allow a - // sheet to be created without a valid associated filename to be - // read from. - m_Parent->GetScreen()->ClearUndoRedoList(); - - // set filename and the associated screen - m_CurrentSheet->ChangeFileName( m_Parent, fn.GetFullPath() ); - } - } - - msg = m_FileNameSize->GetValue(); - m_CurrentSheet->m_FileNameSize = - ReturnValueFromString( g_UnitMetric, - msg, m_Parent->m_InternalUnits ); - - m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue(); - msg = m_SheetNameSize->GetValue(); - m_CurrentSheet->m_SheetNameSize = - ReturnValueFromString( g_UnitMetric, - msg, m_Parent->m_InternalUnits ); - - if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) ) - { - m_CurrentSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), - GetTimeStamp() ); - } - - - EndModal( TRUE ); -} - - /* Routine to edit the SheetName and the FileName for the sheet "Sheet" */ -bool WinEDA_SchematicFrame::EditSheet( SCH_SHEET* Sheet, wxDC* DC ) +bool WinEDA_SchematicFrame::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) { - WinEDA_SheetPropertiesFrame* frame; - bool edit = TRUE; + bool edit = true; - if( Sheet == NULL ) - return FALSE; + if( aSheet == NULL ) + return false; /* Get the new texts */ - RedrawOneStruct( DrawPanel, DC, Sheet, g_XorMode ); + RedrawOneStruct( DrawPanel, aDC, aSheet, g_XorMode ); + + DrawPanel->m_IgnoreMouseEvents = true; + + DIALOG_SCH_SHEET_PROPS dlg( this ); + + wxString units = GetUnitsLabel( g_UnitMetric ); + dlg.SetFileName( aSheet->GetFileName() ); + dlg.SetFileNameTextSize( ReturnStringFromValue( g_UnitMetric, + aSheet->m_FileNameSize, + m_InternalUnits ) ); + dlg.SetFileNameTextSizeUnits( units ); + dlg.SetSheetName( aSheet->m_SheetName ); + dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UnitMetric, + aSheet->m_SheetNameSize, + m_InternalUnits ) ); + dlg.SetSheetNameTextSizeUnits( units ); + + /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier + * versions for the flex grid sizer in wxGTK that prevents the last + * column from being sized correctly. It doesn't cause any problems + * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__ + * #endif. + */ + dlg.Layout(); + dlg.Fit(); + dlg.SetMinSize( dlg.GetSize() ); + + if( dlg.ShowModal() == wxID_OK ) + { + wxFileName fileName; + wxString msg; + + fileName = dlg.GetFileName(); + + if( !fileName.IsOk() ) + { + DisplayError( this, _( "File name is not valid! Aborted" ) ); + edit = false; + } + else + { + fileName.SetExt( SchematicFileExtension ); + + /* m_CurrentSheet->m_AssociatedScreen must be a valid screen, and the + * sheet must have a valid associated filename, + * so we must call m_CurrentSheet->ChangeFileName to set a filename, + * AND always when a new sheet is created ( when + * m_CurrentSheet->m_AssociatedScreen is null ), + * to create or set an Associated Screen + */ + if( ( fileName.GetFullPath() != aSheet->GetFileName() ) + || ( aSheet->m_AssociatedScreen == NULL ) ) + { + msg = _( "Changing the sheet file name can change all the schematic \ +structures and cannot be undone.\nOk to continue renaming?" ); + + if( aSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) ) + { + // do not prompt on a new sheet. in fact, we should not allow a + // sheet to be created without a valid associated filename to be + // read from. + GetScreen()->ClearUndoRedoList(); + + // set filename and the associated screen + aSheet->ChangeFileName( this, fileName.GetFullPath() ); + } + } + + aSheet->m_FileNameSize = ReturnValueFromString( g_UnitMetric, + dlg.GetFileNameTextSize(), + m_InternalUnits ); + + aSheet->m_SheetName = dlg.GetSheetName(); + aSheet->m_SheetNameSize = ReturnValueFromString( g_UnitMetric, + dlg.GetSheetNameTextSize(), + m_InternalUnits ); + + if( aSheet->m_SheetName.IsEmpty() ) + { + aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() ); + } + } + } + else + { + edit = false; + } - DrawPanel->m_IgnoreMouseEvents = TRUE; - frame = new WinEDA_SheetPropertiesFrame( this, Sheet ); - edit = frame->ShowModal(); frame->Destroy(); DrawPanel->MouseToCursorSchema(); - DrawPanel->m_IgnoreMouseEvents = FALSE; + DrawPanel->m_IgnoreMouseEvents = false; + + RedrawOneStruct( DrawPanel, aDC, aSheet, GR_DEFAULT_DRAWMODE ); - RedrawOneStruct( DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE ); return edit; } +/* Move selected sheet with the cursor. + * Callback function use by ManageCurseur. + */ +static void MoveSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase ) +{ + wxPoint moveVector; + SCH_SHEET_PIN* sheetLabel; + BASE_SCREEN* screen = aPanel->GetScreen(); + SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem(); + + if( aErase ) + RedrawOneStruct( aPanel, aDC, sheet, g_XorMode ); + + if( sheet->m_Flags & IS_RESIZED ) + { + sheet->m_Size.x = MAX( s_PreviousSheetWidth, screen->m_Curseur.x - sheet->m_Pos.x ); + sheet->m_Size.y = MAX( s_PreviousSheetHeight, screen->m_Curseur.y - sheet->m_Pos.y ); + sheetLabel = sheet->m_Label; + + while( sheetLabel ) + { + if( sheetLabel->m_Edge ) + sheetLabel->m_Pos.x = sheet->m_Pos.x + sheet->m_Size.x; + sheetLabel = sheetLabel->Next(); + } + } + else /* Move Sheet */ + { + moveVector = screen->m_Curseur - sheet->m_Pos; + sheet->Move( moveVector ); + } + + RedrawOneStruct( aPanel, aDC, sheet, g_XorMode ); +} + + +/* Complete sheet move. */ +static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC ) +{ + SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); + SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem(); + + if( sheet == NULL ) + return; + + if( sheet->m_Flags & IS_NEW ) + { + RedrawOneStruct( aPanel, aDC, sheet, g_XorMode ); + SAFE_DELETE( sheet ); + } + else if( sheet->m_Flags & IS_RESIZED ) + { + /* Resize in progress, cancel move. */ + RedrawOneStruct( aPanel, aDC, sheet, g_XorMode ); + sheet->m_Size.x = s_OldPos.x; + sheet->m_Size.y = s_OldPos.y; + RedrawOneStruct( aPanel, aDC, sheet, GR_DEFAULT_DRAWMODE ); + sheet->m_Flags = 0; + } + else if( sheet->m_Flags & IS_MOVED ) + { + wxPoint curspos = screen->m_Curseur; + aPanel->GetScreen()->m_Curseur = s_OldPos; + MoveSheet( aPanel, aDC, true ); + RedrawOneStruct( aPanel, aDC, sheet, GR_DEFAULT_DRAWMODE ); + sheet->m_Flags = 0; + screen->m_Curseur = curspos; + } + else + { + sheet->m_Flags = 0; + } + + screen->SetCurItem( NULL ); + aPanel->ManageCurseur = NULL; + aPanel->ForceCloseManageCurseur = NULL; +} + + #define SHEET_MIN_WIDTH 500 #define SHEET_MIN_HEIGHT 150 + /* Create hierarchy sheet. */ -SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* DC ) +SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC ) { g_ItemToRepeat = NULL; - SCH_SHEET* Sheet = new SCH_SHEET( GetScreen()->m_Curseur ); + SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur ); - Sheet->m_Flags = IS_NEW | IS_RESIZED; - Sheet->m_TimeStamp = GetTimeStamp(); - Sheet->SetParent( GetScreen() ); - Sheet->m_AssociatedScreen = NULL; - s_SheetMindx = SHEET_MIN_WIDTH; - s_SheetMindy = SHEET_MIN_HEIGHT; + sheet->m_Flags = IS_NEW | IS_RESIZED; + sheet->m_TimeStamp = GetTimeStamp(); + sheet->SetParent( GetScreen() ); + sheet->m_AssociatedScreen = NULL; + s_PreviousSheetWidth = SHEET_MIN_WIDTH; + s_PreviousSheetHeight = SHEET_MIN_HEIGHT; - //need to check if this is being added to the EEDrawList. - //also need to update the hierarchy, if we are adding + // need to check if this is being added to the EEDrawList. + // also need to update the hierarchy, if we are adding // a sheet to a screen that already has multiple instances (!) - GetScreen()->SetCurItem( Sheet ); + GetScreen()->SetCurItem( sheet ); - DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ManageCurseur = MoveSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); + DrawPanel->ManageCurseur( DrawPanel, aDC, false ); - return Sheet; + return sheet; } -void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* Sheet, wxDC* DC ) +void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) { - SCH_SHEET_PIN* sheetlabel; + SCH_SHEET_PIN* sheetLabel; - if( Sheet == NULL ) - return; - if( Sheet->m_Flags & IS_NEW ) + if( aSheet == NULL || aSheet->m_Flags & IS_NEW ) return; - if( Sheet->Type() != DRAW_SHEET_STRUCT_TYPE ) + if( aSheet->Type() != DRAW_SHEET_STRUCT_TYPE ) { DisplayError( this, wxT( "WinEDA_SchematicFrame::ReSizeSheet: Bad SructType" ) ); @@ -438,142 +261,44 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* Sheet, wxDC* DC ) } GetScreen()->SetModify(); - Sheet->m_Flags |= IS_RESIZED; + aSheet->m_Flags |= IS_RESIZED; - s_OldPos.x = Sheet->m_Size.x; - s_OldPos.y = Sheet->m_Size.y; + s_OldPos.x = aSheet->m_Size.x; + s_OldPos.y = aSheet->m_Size.y; - s_SheetMindx = SHEET_MIN_WIDTH; - s_SheetMindy = SHEET_MIN_HEIGHT; - sheetlabel = Sheet->m_Label; - while( sheetlabel ) + s_PreviousSheetWidth = SHEET_MIN_WIDTH; + s_PreviousSheetHeight = SHEET_MIN_HEIGHT; + sheetLabel = aSheet->m_Label; + + while( sheetLabel ) { - s_SheetMindx = MAX( s_SheetMindx, - (int) ( ( sheetlabel->GetLength() + 1 ) * - sheetlabel->m_Size.x ) ); - s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y ); - sheetlabel = sheetlabel->Next(); + s_PreviousSheetWidth = MAX( s_PreviousSheetWidth, + (int) ( ( sheetLabel->GetLength() + 1 ) * + sheetLabel->m_Size.x ) ); + s_PreviousSheetHeight = MAX( s_PreviousSheetHeight, + sheetLabel->m_Pos.y - aSheet->m_Pos.y ); + sheetLabel = sheetLabel->Next(); } - DrawPanel->ManageCurseur = DeplaceSheet; + DrawPanel->ManageCurseur = MoveSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); + DrawPanel->ManageCurseur( DrawPanel, aDC, true ); } -void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* Sheet, wxDC* DC ) +void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC ) { - if( ( Sheet == NULL ) || ( Sheet->Type() != DRAW_SHEET_STRUCT_TYPE ) ) + if( ( aSheet == NULL ) || ( aSheet->Type() != DRAW_SHEET_STRUCT_TYPE ) ) return; - DrawPanel->CursorOff( DC ); - GetScreen()->m_Curseur = Sheet->m_Pos; + DrawPanel->CursorOff( aDC ); + GetScreen()->m_Curseur = aSheet->m_Pos; DrawPanel->MouseToCursorSchema(); - s_OldPos = Sheet->m_Pos; - Sheet->m_Flags |= IS_MOVED; - DrawPanel->ManageCurseur = DeplaceSheet; + s_OldPos = aSheet->m_Pos; + aSheet->m_Flags |= IS_MOVED; + DrawPanel->ManageCurseur = MoveSheet; DrawPanel->ForceCloseManageCurseur = ExitSheet; - DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); - - DrawPanel->CursorOn( DC ); -} - - -/* Move selected sheet with the cursor. - * Callback function use by ManageCurseur. - */ -static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) -{ - wxPoint move_vector; - SCH_SHEET_PIN* SheetLabel; - BASE_SCREEN* screen = panel->GetScreen(); - - SCH_SHEET* Sheet = (SCH_SHEET*) screen->GetCurItem(); - - if( erase ) - RedrawOneStruct( panel, DC, Sheet, g_XorMode ); - - if( Sheet->m_Flags & IS_RESIZED ) - { - Sheet->m_Size.x = - MAX( s_SheetMindx, screen->m_Curseur.x - Sheet->m_Pos.x ); - Sheet->m_Size.y = - MAX( s_SheetMindy, screen->m_Curseur.y - Sheet->m_Pos.y ); - SheetLabel = Sheet->m_Label; - while( SheetLabel ) - { - if( SheetLabel->m_Edge ) - SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; - SheetLabel = SheetLabel->Next(); - } - } - else /* Move Sheet */ - { - move_vector = screen->m_Curseur - Sheet->m_Pos; - Sheet->Move( move_vector ); - } - - RedrawOneStruct( panel, DC, Sheet, g_XorMode ); -} - - -/* Complete sheet move. */ -static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) -{ - SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen(); - SCH_SHEET* Sheet = (SCH_SHEET*) Screen->GetCurItem(); - - if( Sheet == NULL ) - return; - - if( Sheet->m_Flags & IS_NEW ) - { - RedrawOneStruct( Panel, DC, Sheet, g_XorMode ); - SAFE_DELETE( Sheet ); - } - else if( Sheet->m_Flags & IS_RESIZED ) - { - /* Resize in progress, cancel move. */ - RedrawOneStruct( Panel, DC, Sheet, g_XorMode ); - Sheet->m_Size.x = s_OldPos.x; - Sheet->m_Size.y = s_OldPos.y; - RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE ); - Sheet->m_Flags = 0; - } - else if( Sheet->m_Flags & IS_MOVED ) - { - wxPoint curspos = Screen->m_Curseur; - Panel->GetScreen()->m_Curseur = s_OldPos; - DeplaceSheet( Panel, DC, TRUE ); - RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE ); - Sheet->m_Flags = 0; - Screen->m_Curseur = curspos; - } - else - Sheet->m_Flags = 0; - - Screen->SetCurItem( NULL ); - Panel->ManageCurseur = NULL; - Panel->ForceCloseManageCurseur = NULL; -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - -void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( 0 ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) -{ - SheetPropertiesAccept( event ); + DrawPanel->ManageCurseur( DrawPanel, aDC, true ); + DrawPanel->CursorOn( aDC ); } diff --git a/eeschema/sheet.h b/eeschema/sheet.h deleted file mode 100644 index a95b322d09..0000000000 --- a/eeschema/sheet.h +++ /dev/null @@ -1,125 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: sheet.h -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 08/02/2006 18:37:02 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// - -// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02 - -#ifndef _SHEET_H_ -#define _SHEET_H_ - -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "sheet.h" -#endif - -/*! - * Includes - */ - -////@begin includes -#include "wx/valtext.h" -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_TEXTCTRL1 10002 -#define ID_TEXTCTRL 10001 -#define ID_TEXTCTRL2 10003 -#define ID_TEXTCTRL3 10004 -#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE _("Sheet properties") -#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_SheetPropertiesFrame class declaration - */ - -class WinEDA_SheetPropertiesFrame: public wxDialog -{ - DECLARE_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame ) - DECLARE_EVENT_TABLE() - -public: - /// Constructors - WinEDA_SheetPropertiesFrame( ); - WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent, - SCH_SHEET * currentsheet, - wxWindowID id = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME, - const wxString& caption = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE, - const wxPoint& pos = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION, - const wxSize& size = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE, - long style = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE ); - - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_SHEETPROPERTIESFRAME_STYLE ); - - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_SheetPropertiesFrame event handler declarations - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - void OnCancelClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - void OnOkClick( wxCommandEvent& event ); - -////@end WinEDA_SheetPropertiesFrame event handler declarations - -////@begin WinEDA_SheetPropertiesFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_SheetPropertiesFrame member function declarations - - /// Should we show tooltips? - static bool ShowToolTips(); - void SheetPropertiesAccept(wxCommandEvent& event); - -////@begin WinEDA_SheetPropertiesFrame member variables - wxTextCtrl* m_FileNameWin; - wxTextCtrl* m_SheetNameWin; - wxStaticText* m_FileNameTextSize; - wxTextCtrl* m_FileNameSize; - wxStaticText* m_SheetNameTextSize; - wxTextCtrl* m_SheetNameSize; - wxButton* m_btClose; -////@end WinEDA_SheetPropertiesFrame member variables - - WinEDA_SchematicFrame * m_Parent; - SCH_SHEET* m_CurrentSheet; -}; - -#endif - // _SHEET_H_ diff --git a/eeschema/sheet.pjd b/eeschema/sheet.pjd deleted file mode 100644 index 3afff6b16b..0000000000 --- a/eeschema/sheet.pjd +++ /dev/null @@ -1,1217 +0,0 @@ - - -
- 0 - "" - "" - "" - "" - "" - 0 - 0 - 0 - 1 - 1 - 1 - 1 - 0 - "jean-pierre Charras" - "License GNU" - "" - 0 - 0 - 0 - "<All platforms>" - "<Any>" - "///////////////////////////////////////////////////////////////////////////// -// Name: %HEADER-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SOURCE-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SYMBOLS-FILENAME% -// Purpose: Symbols file -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "%HEADER-FILENAME%" -#endif - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "%HEADER-FILENAME%" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -" - " /// %BODY% -" - " -/*! - * %BODY% - */ - -" - "app_resources.h" - "app_resources.cpp" - "AppResources" - "app.h" - "app.cpp" - "Application" - 0 - "" - "<None>" - "<System>" - "utf-8" - "<System>" - "" - 0 - 0 - 4 - " " - "" - 0 - 0 - 1 - 0 - 1 - 1 - 0 - 1 - 0 - 0 -
- - - "" - "data-document" - "" - "" - 0 - 1 - 0 - 0 - - "Configurations" - "config-data-document" - "" - "" - 0 - 1 - 0 - 0 - "" - 1 - -8519680 - "" - "Debug" - "ANSI" - "Static" - "Modular" - "GUI" - "wxMSW" - "Dynamic" - "Yes" - "No" - "No" - "%WXVERSION%" - "%EXECUTABLE%" - "" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - 0 - 1 - "" - - - - - - - "Projects" - "root-document" - "" - "project" - 1 - 1 - 0 - 1 - - "Windows" - "html-document" - "" - "dialogsfolder" - 1 - 1 - 0 - 1 - - "Sheet properties" - "dialog-document" - "" - "dialog" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbDialogProxy" - 10000 - 0 - "" - 0 - "" - 0 - 0 - "ID_DIALOG" - 10000 - "WinEDA_SheetPropertiesFrame" - "wxDialog" - "wxDialog" - "sheet.cpp" - "sheet.h" - "" - "Sheet properties" - 1 - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "Tiled" - 0 - 1 - 0 - 1 - 0 - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - "MAYBE_RESIZE_BORDER" - 0 - 1 - -1 - -1 - 400 - 300 - 0 - "" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "wbBoxSizerProxy" - "Vertical" - "" - 0 - 0 - 0 - "<Any platform>" - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "" - "Filename:" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Top" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL1" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "8/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL1" - 10002 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_FileNameWin" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 300 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "" - "Sheetname:" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Top" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "8/5/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL" - 10001 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_SheetNameWin" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "m_CurrentSheet->m_SheetName" - "wxTextValidator(wxFILTER_NONE, & %VARIABLE%)" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 300 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "m_FileNameTextSize" - "Size" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Top" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL2" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL2" - 10003 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_FileNameSize" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - 0 - - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "m_SheetNameTextSize" - "Size" - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Top" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL3" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL3" - 10004 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_SheetNameSize" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - 0 - - - - - "Spacer" - "dialog-control-document" - "" - "spacer" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbSpacerProxy" - 5 - 5 - "Expand" - "Centre" - 1 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxButton: wxID_CANCEL" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick|||WinEDA_SheetPropertiesFrame" - "wxID_CANCEL" - 5101 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "m_btClose" - "&Cancel" - 0 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxButton: wxID_OK" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "8/11/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" - "wxID_OK" - 5100 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "" - "&OK" - 1 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - - - - - "Sources" - "html-document" - "" - "sourcesfolder" - 1 - 1 - 0 - 1 - - "sheet.rc" - "source-editor-document" - "sheet.rc" - "source-editor" - 0 - 0 - 1 - 0 - "8/11/2006" - "" - - - - "Images" - "html-document" - "" - "bitmapsfolder" - 1 - 1 - 0 - 1 - - - - -
diff --git a/eeschema/sheet.rc b/eeschema/sheet.rc deleted file mode 100644 index b86c4e2265..0000000000 --- a/eeschema/sheet.rc +++ /dev/null @@ -1 +0,0 @@ -#include "wx/msw/wx.rc" diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 6f34c2a16e..ae6d4e39b4 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -20,6 +20,7 @@ #include "class_library.h" #include +#include /* @@ -32,7 +33,6 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) { LIB_COMPONENT* Component; - FILE* ImportFile; wxString msg, err; CMP_LIBRARY* Lib; @@ -58,17 +58,6 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) wxFileName fn = dlg.GetPath(); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); - /* Load data */ - ImportFile = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); - - if( ImportFile == NULL ) - { - msg.Printf( _( "Failed to open Symbol File <%s>" ), - GetChars( fn.GetFullPath() ) ); - DisplayError( this, msg ); - return; - } - Lib = new CMP_LIBRARY( LIBRARY_TYPE_SYMBOL, fn ); if( !Lib->Load( err ) ) @@ -76,13 +65,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) msg.Printf( _( "Error <%s> occurred loading symbol library <%s>." ), GetChars( err ), GetChars( fn.GetName() ) ); DisplayError( this, msg ); - fclose( ImportFile ); delete Lib; return; } - fclose( ImportFile ); - if( Lib->IsEmpty() ) { msg.Printf( _( "No components found in symbol library <%s>." ), @@ -92,7 +78,11 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) } if( Lib->GetCount() > 1 ) - DisplayError( this, _( "Warning: more than 1 part in symbol file." ) ); + { + msg.Printf( _( "More than one part in symbol file <%s>." ), + GetChars( fn.GetName() ) ); + wxMessageBox( msg, _( "Warning" ), wxOK | wxICON_EXCLAMATION, this ); + } Component = (LIB_COMPONENT*) Lib->GetFirstEntry(); LIB_DRAW_ITEM_LIST& drawList = Component->GetDrawItemList(); @@ -113,10 +103,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) m_component->AddDrawItem( newItem ); } - // Remove duplicated drawings: m_component->RemoveDuplicateDrawItems(); - - // Clear flags m_component->ClearSelectedItems(); GetScreen()->SetModify(); @@ -127,7 +114,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) /* - * Save in file the current symbol. + * Save the current symbol to a file. * * The symbol file format is like the standard libraries, but there is only * one symbol. @@ -137,7 +124,6 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) void WinEDA_LibeditFrame::SaveOneSymbol() { wxString msg; - FILE* ExportFile; if( m_component->GetDrawItemList().empty() ) return; @@ -160,50 +146,57 @@ void WinEDA_LibeditFrame::SaveOneSymbol() wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); - ExportFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); + wxFFile file( fn.GetFullPath(), wxT( "wt" ) ); - if( ExportFile == NULL ) + if( !file.IsOpened() ) { - msg.Printf( _( "Unable to create <%s>" ), + msg.Printf( _( "Unable to create file <%s>" ), GetChars( fn.GetFullPath() ) ); DisplayError( this, msg ); return; } - msg.Printf( _( "Save Symbol in [%s]" ), GetChars( fn.GetPath() ) ); + msg.Printf( _( "Saving symbol in [%s]" ), GetChars( fn.GetPath() ) ); Affiche_Message( msg ); - char Line[256]; - fprintf( ExportFile, "%s %d.%d %s Date: %s\n", LIBFILE_IDENT, - LIB_VERSION_MAJOR, LIB_VERSION_MINOR, - "SYMBOL", DateAndTime( Line ) ); + wxString line; - /* Component name. */ - fprintf( ExportFile, "# SYMBOL %s\n#\n", - CONV_TO_UTF8( m_component->GetName() ) ); + /* File header */ + line << wxT( LIBFILE_IDENT ) << wxT( " " ) << LIB_VERSION_MAJOR + << wxT( "." ) << LIB_VERSION_MINOR << wxT( " SYMBOL " ) + << wxT( "Date: " ) << DateAndTime() << wxT( "\n" ); + + /* Component name comment and definition. */ + line << wxT( "# SYMBOL " ) << m_component->GetName() << wxT( "\n#\nDEF " ) + << m_component->GetName() << wxT( " " ); - fprintf( ExportFile, "DEF %s", - CONV_TO_UTF8( m_component->GetName() ) ); if( !m_component->GetReferenceField().m_Text.IsEmpty() ) - fprintf( ExportFile, " %s", - CONV_TO_UTF8( m_component->GetReferenceField().m_Text ) ); + line << m_component->GetReferenceField().m_Text << wxT( " " ); else - fprintf( ExportFile, " ~" ); + line << wxT( "~ " ); - fprintf( ExportFile, " %d %d %c %c %d %d %c\n", - 0, /* unused */ - m_component->m_TextInside, - m_component->m_DrawPinNum ? 'Y' : 'N', - m_component->m_DrawPinName ? 'Y' : 'N', - 1, 0 /* unused */, 'N' ); + line << 0 << wxT( " " ) << m_component->m_TextInside << wxT( " " ); - m_component->GetReferenceField().Save( ExportFile ); - m_component->GetValueField().Save( ExportFile ); + if( m_component->m_DrawPinNum ) + line << wxT( "Y " ); + else + line << wxT( "N " ); + + if( m_component->m_DrawPinName ) + line << wxT( "Y " ); + else + line << wxT( "N " ); + + line << wxT( "1 0 N\n" ); + + if( !file.Write( line ) + || !m_component->GetReferenceField().Save( file.fp() ) + || !m_component->GetValueField().Save( file.fp() ) + || !file.Write( wxT( "DRAW\n" ) ) ) + return; LIB_DRAW_ITEM_LIST& drawList = m_component->GetDrawItemList(); - fprintf( ExportFile, "DRAW\n" ); - BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList ) { if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) @@ -214,19 +207,20 @@ void WinEDA_LibeditFrame::SaveOneSymbol() if( m_convert && item.m_Convert && ( item.m_Convert != m_convert ) ) continue; - item.Save( ExportFile ); + if( !item.Save( file.fp() ) ) + return; } - fprintf( ExportFile, "ENDDRAW\n" ); - fprintf( ExportFile, "ENDDEF\n" ); - fclose( ExportFile ); + if( !file.Write( wxT( "ENDDRAW\n" ) ) + || !file.Write( wxT( "ENDDEF\n" ) ) ) + return; } /* * Place anchor reference coordinators for current component * - * All coordinates of the object are offset to the cursor position * / + * All coordinates of the object are offset to the cursor position. */ void WinEDA_LibeditFrame::PlaceAncre() { diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index e7f394bb0d..674c19fc5e 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -159,7 +159,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() SelpartBox->Enable( parts_count > 1 ); m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, - entry && ( entry->m_DocFile != wxEmptyString ) ); + entry && ( entry->GetDocFileName() != wxEmptyString ) ); } diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index 32032892eb..99f0084366 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -51,8 +51,8 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName, m_libraryName ); - if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) ) - GetAssociatedDocument( this, LibEntry->m_DocFile, + if( LibEntry && ( !LibEntry->GetDocFileName().IsEmpty() ) ) + GetAssociatedDocument( this, LibEntry->GetDocFileName(), &wxGetApp().GetLibraryPathList() ); break; @@ -280,12 +280,12 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) DrawPanel->DrawBackGround( DC ); - if( entry->Type != ROOT ) + if( entry->isAlias() ) { LIB_ALIAS* alias = (LIB_ALIAS*) entry; component = alias->GetComponent(); - wxASSERT( component != NULL && component->Type == ROOT ); + wxASSERT( component != NULL && component->isComponent() ); msg = alias->GetName(); @@ -313,8 +313,8 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ClearMsgPanel(); AppendMsgPanel( _( "Part" ), component->GetName(), BLUE, 6 ); AppendMsgPanel( _( "Alias" ), msg, RED, 6 ); - AppendMsgPanel( _( "Description" ), entry->m_Doc, CYAN, 6 ); - AppendMsgPanel( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY ); + AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 ); + AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY ); DrawPanel->Trace_Curseur( DC ); } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index f5def2d30e..1d917a370e 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -1234,15 +1234,14 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, wxPoint rotate( wxPoint p, int angle ) { wxPoint n; - float theta = M_PI * angle/1800; - n.x = float(p.x) * cos(theta) - float(p.y) * sin(theta); - n.y = p.x * sin(theta) + p.y * cos(theta); + double theta = M_PI * (double) angle / 1800.0; + n.x = wxRound( (double ) p.x * cos( theta ) - (double) p.y * sin( theta ) ); + n.y = wxRound( p.x * sin( theta ) + p.y * cos( theta ) ); return n; } -/**************************************************************************************/ + bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) -/***************************************************************************************/ { wxPoint rel_pos; int dist;;