Commit cfc3d6df authored by Wayne Stambaugh's avatar Wayne Stambaugh

EESchema sheet pin code improvements.

* Change all code references to pin sheet and sheet label to sheet pin to
  more closely match the sheet pin object for improved code readability.
* Change menu and tool bar text from pin sheet to sheet pin for improved
  user readability.
* Moved sheet pin place method to sheet pin object source file.
* Move last sheet pin stored state information into schematic frame object.
* Add Doxygen comments for the sheet pin editing methods.
parent c38d59a6
...@@ -46,11 +46,11 @@ void GenListeGLabels( LABEL_OBJECT_LIST& aList ) ...@@ -46,11 +46,11 @@ void GenListeGLabels( LABEL_OBJECT_LIST& aList )
{ {
SCH_SHEET* sheet = (SCH_SHEET*) schItem; SCH_SHEET* sheet = (SCH_SHEET*) schItem;
BOOST_FOREACH( SCH_SHEET_PIN& sheetLabel, sheet->GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, sheet->GetPins() )
{ {
label.m_LabelType = SCH_SHEET_LABEL_T; label.m_LabelType = SCH_SHEET_PIN_T;
label.m_SheetPath = *path; label.m_SheetPath = *path;
label.m_Label = &sheetLabel; label.m_Label = &sheetPin;
aList.push_back( label ); aList.push_back( label );
} }
} }
...@@ -75,12 +75,12 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) ...@@ -75,12 +75,12 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
int ii; int ii;
wxString* Text1, * Text2; wxString* Text1, * Text2;
if( obj1.m_LabelType == SCH_SHEET_LABEL_T ) if( obj1.m_LabelType == SCH_SHEET_PIN_T )
Text1 = &( (SCH_SHEET_PIN*)(obj1.m_Label) )->m_Text; Text1 = &( (SCH_SHEET_PIN*)(obj1.m_Label) )->m_Text;
else else
Text1 = &( (SCH_TEXT*)(obj1.m_Label) )->m_Text; Text1 = &( (SCH_TEXT*)(obj1.m_Label) )->m_Text;
if( obj2.m_LabelType == SCH_SHEET_LABEL_T ) if( obj2.m_LabelType == SCH_SHEET_PIN_T )
Text2 = &( (SCH_SHEET_PIN*)(obj2.m_Label) )->m_Text; Text2 = &( (SCH_SHEET_PIN*)(obj2.m_Label) )->m_Text;
else else
Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text; Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text;
...@@ -109,12 +109,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) ...@@ -109,12 +109,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
if( ii == 0 ) if( ii == 0 )
{ {
if( obj1.m_LabelType == SCH_SHEET_LABEL_T ) if( obj1.m_LabelType == SCH_SHEET_PIN_T )
Text1 = ( (SCH_SHEET_PIN*) obj1.m_Label )->m_Text; Text1 = ( (SCH_SHEET_PIN*) obj1.m_Label )->m_Text;
else else
Text1 = ( (SCH_TEXT*) obj1.m_Label )->m_Text; Text1 = ( (SCH_TEXT*) obj1.m_Label )->m_Text;
if( obj2.m_LabelType == SCH_SHEET_LABEL_T ) if( obj2.m_LabelType == SCH_SHEET_PIN_T )
Text2 = ( (SCH_SHEET_PIN*) obj2.m_Label )->m_Text; Text2 = ( (SCH_SHEET_PIN*) obj2.m_Label )->m_Text;
else else
Text2 = ( (SCH_TEXT*) obj2.m_Label )->m_Text; Text2 = ( (SCH_TEXT*) obj2.m_Label )->m_Text;
...@@ -157,7 +157,7 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList ) ...@@ -157,7 +157,7 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )
fputs( TO_UTF8( msg ), f ); fputs( TO_UTF8( msg ), f );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
{ {
pinsheet = (SCH_SHEET_PIN*) aList[ii].m_Label; pinsheet = (SCH_SHEET_PIN*) aList[ii].m_Label;
int jj = pinsheet->m_Shape; int jj = pinsheet->m_Shape;
......
...@@ -84,7 +84,7 @@ void DialogLabelEditor::InitDialog() ...@@ -84,7 +84,7 @@ void DialogLabelEditor::InitDialog()
SetTitle( _( "Label Properties" ) ); SetTitle( _( "Label Properties" ) );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
SetTitle( _( "Hierarchical Sheet Pin Properties." ) ); SetTitle( _( "Hierarchical Sheet Pin Properties." ) );
break; break;
......
...@@ -43,7 +43,7 @@ enum id_eeschema_frm ...@@ -43,7 +43,7 @@ enum id_eeschema_frm
ID_GLABEL_BUTT, ID_GLABEL_BUTT,
ID_HIERLABEL_BUTT, ID_HIERLABEL_BUTT,
ID_IMPORT_HLABEL_BUTT, ID_IMPORT_HLABEL_BUTT,
ID_SHEET_LABEL_BUTT, ID_SHEET_PIN_BUTT,
ID_NOCONN_BUTT, ID_NOCONN_BUTT,
ID_JUNCTION_BUTT, ID_JUNCTION_BUTT,
ID_SHEET_SYMBOL_BUTT, ID_SHEET_SYMBOL_BUTT,
...@@ -84,8 +84,8 @@ enum id_eeschema_frm ...@@ -84,8 +84,8 @@ enum id_eeschema_frm
ID_POPUP_SCH_EDIT_SHEET, ID_POPUP_SCH_EDIT_SHEET,
ID_POPUP_SCH_RESIZE_SHEET, ID_POPUP_SCH_RESIZE_SHEET,
ID_POPUP_SCH_CLEANUP_SHEET, ID_POPUP_SCH_CLEANUP_SHEET,
ID_POPUP_SCH_EDIT_PINSHEET, ID_POPUP_SCH_EDIT_SHEET_PIN,
ID_POPUP_SCH_MOVE_PINSHEET, ID_POPUP_SCH_MOVE_SHEET_PIN,
ID_POPUP_IMPORT_GLABEL, ID_POPUP_IMPORT_GLABEL,
ID_POPUP_SCH_GENERIC_ORIENT_CMP, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
ID_POPUP_SCH_GENERIC_EDIT_CMP, ID_POPUP_SCH_GENERIC_EDIT_CMP,
......
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
_(\ _(\
"Place a global label.\nWarning: all global labels with the same name are connected in whole hierarchy" ) "Place a global label.\nWarning: all global labels with the same name are connected in whole hierarchy" )
#define HELP_PLACE_HIER_LABEL \ #define HELP_PLACE_HIER_LABEL \
_( "Place a hierarchical label. This label will be seen as a pin sheet in the sheet symbol" ) _( "Place a hierarchical label. This label will be seen as a hierarchical pin in the sheet symbol" )
#define HELP_PLACE_JUNCTION _( "Place a junction" ) #define HELP_PLACE_JUNCTION _( "Place a junction" )
#define HELP_PLACE_SHEET _( "Create a hierarchical sheet" ) #define HELP_PLACE_SHEET _( "Create a hierarchical sheet" )
#define HELP_IMPORT_PINSHEET _( \ #define HELP_IMPORT_SHEETPIN _( \
"Place a pin sheet, imported from the corresponding hierarchical label in sheet" ) "Place a hierarchical pin imported from the corresponding hierarchical label in sheet" )
#define HELP_PLACE_PINSHEET _( "Place a hierarchical pin to sheet" ) #define HELP_PLACE_SHEETPIN _( "Place a hierarchical pin in sheet" )
#define HELP_PLACE_GRAPHICLINES _( "Place graphic lines or polygons" ) #define HELP_PLACE_GRAPHICLINES _( "Place graphic lines or polygons" )
#define HELP_PLACE_GRAPHICTEXTS _( "Place graphic text (comment)" ) #define HELP_PLACE_GRAPHICTEXTS _( "Place graphic text (comment)" )
......
...@@ -743,8 +743,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -743,8 +743,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
wxPostEvent( this, cmd ); wxPostEvent( this, cmd );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
cmd.SetId( ID_POPUP_SCH_MOVE_PINSHEET ); cmd.SetId( ID_POPUP_SCH_MOVE_SHEET_PIN );
wxPostEvent( this, cmd ); wxPostEvent( this, cmd );
break; break;
...@@ -791,8 +791,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -791,8 +791,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
wxPostEvent( this, cmd ); wxPostEvent( this, cmd );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
cmd.SetId( ID_POPUP_SCH_EDIT_PINSHEET ); cmd.SetId( ID_POPUP_SCH_EDIT_SHEET_PIN );
wxPostEvent( this, cmd ); wxPostEvent( this, cmd );
break; break;
......
...@@ -337,13 +337,13 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() ...@@ -337,13 +337,13 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
/* Import hierarchical sheet */ /* Import hierarchical sheet */
item = new wxMenuItem( placeMenu, ID_IMPORT_HLABEL_BUTT, _( "Import Hierarchical Label" ), item = new wxMenuItem( placeMenu, ID_IMPORT_HLABEL_BUTT, _( "Import Hierarchical Label" ),
HELP_IMPORT_PINSHEET, wxITEM_NORMAL ); HELP_IMPORT_SHEETPIN, wxITEM_NORMAL );
item->SetBitmap( import_hierarchical_label_xpm ); item->SetBitmap( import_hierarchical_label_xpm );
placeMenu->Append( item ); placeMenu->Append( item );
/* Add hierarchical Pin to Sheet */ /* Add hierarchical Pin to Sheet */
item = new wxMenuItem( placeMenu, ID_SHEET_LABEL_BUTT, _( "Add Hierarchical Pin to Sheet" ), item = new wxMenuItem( placeMenu, ID_SHEET_PIN_BUTT, _( "Add Hierarchical Pin to Sheet" ),
HELP_PLACE_PINSHEET, wxITEM_NORMAL ); HELP_PLACE_SHEETPIN, wxITEM_NORMAL );
item->SetBitmap( add_hierar_pin_xpm ); item->SetBitmap( add_hierar_pin_xpm );
placeMenu->Append( item ); placeMenu->Append( item );
......
...@@ -694,19 +694,19 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -694,19 +694,19 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
list.Push( STRUCT ); list.Push( STRUCT );
SCH_SHEET* sheet = (SCH_SHEET*) DrawList; SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN pin, sheet->GetPins() )
{ {
ii = IsBusLabel( label.m_Text ); ii = IsBusLabel( pin.m_Text );
new_item = new NETLIST_OBJECT(); new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist; new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = &label; new_item->m_Comp = &pin;
new_item->m_SheetList = *sheetlist; new_item->m_SheetList = *sheetlist;
new_item->m_Link = DrawList; new_item->m_Link = DrawList;
new_item->m_Type = NET_SHEETLABEL; new_item->m_Type = NET_SHEETLABEL;
new_item->m_ElectricalType = label.m_Shape; new_item->m_ElectricalType = pin.m_Shape;
new_item->m_Label = label.m_Text; new_item->m_Label = pin.m_Text;
new_item->m_SheetListInclude = list; new_item->m_SheetListInclude = list;
new_item->m_Start = new_item->m_End = label.m_Pos; new_item->m_Start = new_item->m_End = pin.m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
if( ii ) if( ii )
...@@ -716,7 +716,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -716,7 +716,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break; break;
} }
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
default: default:
{ {
wxString msg; wxString msg;
......
...@@ -44,7 +44,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -44,7 +44,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
case SCH_SHEET_T: case SCH_SHEET_T:
case SCH_BUS_ENTRY_T: case SCH_BUS_ENTRY_T:
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
...@@ -239,7 +239,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -239,7 +239,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_IMPORT_HLABEL_BUTT: case ID_IMPORT_HLABEL_BUTT:
case ID_SHEET_LABEL_BUTT: case ID_SHEET_PIN_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::SheetsAndSheetLabels ); item = LocateAndShowItem( aPosition, SCH_COLLECTOR::SheetsAndSheetLabels );
...@@ -249,11 +249,11 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -249,11 +249,11 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) ) if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) )
{ {
if( GetToolId() == ID_IMPORT_HLABEL_BUTT ) if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) ); GetScreen()->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, aDC ) );
else else
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) item, aDC ) ); GetScreen()->SetCurItem( CreateSheetPin( (SCH_SHEET*) item, aDC ) );
} }
else if( (item->Type() == SCH_SHEET_LABEL_T) && (item->GetFlags() != 0) ) else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) )
{ {
item->Place( this, aDC ); item->Place( this, aDC );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
......
...@@ -33,7 +33,7 @@ static void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame ); ...@@ -33,7 +33,7 @@ static void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame );
static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ); static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame );
static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ); static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame );
static void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ); static void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet );
static void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ); static void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet );
static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ); static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ); static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ); static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
...@@ -186,8 +186,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -186,8 +186,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenusForHierchicalSheet( PopMenu, (SCH_SHEET*) item ); AddMenusForHierchicalSheet( PopMenu, (SCH_SHEET*) item );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
AddMenusForPinSheet( PopMenu, (SCH_SHEET_PIN*) item ); AddMenusForSheetPin( PopMenu, (SCH_SHEET_PIN*) item );
break; break;
default: default:
...@@ -587,11 +587,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) ...@@ -587,11 +587,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ),
resize_sheet_xpm ); resize_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_IMPORT_GLABEL, _( "Import PinSheets" ), ADD_MENUITEM( PopMenu, ID_POPUP_IMPORT_GLABEL, _( "Import Sheet Pins" ),
import_hierarchical_label_xpm ); import_hierarchical_label_xpm );
if( Sheet->HasUndefinedLabels() ) // Sheet has pin labels, and can be cleaned if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup PinSheets" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
options_pinsheet_xpm ); options_pinsheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete Sheet" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Sheet" ), s_Schematic_Hokeys_Descr, HK_DELETE );
...@@ -600,21 +600,21 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) ...@@ -600,21 +600,21 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
} }
void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
{ {
wxString msg; wxString msg;
if( !PinSheet->GetFlags() ) if( !PinSheet->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move PinSheet" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Sheet Pin" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, msg, move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_SHEET_PIN, msg, move_xpm );
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET_PIN, _( "Edit Sheet Pin" ), edit_xpm );
if( !PinSheet->GetFlags() ) if( !PinSheet->GetFlags() )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet Pin" ), delete_pinsheet_xpm );
} }
......
...@@ -42,7 +42,7 @@ void SetSchItemParent( SCH_ITEM* Struct, SCH_SCREEN* Screen ) ...@@ -42,7 +42,7 @@ void SetSchItemParent( SCH_ITEM* Struct, SCH_SCREEN* Screen )
Struct->SetParent( Screen ); Struct->SetParent( Screen );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
break; break;
default: default:
...@@ -121,10 +121,10 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -121,10 +121,10 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
ITEM_PICKER itemWrapper( item, UR_DELETED ); ITEM_PICKER itemWrapper( item, UR_DELETED );
if( item->Type() == SCH_SHEET_LABEL_T ) if( item->Type() == SCH_SHEET_PIN_T )
{ {
/* this item is depending on a sheet, and is not in global list */ /* this item is depending on a sheet, and is not in global list */
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_LABEL_T" ) ); wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_PIN_T" ) );
} }
else else
{ {
...@@ -147,14 +147,14 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem ) ...@@ -147,14 +147,14 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
if( aItem->Type() == SCH_SHEET_LABEL_T ) if( aItem->Type() == SCH_SHEET_PIN_T )
{ {
// This iten is attached to a node, and is not accessible by the global list directly. // This iten is attached to a node, and is not accessible by the global list directly.
SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent(); SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T), wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
wxT( "Sheet label has invalid parent item." ) ); wxT( "Sheet label has invalid parent item." ) );
SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED );
sheet->RemoveLabel( (SCH_SHEET_PIN*) aItem ); sheet->RemovePin( (SCH_SHEET_PIN*) aItem );
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
} }
else else
...@@ -198,7 +198,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, ...@@ -198,7 +198,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
case SCH_MARKER_T: case SCH_MARKER_T:
case SCH_NO_CONNECT_T: case SCH_NO_CONNECT_T:
default: default:
......
...@@ -250,7 +250,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText ) ...@@ -250,7 +250,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
switch( aSchText->Type() ) switch( aSchText->Type() )
{ {
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
case SCH_LABEL_T: case SCH_LABEL_T:
...@@ -373,7 +373,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) ...@@ -373,7 +373,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) ); plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
/* Draw texts : SheetLabel */ /* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) { BOOST_FOREACH( SCH_SHEET_PIN& pin_sheet, Struct->GetPins() )
{
//pin_sheet.Plot( plotter ); //pin_sheet.Plot( plotter );
PlotTextStruct( plotter, &pin_sheet ); PlotTextStruct( plotter, &pin_sheet );
} }
...@@ -443,7 +444,7 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist ) ...@@ -443,7 +444,7 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist )
case SCH_POLYLINE_T: case SCH_POLYLINE_T:
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
break; break;
case SCH_MARKER_T: case SCH_MARKER_T:
......
...@@ -43,7 +43,7 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = { ...@@ -43,7 +43,7 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = {
SCH_FIELD_T, SCH_FIELD_T,
SCH_COMPONENT_T, SCH_COMPONENT_T,
LIB_PIN_T, LIB_PIN_T,
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
EOT EOT
}; };
...@@ -62,7 +62,7 @@ const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = { ...@@ -62,7 +62,7 @@ const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
SCH_HIERARCHICAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T, SCH_FIELD_T,
SCH_COMPONENT_T, SCH_COMPONENT_T,
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
EOT EOT
}; };
...@@ -75,7 +75,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = { ...@@ -75,7 +75,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
SCH_HIERARCHICAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T, SCH_FIELD_T,
SCH_COMPONENT_T, SCH_COMPONENT_T,
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
EOT EOT
}; };
...@@ -94,7 +94,7 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = { ...@@ -94,7 +94,7 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
SCH_HIERARCHICAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T, SCH_FIELD_T,
SCH_COMPONENT_T, SCH_COMPONENT_T,
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
EOT EOT
}; };
...@@ -154,7 +154,7 @@ const KICAD_T SCH_COLLECTOR::SheetsOnly[] = { ...@@ -154,7 +154,7 @@ const KICAD_T SCH_COLLECTOR::SheetsOnly[] = {
const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = { const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = {
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
EOT EOT
}; };
......
...@@ -149,14 +149,14 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem ) ...@@ -149,14 +149,14 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
SetModify(); SetModify();
if( aItem->Type() == SCH_SHEET_LABEL_T ) if( aItem->Type() == SCH_SHEET_PIN_T )
{ {
// This structure is attached to a sheet, get the parent sheet object. // This structure is attached to a sheet, get the parent sheet object.
SCH_SHEET_PIN* sheetLabel = (SCH_SHEET_PIN*) aItem; SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
SCH_SHEET* sheet = sheetLabel->GetParent(); SCH_SHEET* sheet = sheetPin->GetParent();
wxCHECK_RET( sheet != NULL, wxCHECK_RET( sheet != NULL,
wxT( "Sheet label parent not properly set, bad programmer!" ) ); wxT( "Sheet label parent not properly set, bad programmer!" ) );
sheet->RemoveLabel( sheetLabel ); sheet->RemovePin( sheetPin );
return; return;
} }
else else
...@@ -228,11 +228,11 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T ...@@ -228,11 +228,11 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
return (SCH_ITEM*) field; return (SCH_ITEM*) field;
} }
} }
else if( (aType == SCH_SHEET_LABEL_T) && (item->Type() == SCH_SHEET_T) ) else if( (aType == SCH_SHEET_PIN_T) && (item->Type() == SCH_SHEET_T) )
{ {
SCH_SHEET* sheet = (SCH_SHEET*)item; SCH_SHEET* sheet = (SCH_SHEET*)item;
SCH_SHEET_PIN* label = sheet->GetLabel( aPosition ); SCH_SHEET_PIN* label = sheet->GetPin( aPosition );
if( label ) if( label )
return (SCH_ITEM*) label; return (SCH_ITEM*) label;
...@@ -625,7 +625,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen ...@@ -625,7 +625,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition ) SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
{ {
SCH_SHEET_PIN* sheetLabel = NULL; SCH_SHEET_PIN* sheetPin = NULL;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{ {
...@@ -633,13 +633,13 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition ) ...@@ -633,13 +633,13 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
continue; continue;
SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) item;
sheetLabel = sheet->GetLabel( aPosition ); sheetPin = sheet->GetPin( aPosition );
if( sheetLabel ) if( sheetPin )
break; break;
} }
return sheetLabel; return sheetPin;
} }
......
...@@ -53,10 +53,10 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : ...@@ -53,10 +53,10 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
m_AssociatedScreen = aSheet.m_AssociatedScreen; m_AssociatedScreen = aSheet.m_AssociatedScreen;
m_SheetName = aSheet.m_SheetName; m_SheetName = aSheet.m_SheetName;
m_FileName = aSheet.m_FileName; m_FileName = aSheet.m_FileName;
m_labels = aSheet.m_labels; m_pins = aSheet.m_pins;
for( size_t i = 0; i < m_labels.size(); i++ ) for( size_t i = 0; i < m_pins.size(); i++ )
m_labels[i].SetParent( this ); m_pins[i].SetParent( this );
if( m_AssociatedScreen ) if( m_AssociatedScreen )
m_AssociatedScreen->IncRefCount(); m_AssociatedScreen->IncRefCount();
...@@ -145,7 +145,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const ...@@ -145,7 +145,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const
/* Save the list of labels in the sheet. */ /* Save the list of labels in the sheet. */
BOOST_FOREACH( const SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( const SCH_SHEET_PIN& label, m_pins )
{ {
if( !label.Save( aFile ) ) if( !label.Save( aFile ) )
return false; return false;
...@@ -161,7 +161,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const ...@@ -161,7 +161,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const
bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
{ {
int fieldNdx, size; int fieldNdx, size;
SCH_SHEET_PIN* SheetLabel; SCH_SHEET_PIN* sheetPin;
char* ptcar; char* ptcar;
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
...@@ -267,16 +267,16 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -267,16 +267,16 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( fieldNdx > 1 ) if( fieldNdx > 1 )
{ {
SheetLabel = new SCH_SHEET_PIN( this ); sheetPin = new SCH_SHEET_PIN( this );
if( !SheetLabel->Load( aLine, aErrorMsg ) ) if( !sheetPin->Load( aLine, aErrorMsg ) )
{ {
delete SheetLabel; delete sheetPin;
SheetLabel = NULL; sheetPin = NULL;
return false; return false;
} }
AddLabel( SheetLabel ); AddPin( sheetPin );
} }
} }
...@@ -299,59 +299,59 @@ void SCH_SHEET::SwapData( SCH_SHEET* copyitem ) ...@@ -299,59 +299,59 @@ void SCH_SHEET::SwapData( SCH_SHEET* copyitem )
EXCHG( m_SheetName, copyitem->m_SheetName ); EXCHG( m_SheetName, copyitem->m_SheetName );
EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize ); EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize );
EXCHG( m_FileNameSize, copyitem->m_FileNameSize ); EXCHG( m_FileNameSize, copyitem->m_FileNameSize );
m_labels.swap( copyitem->m_labels ); m_pins.swap( copyitem->m_pins );
// Ensure sheet labels have their .m_Parent member pointing really on their // Ensure sheet labels have their .m_Parent member pointing really on their
// parent, after swapping. // parent, after swapping.
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
{ {
sheetPin.SetParent( this ); sheetPin.SetParent( this );
} }
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, copyitem->m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, copyitem->m_pins )
{ {
sheetPin.SetParent( copyitem ); sheetPin.SetParent( copyitem );
} }
} }
void SCH_SHEET::AddLabel( SCH_SHEET_PIN* aLabel ) void SCH_SHEET::AddPin( SCH_SHEET_PIN* aSheetPin )
{ {
wxASSERT( aLabel != NULL ); wxASSERT( aSheetPin != NULL );
wxASSERT( aLabel->Type() == SCH_SHEET_LABEL_T ); wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
m_labels.push_back( aLabel ); m_pins.push_back( aSheetPin );
renumberLabels(); renumberPins();
} }
void SCH_SHEET::RemoveLabel( SCH_SHEET_PIN* aLabel ) void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin )
{ {
wxASSERT( aLabel != NULL ); wxASSERT( aSheetPin != NULL );
wxASSERT( aLabel->Type() == SCH_SHEET_LABEL_T ); wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
SCH_SHEET_PIN_LIST::iterator i; SCH_SHEET_PINS::iterator i;
for( i = m_labels.begin(); i < m_labels.end(); ++i ) for( i = m_pins.begin(); i < m_pins.end(); ++i )
{ {
if( *i == aLabel ) if( *i == aSheetPin )
{ {
m_labels.erase( i ); m_pins.erase( i );
renumberLabels(); renumberPins();
return; return;
} }
} }
wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ), wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
GetChars( aLabel->m_Text ), GetChars( m_SheetName ) ); GetChars( aSheetPin->m_Text ), GetChars( m_SheetName ) );
} }
bool SCH_SHEET::HasLabel( const wxString& aName ) bool SCH_SHEET::HasPin( const wxString& aName )
{ {
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
{ {
if( label.m_Text.CmpNoCase( aName ) == 0 ) if( pin.m_Text.CmpNoCase( aName ) == 0 )
return true; return true;
} }
...@@ -361,18 +361,18 @@ bool SCH_SHEET::HasLabel( const wxString& aName ) ...@@ -361,18 +361,18 @@ bool SCH_SHEET::HasLabel( const wxString& aName )
bool SCH_SHEET::IsVerticalOrientation() bool SCH_SHEET::IsVerticalOrientation()
{ {
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
{ {
if( label.GetEdge() > 1 ) if( pin.GetEdge() > 1 )
return true; return true;
} }
return false; return false;
} }
bool SCH_SHEET::HasUndefinedLabels() bool SCH_SHEET::HasUndefinedPins()
{ {
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
{ {
/* Search the schematic for a hierarchical label corresponding to this sheet label. */ /* Search the schematic for a hierarchical label corresponding to this sheet label. */
EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems(); EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems();
...@@ -385,7 +385,7 @@ bool SCH_SHEET::HasUndefinedLabels() ...@@ -385,7 +385,7 @@ bool SCH_SHEET::HasUndefinedLabels()
HLabel = (SCH_HIERLABEL*) DrawStruct; HLabel = (SCH_HIERLABEL*) DrawStruct;
if( label.m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) if( pin.m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
break; // Found! break; // Found!
HLabel = NULL; HLabel = NULL;
...@@ -447,9 +447,9 @@ void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) ...@@ -447,9 +447,9 @@ void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
*/ */
void SCH_SHEET::CleanupSheet() void SCH_SHEET::CleanupSheet()
{ {
SCH_SHEET_PIN_LIST::iterator i = m_labels.begin(); SCH_SHEET_PINS::iterator i = m_pins.begin();
while( i != m_labels.end() ) while( i != m_pins.end() )
{ {
/* Search the schematic for a hierarchical label corresponding to this sheet label. */ /* Search the schematic for a hierarchical label corresponding to this sheet label. */
EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems(); EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems();
...@@ -469,19 +469,19 @@ void SCH_SHEET::CleanupSheet() ...@@ -469,19 +469,19 @@ void SCH_SHEET::CleanupSheet()
} }
if( HLabel == NULL ) // Hlabel not found: delete sheet label. if( HLabel == NULL ) // Hlabel not found: delete sheet label.
m_labels.erase( i ); m_pins.erase( i );
else else
++i; ++i;
} }
} }
SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition ) SCH_SHEET_PIN* SCH_SHEET::GetPin( const wxPoint& aPosition )
{ {
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& pin, m_pins )
{ {
if( label.HitTest( aPosition ) ) if( pin.HitTest( aPosition ) )
return &label; return &pin;
} }
return NULL; return NULL;
...@@ -585,7 +585,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -585,7 +585,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
/* Draw text : SheetLabel */ /* Draw text : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
{ {
if( !( sheetPin.m_Flags & IS_MOVED ) ) if( !( sheetPin.m_Flags & IS_MOVED ) )
sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
...@@ -805,7 +805,7 @@ void SCH_SHEET::Rotate(wxPoint rotationPoint) ...@@ -805,7 +805,7 @@ void SCH_SHEET::Rotate(wxPoint rotationPoint)
NEGATE( m_Size.y ); NEGATE( m_Size.y );
} }
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
{ {
sheetPin.Rotate( rotationPoint ); sheetPin.Rotate( rotationPoint );
} }
...@@ -819,7 +819,7 @@ void SCH_SHEET::Mirror_X( int aXaxis_position ) ...@@ -819,7 +819,7 @@ void SCH_SHEET::Mirror_X( int aXaxis_position )
m_Pos.y += aXaxis_position; m_Pos.y += aXaxis_position;
m_Pos.y -= m_Size.y; m_Pos.y -= m_Size.y;
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
{ {
sheetPin.Mirror_X( aXaxis_position ); sheetPin.Mirror_X( aXaxis_position );
} }
...@@ -833,7 +833,7 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position ) ...@@ -833,7 +833,7 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position )
m_Pos.x += aYaxis_position; m_Pos.x += aYaxis_position;
m_Pos.x -= m_Size.x; m_Pos.x -= m_Size.x;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
{ {
label.Mirror_Y( aYaxis_position ); label.Mirror_Y( aYaxis_position );
} }
...@@ -848,7 +848,7 @@ void SCH_SHEET::Resize( const wxSize& aSize ) ...@@ -848,7 +848,7 @@ void SCH_SHEET::Resize( const wxSize& aSize )
m_Size = aSize; m_Size = aSize;
/* Move the sheet labels according to the new sheet size. */ /* Move the sheet labels according to the new sheet size. */
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
{ {
label.ConstraintOnEdge( label.m_Pos ); label.ConstraintOnEdge( label.m_Pos );
} }
...@@ -877,14 +877,14 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint ...@@ -877,14 +877,14 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
} }
void SCH_SHEET::renumberLabels() void SCH_SHEET::renumberPins()
{ {
int labelId = 2; int id = 2;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& pin, m_pins )
{ {
label.SetNumber( labelId ); pin.SetNumber( id );
labelId++; id++;
} }
} }
...@@ -893,11 +893,11 @@ void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) ...@@ -893,11 +893,11 @@ void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{ {
// Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet). // Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet).
// I do not know why. // I do not know why.
for( unsigned ii = 0; ii < GetSheetPins().size(); ii++ ) for( unsigned ii = 0; ii < GetPins().size(); ii++ )
{ {
SCH_SHEET_PIN &pinsheet = GetSheetPins()[ii]; SCH_SHEET_PIN &pinsheet = GetPins()[ii];
wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_LABEL_T, continue, wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_PIN_T, continue,
wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) ); wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
pinsheet.GetEndPoints( aItemList ); pinsheet.GetEndPoints( aItemList );
...@@ -909,7 +909,7 @@ bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemL ...@@ -909,7 +909,7 @@ bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemL
{ {
bool currentState = IsDangling(); bool currentState = IsDangling();
BOOST_FOREACH( SCH_SHEET_PIN& pinsheet, GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN& pinsheet, GetPins() )
{ {
pinsheet.IsDanglingStateChanged( aItemList ); pinsheet.IsDanglingStateChanged( aItemList );
} }
...@@ -921,9 +921,9 @@ bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemL ...@@ -921,9 +921,9 @@ bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemL
bool SCH_SHEET::IsDangling() const bool SCH_SHEET::IsDangling() const
{ {
// If any hierarchical label in the sheet is dangling, then the sheet is dangling. // If any hierarchical label in the sheet is dangling, then the sheet is dangling.
for( size_t i = 0; i < GetSheetPins().size(); i++ ) for( size_t i = 0; i < GetPins().size(); i++ )
{ {
if( GetSheetPins()[i].IsDangling() ) if( GetPins()[i].IsDangling() )
return true; return true;
} }
...@@ -948,8 +948,8 @@ bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect ) ...@@ -948,8 +948,8 @@ bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{ {
for( size_t i = 0; i < GetSheetPins().size(); i++ ) for( size_t i = 0; i < GetPins().size(); i++ )
aPoints.push_back( GetSheetPins()[i].m_Pos ); aPoints.push_back( GetPins()[i].m_Pos );
} }
...@@ -966,12 +966,12 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData, ...@@ -966,12 +966,12 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData,
if( SEARCH_QUIT == aInspector->Inspect( this, aTestData ) ) if( SEARCH_QUIT == aInspector->Inspect( this, aTestData ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
else if( stype == SCH_SHEET_LABEL_T ) else if( stype == SCH_SHEET_PIN_T )
{ {
// Test the bounding boxes of sheet labels. // Test the bounding boxes of sheet labels.
for( size_t i = 0; i < m_labels.size(); i++ ) for( size_t i = 0; i < m_pins.size(); i++ )
{ {
if( SEARCH_QUIT == aInspector->Inspect( &m_labels[ i ], aTestData ) ) if( SEARCH_QUIT == aInspector->Inspect( &m_pins[ i ], aTestData ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
} }
...@@ -1023,7 +1023,7 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os ) ...@@ -1023,7 +1023,7 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os )
<< TO_UTF8( m_SheetName ) << '"' << ">\n"; << TO_UTF8( m_SheetName ) << '"' << ">\n";
// show all the pins, and check the linked list integrity // show all the pins, and check the linked list integrity
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
{ {
label.Show( nestLevel + 1, os ); label.Show( nestLevel + 1, os );
} }
......
...@@ -38,7 +38,7 @@ private: ...@@ -38,7 +38,7 @@ private:
///< 0 is reserved for the sheet name. ///< 0 is reserved for the sheet name.
///< 1 is reserve for the sheet file name. ///< 1 is reserve for the sheet file name.
int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin
* m_Edge define on which edge the pin is positionned: * m_Edge define on which edge the pin is positioned:
* 0: pin on left side * 0: pin on left side
* 1: pin on right side * 1: pin on right side
* 2: pin on top side * 2: pin on top side
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
int aColor = -1 ); int aColor = -1 );
/** /**
* Function CreateGraphicShape (virual) * Function CreateGraphicShape (virtual)
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param aPos = Position of the shape * @param aPos = Position of the shape
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
/** /**
* Function ConstraintOnEdge * Function ConstraintOnEdge
* is used to adjust label position to egde based on proximity to vertical / horizontal edge * is used to adjust label position to edge based on proximity to vertical / horizontal edge
* of the parent sheet. * of the parent sheet.
*/ */
void ConstraintOnEdge( wxPoint Pos ); void ConstraintOnEdge( wxPoint Pos );
...@@ -126,12 +126,12 @@ public: ...@@ -126,12 +126,12 @@ public:
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** /**
* Load schematic sheet hierarchical lable from \a aLine in a .sch file. * Load schematic sheet hierarchical label from \a aLine in a .sch file.
* *
* @param aLine - Essentially this is file to read the sheet hierarchical label from. * @param aLine - Essentially this is file to read the sheet hierarchical label from.
* @param aErrorMsg - Description of the error if an error occurs while loading the sheet * @param aErrorMsg - Description of the error if an error occurs while loading the sheet
* hierarchical label. * hierarchical label.
* @return True if the sheet heirarchical label loaded successfully. * @return True if the sheet hierarchical label loaded successfully.
*/ */
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
}; };
typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PIN_LIST; typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PINS;
/* class SCH_SHEET /* class SCH_SHEET
...@@ -205,7 +205,7 @@ class SCH_SHEET : public SCH_ITEM ...@@ -205,7 +205,7 @@ class SCH_SHEET : public SCH_ITEM
SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for
///< the sheet. In complex hierarchies multiple ///< the sheet. In complex hierarchies multiple
///< sheets can share a common screen. ///< sheets can share a common screen.
SCH_SHEET_PIN_LIST m_labels; ///< List of sheet connection points. SCH_SHEET_PINS m_pins; ///< List of sheet connection points.
wxString m_FileName; /* also in SCH_SCREEN (redundant), wxString m_FileName; /* also in SCH_SCREEN (redundant),
* but need it here for loading after * but need it here for loading after
* reading the sheet description from * reading the sheet description from
...@@ -286,64 +286,64 @@ public: ...@@ -286,64 +286,64 @@ public:
bool IsVerticalOrientation(); bool IsVerticalOrientation();
/** /**
* Add aLabel to this sheet. * Add aSheetPin to the sheet.
* *
* Note: Once a label is added to the sheet, it is owned by the sheet. * Note: Once a sheet pin is added to the sheet, it is owned by the sheet.
* Do not delete the label object or you will likely get a segfault * Do not delete the sheet pin object or you will likely get a segfault
* when this sheet is destroyed. * when the sheet is destroyed.
* *
* @param aLabel - The label to add to the sheet. * @param aSheetPin The sheet pin item to add to the sheet.
*/ */
void AddLabel( SCH_SHEET_PIN* aLabel ); void AddPin( SCH_SHEET_PIN* aSheetPin );
SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; } SCH_SHEET_PINS& GetPins() { return m_pins; }
SCH_SHEET_PIN_LIST& GetSheetPins() const SCH_SHEET_PINS& GetPins() const
{ {
return const_cast< SCH_SHEET_PIN_LIST& >( m_labels ); return const_cast< SCH_SHEET_PINS& >( m_pins );
} }
/** /**
* Remove a sheet label from this sheet. * Remove \a aSheetPin from the sheet.
* *
* @param aSheetLabel - The sheet label to remove from the list. * @param aSheetPin The sheet pin item to remove from the sheet.
*/ */
void RemoveLabel( SCH_SHEET_PIN* aSheetLabel ); void RemovePin( SCH_SHEET_PIN* aSheetPin );
/** /**
* Delete sheet label which do not have a corresponding hierarchical label. * Delete sheet label which do not have a corresponding hierarchical label.
* *
* Note: Make sure you save a copy of the sheet in the undo list before calling * Note: Make sure you save a copy of the sheet in the undo list before calling
* CleanupSheet() otherwise any unrefernced sheet labels will be lost. * CleanupSheet() otherwise any unreferenced sheet labels will be lost.
*/ */
void CleanupSheet(); void CleanupSheet();
/** /**
* Return the label found at aPosition in this sheet. * Return the sheet pin item found at \a aPosition in the sheet.
* *
* @param aPosition - The position to check for a label. * @param aPosition The position to check for a sheet pin.
* *
* @return The label found at aPosition or NULL if no label is found. * @return The sheet pin found at \a aPosition or NULL if no sheet pin is found.
*/ */
SCH_SHEET_PIN* GetLabel( const wxPoint& aPosition ); SCH_SHEET_PIN* GetPin( const wxPoint& aPosition );
/** /**
* Checks if a label already exists with aName. * Checks if the sheet already has a sheet pin named \a aName.
* *
* @param aName - Name of label to search for. * @param aName Name of the sheet pin to search for.
* *
* @return - True if label found, otherwise false. * @return True if sheet pin with \a aName is found, otherwise false.
*/ */
bool HasLabel( const wxString& aName ); bool HasPin( const wxString& aName );
bool HasLabels() { return !m_labels.empty(); } bool HasPins() { return !m_pins.empty(); }
/** /**
* Check all sheet labels against schematic for undefined hierarchical labels. * Check all sheet labels against schematic for undefined hierarchical labels.
* *
* @return True if there are any undefined labels. * @return True if there are any undefined labels.
*/ */
bool HasUndefinedLabels(); bool HasUndefinedPins();
/** /**
* Function GetPenSize * Function GetPenSize
...@@ -453,9 +453,9 @@ public: ...@@ -453,9 +453,9 @@ public:
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) BOOST_FOREACH( SCH_SHEET_PIN& pin, m_pins )
{ {
label.Move( aMoveVector ); pin.Move( aMoveVector );
} }
} }
...@@ -531,13 +531,13 @@ public: ...@@ -531,13 +531,13 @@ public:
protected: protected:
/** /**
* Renumber labels in list. * Renumber the sheet pins in the sheet.
* *
* This method is used internally by SCH_SHEET to update the label numbering * This method is used internally by SCH_SHEET to update the pin numbering
* when the label list changes. Make sure you call this method any time a * when the pin list changes. Make sure you call this method any time a
* label is added or removed. * sheet pin is added or removed.
*/ */
void renumberLabels(); void renumberPins();
private: private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
*/ */
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) : SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
SCH_HIERLABEL( pos, text, SCH_SHEET_LABEL_T ) SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T )
{ {
SetParent( parent ); SetParent( parent );
wxASSERT( parent ); wxASSERT( parent );
...@@ -112,6 +113,40 @@ void SCH_SHEET_PIN::SetNumber( int aNumber ) ...@@ -112,6 +113,40 @@ void SCH_SHEET_PIN::SetNumber( int aNumber )
} }
void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
{
SCH_SHEET* sheet = (SCH_SHEET*) GetParent();
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
SAFE_DELETE( g_ItemToUndoCopy );
int flags = m_Flags;
m_Flags = 0;
if( flags & IS_NEW )
{
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
sheet->AddPin( this );
}
else // pin sheet was existing and only moved
{
wxPoint tmp = m_Pos;
m_Pos = aFrame->GetLastSheetPinPosition();
SetEdge( aFrame->GetLastSheetPinEdge() );
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
m_Pos = tmp;
}
ConstraintOnEdge( aFrame->GetScreen()->GetCrossHairPosition() );
sheet->Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
aFrame->DrawPanel->SetMouseCapture( NULL, NULL );
aFrame->DrawPanel->EndMouseCapture();
}
void SCH_SHEET_PIN::SetEdge( int aEdge ) void SCH_SHEET_PIN::SetEdge( int aEdge )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
...@@ -462,7 +497,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) ...@@ -462,7 +497,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
wxString SCH_SHEET_PIN::GetSelectMenuText() const wxString SCH_SHEET_PIN::GetSelectMenuText() const
{ {
wxString tmp; wxString tmp;
tmp.Printf( _( "Hierarchical Sheet Label %s" ), GetChars( GetText() ) ); tmp.Printf( _( "Hierarchical Sheet Pin %s" ), GetChars( GetText() ) );
return tmp; return tmp;
} }
......
...@@ -53,8 +53,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -53,8 +53,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_END_SHEET: case ID_POPUP_SCH_END_SHEET:
case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_SCH_RESIZE_SHEET:
case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_IMPORT_GLABEL:
case ID_POPUP_SCH_EDIT_PINSHEET: case ID_POPUP_SCH_EDIT_SHEET_PIN:
case ID_POPUP_SCH_MOVE_PINSHEET: case ID_POPUP_SCH_MOVE_SHEET_PIN:
case ID_POPUP_SCH_MOVE_ITEM_REQUEST: case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST: case ID_POPUP_SCH_MOVE_CMP_REQUEST:
case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_CMP_REQUEST:
...@@ -227,7 +227,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -227,7 +227,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_IMPORT_GLABEL:
if( item != NULL && item->Type() == SCH_SHEET_T ) if( item != NULL && item->Type() == SCH_SHEET_T )
screen->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, &dc ) ); screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
break; break;
case ID_POPUP_SCH_CLEANUP_SHEET: case ID_POPUP_SCH_CLEANUP_SHEET:
...@@ -235,7 +235,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -235,7 +235,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
SCH_SHEET* sheet = (SCH_SHEET*) item; SCH_SHEET* sheet = (SCH_SHEET*) item;
if( !sheet->HasUndefinedLabels() ) if( !sheet->HasUndefinedPins() )
{ {
DisplayInfoMessage( this, DisplayInfoMessage( this,
_( "There are no undefined labels in this sheet to clean up." ) ); _( "There are no undefined labels in this sheet to clean up." ) );
...@@ -253,13 +253,13 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -253,13 +253,13 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_POPUP_SCH_EDIT_PINSHEET: case ID_POPUP_SCH_EDIT_SHEET_PIN:
Edit_PinSheet( (SCH_SHEET_PIN*) item, &dc ); EditSheetPin( (SCH_SHEET_PIN*) item, &dc );
break; break;
case ID_POPUP_SCH_MOVE_PINSHEET: case ID_POPUP_SCH_MOVE_SHEET_PIN:
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
StartMove_PinSheet( (SCH_SHEET_PIN*) item, &dc ); MoveSheetPin( (SCH_SHEET_PIN*) item, &dc );
break; break;
case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_CMP_REQUEST:
...@@ -498,7 +498,7 @@ void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC ) ...@@ -498,7 +498,7 @@ void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
break; break;
case SCH_MARKER_T: case SCH_MARKER_T:
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
default: default:
wxString msg; wxString msg;
msg.Printf( wxT( "SCH_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ), msg.Printf( wxT( "SCH_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
...@@ -596,7 +596,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) ...@@ -596,7 +596,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
break; break;
case ID_SHEET_LABEL_BUTT: case ID_SHEET_PIN_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) ); SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
break; break;
......
...@@ -160,7 +160,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage ) ...@@ -160,7 +160,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Pos, DEST->m_Pos ); EXCHG( SOURCE->m_Pos, DEST->m_Pos );
break; break;
case SCH_SHEET_LABEL_T: case SCH_SHEET_PIN_T:
#undef SOURCE #undef SOURCE
#undef DEST #undef DEST
#define SOURCE ( (SCH_SHEET_PIN*) aItem ) #define SOURCE ( (SCH_SHEET_PIN*) aItem )
......
...@@ -329,12 +329,12 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -329,12 +329,12 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
s_PreviousSheetWidth = SHEET_MIN_WIDTH; s_PreviousSheetWidth = SHEET_MIN_WIDTH;
s_PreviousSheetHeight = SHEET_MIN_HEIGHT; s_PreviousSheetHeight = SHEET_MIN_HEIGHT;
BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, aSheet->GetSheetPins() ) BOOST_FOREACH( SCH_SHEET_PIN sheetPin, aSheet->GetPins() )
{ {
s_PreviousSheetWidth = MAX( s_PreviousSheetWidth, s_PreviousSheetWidth = MAX( s_PreviousSheetWidth,
( sheetLabel.GetLength() + 1 ) * sheetLabel.m_Size.x ); ( sheetPin.GetLength() + 1 ) * sheetPin.m_Size.x );
s_PreviousSheetHeight = MAX( s_PreviousSheetHeight, s_PreviousSheetHeight = MAX( s_PreviousSheetHeight,
sheetLabel.m_Pos.y - aSheet->m_Pos.y ); sheetPin.m_Pos.y - aSheet->m_Pos.y );
} }
DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); DrawPanel->SetMouseCapture( MoveOrResizeSheet, ExitSheet );
......
...@@ -19,122 +19,89 @@ ...@@ -19,122 +19,89 @@
#include "dialogs/dialog_sch_edit_sheet_pin.h" #include "dialogs/dialog_sch_edit_sheet_pin.h"
static void ExitPinSheet( EDA_DRAW_PANEL* Panel, wxDC* DC ); int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
static void Move_PinSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
bool aErase ); wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition;
int SCH_EDIT_FRAME::m_lastSheetPinEdge;
static int s_CurrentTypeLabel = NET_INPUT;
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
static wxPoint s_InitialPosition; // remember the initial value of the pin label when moving it
static int s_InitialEdge;
/* Called when aborting a move pinsheet label /* Called when aborting a move pinsheet label
* delete a new pin sheet label, or restire its old position * delete a new pin sheet label, or restire its old position
*/ */
static void ExitPinSheet( EDA_DRAW_PANEL* Panel, wxDC* DC ) static void abortSheetPinMove( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{ {
SCH_SHEET_PIN* SheetLabel = (SCH_SHEET_PIN*) Panel->GetScreen()->GetCurItem(); wxCHECK_RET( (aPanel != NULL) && (aDC != NULL), wxT( "Invalid panel or device context." ) );
if( SheetLabel == NULL ) SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent();
return; SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aPanel->GetScreen()->GetCurItem();
wxCHECK_RET( (frame != NULL) && (sheetPin != NULL) && (sheetPin->Type() == SCH_SHEET_PIN_T),
wxT( "Invalid frame or sheet pin." ) );
if( SheetLabel->IsNew() ) sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( sheetPin->IsNew() )
{ {
SheetLabel->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode ); SAFE_DELETE( sheetPin );
SAFE_DELETE( SheetLabel );
} }
else else
{ {
SheetLabel->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode );
SheetLabel->m_Pos = s_InitialPosition;
// Restore edge position: // Restore edge position:
SheetLabel->SetEdge( s_InitialEdge ); sheetPin->m_Pos = frame->GetLastSheetPinPosition();
SheetLabel->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); sheetPin->SetEdge( frame->GetLastSheetPinEdge() );
SheetLabel->m_Flags = 0; sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
sheetPin->ClearFlags();
} }
Panel->GetScreen()->SetCurItem( NULL ); aPanel->GetScreen()->SetCurItem( NULL );
} }
void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) static void moveSheetPin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aPanel->GetScreen()->GetCurItem();
wxASSERT( Sheet != NULL && Sheet->Type() == SCH_SHEET_T ); if( sheetPin == NULL || sheetPin->Type() != SCH_SHEET_PIN_T )
SAFE_DELETE( g_ItemToUndoCopy ); return;
int flags = m_Flags;
m_Flags = 0;
if( flags & IS_NEW )
{
frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
Sheet->AddLabel( this );
}
else // pin sheet was existing and only moved
{
wxPoint tmp = m_Pos;
m_Pos = s_InitialPosition;
SetEdge( s_InitialEdge );
frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
m_Pos = tmp;
}
ConstraintOnEdge( frame->GetScreen()->GetCrossHairPosition() ); if( aErase )
sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
Sheet->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); sheetPin->ConstraintOnEdge( aPanel->GetScreen()->GetCrossHairPosition() );
frame->DrawPanel->SetMouseCapture( NULL, NULL ); sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
frame->DrawPanel->EndMouseCapture();
} }
void SCH_EDIT_FRAME::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC ) void SCH_EDIT_FRAME::MoveSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
{ {
NetSheetTextSize = SheetLabel->m_Size; wxCHECK_RET( (aSheetPin != NULL) && (aSheetPin->Type() == SCH_SHEET_PIN_T),
s_CurrentTypeLabel = SheetLabel->m_Shape; wxT( "Cannot move invalid schematic sheet pin object." ) );
SheetLabel->m_Flags |= IS_MOVED;
s_InitialPosition = SheetLabel->m_Pos;
s_InitialEdge = SheetLabel->GetEdge();
DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true );
}
m_lastSheetPinTextSize = aSheetPin->m_Size;
m_lastSheetPinType = aSheetPin->m_Shape;
m_lastSheetPinPosition = aSheetPin->m_Pos;
m_lastSheetPinEdge = aSheetPin->GetEdge();
aSheetPin->SetFlags( IS_MOVED );
static void Move_PinSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove );
bool aErase ) moveSheetPin( DrawPanel, aDC, wxDefaultPosition, true );
{
SCH_SHEET_PIN* SheetLabel = (SCH_SHEET_PIN*) aPanel->GetScreen()->GetCurItem();
if( SheetLabel == NULL )
return;
if( aErase )
SheetLabel->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
SheetLabel->ConstraintOnEdge( aPanel->GetScreen()->GetCrossHairPosition() );
SheetLabel->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
} }
int SCH_EDIT_FRAME::Edit_PinSheet( SCH_SHEET_PIN* aLabel, wxDC* aDC ) int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
{ {
if( aLabel == NULL ) if( aSheetPin == NULL )
return wxID_CANCEL; return wxID_CANCEL;
DIALOG_SCH_EDIT_SHEET_PIN dlg( this ); DIALOG_SCH_EDIT_SHEET_PIN dlg( this );
dlg.SetLabelName( aLabel->m_Text ); dlg.SetLabelName( aSheetPin->m_Text );
dlg.SetTextHeight( ReturnStringFromValue( g_UserUnit, aLabel->m_Size.y, m_InternalUnits ) ); dlg.SetTextHeight( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.y, m_InternalUnits ) );
dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) );
dlg.SetTextWidth( ReturnStringFromValue( g_UserUnit, aLabel->m_Size.x, m_InternalUnits ) ); dlg.SetTextWidth( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.x, m_InternalUnits ) );
dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) );
dlg.SetConnectionType( aLabel->m_Shape ); dlg.SetConnectionType( aSheetPin->m_Shape );
/* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier versions for /* 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 * the flex grid sizer in wxGTK that prevents the last column from being sized
...@@ -149,98 +116,93 @@ int SCH_EDIT_FRAME::Edit_PinSheet( SCH_SHEET_PIN* aLabel, wxDC* aDC ) ...@@ -149,98 +116,93 @@ int SCH_EDIT_FRAME::Edit_PinSheet( SCH_SHEET_PIN* aLabel, wxDC* aDC )
return wxID_CANCEL; return wxID_CANCEL;
if( aDC ) if( aDC )
aLabel->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); aSheetPin->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
aLabel->m_Text = dlg.GetLabelName(); aSheetPin->m_Text = dlg.GetLabelName();
aLabel->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_InternalUnits ); aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_InternalUnits );
aLabel->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_InternalUnits ); aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_InternalUnits );
aLabel->m_Shape = dlg.GetConnectionType(); aSheetPin->m_Shape = dlg.GetConnectionType();
if( aDC ) if( aDC )
aLabel->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); aSheetPin->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
return wxID_OK; return wxID_OK;
} }
/* Add a new sheet pin to the sheet at the current cursor position. SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
*/
SCH_SHEET_PIN* SCH_EDIT_FRAME::Create_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
{ {
wxString Line, Text; wxString line;
SCH_SHEET_PIN* NewSheetLabel; SCH_SHEET_PIN* sheetPin;
NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), Line ); sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
NewSheetLabel->m_Flags = IS_NEW; sheetPin->SetFlags( IS_NEW );
NewSheetLabel->m_Size = NetSheetTextSize; sheetPin->m_Size = m_lastSheetPinTextSize;
NewSheetLabel->m_Shape = s_CurrentTypeLabel; sheetPin->m_Shape = m_lastSheetPinType;
int diag = Edit_PinSheet( NewSheetLabel, NULL ); int response = EditSheetPin( sheetPin, NULL );
if( NewSheetLabel->m_Text.IsEmpty() || (diag == wxID_CANCEL) ) if( sheetPin->m_Text.IsEmpty() || (response == wxID_CANCEL) )
{ {
delete NewSheetLabel; delete sheetPin;
return NULL; return NULL;
} }
GetScreen()->SetCurItem( NewSheetLabel ); GetScreen()->SetCurItem( sheetPin );
s_CurrentTypeLabel = NewSheetLabel->m_Shape; m_lastSheetPinType = sheetPin->m_Shape;
m_lastSheetPinTextSize = sheetPin->m_Size;
DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet ); DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true ); moveSheetPin( DrawPanel, aDC, wxDefaultPosition, false );
OnModify(); OnModify();
return NewSheetLabel; return sheetPin;
} }
/* Automatically create a sheet labels from global labels for each node in SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
* the corresponding hierarchy.
*/
SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
{ {
EDA_ITEM* DrawStruct; EDA_ITEM* item;
SCH_SHEET_PIN* NewSheetLabel; SCH_SHEET_PIN* sheetPin;
SCH_HIERLABEL* HLabel = NULL; SCH_HIERLABEL* label = NULL;
if( !Sheet->GetScreen() ) if( !aSheet->GetScreen() )
return NULL; return NULL;
DrawStruct = Sheet->GetScreen()->GetDrawItems(); item = aSheet->GetScreen()->GetDrawItems();
HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; item != NULL; item = item->Next() )
{ {
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T ) if( item->Type() != SCH_HIERARCHICAL_LABEL_T )
continue; continue;
HLabel = (SCH_HIERLABEL*) DrawStruct; label = (SCH_HIERLABEL*) item;
/* A global label has been found: check if there a corresponding sheet label. */ /* A global label has been found: check if there a corresponding sheet label. */
if( !Sheet->HasLabel( HLabel->m_Text ) ) if( !aSheet->HasPin( label->m_Text ) )
break; break;
HLabel = NULL; label = NULL;
} }
if( HLabel == NULL ) if( label == NULL )
{ {
DisplayInfoMessage( this, _( "No new hierarchical labels found" ) ); DisplayInfoMessage( this, _( "No new hierarchical labels found." ) );
return NULL; return NULL;
} }
OnModify(); OnModify();
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
SaveCopyInUndoList( Sheet, UR_CHANGED ); SaveCopyInUndoList( aSheet, UR_CHANGED );
NewSheetLabel = new SCH_SHEET_PIN( Sheet, wxPoint( 0, 0 ), HLabel->m_Text ); sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->m_Text );
NewSheetLabel->m_Flags = IS_NEW; sheetPin->SetFlags( IS_NEW );
NewSheetLabel->m_Size = NetSheetTextSize; sheetPin->m_Size = m_lastSheetPinTextSize;
s_CurrentTypeLabel = NewSheetLabel->m_Shape = HLabel->m_Shape; m_lastSheetPinType = sheetPin->m_Shape = label->m_Shape;
GetScreen()->SetCurItem( NewSheetLabel ); GetScreen()->SetCurItem( sheetPin );
DrawPanel->SetMouseCapture( Move_PinSheet, ExitPinSheet ); DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove );
Move_PinSheet( DrawPanel, DC, wxDefaultPosition, false ); moveSheetPin( DrawPanel, aDC, wxDefaultPosition, false );
return NewSheetLabel; return sheetPin;
} }
...@@ -175,11 +175,11 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() ...@@ -175,11 +175,11 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
m_VToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
wxBitmap( import_hierarchical_label_xpm ), wxBitmap( import_hierarchical_label_xpm ),
HELP_IMPORT_PINSHEET, wxITEM_CHECK ); HELP_IMPORT_SHEETPIN, wxITEM_CHECK );
m_VToolBar->AddTool( ID_SHEET_LABEL_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_SHEET_PIN_BUTT, wxEmptyString,
wxBitmap( add_hierar_pin_xpm ), wxBitmap( add_hierar_pin_xpm ),
HELP_PLACE_PINSHEET, wxITEM_CHECK ); HELP_PLACE_SHEETPIN, wxITEM_CHECK );
m_VToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString, m_VToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
wxBitmap( add_dashed_line_xpm ), wxBitmap( add_dashed_line_xpm ),
......
...@@ -61,7 +61,7 @@ enum KICAD_T { ...@@ -61,7 +61,7 @@ enum KICAD_T {
SCH_HIERARCHICAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T, SCH_FIELD_T,
SCH_COMPONENT_T, SCH_COMPONENT_T,
SCH_SHEET_LABEL_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
// General // General
......
...@@ -96,6 +96,12 @@ private: ...@@ -96,6 +96,12 @@ private:
int m_repeatLabelDelta; ///< Repeat label number increment step. int m_repeatLabelDelta; ///< Repeat label number increment step.
SCH_COLLECTOR m_collectedItems; ///< List of collected items. SCH_COLLECTOR m_collectedItems; ///< List of collected items.
static int m_lastSheetPinType; ///< Last sheet pin type.
static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
static int m_lastSheetPinEdge; ///< Last sheet edge a sheet pin was placed.
public: public:
SCH_EDIT_FRAME( wxWindow* father, SCH_EDIT_FRAME( wxWindow* father,
const wxString& title, const wxString& title,
...@@ -528,15 +534,48 @@ private: ...@@ -528,15 +534,48 @@ private:
public: public:
bool EditSheet( SCH_SHEET* Sheet, wxDC* DC ); bool EditSheet( SCH_SHEET* Sheet, wxDC* DC );
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
int GetLastSheetPinEdge() const { return m_lastSheetPinEdge; }
private: private:
void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC ); void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC );
SCH_SHEET_PIN* Create_PinSheet( SCH_SHEET* Sheet, wxDC* DC );
int Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC ); /**
void StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel, * Function CreateSheetPin
wxDC* DC ); * creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.
void Place_PinSheet( SCH_SHEET_PIN* SheetLabel, * @param aSheet The sheet to add the new sheet pin to.
wxDC* DC ); * @param aDC The device context to draw on.
SCH_SHEET_PIN* Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC ); * @return The new sheet pin object created or NULL if the task was aborted by the user.
*/
SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC );
/**
* Function EditSheetPin
* displays the dialog for editing the parameters of \a aSheetPin.
* @param aSheetPin The sheet pin item to edit.
* @param aDC The device context to draw on.
* @return The user response from the edit dialog.
*/
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
/**
* Function MoveSheetPin
* moves \a aSheetPin within it's parent sheet object.
* @param aSheetPin The sheet pin item to move.
* @param aDC The device context to draw on.
*/
void MoveSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
/**
* Function ImportSheetPin
* automatically creates a sheet pin from the hierarchical labels in the schematic
* referenced by \a aSheet.
* @param aSheet The sheet to import the new sheet pin to.
* @param aDC The device context to draw on.
* @return The new sheet pin object importd or NULL if the task was aborted by the user.
*/
SCH_SHEET_PIN* ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC );
public: public:
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment