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 )
{
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_Label = &sheetLabel;
label.m_Label = &sheetPin;
aList.push_back( label );
}
}
......@@ -75,12 +75,12 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
int ii;
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;
else
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;
else
Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text;
......@@ -109,12 +109,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
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;
else
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;
else
Text2 = ( (SCH_TEXT*) obj2.m_Label )->m_Text;
......@@ -157,7 +157,7 @@ int PrintListeGLabel( FILE* f, LABEL_OBJECT_LIST& aList )
fputs( TO_UTF8( msg ), f );
break;
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
{
pinsheet = (SCH_SHEET_PIN*) aList[ii].m_Label;
int jj = pinsheet->m_Shape;
......
......@@ -84,7 +84,7 @@ void DialogLabelEditor::InitDialog()
SetTitle( _( "Label Properties" ) );
break;
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
SetTitle( _( "Hierarchical Sheet Pin Properties." ) );
break;
......
......@@ -43,7 +43,7 @@ enum id_eeschema_frm
ID_GLABEL_BUTT,
ID_HIERLABEL_BUTT,
ID_IMPORT_HLABEL_BUTT,
ID_SHEET_LABEL_BUTT,
ID_SHEET_PIN_BUTT,
ID_NOCONN_BUTT,
ID_JUNCTION_BUTT,
ID_SHEET_SYMBOL_BUTT,
......@@ -84,8 +84,8 @@ enum id_eeschema_frm
ID_POPUP_SCH_EDIT_SHEET,
ID_POPUP_SCH_RESIZE_SHEET,
ID_POPUP_SCH_CLEANUP_SHEET,
ID_POPUP_SCH_EDIT_PINSHEET,
ID_POPUP_SCH_MOVE_PINSHEET,
ID_POPUP_SCH_EDIT_SHEET_PIN,
ID_POPUP_SCH_MOVE_SHEET_PIN,
ID_POPUP_IMPORT_GLABEL,
ID_POPUP_SCH_GENERIC_ORIENT_CMP,
ID_POPUP_SCH_GENERIC_EDIT_CMP,
......
......@@ -39,13 +39,13 @@
_(\
"Place a global label.\nWarning: all global labels with the same name are connected in whole hierarchy" )
#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_SHEET _( "Create a hierarchical sheet" )
#define HELP_IMPORT_PINSHEET _( \
"Place a pin sheet, imported from the corresponding hierarchical label in sheet" )
#define HELP_PLACE_PINSHEET _( "Place a hierarchical pin to sheet" )
#define HELP_IMPORT_SHEETPIN _( \
"Place a hierarchical pin imported from the corresponding hierarchical label in sheet" )
#define HELP_PLACE_SHEETPIN _( "Place a hierarchical pin in sheet" )
#define HELP_PLACE_GRAPHICLINES _( "Place graphic lines or polygons" )
#define HELP_PLACE_GRAPHICTEXTS _( "Place graphic text (comment)" )
......
......@@ -743,8 +743,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
wxPostEvent( this, cmd );
break;
case SCH_SHEET_LABEL_T:
cmd.SetId( ID_POPUP_SCH_MOVE_PINSHEET );
case SCH_SHEET_PIN_T:
cmd.SetId( ID_POPUP_SCH_MOVE_SHEET_PIN );
wxPostEvent( this, cmd );
break;
......@@ -791,8 +791,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
wxPostEvent( this, cmd );
break;
case SCH_SHEET_LABEL_T:
cmd.SetId( ID_POPUP_SCH_EDIT_PINSHEET );
case SCH_SHEET_PIN_T:
cmd.SetId( ID_POPUP_SCH_EDIT_SHEET_PIN );
wxPostEvent( this, cmd );
break;
......
......@@ -337,13 +337,13 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
/* Import hierarchical sheet */
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 );
placeMenu->Append( item );
/* Add hierarchical Pin to Sheet */
item = new wxMenuItem( placeMenu, ID_SHEET_LABEL_BUTT, _( "Add Hierarchical Pin to Sheet" ),
HELP_PLACE_PINSHEET, wxITEM_NORMAL );
item = new wxMenuItem( placeMenu, ID_SHEET_PIN_BUTT, _( "Add Hierarchical Pin to Sheet" ),
HELP_PLACE_SHEETPIN, wxITEM_NORMAL );
item->SetBitmap( add_hierar_pin_xpm );
placeMenu->Append( item );
......
......@@ -694,19 +694,19 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
list.Push( STRUCT );
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->m_SheetListInclude = *sheetlist;
new_item->m_Comp = &label;
new_item->m_Comp = &pin;
new_item->m_SheetList = *sheetlist;
new_item->m_Link = DrawList;
new_item->m_Type = NET_SHEETLABEL;
new_item->m_ElectricalType = label.m_Shape;
new_item->m_Label = label.m_Text;
new_item->m_ElectricalType = pin.m_Shape;
new_item->m_Label = pin.m_Text;
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 );
if( ii )
......@@ -716,7 +716,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break;
}
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
default:
{
wxString msg;
......
......@@ -44,7 +44,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_SHEET_T:
case SCH_BUS_ENTRY_T:
case SCH_JUNCTION_T:
......@@ -239,7 +239,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_IMPORT_HLABEL_BUTT:
case ID_SHEET_LABEL_BUTT:
case ID_SHEET_PIN_BUTT:
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::SheetsAndSheetLabels );
......@@ -249,11 +249,11 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) )
{
if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) );
GetScreen()->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, aDC ) );
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 );
GetScreen()->TestDanglingEnds();
......
......@@ -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 AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame );
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 AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
......@@ -186,8 +186,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenusForHierchicalSheet( PopMenu, (SCH_SHEET*) item );
break;
case SCH_SHEET_LABEL_T:
AddMenusForPinSheet( PopMenu, (SCH_SHEET_PIN*) item );
case SCH_SHEET_PIN_T:
AddMenusForSheetPin( PopMenu, (SCH_SHEET_PIN*) item );
break;
default:
......@@ -587,11 +587,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ),
resize_sheet_xpm );
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 );
if( Sheet->HasUndefinedLabels() ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup PinSheets" ),
if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
options_pinsheet_xpm );
PopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete Sheet" ), s_Schematic_Hokeys_Descr, HK_DELETE );
......@@ -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;
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 );
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() )
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 )
Struct->SetParent( Screen );
break;
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
break;
default:
......@@ -121,10 +121,10 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
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 */
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_LABEL_T" ) );
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_PIN_T" ) );
}
else
{
......@@ -147,14 +147,14 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
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.
SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
wxT( "Sheet label has invalid parent item." ) );
SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED );
sheet->RemoveLabel( (SCH_SHEET_PIN*) aItem );
sheet->RemovePin( (SCH_SHEET_PIN*) aItem );
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
}
else
......@@ -198,7 +198,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:
default:
......
......@@ -250,7 +250,7 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
switch( aSchText->Type() )
{
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_LABEL_T:
......@@ -373,7 +373,8 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
/* 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 );
PlotTextStruct( plotter, &pin_sheet );
}
......@@ -443,7 +444,7 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* aDrawlist )
case SCH_POLYLINE_T:
break;
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
break;
case SCH_MARKER_T:
......
......@@ -43,7 +43,7 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = {
SCH_FIELD_T,
SCH_COMPONENT_T,
LIB_PIN_T,
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
......@@ -62,7 +62,7 @@ const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
......@@ -75,7 +75,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
......@@ -94,7 +94,7 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
......@@ -154,7 +154,7 @@ const KICAD_T SCH_COLLECTOR::SheetsOnly[] = {
const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = {
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
......
......@@ -149,14 +149,14 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
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.
SCH_SHEET_PIN* sheetLabel = (SCH_SHEET_PIN*) aItem;
SCH_SHEET* sheet = sheetLabel->GetParent();
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
SCH_SHEET* sheet = sheetPin->GetParent();
wxCHECK_RET( sheet != NULL,
wxT( "Sheet label parent not properly set, bad programmer!" ) );
sheet->RemoveLabel( sheetLabel );
sheet->RemovePin( sheetPin );
return;
}
else
......@@ -228,11 +228,11 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
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_PIN* label = sheet->GetLabel( aPosition );
SCH_SHEET_PIN* label = sheet->GetPin( aPosition );
if( label )
return (SCH_ITEM*) label;
......@@ -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* sheetLabel = NULL;
SCH_SHEET_PIN* sheetPin = NULL;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() )
{
......@@ -633,13 +633,13 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
continue;
SCH_SHEET* sheet = (SCH_SHEET*) item;
sheetLabel = sheet->GetLabel( aPosition );
sheetPin = sheet->GetPin( aPosition );
if( sheetLabel )
if( sheetPin )
break;
}
return sheetLabel;
return sheetPin;
}
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ private:
///< 0 is reserved for the sheet name.
///< 1 is reserve for the sheet file name.
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
* 1: pin on right side
* 2: pin on top side
......@@ -74,7 +74,7 @@ public:
int aColor = -1 );
/**
* Function CreateGraphicShape (virual)
* Function CreateGraphicShape (virtual)
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param aPos = Position of the shape
......@@ -101,7 +101,7 @@ public:
/**
* 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.
*/
void ConstraintOnEdge( wxPoint Pos );
......@@ -126,12 +126,12 @@ public:
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 aErrorMsg - Description of the error if an error occurs while loading the sheet
* 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 );
......@@ -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
......@@ -202,19 +202,19 @@ typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PIN_LIST;
class SCH_SHEET : public SCH_ITEM
{
SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for
///< the sheet. In complex hierarchies multiple
///< sheets can share a common screen.
SCH_SHEET_PIN_LIST m_labels; ///< List of sheet connection points.
wxString m_FileName; /* also in SCH_SCREEN (redundant),
* but need it here for loading after
* reading the sheet description from
* file. */
SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for
///< the sheet. In complex hierarchies multiple
///< sheets can share a common screen.
SCH_SHEET_PINS m_pins; ///< List of sheet connection points.
wxString m_FileName; /* also in SCH_SCREEN (redundant),
* but need it here for loading after
* reading the sheet description from
* file. */
public:
wxString m_SheetName; /* this is equivalent to C101 for
* components: it is stored in F0 ...
* of the file. */
wxString m_SheetName; /* this is equivalent to C101 for
* components: it is stored in F0 ...
* of the file. */
public:
int m_SheetNameSize; /* Size (height) of the text, used to
* draw the sheet name */
......@@ -286,64 +286,64 @@ public:
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.
* Do not delete the label object or you will likely get a segfault
* when this sheet is destroyed.
* Note: Once a sheet pin is added to the sheet, it is owned by the sheet.
* Do not delete the sheet pin object or you will likely get a segfault
* 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.
*
* 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();
/**
* 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.
*
* @return True if there are any undefined labels.
*/
bool HasUndefinedLabels();
bool HasUndefinedPins();
/**
* Function GetPenSize
......@@ -453,9 +453,9 @@ public:
{
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:
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
* when the label list changes. Make sure you call this method any time a
* label is added or removed.
* This method is used internally by SCH_SHEET to update the pin numbering
* when the pin list changes. Make sure you call this method any time a
* sheet pin is added or removed.
*/
void renumberLabels();
void renumberPins();
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
......
......@@ -19,6 +19,7 @@
#include "trigo.h"
#include "richio.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
#include "protos.h"
......@@ -37,7 +38,7 @@
*/
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 );
wxASSERT( parent );
......@@ -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 )
{
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
......@@ -462,7 +497,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
wxString SCH_SHEET_PIN::GetSelectMenuText() const
{
wxString tmp;
tmp.Printf( _( "Hierarchical Sheet Label %s" ), GetChars( GetText() ) );
tmp.Printf( _( "Hierarchical Sheet Pin %s" ), GetChars( GetText() ) );
return tmp;
}
......
......@@ -53,8 +53,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_END_SHEET:
case ID_POPUP_SCH_RESIZE_SHEET:
case ID_POPUP_IMPORT_GLABEL:
case ID_POPUP_SCH_EDIT_PINSHEET:
case ID_POPUP_SCH_MOVE_PINSHEET:
case ID_POPUP_SCH_EDIT_SHEET_PIN:
case ID_POPUP_SCH_MOVE_SHEET_PIN:
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
......@@ -227,7 +227,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_IMPORT_GLABEL:
if( item != NULL && item->Type() == SCH_SHEET_T )
screen->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, &dc ) );
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
break;
case ID_POPUP_SCH_CLEANUP_SHEET:
......@@ -235,7 +235,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
SCH_SHEET* sheet = (SCH_SHEET*) item;
if( !sheet->HasUndefinedLabels() )
if( !sheet->HasUndefinedPins() )
{
DisplayInfoMessage( this,
_( "There are no undefined labels in this sheet to clean up." ) );
......@@ -253,13 +253,13 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
break;
case ID_POPUP_SCH_EDIT_PINSHEET:
Edit_PinSheet( (SCH_SHEET_PIN*) item, &dc );
case ID_POPUP_SCH_EDIT_SHEET_PIN:
EditSheetPin( (SCH_SHEET_PIN*) item, &dc );
break;
case ID_POPUP_SCH_MOVE_PINSHEET:
case ID_POPUP_SCH_MOVE_SHEET_PIN:
DrawPanel->MoveCursorToCrossHair();
StartMove_PinSheet( (SCH_SHEET_PIN*) item, &dc );
MoveSheetPin( (SCH_SHEET_PIN*) item, &dc );
break;
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
......@@ -498,7 +498,7 @@ void SCH_EDIT_FRAME::Process_Move_Item( SCH_ITEM* DrawStruct, wxDC* DC )
break;
case SCH_MARKER_T:
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
default:
wxString msg;
msg.Printf( wxT( "SCH_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
......@@ -596,7 +596,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
break;
case ID_SHEET_LABEL_BUTT:
case ID_SHEET_PIN_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
break;
......
......@@ -160,7 +160,7 @@ void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage )
EXCHG( SOURCE->m_Pos, DEST->m_Pos );
break;
case SCH_SHEET_LABEL_T:
case SCH_SHEET_PIN_T:
#undef SOURCE
#undef DEST
#define SOURCE ( (SCH_SHEET_PIN*) aItem )
......
......@@ -329,12 +329,12 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
s_PreviousSheetWidth = SHEET_MIN_WIDTH;
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,
( sheetLabel.GetLength() + 1 ) * sheetLabel.m_Size.x );
( sheetPin.GetLength() + 1 ) * sheetPin.m_Size.x );
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 );
......
This diff is collapsed.
......@@ -175,11 +175,11 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
m_VToolBar->AddTool( ID_IMPORT_HLABEL_BUTT, wxEmptyString,
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 ),
HELP_PLACE_PINSHEET, wxITEM_CHECK );
HELP_PLACE_SHEETPIN, wxITEM_CHECK );
m_VToolBar->AddTool( ID_LINE_COMMENT_BUTT, wxEmptyString,
wxBitmap( add_dashed_line_xpm ),
......
......@@ -61,7 +61,7 @@ enum KICAD_T {
SCH_HIERARCHICAL_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_LABEL_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
// General
......
......@@ -96,6 +96,12 @@ private:
int m_repeatLabelDelta; ///< Repeat label number increment step.
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:
SCH_EDIT_FRAME( wxWindow* father,
const wxString& title,
......@@ -528,15 +534,48 @@ private:
public:
bool EditSheet( SCH_SHEET* Sheet, wxDC* DC );
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
int GetLastSheetPinEdge() const { return m_lastSheetPinEdge; }
private:
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,
wxDC* DC );
void Place_PinSheet( SCH_SHEET_PIN* SheetLabel,
wxDC* DC );
SCH_SHEET_PIN* Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC );
/**
* Function CreateSheetPin
* creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.
* @param aSheet The sheet to add the new sheet pin to.
* @param aDC The device context to draw on.
* @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:
/**
......
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