Commit e1b5d49f authored by Wayne Stambaugh's avatar Wayne Stambaugh

EESchema component library and hierarchical sheet label object improvements.

* Continue component library class clean up and encapsulation work.
* Change hierarchical sheet label container to boost::vector_ptr.
* Encapsulate hierarchical label handling in hierarchical sheet class.
* Convert some missed occurrences of wxString::GetData() to GetChars( wxString ).
* Fix some minor code formatting issues.
parent bf9e49dd
...@@ -675,13 +675,12 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -675,13 +675,12 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE ) if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
{ {
SCH_SHEET* sheet = (SCH_SHEET*) Struct;
// Add all pins sheets of a selected hierarchical sheet to the list // Add all pins sheets of a selected hierarchical sheet to the list
SCH_SHEET_PIN* SLabel = ( (SCH_SHEET*) Struct )->m_Label; BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
while( SLabel )
{ {
if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) AddPickedItem( screen, label.m_Pos );
AddPickedItem( screen, SLabel->m_Pos );
SLabel = (SCH_SHEET_PIN*) SLabel->Next();
} }
} }
......
...@@ -340,31 +340,28 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -340,31 +340,28 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
{ {
EDA_BaseStruct* SchItem; EDA_BaseStruct* SchItem;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
SCH_SHEET_PATH* sheet; SCH_SHEET_PATH* sheetPath;
/* Build the sheet (not screen) list */ /* Build the sheet (not screen) list */
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); for( sheetPath = SheetList.GetFirst(); sheetPath != NULL; sheetPath = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( SchItem = sheet->LastDrawList(); SchItem; for( SchItem = sheetPath->LastDrawList(); SchItem; SchItem = SchItem->Next() )
SchItem = SchItem->Next() )
{ {
if( SchItem->Type() != TYPE_SCH_COMPONENT ) if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue; continue;
DrawLibItem = (SCH_COMPONENT*) SchItem; DrawLibItem = (SCH_COMPONENT*) SchItem;
DrawLibItem->SetParent( sheet->LastScreen() ); DrawLibItem->SetParent( sheetPath->LastScreen() );
OBJ_CMP_TO_LIST item; OBJ_CMP_TO_LIST item;
item.m_RootCmp = DrawLibItem; item.m_RootCmp = DrawLibItem;
item.m_SheetPath = *sheet; item.m_SheetPath = *sheetPath;
item.m_Unit = DrawLibItem->GetUnitSelection( sheet ); item.m_Unit = DrawLibItem->GetUnitSelection( sheetPath );
strncpy( item.m_Reference, strncpy( item.m_Reference,
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), CONV_TO_UTF8( DrawLibItem->GetRef( sheetPath ) ),
sizeof( item.m_Reference ) ); sizeof( item.m_Reference ) );
// Ensure always null terminate m_Ref. // Ensure always null terminate m_Ref.
item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0; item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0;
...@@ -384,19 +381,17 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -384,19 +381,17 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
{ {
SCH_ITEM* DrawList; SCH_ITEM* DrawList;
SCH_SHEET_PIN* PinLabel; SCH_SHEET_PATH* sheetPath;
SCH_SHEET_PATH* sheet;
/* Build the sheet list */ /* Build the sheet list */
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
LABEL_OBJECT labet_object; LABEL_OBJECT labet_object;
for( sheet = SheetList.GetFirst(); for( sheetPath = SheetList.GetFirst(); sheetPath != NULL; sheetPath = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
DrawList = (SCH_ITEM*) sheet->LastDrawList(); DrawList = (SCH_ITEM*) sheetPath->LastDrawList();
while( DrawList ) while( DrawList )
{ {
switch( DrawList->Type() ) switch( DrawList->Type() )
...@@ -404,22 +399,21 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) ...@@ -404,22 +399,21 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
labet_object.m_LabelType = DrawList->Type(); labet_object.m_LabelType = DrawList->Type();
labet_object.m_SheetPath = *sheet; labet_object.m_SheetPath = *sheetPath;
labet_object.m_Label = DrawList; labet_object.m_Label = DrawList;
aList.push_back( labet_object ); aList.push_back( labet_object );
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{ {
PinLabel = ( (SCH_SHEET*) DrawList )->m_Label; SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
while( PinLabel != NULL )
BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, sheet->GetSheetPins() )
{ {
labet_object.m_LabelType = labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE; labet_object.m_SheetPath = *sheetPath;
labet_object.m_SheetPath = *sheet; labet_object.m_Label = &sheetLabel;
labet_object.m_Label = PinLabel;
aList.push_back( labet_object ); aList.push_back( labet_object );
PinLabel = PinLabel->Next();
} }
} }
break; break;
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE ) SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
{ {
m_Label = NULL;
m_NbLabel = 0;
m_Layer = LAYER_SHEET; m_Layer = LAYER_SHEET;
m_Pos = pos; m_Pos = pos;
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
...@@ -39,20 +37,12 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : ...@@ -39,20 +37,12 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_SHEET::~SCH_SHEET() SCH_SHEET::~SCH_SHEET()
{ {
SCH_SHEET_PIN* label = m_Label, * next_label;
while( label )
{
next_label = label->Next();
delete label;
label = next_label;
}
// also, look at the associated sheet & its reference count // also, look at the associated sheet & its reference count
// perhaps it should be deleted also. // perhaps it should be deleted also.
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
m_AssociatedScreen->m_RefCount--; m_AssociatedScreen->m_RefCount--;
if( m_AssociatedScreen->m_RefCount == 0 ) if( m_AssociatedScreen->m_RefCount == 0 )
delete m_AssociatedScreen; delete m_AssociatedScreen;
} }
...@@ -66,8 +56,6 @@ SCH_SHEET::~SCH_SHEET() ...@@ -66,8 +56,6 @@ SCH_SHEET::~SCH_SHEET()
*/ */
bool SCH_SHEET::Save( FILE* aFile ) const bool SCH_SHEET::Save( FILE* aFile ) const
{ {
SCH_SHEET_PIN* SheetLabel;
if( fprintf( aFile, "$Sheet\n" ) == EOF if( fprintf( aFile, "$Sheet\n" ) == EOF
|| fprintf( aFile, "S %-4d %-4d %-4d %-4d\n", || fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF ) m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF )
...@@ -92,15 +80,12 @@ bool SCH_SHEET::Save( FILE* aFile ) const ...@@ -92,15 +80,12 @@ bool SCH_SHEET::Save( FILE* aFile ) const
return false; return false;
} }
/* Create the list of labels in the sheet. */ /* Save the list of labels in the sheet. */
SheetLabel = m_Label;
int l_id = 2; BOOST_FOREACH( const SCH_SHEET_PIN& label, m_labels )
while( SheetLabel != NULL )
{ {
SheetLabel->m_Number = l_id; if( !label.Save( aFile ) )
SheetLabel->Save( aFile ); return false;
l_id++;
SheetLabel = SheetLabel->Next();
} }
if( fprintf( aFile, "$EndSheet\n" ) == EOF ) if( fprintf( aFile, "$EndSheet\n" ) == EOF )
...@@ -132,24 +117,14 @@ SCH_SHEET* SCH_SHEET::GenCopy() ...@@ -132,24 +117,14 @@ SCH_SHEET* SCH_SHEET::GenCopy()
*/ */
newitem->m_SheetNameSize = m_SheetNameSize; newitem->m_SheetNameSize = m_SheetNameSize;
newitem->m_Label = NULL; BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
SCH_SHEET_PIN* Slabel = NULL, * label = m_Label;
if( label )
{ {
Slabel = newitem->m_Label = label->GenCopy(); SCH_SHEET_PIN* newSheetPin = sheetPin.GenCopy();
Slabel->SetParent( newitem ); newSheetPin->SetParent( newitem );
label = label->Next(); newitem->GetSheetPins().push_back( newSheetPin );
} }
while( label ) newitem->renumberLabels();
{
Slabel->SetNext( label->GenCopy() );
Slabel = Slabel->Next();
Slabel->SetParent( newitem );
label = label->Next();
}
/* don't copy screen data - just reference it. */ /* don't copy screen data - just reference it. */
newitem->m_AssociatedScreen = m_AssociatedScreen; newitem->m_AssociatedScreen = m_AssociatedScreen;
...@@ -170,24 +145,92 @@ void SCH_SHEET::SwapData( SCH_SHEET* copyitem ) ...@@ -170,24 +145,92 @@ 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 );
EXCHG( m_Label, copyitem->m_Label ); m_labels.swap( copyitem->m_labels );
EXCHG( m_NbLabel, copyitem->m_NbLabel );
// 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.
SCH_SHEET_PIN* label = m_Label; BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
while( label ) {
sheetPin.SetParent( this );
}
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, copyitem->m_labels )
{
sheetPin.SetParent( copyitem );
}
}
void SCH_SHEET::AddLabel( SCH_SHEET_PIN* aLabel )
{
wxASSERT( aLabel != NULL );
wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
m_labels.push_back( aLabel );
renumberLabels();
}
void SCH_SHEET::RemoveLabel( SCH_SHEET_PIN* aLabel )
{
wxASSERT( aLabel != NULL );
wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
SCH_SHEET_PIN_LIST::iterator i;
for( i = m_labels.begin(); i < m_labels.end(); ++i )
{ {
label->SetParent( this ); if( *i == aLabel )
label = label->Next(); {
m_labels.erase( i );
renumberLabels();
return;
}
} }
label = copyitem->m_Label; wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
while( label ) GetChars( aLabel->m_Text ), GetChars( m_SheetName ) );
}
bool SCH_SHEET::HasLabel( const wxString& aName )
{
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
{ {
label->SetParent( copyitem ); if( label.m_Text.CmpNoCase( aName ) == 0 )
label = label->Next(); return true;
} }
return false;
}
bool SCH_SHEET::HasUndefinedLabels()
{
BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
{
/* Search the schematic for a hierarchical label corresponding to this sheet label. */
EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
SCH_HIERLABEL* HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
continue;
HLabel = (SCH_HIERLABEL*) DrawStruct;
if( label.m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
break; // Found!
HLabel = NULL;
}
if( HLabel == NULL ) // Corresponding hierarchical label not found.
return true;
}
return false;
} }
...@@ -233,56 +276,61 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -233,56 +276,61 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
} }
/** Function CleanupSheet /**
* Delete pinsheets which are not corresponding to a hierarchical label * Delete sheet labels which do not have corresponding hierarchical label.
* @param aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame
*/ */
void SCH_SHEET::CleanupSheet( WinEDA_SchematicFrame* aFrame, void SCH_SHEET::CleanupSheet()
bool aRedraw,
bool aSaveForUndoRedo)
{ {
SCH_SHEET_PIN* Pinsheet, * NextPinsheet; SCH_SHEET_PIN_LIST::iterator i = m_labels.begin();
bool isSaved = false;
if( !IsOK( aFrame, _( "Ok to cleanup this sheet" ) ) ) while( i != m_labels.end() )
return;
Pinsheet = m_Label;
while( Pinsheet )
{ {
/* Search Hlabel corresponding to this Pinsheet */ /* Search the schematic for a hierarchical label corresponding to this sheet label. */
EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
SCH_HIERLABEL* HLabel = NULL; SCH_HIERLABEL* HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL ) if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
continue; continue;
HLabel = (SCH_HIERLABEL*) DrawStruct; HLabel = (SCH_HIERLABEL*) DrawStruct;
if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
if( i->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
break; // Found! break; // Found!
HLabel = NULL; HLabel = NULL;
} }
NextPinsheet = Pinsheet->Next(); if( HLabel == NULL ) // Hlabel not found: delete sheet label.
if( HLabel == NULL ) // Hlabel not found: delete pinsheet m_labels.erase( i );
{ else
if( aSaveForUndoRedo && !isSaved ) ++i;
{
isSaved = true;
aFrame->SaveCopyInUndoList( this, UR_CHANGED);
}
aFrame->OnModify( );
aFrame->DeleteSheetLabel( false, Pinsheet );
}
Pinsheet = NextPinsheet;
} }
}
if( aRedraw ) SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition )
aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() ); {
int size, dy, minx, maxx;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{
size = ( label.GetLength() + 1 ) * label.m_Size.x;
if( label.m_Edge )
size = -size;
minx = label.m_Pos.x;
maxx = label.m_Pos.x + size;
if( maxx < minx )
EXCHG( maxx, minx );
dy = label.m_Size.x / 2;
if( ( ABS( aPosition.y - label.m_Pos.y ) <= dy )
&& ( aPosition.x <= maxx ) && ( aPosition.x >= minx ) )
return &label;
}
return NULL;
} }
...@@ -307,7 +355,6 @@ int SCH_SHEET::GetPenSize() ...@@ -307,7 +355,6 @@ int SCH_SHEET::GetPenSize()
void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, int aDrawMode, int aColor ) const wxPoint& aOffset, int aDrawMode, int aColor )
{ {
SCH_SHEET_PIN* SheetLabelStruct;
int txtcolor; int txtcolor;
wxString Text; wxString Text;
int color; int color;
...@@ -350,12 +397,10 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -350,12 +397,10 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/* Draw text : SheetLabel */ /* Draw text : SheetLabel */
SheetLabelStruct = m_Label; BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
while( SheetLabelStruct != NULL )
{ {
if( !( SheetLabelStruct->m_Flags & IS_MOVED ) ) if( !( sheetPin.m_Flags & IS_MOVED ) )
SheetLabelStruct->Draw( aPanel, aDC, aOffset, aDrawMode, aColor ); sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
SheetLabelStruct = SheetLabelStruct->Next();
} }
} }
...@@ -377,8 +422,8 @@ EDA_Rect SCH_SHEET::GetBoundingBox() ...@@ -377,8 +422,8 @@ EDA_Rect SCH_SHEET::GetBoundingBox()
dx = MAX( m_Size.x, textlen1 ); dx = MAX( m_Size.x, textlen1 );
dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16; dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16;
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), wxSize( dx, dy ) );
wxSize( dx, dy ) );
return box; return box;
} }
...@@ -603,7 +648,7 @@ bool SCH_SHEET::ChangeFileName( WinEDA_SchematicFrame* aFrame, ...@@ -603,7 +648,7 @@ bool SCH_SHEET::ChangeFileName( WinEDA_SchematicFrame* aFrame,
{ {
msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \ msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \
data in this sheet will be replaced)?" ), data in this sheet will be replaced)?" ),
aFileName.GetData() ); GetChars( aFileName ) );
if( !IsOK( NULL, msg ) ) if( !IsOK( NULL, msg ) )
{ {
DisplayInfoMessage( (wxWindow*) NULL, DisplayInfoMessage( (wxWindow*) NULL,
...@@ -617,7 +662,7 @@ data in this sheet will be replaced)?" ), ...@@ -617,7 +662,7 @@ data in this sheet will be replaced)?" ),
{ {
msg.Printf( _( "A file named %s exists, load it (otherwise keep \ msg.Printf( _( "A file named %s exists, load it (otherwise keep \
current sheet data if possible)?" ), current sheet data if possible)?" ),
aFileName.GetData() ); GetChars( aFileName ) );
if( IsOK( NULL, msg ) ) if( IsOK( NULL, msg ) )
{ {
LoadFromFile = true; LoadFromFile = true;
...@@ -708,11 +753,25 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position ) ...@@ -708,11 +753,25 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position )
m_Pos.x -= m_Size.x; m_Pos.x -= m_Size.x;
SCH_SHEET_PIN* label = m_Label; BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
while( label != NULL ) {
label.Mirror_Y( aYaxis_position );
}
}
void SCH_SHEET::Resize( const wxSize& aSize )
{
if( aSize == m_Size )
return;
m_Size = aSize;
/* Move the sheet labels according to the new sheet size. */
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{ {
label->Mirror_Y( aYaxis_position ); if( label.m_Edge )
label = label->Next(); label.m_Pos.x = m_Pos.x + m_Size.x;
} }
} }
...@@ -726,27 +785,35 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData ) ...@@ -726,27 +785,35 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData )
} }
void SCH_SHEET::renumberLabels()
{
int labelId = 2;
BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
{
label.SetNumber( labelId );
labelId++;
}
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) void SCH_SHEET::Show( int nestLevel, std::ostream& os )
{ {
// XML output: // XML output:
wxString s = GetClass(); wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName ) << '"' << ">\n";
<< CONV_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
SCH_SHEET_PIN* label; BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
for( label = m_Label; label; label = label->Next() )
{ {
label->Show( nestLevel + 1, os ); label.Show( nestLevel + 1, os );
} }
NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
<< std::flush;
} }
#endif #endif
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
#define CLASS_DRAWSHEET_H #define CLASS_DRAWSHEET_H
#include "base_struct.h" #include "base_struct.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
extern SCH_SHEET* g_RootSheet; extern SCH_SHEET* g_RootSheet;
...@@ -21,12 +24,15 @@ extern SCH_SHEET* g_RootSheet; ...@@ -21,12 +24,15 @@ extern SCH_SHEET* g_RootSheet;
*/ */
class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
{ {
private:
int m_Number; ///< Label number use for saving sheet label to file.
///< Sheet label numbering begins at 2.
///< 0 is reserved for the sheet name.
///< 1 is reserve for the sheet file name.
public: public:
int m_Edge, m_Shape; int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected bool m_IsDangling; // TRUE non connected
int m_Number; // used to numbered labels when writing data on file .
// m_Number >= 2
// value 0 is for sheet name and 1 for sheet filename
public: public:
SCH_SHEET_PIN( SCH_SHEET* parent, SCH_SHEET_PIN( SCH_SHEET* parent,
...@@ -40,6 +46,7 @@ public: ...@@ -40,6 +46,7 @@ public:
return wxT( "SCH_SHEET_PIN" ); return wxT( "SCH_SHEET_PIN" );
} }
bool operator==( const SCH_SHEET_PIN* aPin ) const;
SCH_SHEET_PIN* GenCopy(); SCH_SHEET_PIN* GenCopy();
...@@ -48,14 +55,43 @@ public: ...@@ -48,14 +55,43 @@ public:
return ( SCH_SHEET_PIN*) Pnext; return ( SCH_SHEET_PIN*) Pnext;
} }
void Place( WinEDA_SchematicFrame* frame, /**
wxDC* DC ); * Get the sheet label number.
*
* @return Number of the sheet label.
*/
int GetNumber() { return m_Number; }
/**
* Set the sheet label number.
*
* @param aNumber - New sheet number label.
*/
void SetNumber( int aNumber );
/**
* Get the parent sheet object of this sheet pin.
*
* @return The sheet that is the parent of this sheet pin or NULL if it does
* not have a parent.
*/
SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_Parent; }
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel, void Draw( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
const wxPoint& offset, const wxPoint& offset,
int draw_mode, int draw_mode,
int Color = -1 ); int Color = -1 );
/**
* Plot this sheet pin object to aPlotter.
*
* @param aPlotter - The plotter object to plot to.
*/
void Plot( PLOTTER* aPlotter );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.sch" * writes the data structures for this object out to a FILE in "*.sch"
...@@ -119,6 +155,9 @@ public: ...@@ -119,6 +155,9 @@ public:
}; };
typedef boost::ptr_vector< SCH_SHEET_PIN > SCH_SHEET_PIN_LIST;
/* class SCH_SHEET /* class SCH_SHEET
* This class is the sheet symbol placed in a schematic, and is the entry point * This class is the sheet symbol placed in a schematic, and is the entry point
* for a sub schematic * for a sub schematic
...@@ -131,10 +170,14 @@ public: ...@@ -131,10 +170,14 @@ public:
* components: it is stored in F0 ... * components: it is stored in F0 ...
* of the file. */ * of the file. */
private: private:
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
* file. */ * file. */
protected:
SCH_SHEET_PIN_LIST m_labels; /* List of points to be connected.*/
public: public:
int m_SheetNameSize; /* Size (height) of the text, used to int m_SheetNameSize; /* Size (height) of the text, used to
* draw the sheet name */ * draw the sheet name */
...@@ -143,10 +186,6 @@ public: ...@@ -143,10 +186,6 @@ public:
wxPoint m_Pos; wxPoint m_Pos;
wxSize m_Size; /* Position and Size of *sheet symbol */ wxSize m_Size; /* Position and Size of *sheet symbol */
int m_Layer; int m_Layer;
SCH_SHEET_PIN* m_Label; /* Points Be connection, linked
* list.*/
int m_NbLabel; /* Pins sheet (corresponding to
* hierarchical labels) count */
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which
* handle the physical data * handle the physical data
* In complex hierarchies we * In complex hierarchies we
...@@ -176,14 +215,60 @@ public: ...@@ -176,14 +215,60 @@ public:
SCH_SHEET* GenCopy(); SCH_SHEET* GenCopy();
void DisplayInfo( WinEDA_DrawFrame* frame ); void DisplayInfo( WinEDA_DrawFrame* frame );
/** Function CleanupSheet /**
* Delete pinsheets which are not corresponding to a hierarchical label * Add aLabel to this sheet.
* @param aFrame = the schematic frame *
* @param aRedraw = true to redraw Sheet * Note: Once a label is added to the sheet, it is owned by the sheet.
* @param aSaveForUndoRedo = true to put this sheet in UndoRedo list, * Do not delete the label object or you will likely get a segfault
* if it is modified. * when this sheet is destroyed.
*
* @param aLabel - The label to add to the sheet.
*/
void AddLabel( SCH_SHEET_PIN* aLabel );
SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; }
/**
* Remove a sheet label from this sheet.
*
* @param aSheetLabel - The sheet label to remove from the list.
*/
void RemoveLabel( SCH_SHEET_PIN* aSheetLabel );
/**
* 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.
*/
void CleanupSheet();
/**
* Return the label found at aPosition in this sheet.
*
* @param aPosition - The position to check for a label.
*
* @return The label found at aPosition or NULL if no label is found.
*/
SCH_SHEET_PIN* GetLabel( const wxPoint& aPosition );
/**
* Checks if a label already exists with aName.
*
* @param aName - Name of label to search for.
*
* @return - True if label found, otherwise false.
*/ */
void CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw, bool aSaveForUndoRedo ); bool HasLabel( const wxString& aName );
bool HasLabels() { return !m_labels.empty(); }
/**
* Check all sheet labels against schematic for undefined hierarchical labels.
*
* @return True if there are any undefined labels.
*/
bool HasUndefinedLabels();
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
...@@ -272,7 +357,7 @@ public: ...@@ -272,7 +357,7 @@ public:
wxString GetFileName( void ); wxString GetFileName( void );
// Set a new filename without changing anything else // Set a new filename without changing anything else
void SetFileName( const wxString& aFilename ) void SetFileName( const wxString& aFilename )
{ {
m_FileName = aFilename; m_FileName = aFilename;
} }
...@@ -304,11 +389,9 @@ public: ...@@ -304,11 +389,9 @@ public:
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
SCH_SHEET_PIN* label = m_Label; BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
while( label != NULL )
{ {
label->Move( aMoveVector ); label.Move( aMoveVector );
label = label->Next();
} }
} }
...@@ -323,18 +406,35 @@ public: ...@@ -323,18 +406,35 @@ public:
* Compare schematic sheet file and sheet name against search string. * Compare schematic sheet file and sheet name against search string.
* *
* @param aSearchData - Criteria to search against. * @param aSearchData - Criteria to search against.
* @param aCaseSensitive - True for case sensitive search. *
* @param aWholeWord - True to match whole word.
* @return True if this item matches the search criteria. * @return True if this item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData ); virtual bool Matches( wxFindReplaceData& aSearchData );
/**
* Resize this sheet to aSize and adjust all of the labels accordingly.
*
* @param aSize - The new size for this sheet.
*/
void Resize( const wxSize& aSize );
#if defined(DEBUG) #if defined(DEBUG)
// comment inherited by Doxygen from Base_Struct // comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
protected:
/**
* Renumber labels in list.
*
* 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.
*/
void renumberLabels();
}; };
#endif /* CLASS_DRAWSHEET_H */ #endif /* CLASS_DRAWSHEET_H */
...@@ -16,20 +16,16 @@ ...@@ -16,20 +16,16 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "plot_common.h"
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
/*******************************************************************/ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ), EDA_TextStruct( text )
const wxPoint& pos,
const wxString& text ) :
SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ),
EDA_TextStruct( text )
{ {
/*******************************************************************/
wxASSERT( parent ); wxASSERT( parent );
wxASSERT( Pnext == NULL ); wxASSERT( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
...@@ -41,12 +37,9 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, ...@@ -41,12 +37,9 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent,
} }
/***********************************************************/
SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy() SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy()
{ {
/***********************************************************/ SCH_SHEET_PIN* newitem = new SCH_SHEET_PIN( (SCH_SHEET*) m_Parent, m_Pos, m_Text );
SCH_SHEET_PIN* newitem =
new SCH_SHEET_PIN( (SCH_SHEET*) m_Parent, m_Pos, m_Text );
newitem->m_Edge = m_Edge; newitem->m_Edge = m_Edge;
newitem->m_Shape = m_Shape; newitem->m_Shape = m_Shape;
...@@ -56,6 +49,12 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy() ...@@ -56,6 +49,12 @@ SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy()
} }
bool SCH_SHEET_PIN::operator==(const SCH_SHEET_PIN* aPin ) const
{
return aPin == this;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
...@@ -65,6 +64,16 @@ int SCH_SHEET_PIN::GetPenSize() ...@@ -65,6 +64,16 @@ int SCH_SHEET_PIN::GetPenSize()
} }
void SCH_SHEET_PIN::SetNumber( int aNumber )
{
wxASSERT( aNumber >= 2 );
m_Number = aNumber;
}
/*****************************************************************************/
/* Routine to create hierarchical labels */
/*****************************************************************************/ /*****************************************************************************/
void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel, void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
...@@ -72,8 +81,6 @@ void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel, ...@@ -72,8 +81,6 @@ void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel,
int DrawMode, int DrawMode,
int Color ) int Color )
{ {
/*****************************************************************************/
/* Routine to create hierarchical labels */
GRTextHorizJustifyType side; GRTextHorizJustifyType side;
EDA_Colors txtcolor; EDA_Colors txtcolor;
int posx, tposx, posy; int posx, tposx, posy;
...@@ -117,6 +124,47 @@ void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel, ...@@ -117,6 +124,47 @@ void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* panel,
} }
void SCH_SHEET_PIN::Plot( PLOTTER* aPlotter )
{
wxASSERT( aPlotter != NULL );
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
int posx, tposx, posy, size;
static std::vector <wxPoint> Poly;
txtcolor = ReturnLayerColor( GetLayer() );
posx = m_Pos.x;
posy = m_Pos.y;
size = m_Size.x;
GRTextHorizJustifyType side;
if( m_Edge )
{
tposx = posx - size;
side = GR_TEXT_HJUSTIFY_RIGHT;
}
else
{
tposx = posx + size + (size / 8);
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness = GetPenSize();
aPlotter->set_current_line_width( thickness );
aPlotter->text( wxPoint( tposx, posy ), txtcolor, m_Text, TEXT_ORIENT_HORIZ,
wxSize( size, size ), side, GR_TEXT_VJUSTIFY_CENTER, thickness,
m_Italic, m_Bold );
/* Draw the associated graphic symbol */
CreateGraphicShape( Poly, m_Pos );
aPlotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
}
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates * @param aCorner_list = list to fill with polygon corners coordinates
......
...@@ -180,13 +180,13 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent ) ...@@ -180,13 +180,13 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent )
LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
CMP_LIB_ENTRY( ROOT, aName, aLibrary ) CMP_LIB_ENTRY( ROOT, aName, aLibrary )
{ {
m_LastDate = 0; m_dateModified = 0;
unitCount = 1; unitCount = 1;
m_TextInside = 40; m_pinNameOffset = 40;
m_options = ENTRY_NORMAL; m_options = ENTRY_NORMAL;
m_UnitSelectionLocked = FALSE; m_unitsLocked = FALSE;
m_DrawPinNum = 1; m_showPinNumbers = true;
m_DrawPinName = 1; m_showPinNames = true;
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
// when the field editors are invoked. // when the field editors are invoked.
...@@ -209,11 +209,11 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) ...@@ -209,11 +209,11 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
m_aliasListData = aComponent.m_aliasListData; m_aliasListData = aComponent.m_aliasListData;
m_FootprintList = aComponent.m_FootprintList; m_FootprintList = aComponent.m_FootprintList;
unitCount = aComponent.unitCount; unitCount = aComponent.unitCount;
m_UnitSelectionLocked = aComponent.m_UnitSelectionLocked; m_unitsLocked = aComponent.m_unitsLocked;
m_TextInside = aComponent.m_TextInside; m_pinNameOffset = aComponent.m_pinNameOffset;
m_DrawPinNum = aComponent.m_DrawPinNum; m_showPinNumbers = aComponent.m_showPinNumbers;
m_DrawPinName = aComponent.m_DrawPinName; m_showPinNames = aComponent.m_showPinNames;
m_LastDate = aComponent.m_LastDate; m_dateModified = aComponent.m_dateModified;
m_options = aComponent.m_options; m_options = aComponent.m_options;
BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, aComponent.GetDrawItemList() ) BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, aComponent.GetDrawItemList() )
...@@ -554,10 +554,10 @@ bool LIB_COMPONENT::Save( FILE* aFile ) ...@@ -554,10 +554,10 @@ bool LIB_COMPONENT::Save( FILE* aFile )
} }
if( fprintf( aFile, " %d %d %c %c %d %c %c\n", if( fprintf( aFile, " %d %d %c %c %d %c %c\n",
0, m_TextInside, 0, m_pinNameOffset,
m_DrawPinNum ? 'Y' : 'N', m_showPinNumbers ? 'Y' : 'N',
m_DrawPinName ? 'Y' : 'N', m_showPinNames ? 'Y' : 'N',
unitCount, m_UnitSelectionLocked ? 'L' : 'F', unitCount, m_unitsLocked ? 'L' : 'F',
m_options == ENTRY_POWER ? 'P' : 'N' ) < 0 ) m_options == ENTRY_POWER ? 'P' : 'N' ) < 0 )
return false; return false;
...@@ -688,7 +688,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, ...@@ -688,7 +688,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum,
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* NumOfPins: */
|| sscanf( p, "%d", &unused ) != 1 || sscanf( p, "%d", &unused ) != 1
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* TextInside: */
|| sscanf( p, "%d", &m_TextInside ) != 1 || sscanf( p, "%d", &m_pinNameOffset ) != 1
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
|| sscanf( p, "%c", &drawnum ) != 1 || sscanf( p, "%c", &drawnum ) != 1
|| ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */
...@@ -712,8 +712,8 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, ...@@ -712,8 +712,8 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum,
if( unitCount < 1 ) if( unitCount < 1 )
unitCount = 1; unitCount = 1;
m_DrawPinNum = ( drawnum == 'N' ) ? FALSE : true; m_showPinNumbers = ( drawnum == 'N' ) ? false : true;
m_DrawPinName = ( drawname == 'N' ) ? FALSE : true; m_showPinNames = ( drawname == 'N' ) ? false : true;
/* Copy part name and prefix. */ /* Copy part name and prefix. */
LIB_FIELD& value = GetValueField(); LIB_FIELD& value = GetValueField();
...@@ -743,7 +743,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, ...@@ -743,7 +743,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum,
// Copy optional infos // Copy optional infos
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' ) if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' )
m_UnitSelectionLocked = true; m_unitsLocked = true;
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' ) if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' )
m_options = ENTRY_POWER; m_options = ENTRY_POWER;
...@@ -1101,15 +1101,15 @@ bool LIB_COMPONENT::SaveDateAndTime( FILE* aFile ) ...@@ -1101,15 +1101,15 @@ bool LIB_COMPONENT::SaveDateAndTime( FILE* aFile )
{ {
int year, mon, day, hour, min, sec; int year, mon, day, hour, min, sec;
if( m_LastDate == 0 ) if( m_dateModified == 0 )
return true; return true;
sec = m_LastDate & 63; sec = m_dateModified & 63;
min = ( m_LastDate >> 6 ) & 63; min = ( m_dateModified >> 6 ) & 63;
hour = ( m_LastDate >> 12 ) & 31; hour = ( m_dateModified >> 12 ) & 31;
day = ( m_LastDate >> 17 ) & 31; day = ( m_dateModified >> 17 ) & 31;
mon = ( m_LastDate >> 22 ) & 15; mon = ( m_dateModified >> 22 ) & 15;
year = ( m_LastDate >> 26 ) + 1990; year = ( m_dateModified >> 26 ) + 1990;
if ( fprintf( aFile, "Ti %d/%d/%d %d:%d:%d\n", if ( fprintf( aFile, "Ti %d/%d/%d %d:%d:%d\n",
year, mon, day, hour, min, sec ) < 0 ) year, mon, day, hour, min, sec ) < 0 )
...@@ -1134,7 +1134,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* aLine ) ...@@ -1134,7 +1134,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* aLine )
&year, &mon, &day, &hour, &min, &sec ) != 6 ) &year, &mon, &day, &hour, &min, &sec ) != 6 )
return false; return false;
m_LastDate = ( sec & 63 ) + ( ( min & 63 ) << 6 ) + m_dateModified = ( sec & 63 ) + ( ( min & 63 ) << 6 ) +
( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) + ( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) +
( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 ); ( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 );
...@@ -1192,7 +1192,7 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, ...@@ -1192,7 +1192,7 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& aRect, int aUnit, int aConvert,
continue; continue;
// Specific rules for pins. // Specific rules for pins.
if( aEditPinByPin || m_UnitSelectionLocked if( aEditPinByPin || m_unitsLocked
|| ( item.m_Convert && item.m_Convert != aConvert ) ) || ( item.m_Convert && item.m_Convert != aConvert ) )
continue; continue;
} }
......
...@@ -49,13 +49,11 @@ protected: ...@@ -49,13 +49,11 @@ protected:
LibrEntryType type; LibrEntryType type;
wxString description; /* documentation for info */ wxString description; /* documentation for info */
wxString keyWords; /* keyword list (used for search for wxString keyWords; /* keyword list (used for search for components by keyword) */
* components by keyword) */
wxString docFileName; /* Associate doc file name */ wxString docFileName; /* Associate doc file name */
public: public:
CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
CMP_LIBRARY* aLibrary = NULL );
CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL ); CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL );
virtual ~CMP_LIB_ENTRY(); virtual ~CMP_LIB_ENTRY();
...@@ -129,10 +127,7 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY ...@@ -129,10 +127,7 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY
/** /**
* Library component object definition. * Library component object definition.
* *
* Library component object definition. * A library component object is typically saved and loaded in a component library file (.lib).
*
* A library component object is typically saved and loaded
* in a component library file (.lib).
* Library components are different from schematic components. * Library components are different from schematic components.
*/ */
class LIB_COMPONENT : public CMP_LIB_ENTRY class LIB_COMPONENT : public CMP_LIB_ENTRY
...@@ -142,25 +137,7 @@ public: ...@@ -142,25 +137,7 @@ public:
wxArrayString m_FootprintList; /* list of suitable footprint names wxArrayString m_FootprintList; /* list of suitable footprint names
* for the component (wildcard names * for the component (wildcard names
* accepted) */ * accepted) */
bool m_UnitSelectionLocked; /* True if units are different
* and their selection is
* locked (i.e. if part A cannot
* be automatically changed in
* part B */
int m_TextInside; /* if 0: pin name drawn on the pin
* itself if > 0 pin name drawn inside
* the component, with a distance of
* m_TextInside in mils */
bool m_DrawPinNum;
bool m_DrawPinName;
long m_LastDate; // Last change Date
protected:
LibrEntryOptions m_options; // special features (i.e. Entry is a POWER)
int unitCount; /* Units (parts) per package */
LIB_DRAW_ITEM_LIST drawings; /* How to draw this part */
public:
/* Offsets used in editing library component, /* Offsets used in editing library component,
* for handle aliases data in m_AliasListData array string * for handle aliases data in m_AliasListData array string
* when editing a library component, aliases data is stored * when editing a library component, aliases data is stored
...@@ -178,7 +155,18 @@ public: ...@@ -178,7 +155,18 @@ public:
ALIAS_DOC_FILENAME_IDX = 3, ALIAS_DOC_FILENAME_IDX = 3,
ALIAS_NEXT_IDX = 4 ALIAS_NEXT_IDX = 4
}; };
private: private:
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
///< to draw the pin name above the pin.
bool m_unitsLocked; ///< True if component has multple parts and changing
///< one part does not automatically change another part.
bool m_showPinNames; ///< Determines if component pin names are visible.
bool m_showPinNumbers; ///< Determines if component pin numbers are visible.
long m_dateModified; ///< Date the component was last modified.
LibrEntryOptions m_options; // special features (i.e. Entry is a POWER)
int unitCount; /* Units (parts) per package */
LIB_DRAW_ITEM_LIST drawings; /* How to draw this part */
wxArrayString m_aliasListData; /* ALIAS data (name, doc, keywords and doc filename). wxArrayString m_aliasListData; /* ALIAS data (name, doc, keywords and doc filename).
* Used only by the component editor LibEdit * Used only by the component editor LibEdit
* to store aliases info during edition * to store aliases info during edition
...@@ -281,7 +269,7 @@ public: ...@@ -281,7 +269,7 @@ public:
bool Save( FILE* aFile ); bool Save( FILE* aFile );
/** /**
* Load component definition from /a aFile. * Load component definition from \a aFile.
* *
* @param aFile - File descriptor of file to load form. * @param aFile - File descriptor of file to load form.
* @param aLine - The first line of the component definition. * @param aLine - The first line of the component definition.
...@@ -291,11 +279,9 @@ public: ...@@ -291,11 +279,9 @@ public:
*/ */
bool Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg ); bool Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
bool LoadField( char* aLine, wxString& aErrorMsg ); bool LoadField( char* aLine, wxString& aErrorMsg );
bool LoadDrawEntries( FILE* aFile, char* aLine, bool LoadDrawEntries( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
int* aLineNum, wxString& aErrorMsg );
bool LoadAliases( char* aLine, wxString& aErrorMsg ); bool LoadAliases( char* aLine, wxString& aErrorMsg );
bool LoadFootprints( FILE* aFile, char* aLine, bool LoadFootprints( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
int* aLineNum, wxString& aErrorMsg );
bool isPower() { return m_options == ENTRY_POWER; } bool isPower() { return m_options == ENTRY_POWER; }
bool isNormal() { return m_options == ENTRY_NORMAL; } bool isNormal() { return m_options == ENTRY_NORMAL; }
...@@ -303,6 +289,9 @@ public: ...@@ -303,6 +289,9 @@ public:
void SetPower() { m_options = ENTRY_POWER; } void SetPower() { m_options = ENTRY_POWER; }
void SetNormal() { m_options = ENTRY_NORMAL; } void SetNormal() { m_options = ENTRY_NORMAL; }
void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
bool UnitsLocked() { return m_unitsLocked; }
/** /**
* Function SetFields * Function SetFields
* overwrites all the existing in this component with fields supplied * overwrites all the existing in this component with fields supplied
...@@ -381,22 +370,20 @@ public: ...@@ -381,22 +370,20 @@ public:
const int aTransform[2][2] ); const int aTransform[2][2] );
/** /**
* Add a new draw /a aItem to the draw object list. * Add a new draw \a aItem to the draw object list.
* *
* @param item - New draw object to add to component. * @param item - New draw object to add to component.
*/ */
void AddDrawItem( LIB_DRAW_ITEM* aItem ); void AddDrawItem( LIB_DRAW_ITEM* aItem );
/** /**
* Remove draw /a aItem from list. * Remove draw \a aItem from list.
* *
* @param aItem - Draw item to remove from list. * @param aItem - Draw item to remove from list.
* @param aPanel - Panel to remove part from. * @param aPanel - Panel to remove part from.
* @param aDc - Device context to remove part from. * @param aDc - Device context to remove part from.
*/ */
void RemoveDrawItem( LIB_DRAW_ITEM* aItem, void RemoveDrawItem( LIB_DRAW_ITEM* aItem, WinEDA_DrawPanel* aPanel = NULL, wxDC* aDc = NULL );
WinEDA_DrawPanel* aPanel = NULL,
wxDC* aDc = NULL );
/** /**
* Return the next draw object pointer. * Return the next draw object pointer.
...@@ -407,9 +394,7 @@ public: ...@@ -407,9 +394,7 @@ public:
* if TYPE_NOT_INIT search for all items types * if TYPE_NOT_INIT search for all items types
* @return - The next drawing object in the list if found, otherwise NULL. * @return - The next drawing object in the list if found, otherwise NULL.
*/ */
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* aItem = NULL, KICAD_T aType = TYPE_NOT_INIT );
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* aItem = NULL,
KICAD_T aType = TYPE_NOT_INIT );
/** /**
* Return the next pin object from the draw list. * Return the next pin object from the draw list.
...@@ -422,8 +407,7 @@ public: ...@@ -422,8 +407,7 @@ public:
*/ */
LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL ) LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL )
{ {
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, COMPONENT_PIN_DRAW_TYPE );
COMPONENT_PIN_DRAW_TYPE );
} }
...@@ -443,7 +427,7 @@ public: ...@@ -443,7 +427,7 @@ public:
void GetPins( LIB_PIN_LIST& aList, int aUnit = 0, int aConvert = 0 ); void GetPins( LIB_PIN_LIST& aList, int aUnit = 0, int aConvert = 0 );
/** /**
* Return pin object with the requested pin /a aNumber. * Return pin object with the requested pin \a aNumber.
* *
* @param aNumber - Number of the pin to find. * @param aNumber - Number of the pin to find.
* @param aUnit - Unit of the component to find. Set to 0 if a specific * @param aUnit - Unit of the component to find. Set to 0 if a specific
...@@ -455,7 +439,7 @@ public: ...@@ -455,7 +439,7 @@ public:
LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 ); LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 );
/** /**
* Move the component /a aOffset. * Move the component \a aOffset.
* *
* @param aOffset - Offset displacement. * @param aOffset - Offset displacement.
*/ */
...@@ -474,7 +458,7 @@ public: ...@@ -474,7 +458,7 @@ public:
bool HasConversion() const; bool HasConversion() const;
/** /**
* Test if alias /a aName is in component alias list. * Test if alias \a aName is in component alias list.
* *
* Alias name comparisons are case insensitive. * Alias name comparisons are case insensitive.
* *
...@@ -506,8 +490,7 @@ public: ...@@ -506,8 +490,7 @@ public:
* @return The number of draw objects found inside the block select * @return The number of draw objects found inside the block select
* rectangle. * rectangle.
*/ */
int SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, int SelectItems( EDA_Rect& aRect, int aUnit, int aConvert, bool aEditPinByPin );
bool aEditPinByPin );
/** /**
* Clears all the draw items marked by a block select. * Clears all the draw items marked by a block select.
...@@ -553,8 +536,7 @@ public: ...@@ -553,8 +536,7 @@ public:
* @param aPoint - Coordinate for hit testing. * @param aPoint - Coordinate for hit testing.
* @return The draw object if found. Otherwise NULL. * @return The draw object if found. Otherwise NULL.
*/ */
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const wxPoint& aPoint );
const wxPoint& aPoint );
/** /**
* Locate a draw object (overlaid) * Locate a draw object (overlaid)
...@@ -567,8 +549,7 @@ public: ...@@ -567,8 +549,7 @@ public:
* @return The draw object if found. Otherwise NULL. * @return The draw object if found. Otherwise NULL.
*/ */
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
const wxPoint& aPoint, const wxPoint& aPoint, const int aTransfrom[2][2] );
const int aTransfrom[2][2] );
/** /**
* Return a reference to the draw item list. * Return a reference to the draw item list.
...@@ -617,6 +598,35 @@ public: ...@@ -617,6 +598,35 @@ public:
* @param aSetConvert - Set or clear the component alternate body style. * @param aSetConvert - Set or clear the component alternate body style.
*/ */
void SetConversion( bool aSetConvert ); void SetConversion( bool aSetConvert );
/**
* Set the offset in mils of the pin name text from the pin symbol.
*
* Set the offset to 0 to draw the pin name above the pin symbol.
*
* @param aOffset - The offset in mils.
*/
void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
int GetPinNameOffset() { return m_pinNameOffset; }
/**
* Set or clear the pin name visibility flag.
*
* @param aShow - True to make the component pin names visible.
*/
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
bool ShowPinNames() { return m_showPinNames; }
/**
* Set or clear the pin number visibility flag.
*
* @param aShow - True to make the component pin numbers visible.
*/
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
bool ShowPinNumbers() { return m_showPinNumbers; }
}; };
......
...@@ -82,7 +82,7 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) ...@@ -82,7 +82,7 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
out << " <start " << m_Start << "/> <end " << m_End << "/>\n"; out << " <start " << m_Start << "/> <end " << m_End << "/>\n";
if( m_Label ) if( m_Label )
out << " <label>" << m_Label->mb_str() << "</label>\n"; out << " <label>" << m_Label.mb_str() << "</label>\n";
if( m_Comp ) if( m_Comp )
m_Comp->Show( 1, out ); m_Comp->Show( 1, out );
...@@ -98,26 +98,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) ...@@ -98,26 +98,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
NETLIST_OBJECT::NETLIST_OBJECT() NETLIST_OBJECT::NETLIST_OBJECT()
{ {
m_Type = NET_ITEM_UNSPECIFIED; /* Type of this item (see NetObjetType enum) */ m_Type = NET_ITEM_UNSPECIFIED; /* Type of this item (see NetObjetType enum) */
m_Comp = NULL; /* Pointer on the library item that created this net object (the parent)*/ m_Comp = NULL; /* Pointer on the library item that created this net object
m_Link = NULL; /* For SCH_SHEET_PIN: * (the parent)*/
* Pointer to the hierarchy sheet that contains this SCH_SHEET_PIN m_Link = NULL; /* For SCH_SHEET_PIN:
* For Pins: pointer to the component that contains this pin * Pointer to the hierarchy sheet that contains this
*/ * SCH_SHEET_PIN For Pins: pointer to the component that
m_Flag = 0; /* flag used in calculations */ * contains this pin
m_ElectricalType = 0; /* Has meaning only for Pins and hierachical pins: electrical type */ */
m_NetCode = 0; /* net code for all items except BUS labels because a BUS label has m_Flag = 0; /* flag used in calculations */
* as many net codes as bus members m_ElectricalType = 0; /* Has meaning only for Pins and hierachical pins: electrical
*/ * type */
m_BusNetCode = 0; /* Used for BUS connections */ m_NetCode = 0; /* net code for all items except BUS labels because a BUS
m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label ) * label has as many net codes as bus members
* member number */
*/ m_BusNetCode = 0; /* Used for BUS connections */
m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created
* from the BUS label ) member number
*/
m_FlagOfConnection = UNCONNECTED; m_FlagOfConnection = UNCONNECTED;
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */ m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_Label = 0; /* For all labels:pointer on the text label */ m_NetNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
m_NetNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this object * object used to give a name to the net
* used to give a name to the net
*/ */
} }
...@@ -125,30 +127,10 @@ NETLIST_OBJECT::NETLIST_OBJECT() ...@@ -125,30 +127,10 @@ NETLIST_OBJECT::NETLIST_OBJECT()
// Copy constructor // Copy constructor
NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource ) NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
{ {
*this = aSource; *this = aSource;
m_Label = NULL; // set to null because some items are owner, so the delete operator can create problems
// if this member is copied here (if 2 different items are owner of the same object)
} }
NETLIST_OBJECT::~NETLIST_OBJECT() NETLIST_OBJECT::~NETLIST_OBJECT()
{ {
/* NETLIST_OBJECT is owner of m_Label only if its type is
* NET_HIERBUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_SHEETBUSLABELMEMBER or NET_BUSLABELMEMBER
* So we must delete m_Label only for these cases
* ( see the note in ConvertBustToMembers)
*/
switch( m_Type )
{
default:
break;
case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_BUSLABELMEMBER:
SAFE_DELETE( m_Label );
break;
}
} }
...@@ -84,8 +84,7 @@ public: ...@@ -84,8 +84,7 @@ public:
* connects to.*/ * connects to.*/
long m_PinNum; /* pin number ( 1 long = 4 bytes -> long m_PinNum; /* pin number ( 1 long = 4 bytes ->
* 4 ascii codes) */ * 4 ascii codes) */
const wxString* m_Label; /* For all labels:pointer on the text wxString m_Label; /* Label text. */
* label */
wxPoint m_Start; // Position of object or for segments: wxPoint m_Start; // Position of object or for segments:
// starting point // starting point
wxPoint m_End; // For segments (wire and buses): wxPoint m_End; // For segments (wire and buses):
......
...@@ -809,8 +809,8 @@ void LIB_PIN::Draw( WinEDA_DrawPanel* aPanel, ...@@ -809,8 +809,8 @@ void LIB_PIN::Draw( WinEDA_DrawPanel* aPanel,
if( DrawPinText ) if( DrawPinText )
{ {
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->m_TextInside, DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(),
Entry->m_DrawPinNum, Entry->m_DrawPinName, Entry->ShowPinNumbers(), Entry->ShowPinNames(),
aColor, aDrawMode ); aColor, aDrawMode );
} }
...@@ -1610,8 +1610,8 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, ...@@ -1610,8 +1610,8 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
plotter->set_current_line_width( GetPenSize() ); plotter->set_current_line_width( GetPenSize() );
PlotPinSymbol( plotter, pos, m_PinLen, orient, m_PinShape ); PlotPinSymbol( plotter, pos, m_PinLen, orient, m_PinShape );
PlotPinTexts( plotter, pos, orient, GetParent()->m_TextInside, PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
GetParent()->m_DrawPinNum, GetParent()->m_DrawPinName, GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
GetPenSize() ); GetPenSize() );
} }
......
...@@ -659,7 +659,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet ) ...@@ -659,7 +659,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet )
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry && Entry->m_UnitSelectionLocked ) if( Entry && Entry->UnitsLocked() )
KeepMulti = true; KeepMulti = true;
while( defRef.Last() == '?' ) while( defRef.Last() == '?' )
......
...@@ -415,18 +415,15 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -415,18 +415,15 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{ {
SCH_SHEET_PIN* pinsheet; SCH_SHEET* sheet = (SCH_SHEET*) DrawItem;
for( pinsheet = ( (SCH_SHEET*) DrawItem )->m_Label;
pinsheet; BOOST_FOREACH( SCH_SHEET_PIN pinsheet, sheet->GetSheetPins() )
pinsheet = pinsheet->Next() )
{ {
wxASSERT( pinsheet->Type() == wxASSERT( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
item = new DanglingEndHandle( SHEET_LABEL_END ); item = new DanglingEndHandle( SHEET_LABEL_END );
item->m_Item = &pinsheet;
item->m_Item = pinsheet; item->m_Pos = pinsheet.m_Pos;
item->m_Pos = pinsheet->m_Pos;
if( lastitem ) if( lastitem )
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
......
...@@ -389,7 +389,6 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -389,7 +389,6 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC )
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
{ {
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
SCH_SHEET_PIN* SheetLabel, * NextLabel;
if( DrawStruct == NULL ) if( DrawStruct == NULL )
return; return;
...@@ -401,44 +400,12 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) ...@@ -401,44 +400,12 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{ {
//this structure is attached to a sheet , which we must find. // This structure is attached to a sheet, get the parent sheet object.
DrawList = Screen->EEDrawList; SCH_SHEET_PIN* sheetLabel = (SCH_SHEET_PIN*) DrawStruct;
for( ; DrawList != NULL; DrawList = DrawList->Next() ) SCH_SHEET* sheet = sheetLabel->GetParent();
{ wxASSERT_MSG( sheet != NULL,
if( DrawList->Type() != DRAW_SHEET_STRUCT_TYPE ) wxT( "Sheet label parent not properly set, bad programmer!" ) );
continue; sheet->RemoveLabel( sheetLabel );
/* See if our item is in this Sheet */
SheetLabel = ( (SCH_SHEET*) DrawList )->m_Label;
if( SheetLabel == NULL )
continue;
if( SheetLabel == (SCH_SHEET_PIN*) DrawStruct )
{
( (SCH_SHEET*) DrawList )->m_Label =
(SCH_SHEET_PIN*) SheetLabel->Next();
SAFE_DELETE( DrawStruct );
return;
}
else
{
while( SheetLabel->Next() )
{
NextLabel = (SCH_SHEET_PIN*) SheetLabel->Next();
if( NextLabel == (SCH_SHEET_PIN*) DrawStruct )
{
SheetLabel->SetNext( (EDA_BaseStruct*) NextLabel->Next() );
SAFE_DELETE( DrawStruct );
return;
}
SheetLabel = NextLabel;
}
}
}
return; return;
} }
else else
......
...@@ -110,9 +110,9 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) ...@@ -110,9 +110,9 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
component.SetPartCount( m_PartsCount->GetSelection() + 1 ); component.SetPartCount( m_PartsCount->GetSelection() + 1 );
component.GetReference().m_Text = m_Reference->GetValue(); component.GetReference().m_Text = m_Reference->GetValue();
if ( m_PinNameInside->GetValue() == FALSE) if ( m_PinNameInside->GetValue() == FALSE)
component.m_TextInside = 0; component.SetPinNameOffset( 0 );
else else
component.m_TextInside = m_SetSkew->GetValue(); component.SetPinNameOffset( m_SetSkew->GetValue() );
if ( m_IsPowerSymbol->GetValue() == TRUE ) if ( m_IsPowerSymbol->GetValue() == TRUE )
component.SetPower(); component.SetPower();
...@@ -121,9 +121,9 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) ...@@ -121,9 +121,9 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
/* Set the option "Units locked". /* Set the option "Units locked".
Obviously, cannot be TRUE if there is only one part */ Obviously, cannot be TRUE if there is only one part */
component.m_UnitSelectionLocked = m_PartsAreLocked->GetValue(); component.LockUnits( m_PartsAreLocked->GetValue() );
if ( component.GetPartCount() <= 1 ) if ( component.GetPartCount() <= 1 )
component.m_UnitSelectionLocked = FALSE; component.LockUnits( false );
} }
/*! /*!
......
...@@ -146,11 +146,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() ...@@ -146,11 +146,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
return; return;
} }
m_ShowPinNumButt->SetValue( component->m_DrawPinNum ); m_ShowPinNumButt->SetValue( component->ShowPinNumbers() );
m_ShowPinNameButt->SetValue( component->m_DrawPinName ); m_ShowPinNameButt->SetValue( component->ShowPinNames() );
m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 ); m_PinsNameInsideButt->SetValue( component->GetPinNameOffset() != 0 );
m_SelNumberOfUnits->SetValue( component->GetPartCount() ); m_SelNumberOfUnits->SetValue( component->GetPartCount() );
m_SetSkew->SetValue( component->m_TextInside ); m_SetSkew->SetValue( component->GetPinNameOffset() );
m_OptionPower->SetValue( component->isPower() ); m_OptionPower->SetValue( component->isPower() );
m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked ); m_OptionPartsLocked->SetValue( component->UnitsLocked() );
} }
...@@ -763,7 +763,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -763,7 +763,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
} }
// Show the "Parts Locked" option? // Show the "Parts Locked" option?
if( !m_LibEntry || !m_LibEntry->m_UnitSelectionLocked ) if( !m_LibEntry || !m_LibEntry->UnitsLocked() )
{ {
D( printf( "partsAreLocked->false\n" ); ) D( printf( "partsAreLocked->false\n" ); )
partsAreLockedLabel->Show( false ); partsAreLockedLabel->Show( false );
......
...@@ -32,15 +32,15 @@ ...@@ -32,15 +32,15 @@
void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
{ {
bool partLocked = GetComponent()->m_UnitSelectionLocked; bool partLocked = GetComponent()->UnitsLocked();
EditComponentProperties(); EditComponentProperties();
if( partLocked != GetComponent()->m_UnitSelectionLocked ) if( partLocked != GetComponent()->UnitsLocked() )
{ // g_EditPinByPinIsOn is set to the better value, { // g_EditPinByPinIsOn is set to the better value,
// if m_UnitSelectionLocked has changed // if m_UnitSelectionLocked has changed
g_EditPinByPinIsOn = GetComponent()->m_UnitSelectionLocked ? true : false; g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn ); m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
} }
m_HToolBar->Refresh(); m_HToolBar->Refresh();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
...@@ -143,17 +143,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -143,17 +143,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
} }
} }
component->m_DrawPinNum = m_ShowPinNumButt->GetValue() ? 1 : 0; component->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
component->m_DrawPinName = m_ShowPinNameButt->GetValue() ? 1 : 0; component->SetShowPinNames( m_ShowPinNameButt->GetValue() );
if( m_PinsNameInsideButt->GetValue() == false ) if( m_PinsNameInsideButt->GetValue() == false )
component->m_TextInside = 0; // pin text outside the body (name is on the pin) component->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
else else
{ {
component->m_TextInside = m_SetSkew->GetValue(); component->SetPinNameOffset( m_SetSkew->GetValue() );
// Ensure component->m_TextInside != 0, because the meaning is "text outside". // Ensure component->m_TextInside != 0, because the meaning is "text outside".
if( component->m_TextInside == 0 ) if( component->GetPinNameOffset() == 0 )
component->m_TextInside = 20; // give a reasonnable value component->SetPinNameOffset( 20 ); // give a reasonnable value
} }
if( m_OptionPower->GetValue() == true ) if( m_OptionPower->GetValue() == true )
...@@ -163,9 +163,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -163,9 +163,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Set the option "Units locked". /* Set the option "Units locked".
* Obviously, cannot be true if there is only one part */ * Obviously, cannot be true if there is only one part */
component->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue(); component->LockUnits( m_OptionPartsLocked->GetValue() );
if( component->GetPartCount() <= 1 ) if( component->GetPartCount() <= 1 )
component->m_UnitSelectionLocked = false; component->LockUnits( false );
/* Update the footprint filter list */ /* Update the footprint filter list */
component->m_FootprintList.Clear(); component->m_FootprintList.Clear();
......
...@@ -428,11 +428,14 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -428,11 +428,14 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) ) || (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
{ {
msg.Printf( _( "HLabel %s not connected to SheetLabel" ), msg.Printf( _( "HLabel %s not connected to SheetLabel" ),
aNetItemRef->m_Label->GetData() ); GetChars( aNetItemRef->m_Label ) );
} }
else else
{
msg.Printf( _( "SheetLabel %s not connected to HLabel" ), msg.Printf( _( "SheetLabel %s not connected to HLabel" ),
aNetItemRef->m_Label->GetData() ); GetChars( aNetItemRef->m_Label ) );
}
Marker->SetData( ERCE_HIERACHICAL_LABEL, Marker->SetData( ERCE_HIERACHICAL_LABEL,
aNetItemRef->m_Start, aNetItemRef->m_Start,
...@@ -458,7 +461,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -458,7 +461,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
if( aMinConn == NOC ) /* Only 1 element in the net. */ if( aMinConn == NOC ) /* Only 1 element in the net. */
{ {
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ), msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
cmp_ref.GetData(), string_pinnum.GetData(), GetChars( cmp_ref ), GetChars( string_pinnum ),
MsgPinElectricType[ii] ); MsgPinElectricType[ii] );
Marker->SetData( ERCE_PIN_NOT_CONNECTED, Marker->SetData( ERCE_PIN_NOT_CONNECTED,
aNetItemRef->m_Start, aNetItemRef->m_Start,
...@@ -473,7 +476,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -473,7 +476,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList ); &aNetItemRef->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ), msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
cmp_ref.GetData(), string_pinnum.GetData(), GetChars( cmp_ref ), GetChars( string_pinnum ),
MsgPinElectricType[ii], aNetItemRef->GetNet() ); MsgPinElectricType[ii], aNetItemRef->GetNet() );
Marker->SetData( ERCE_PIN_NOT_DRIVEN, Marker->SetData( ERCE_PIN_NOT_DRIVEN,
aNetItemRef->m_Start, aNetItemRef->m_Start,
...@@ -513,15 +516,13 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -513,15 +516,13 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef(
&aNetItemTst->m_SheetList ); &aNetItemTst->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ), msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ),
cmp_ref.GetData(), GetChars( cmp_ref ), GetChars( string_pinnum ), MsgPinElectricType[ii] );
string_pinnum.GetData(), MsgPinElectricType[ii] );
Marker->SetData( errortype, Marker->SetData( errortype,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ), msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
alt_cmp.GetData(), GetChars( alt_cmp ), GetChars( alt_string_pinnum ), MsgPinElectricType[jj],
alt_string_pinnum.GetData(), MsgPinElectricType[jj],
aNetItemRef->GetNet() ); aNetItemRef->GetNet() );
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start ); Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
} }
...@@ -703,7 +704,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) ...@@ -703,7 +704,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
else else
{ {
wxString str = Sheet->PathHumanReadable(); wxString str = Sheet->PathHumanReadable();
msg.Printf( _( "\n***** Sheet %s\n" ), str.GetData() ); msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( str ) );
} }
fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) ); fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) );
......
...@@ -107,9 +107,9 @@ library \"%s\"." ), ...@@ -107,9 +107,9 @@ library \"%s\"." ),
if( !LoadOneLibraryPartAux( LibEntry, m_library ) ) if( !LoadOneLibraryPartAux( LibEntry, m_library ) )
return; return;
g_EditPinByPinIsOn = m_component->m_UnitSelectionLocked ? true : false; g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn ); m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false ); Zoom_Automatique( false );
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -556,21 +556,21 @@ created. Aborted" ) ); ...@@ -556,21 +556,21 @@ created. Aborted" ) );
SetShowDeMorgan( dlg.GetAlternateBodyStyle() ); SetShowDeMorgan( dlg.GetAlternateBodyStyle() );
if( dlg.GetPinNameInside( ) ) if( dlg.GetPinNameInside( ) )
{ {
component->m_TextInside = dlg.GetPinTextPosition(); component->SetPinNameOffset( dlg.GetPinTextPosition() );
if( component->m_TextInside == 0 ) if( component->GetPinNameOffset() == 0 )
component->m_TextInside = 1; component->SetPinNameOffset( 1 );
} }
else else
{ {
component->m_TextInside = 0; component->SetPinNameOffset( 0 );
} }
( dlg.GetPowerSymbol() ) ? component->SetPower() : component->SetNormal(); ( dlg.GetPowerSymbol() ) ? component->SetPower() : component->SetNormal();
component->m_DrawPinNum = dlg.GetShowPinNumber(); component->SetShowPinNumbers( dlg.GetShowPinNumber() );
component->m_DrawPinName = dlg.GetShowPinName(); component->SetShowPinNames( dlg.GetShowPinName() );
component->m_UnitSelectionLocked = dlg.GetLockItems(); component->LockUnits( dlg.GetLockItems() );
if( dlg.GetPartCount() < 2 ) if( dlg.GetPartCount() < 2 )
component->m_UnitSelectionLocked = false; component->LockUnits( false );
if( m_component ) if( m_component )
{ {
...@@ -584,7 +584,7 @@ created. Aborted" ) ); ...@@ -584,7 +584,7 @@ created. Aborted" ) );
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
g_EditPinByPinIsOn = m_component->m_UnitSelectionLocked ? true : false; g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn ); m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
......
...@@ -49,12 +49,12 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, ...@@ -49,12 +49,12 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen,
SCH_JUNCTION* ConnectionStruct; SCH_JUNCTION* ConnectionStruct;
SCH_POLYLINE* PolylineStruct; SCH_POLYLINE* PolylineStruct;
SCH_LINE* SegmentStruct; SCH_LINE* SegmentStruct;
SCH_BUS_ENTRY* RaccordStruct; SCH_BUS_ENTRY* busEntry;
SCH_NO_CONNECT* NoConnectStruct; SCH_NO_CONNECT* NoConnectStruct;
int LineCount; int LineCount;
wxString MsgDiag; /* Error and log messages */ wxString MsgDiag; /* Error and log messages */
FILE* f; FILE* f;
if( screen == NULL ) if( screen == NULL )
return FALSE; return FALSE;
...@@ -138,29 +138,28 @@ again." ); ...@@ -138,29 +138,28 @@ again." );
{ {
case '$': /* identification block */ case '$': /* identification block */
if( Line[1] == 'C' ) if( Line[1] == 'C' )
Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen );
screen );
else if( Line[1] == 'S' ) else if( Line[1] == 'S' )
Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, screen );
screen );
else if( Line[1] == 'D' ) else if( Line[1] == 'D' )
Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen );
screen );
else if( Line[1] == 'T' ) //text part else if( Line[1] == 'T' ) //text part
{ {
printf("**** TEXT PART\n"); printf( "**** TEXT PART\n" );
SCH_ITEM* Struct; SCH_ITEM* Struct;
Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version );
&LineCount, version);
if( Struct ) if( Struct )
{ {
Struct->SetNext( screen->EEDrawList ); Struct->SetNext( screen->EEDrawList );
screen->EEDrawList = Struct; screen->EEDrawList = Struct;
} }
else else
Failed = true; {
Failed = true;
}
} }
break; break;
...@@ -222,28 +221,27 @@ again." ); ...@@ -222,28 +221,27 @@ again." );
ii = WIRE_TO_BUS; ii = WIRE_TO_BUS;
if( Name1[0] == 'B' ) if( Name1[0] == 'B' )
ii = BUS_TO_BUS; ii = BUS_TO_BUS;
RaccordStruct = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii );
LineCount++; LineCount++;
if( fgets( Line, 256 - 1, f ) == NULL if( fgets( Line, 256 - 1, f ) == NULL
|| sscanf( Line, "%d %d %d %d ", &RaccordStruct->m_Pos.x, || sscanf( Line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y,
&RaccordStruct->m_Pos.y, &RaccordStruct->m_Size.x, &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 )
&RaccordStruct->m_Size.y ) != 4 )
{ {
MsgDiag.Printf( wxT( "EESchema file Bus Entry struct error at line %d, aborted" ), MsgDiag.Printf( wxT( "EESchema file Bus Entry struct error at line %d, aborted" ),
LineCount ); LineCount );
MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line );
Failed = true; Failed = true;
SAFE_DELETE( RaccordStruct ); SAFE_DELETE( busEntry );
break; break;
} }
if( !Failed ) if( !Failed )
{ {
RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; busEntry->m_Size.x -= busEntry->m_Pos.x;
RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; busEntry->m_Size.y -= busEntry->m_Pos.y;
RaccordStruct->SetNext( screen->EEDrawList ); busEntry->SetNext( screen->EEDrawList );
screen->EEDrawList = RaccordStruct; screen->EEDrawList = busEntry;
} }
break; break;
...@@ -333,8 +331,8 @@ at line %d, aborted" ), ...@@ -333,8 +331,8 @@ at line %d, aborted" ),
case 'T': /* It is a text item. */ case 'T': /* It is a text item. */
{ {
SCH_ITEM* Struct; SCH_ITEM* Struct;
Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version);
&LineCount, version);
if( Struct ) if( Struct )
{ {
Struct->SetNext( screen->EEDrawList ); Struct->SetNext( screen->EEDrawList );
......
...@@ -459,33 +459,11 @@ bool IsItemInBox( EDA_Rect& aBox, SCH_ITEM* DrawStruct ) ...@@ -459,33 +459,11 @@ bool IsItemInBox( EDA_Rect& aBox, SCH_ITEM* DrawStruct )
SCH_SHEET_PIN* LocateSheetLabel( SCH_SHEET* Sheet, const wxPoint& pos ) SCH_SHEET_PIN* LocateSheetLabel( SCH_SHEET* Sheet, const wxPoint& pos )
{ {
int size, dy, minx, maxx; return Sheet->GetLabel( pos );
SCH_SHEET_PIN* SheetLabel;
SheetLabel = Sheet->m_Label;
while( SheetLabel
&& SheetLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
size = ( SheetLabel->GetLength() + 1 ) * SheetLabel->m_Size.x;
if( SheetLabel->m_Edge )
size = -size;
minx = SheetLabel->m_Pos.x; maxx = SheetLabel->m_Pos.x + size;
if( maxx < minx )
EXCHG( maxx, minx );
dy = SheetLabel->m_Size.x / 2;
if( (ABS( pos.y - SheetLabel->m_Pos.y ) <= dy )
&& (pos.x <= maxx)
&& (pos.x >= minx) )
return SheetLabel;
SheetLabel = SheetLabel->Next();
}
return NULL;
} }
LIB_PIN* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, LIB_PIN* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, SCH_COMPONENT** libpart )
SCH_COMPONENT** libpart )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
......
...@@ -110,9 +110,8 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL, ...@@ -110,9 +110,8 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL,
* considered) * considered)
* Must be deallocated by the user * Must be deallocated by the user
*/ */
static SCH_COMPONENT* FindNextComponentAndCreatPinList( static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList,
EDA_BaseStruct* DrawList, SCH_SHEET_PATH* sheet )
SCH_SHEET_PATH* sheet )
{ {
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
...@@ -169,8 +168,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -169,8 +168,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
{ {
LIB_PIN_LIST pins; LIB_PIN_LIST pins;
Entry->GetPins( pins, Component->GetUnitSelection( sheet ), Entry->GetPins( pins, Component->GetUnitSelection( sheet ), Component->m_Convert );
Component->m_Convert );
for( size_t i = 0; i < pins.size(); i++ ) for( size_t i = 0; i < pins.size(); i++ )
{ {
...@@ -205,18 +203,17 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -205,18 +203,17 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
* "netname" for global net (like gnd, vcc .. * "netname" for global net (like gnd, vcc ..
* "netname_sheetnumber" for the usual nets * "netname_sheetnumber" for the usual nets
*/ */
static wxString ReturnPinNetName( NETLIST_OBJECT* Pin, static wxString ReturnPinNetName( NETLIST_OBJECT* Pin, const wxString& DefaultFormatNetname )
const wxString& DefaultFormatNetname )
{ {
int netcode = Pin->GetNet(); int netcode = Pin->GetNet();
wxString NetName; wxString NetName;
if( (netcode == 0 ) || ( Pin->m_FlagOfConnection != PAD_CONNECT ) ) if( ( netcode == 0 ) || ( Pin->m_FlagOfConnection != PAD_CONNECT ) )
return NetName; return NetName;
NETLIST_OBJECT* netref = Pin->m_NetNameCandidate; NETLIST_OBJECT* netref = Pin->m_NetNameCandidate;
if( netref ) if( netref )
NetName = *netref->m_Label; NetName = netref->m_Label;
if( !NetName.IsEmpty() ) if( !NetName.IsEmpty() )
{ {
...@@ -233,7 +230,9 @@ static wxString ReturnPinNetName( NETLIST_OBJECT* Pin, ...@@ -233,7 +230,9 @@ static wxString ReturnPinNetName( NETLIST_OBJECT* Pin,
} }
} }
else else
{
NetName.Printf( DefaultFormatNetname.GetData(), netcode ); NetName.Printf( DefaultFormatNetname.GetData(), netcode );
}
return NetName; return NetName;
} }
...@@ -242,8 +241,7 @@ static wxString ReturnPinNetName( NETLIST_OBJECT* Pin, ...@@ -242,8 +241,7 @@ static wxString ReturnPinNetName( NETLIST_OBJECT* Pin,
/* Create a generic netlist, and call an external netlister /* Create a generic netlist, and call an external netlister
* to change the netlist syntax and create the file * to change the netlist syntax and create the file
*/ */
void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName )
const wxString& FullFileName )
{ {
wxString Line, FootprintName; wxString Line, FootprintName;
SCH_SHEET_PATH* sheet; SCH_SHEET_PATH* sheet;
...@@ -270,16 +268,11 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, ...@@ -270,16 +268,11 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
fprintf( tmpfile, "$BeginComponentList\n" ); fprintf( tmpfile, "$BeginComponentList\n" );
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( SchItem = sheet->LastDrawList(); for( SchItem = sheet->LastDrawList(); SchItem != NULL; SchItem = SchItem->Next() )
SchItem != NULL;
SchItem = SchItem->Next() )
{ {
SchItem = Component = FindNextComponentAndCreatPinList( SchItem, SchItem = Component = FindNextComponentAndCreatPinList( SchItem, sheet );
sheet );
if( Component == NULL ) if( Component == NULL )
break; // No component left break; // No component left
...@@ -294,8 +287,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, ...@@ -294,8 +287,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
fprintf( tmpfile, "\n$BeginComponent\n" ); fprintf( tmpfile, "\n$BeginComponent\n" );
fprintf( tmpfile, "TimeStamp=%8.8lX\n", Component->m_TimeStamp ); fprintf( tmpfile, "TimeStamp=%8.8lX\n", Component->m_TimeStamp );
fprintf( tmpfile, "Footprint=%s\n", CONV_TO_UTF8( FootprintName ) ); fprintf( tmpfile, "Footprint=%s\n", CONV_TO_UTF8( FootprintName ) );
Line = wxT( "Reference=" ) + Component->GetRef( sheet ) + wxT( Line = wxT( "Reference=" ) + Component->GetRef( sheet ) + wxT( "\n" );
"\n" );
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
fputs( CONV_TO_UTF8( Line ), tmpfile ); fputs( CONV_TO_UTF8( Line ), tmpfile );
...@@ -317,8 +309,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, ...@@ -317,8 +309,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
netname = ReturnPinNetName( Pin, wxT( "$-%.6d" ) ); netname = ReturnPinNetName( Pin, wxT( "$-%.6d" ) );
if( netname.IsEmpty() ) if( netname.IsEmpty() )
netname = wxT( "?" ); netname = wxT( "?" );
fprintf( tmpfile, "%.4s=%s\n", (char*) &Pin->m_PinNum, fprintf( tmpfile, "%.4s=%s\n", (char*) &Pin->m_PinNum, CONV_TO_UTF8( netname ) );
CONV_TO_UTF8( netname ) );
} }
fprintf( tmpfile, "$EndPinList\n" ); fprintf( tmpfile, "$EndPinList\n" );
...@@ -369,8 +360,7 @@ static void ClearUsedFlags( void ) ...@@ -369,8 +360,7 @@ static void ClearUsedFlags( void )
* [.-] Or PSpice gnucap are beginning * [.-] Or PSpice gnucap are beginning
* + + Gnucap and PSpice are ultimately NetList * + + Gnucap and PSpice are ultimately NetList
*/ */
static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_netnames )
bool use_netnames )
{ {
char Line[1024]; char Line[1024];
SCH_SHEET_PATH* sheet; SCH_SHEET_PATH* sheet;
...@@ -458,16 +448,11 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, ...@@ -458,16 +448,11 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
/* Create component list */ /* Create component list */
ClearUsedFlags(); /* Reset the flags FlagControlMulti in all schematic ClearUsedFlags(); /* Reset the flags FlagControlMulti in all schematic
* files*/ * files*/
for( sheet = SheetList.GetFirst(); for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( DrawList = sheet->LastDrawList(); for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() )
DrawList != NULL;
DrawList = DrawList->Next() )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet );
sheet );
if( Component == NULL ) if( Component == NULL )
break; break;
...@@ -527,9 +512,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, ...@@ -527,9 +512,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
* = FALSE if with_pcbnew * = FALSE if with_pcbnew
* Format ORCADPCB2 strict * Format ORCADPCB2 strict
*/ */
static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew )
FILE* f,
bool with_pcbnew )
{ {
wxString Line, FootprintName; wxString Line, FootprintName;
char Buf[256]; char Buf[256];
...@@ -552,16 +535,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, ...@@ -552,16 +535,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame,
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( DrawList = sheet->LastDrawList(); for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() )
DrawList != NULL;
DrawList = DrawList->Next() )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet );
sheet );
if( Component == NULL ) if( Component == NULL )
break; break;
...@@ -577,8 +555,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, ...@@ -577,8 +555,7 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame,
if( CmpList == NULL ) if( CmpList == NULL )
{ {
CmpList = (OBJ_CMP_TO_LIST*) CmpList = (OBJ_CMP_TO_LIST*)
MyZMalloc( sizeof(OBJ_CMP_TO_LIST) * MyZMalloc( sizeof(OBJ_CMP_TO_LIST) * CmpListSize );
CmpListSize );
} }
if( CmpListCount >= CmpListSize ) if( CmpListCount >= CmpListSize )
{ {
...@@ -715,8 +692,7 @@ static void AddPinToComponentPinList( SCH_COMPONENT* Component, ...@@ -715,8 +692,7 @@ static void AddPinToComponentPinList( SCH_COMPONENT* Component,
if( s_SortedComponentPinList.size() >= MAXPIN ) if( s_SortedComponentPinList.size() >= MAXPIN )
{ {
/* Log message for Internal error */ /* Log message for Internal error */
DisplayError( NULL, DisplayError( NULL, wxT( "AddPinToComponentPinList err: MAXPIN reached" ) );
wxT( "AddPinToComponentPinList err: MAXPIN reached" ) );
return; return;
} }
} }
...@@ -801,11 +777,9 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in, ...@@ -801,11 +777,9 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL; for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet = SheetList.GetNext() )
{ {
for( SchItem = sheet->LastDrawList(); SchItem; for( SchItem = sheet->LastDrawList(); SchItem; SchItem = SchItem->Next() )
SchItem = SchItem->Next() )
{ {
if( SchItem->Type() != TYPE_SCH_COMPONENT ) if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue; continue;
...@@ -819,8 +793,7 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in, ...@@ -819,8 +793,7 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
for( pin = Entry->GetNextPin(); pin != NULL; for( pin = Entry->GetNextPin(); pin != NULL; pin = Entry->GetNextPin( pin ) )
pin = Entry->GetNextPin( pin ) )
{ {
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
...@@ -881,7 +854,7 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -881,7 +854,7 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
NETLIST_OBJECT* netref; NETLIST_OBJECT* netref;
netref = aObjectsList[ii]->m_NetNameCandidate; netref = aObjectsList[ii]->m_NetNameCandidate;
if( netref ) if( netref )
NetName = *netref->m_Label; NetName = netref->m_Label;
NetcodeName.Printf( wxT( "Net %d " ), NetCode ); NetcodeName.Printf( wxT( "Net %d " ), NetCode );
NetcodeName += wxT( "\"" ); NetcodeName += wxT( "\"" );
...@@ -890,8 +863,7 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -890,8 +863,7 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
if( netref->m_Type != NET_PINLABEL ) if( netref->m_Type != NET_PINLABEL )
{ {
// usual net name, prefix it by the sheet path // usual net name, prefix it by the sheet path
NetcodeName += NetcodeName += netref->m_SheetList.PathHumanReadable();
netref->m_SheetList.PathHumanReadable();
} }
NetcodeName += NetName; NetcodeName += NetName;
} }
...@@ -934,7 +906,6 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -934,7 +906,6 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
if( SameNetcodeCount >= 2 ) if( SameNetcodeCount >= 2 )
fprintf( f, " %s %.4s\n", CONV_TO_UTF8( CmpRef ), fprintf( f, " %s %.4s\n", CONV_TO_UTF8( CmpRef ),
(const char*) &aObjectsList[ii]->m_PinNum ); (const char*) &aObjectsList[ii]->m_PinNum );
} }
} }
...@@ -992,16 +963,11 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) ...@@ -992,16 +963,11 @@ static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
*files*/ *files*/
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( DrawList = sheet->LastDrawList(); for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() )
DrawList != NULL;
DrawList = DrawList->Next() )
{ {
DrawList = Component = FindNextComponentAndCreatPinList( DrawList, DrawList = Component = FindNextComponentAndCreatPinList( DrawList, sheet );
sheet );
if( Component == NULL ) if( Component == NULL )
break; break;
...@@ -1062,10 +1028,11 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -1062,10 +1028,11 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
if( ( NetCode = aObjectsList[ii]->GetNet() ) != LastNetCode ) if( ( NetCode = aObjectsList[ii]->GetNet() ) != LastNetCode )
{ {
NetName.Empty(); NetName.Empty();
NETLIST_OBJECT* netref; NETLIST_OBJECT* netref;
netref = aObjectsList[ii]->m_NetNameCandidate; netref = aObjectsList[ii]->m_NetNameCandidate;
if( netref ) if( netref )
NetName = *netref->m_Label; NetName = netref->m_Label;
NetcodeName = wxT( "\"" ); NetcodeName = wxT( "\"" );
if( !NetName.IsEmpty() ) if( !NetName.IsEmpty() )
......
...@@ -361,7 +361,7 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer ) ...@@ -361,7 +361,7 @@ void FindBestNetNameForEachNet( NETLIST_OBJECT_LIST& aNetItemBuffer )
* pin labels are global labels and have the highter priority * pin labels are global labels and have the highter priority
* local labels have the lower priority * local labels have the lower priority
* labels having the same priority are sorted by alphabetic order. * labels having the same priority are sorted by alphabetic order.
* *
*/ */
static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
{ {
...@@ -385,7 +385,7 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -385,7 +385,7 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
item = candidate; item = candidate;
else if( candidate->m_Type == NET_HIERLABEL ) else if( candidate->m_Type == NET_HIERLABEL )
{ {
if( candidate->m_Label->Cmp(*item->m_Label) < 0 ) if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
item = candidate; item = candidate;
} }
break; break;
...@@ -393,7 +393,7 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -393,7 +393,7 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
case NET_LABEL: case NET_LABEL:
if( candidate->m_Type == NET_LABEL ) if( candidate->m_Type == NET_LABEL )
{ {
if( candidate->m_Label->Cmp(*item->m_Label) < 0 ) if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
item = candidate; item = candidate;
} }
else else
...@@ -403,10 +403,10 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer ) ...@@ -403,10 +403,10 @@ static NETLIST_OBJECT* FindBestNetName( NETLIST_OBJECT_LIST& aLabelItemBuffer )
case NET_PINLABEL: case NET_PINLABEL:
if( candidate->m_Type != NET_PINLABEL ) if( candidate->m_Type != NET_PINLABEL )
break; break;
if( candidate->m_Label->Cmp(*item->m_Label) < 0 ) if( candidate->m_Label.Cmp( item->m_Label ) < 0 )
item = candidate; item = candidate;
break; break;
default: // Should not occur. default: // Should not occur.
break; break;
} }
...@@ -439,9 +439,7 @@ static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel ) ...@@ -439,9 +439,7 @@ static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
if( ObjetNet->GetNet() == SheetLabel->GetNet() ) if( ObjetNet->GetNet() == SheetLabel->GetNet() )
continue; //already connected. continue; //already connected.
wxASSERT( ObjetNet->m_Label ); if( ObjetNet->m_Label.CmpNoCase( SheetLabel->m_Label ) != 0 )
wxASSERT( SheetLabel->m_Label );
if( ObjetNet->m_Label->CmpNoCase( *SheetLabel->m_Label ) != 0 )
continue; //different names. continue; //different names.
/* Propagate Netcode having all the objects of the same Netcode. */ /* Propagate Netcode having all the objects of the same Netcode. */
...@@ -470,7 +468,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -470,7 +468,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LIB_PIN* pin; LIB_PIN* pin;
SCH_SHEET_PIN* SheetLabel;
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
DrawList = sheetlist->LastScreen()->EEDrawList; DrawList = sheetlist->LastScreen()->EEDrawList;
...@@ -547,7 +544,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -547,7 +544,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
if( STRUCT->m_Layer == LAYER_HIERLABEL ) if( STRUCT->m_Layer == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL; new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = &STRUCT->m_Text; new_item->m_Label = STRUCT->m_Text;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos; new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
...@@ -576,7 +573,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -576,7 +573,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
if( STRUCT->m_Layer == LAYER_HIERLABEL ) if( STRUCT->m_Layer == LAYER_HIERLABEL )
new_item->m_Type = NET_HIERLABEL; new_item->m_Type = NET_HIERLABEL;
new_item->m_Label = &STRUCT->m_Text; new_item->m_Label = STRUCT->m_Text;
new_item->m_Start = new_item->m_End = STRUCT->m_Pos; new_item->m_Start = new_item->m_End = STRUCT->m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
...@@ -622,7 +619,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -622,7 +619,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_Link = DrawLibItem; new_item->m_Link = DrawLibItem;
new_item->m_ElectricalType = pin->m_PinType; new_item->m_ElectricalType = pin->m_PinType;
new_item->m_PinNum = pin->m_PinNum; new_item->m_PinNum = pin->m_PinNum;
new_item->m_Label = &pin->m_PinName; new_item->m_Label = pin->m_PinName;
new_item->m_Start = new_item->m_End = pos2; new_item->m_Start = new_item->m_End = pos2;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
...@@ -636,7 +633,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -636,7 +633,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
new_item->m_Comp = NULL; new_item->m_Comp = NULL;
new_item->m_SheetList = *sheetlist; new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PINLABEL; new_item->m_Type = NET_PINLABEL;
new_item->m_Label = &pin->m_PinName; new_item->m_Label = pin->m_PinName;
new_item->m_Start = pos2; new_item->m_Start = pos2;
new_item->m_End = new_item->m_Start; new_item->m_End = new_item->m_Start;
...@@ -653,24 +650,26 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -653,24 +650,26 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_SHEET*) DrawList ) #define STRUCT ( (SCH_SHEET*) DrawList )
list = *sheetlist; list = *sheetlist;
list.Push( STRUCT ); list.Push( STRUCT );
SheetLabel = STRUCT->m_Label; SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
{ {
ii = IsBusLabel( SheetLabel->m_Text ); ii = IsBusLabel( label.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 = SheetLabel; new_item->m_Comp = &label;
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 = SheetLabel->m_Shape; new_item->m_ElectricalType = label.m_Shape;
new_item->m_Label = &SheetLabel->m_Text; new_item->m_Label = label.m_Text;
new_item->m_SheetListInclude = list; new_item->m_SheetListInclude = list;
new_item->m_Start = new_item->m_End = SheetLabel->m_Pos; new_item->m_Start = new_item->m_End = label.m_Pos;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
if( ii ) if( ii )
...@@ -678,6 +677,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -678,6 +677,7 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
} }
break; break;
}
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
default: default:
...@@ -828,11 +828,11 @@ static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, ...@@ -828,11 +828,11 @@ static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer,
BusLabel.m_Type = NET_BUSLABELMEMBER; BusLabel.m_Type = NET_BUSLABELMEMBER;
/* Conversion of BusLabel to the root Label name + the member id like mybus0, mybus1 ... */ /* Conversion of BusLabel to the root Label name + the member id like mybus0, mybus1 ... */
BufLine = BusLabel.m_Label->Left( RootBusNameLength ); BufLine = BusLabel.m_Label.Left( RootBusNameLength );
BusMember = FirstNumWireBus; BusMember = FirstNumWireBus;
BufLine << BusMember; BufLine << BusMember;
BusLabel.m_Label = new wxString( BufLine ); BusLabel.m_Label = BufLine;
BusLabel.m_Member = BusMember; BusLabel.m_Member = BusMember;
NumItem = 1; NumItem = 1;
...@@ -843,9 +843,9 @@ static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer, ...@@ -843,9 +843,9 @@ static int ConvertBusToMembers( NETLIST_OBJECT_LIST& aNetItemBuffer,
NumItem++; NumItem++;
/* Conversion of BusLabel to the root name + the current member id.*/ /* Conversion of BusLabel to the root name + the current member id.*/
BufLine = BusLabel.m_Label->Left( RootBusNameLength ); BufLine = BusLabel.m_Label.Left( RootBusNameLength );
BufLine << BusMember; BufLine << BusMember;
new_label->m_Label = new wxString( BufLine ); new_label->m_Label = BufLine;
new_label->m_Member = BusMember; new_label->m_Member = BusMember;
aNetItemBuffer.push_back( new_label ); aNetItemBuffer.push_back( new_label );
...@@ -1095,13 +1095,11 @@ void LabelConnect( NETLIST_OBJECT* LabelRef ) ...@@ -1095,13 +1095,11 @@ void LabelConnect( NETLIST_OBJECT* LabelRef )
|| ntype == NET_HIERBUSLABELMEMBER || ntype == NET_HIERBUSLABELMEMBER
|| ntype == NET_PINLABEL ) || ntype == NET_PINLABEL )
{ {
if( g_NetObjectslist[i]->m_Label->CmpNoCase( *LabelRef->m_Label ) if( g_NetObjectslist[i]->m_Label.CmpNoCase( LabelRef->m_Label ) != 0 )
!= 0 )
continue; continue;
if( g_NetObjectslist[i]->GetNet() ) if( g_NetObjectslist[i]->GetNet() )
PropageNetCode( PropageNetCode( g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
g_NetObjectslist[i]->GetNet(), LabelRef->GetNet(), 0 );
else else
g_NetObjectslist[i]->SetNet( LabelRef->GetNet() ); g_NetObjectslist[i]->SetNet( LabelRef->GetNet() );
} }
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
bool IsPartsLocked() bool IsPartsLocked()
{ {
return m_Entry->m_UnitSelectionLocked; return m_Entry->UnitsLocked();
} }
}; };
......
...@@ -21,10 +21,8 @@ using namespace std; ...@@ -21,10 +21,8 @@ using namespace std;
static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ); static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame );
static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, static void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame );
WinEDA_SchematicFrame* frame ); static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, WinEDA_SchematicFrame* frame );
static void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus,
WinEDA_SchematicFrame* 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 AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet );
static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ); static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
...@@ -43,12 +41,10 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, ...@@ -43,12 +41,10 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker,
* *
* This menu is then added to the list of zoom commands. * This menu is then added to the list of zoom commands.
*/ */
bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
wxMenu* PopMenu )
{ {
SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem(); SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem();
bool BlockActive = bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
(GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
// Do not start a block command on context menu. // Do not start a block command on context menu.
DrawPanel->m_CanStartBlock = -1; DrawPanel->m_CanStartBlock = -1;
...@@ -68,8 +64,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -68,8 +64,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) ) if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
{ {
SCH_SHEET_PIN* slabel; SCH_SHEET_PIN* slabel;
slabel = LocateSheetLabel( (SCH_SHEET*) DrawStruct, slabel = LocateSheetLabel( (SCH_SHEET*) DrawStruct, GetScreen()->m_Curseur );
GetScreen()->m_Curseur );
if( slabel ) if( slabel )
DrawStruct = slabel; DrawStruct = slabel;
} }
...@@ -80,13 +75,11 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -80,13 +75,11 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
_( "Cancel" ), cancel_xpm );
} }
else else
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ), cancel_tool_xpm );
_( "End Tool" ), cancel_tool_xpm );
} }
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
...@@ -94,8 +87,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -94,8 +87,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
_( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
} }
...@@ -104,8 +96,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -104,8 +96,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( GetSheet()->Last() != g_RootSheet ) if( GetSheet()->Last() != g_RootSheet )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), leave_sheet_xpm );
_( "Leave Sheet" ), leave_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
return true; return true;
...@@ -120,8 +111,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -120,8 +111,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Noconn" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Noconn" ), delete_xpm );
delete_xpm );
break; break;
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
...@@ -129,21 +119,18 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -129,21 +119,18 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
break; break;
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
if( !flags ){ if( !flags )
wxString msg = AddHotkeyName( _( "Move Bus Entry" ), {
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); wxString msg = AddHotkeyName( _( "Move Bus Entry" ), s_Schematic_Hokeys_Descr,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, HK_MOVE_COMPONENT_OR_ITEM );
msg, move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_xpm );
} }
if( GetBusEntryShape( (SCH_BUS_ENTRY*) DrawStruct ) == '\\' ) if( GetBusEntryShape( (SCH_BUS_ENTRY*) DrawStruct ) == '\\' )
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH, PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH, _( "Set Bus Entry /" ) );
_( "Set Bus Entry /" ) );
else else
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _( "Set Bus Entry \\" ) );
_( "Set Bus Entry \\" ) ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus Entry" ), delete_bus_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Bus Entry" ), delete_bus_xpm );
break; break;
case TYPE_SCH_MARKER: case TYPE_SCH_MARKER:
...@@ -204,10 +191,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -204,10 +191,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
default: default:
if( is_new ) if( is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ), ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ), apply_xpm );
apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Drawing" ), delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Drawing" ), delete_xpm );
break; break;
} }
...@@ -223,8 +208,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -223,8 +208,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
default: default:
wxString msg; wxString msg;
msg.Printf( wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown \ msg.Printf( wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ),
DrawType %d" ),
DrawStruct->Type() ); DrawStruct->Type() );
DisplayError( this, msg ); DisplayError( this, msg );
break; break;
...@@ -237,21 +221,17 @@ DrawType %d" ), ...@@ -237,21 +221,17 @@ DrawType %d" ),
void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field ) void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{ {
wxString msg; wxString msg;
if( !Field->m_Flags ){ if( !Field->m_Flags ){
msg = AddHotkeyName( _( "Move Field" ), msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg, move_text_xpm );
} }
msg = AddHotkeyName( _( "Rotate Field" ), msg = AddHotkeyName( _( "Rotate Field" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
s_Schematic_Hokeys_Descr, HK_ROTATE ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, msg, rotate_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD, _( "Edit Field" ), edit_text_xpm );
msg, rotate_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD,
_( "Edit Field" ), edit_text_xpm );
} }
...@@ -282,59 +262,43 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -282,59 +262,43 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
msg = _( "Move Component" ); msg = _( "Move Component" );
msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text; msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, msg, move_xpm );
msg, move_xpm ); msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr, HK_DRAG );
msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_xpm );
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST,
msg, move_xpm );
} }
wxMenu* orientmenu = new wxMenu; wxMenu* orientmenu = new wxMenu;
msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
HK_ROTATE ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, msg, rotate_pos_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm );
msg, rotate_pos_xpm ); msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr, HK_MIRROR_X_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE,
_( "Rotate -" ), rotate_neg_xpm );
msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr,
HK_MIRROR_X_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm );
msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr, HK_MIRROR_Y_COMPONENT );
HK_MIRROR_Y_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm );
msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hokeys_Descr, HK_ORIENT_NORMAL_COMPONENT );
HK_ORIENT_NORMAL_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu, ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
ID_POPUP_SCH_GENERIC_ORIENT_CMP,
_( "Orient Component" ), orient_xpm ); _( "Orient Component" ), orient_xpm );
wxMenu* editmenu = new wxMenu; wxMenu* editmenu = new wxMenu;
msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr, HK_EDIT );
HK_EDIT ); ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, msg, edit_component_xpm );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, msg,
edit_component_xpm );
if( libComponent && libComponent->isNormal() ) if( libComponent && libComponent->isNormal() )
{ {
msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_VALUE );
HK_EDIT_COMPONENT_VALUE ); ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg, edit_comp_value_xpm );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg,
edit_comp_value_xpm );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), edit_comp_ref_xpm );
_( "Reference" ), edit_comp_ref_xpm );
msg = AddHotkeyName( _( "Footprint " ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Footprint " ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_FOOTPRINT ); HK_EDIT_COMPONENT_FOOTPRINT );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg, ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg, edit_comp_footprint_xpm );
edit_comp_footprint_xpm );
} }
if( libComponent && libComponent->HasConversion() ) if( libComponent && libComponent->HasConversion() )
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ),
_( "Convert" ), component_select_alternate_shape_xpm ); component_select_alternate_shape_xpm );
if( libComponent && ( libComponent->GetPartCount() >= 2 ) ) if( libComponent && ( libComponent->GetPartCount() >= 2 ) )
{ {
...@@ -347,31 +311,24 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -347,31 +311,24 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit ); sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit );
} }
ADD_MENUITEM_WITH_SUBMENU( editmenu, sel_unit_menu, ADD_MENUITEM_WITH_SUBMENU( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
ID_POPUP_SCH_SELECT_UNIT_CMP,
_( "Unit" ), component_select_unit_xpm ); _( "Unit" ), component_select_unit_xpm );
} }
ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP,
ID_POPUP_SCH_GENERIC_EDIT_CMP,
_( "Edit Component" ), edit_component_xpm ); _( "Edit Component" ), edit_component_xpm );
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
msg = AddHotkeyName( _( "Copy Component" ), msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
msg, copy_button ); msg = AddHotkeyName( _( "Delete Component" ), s_Schematic_Hokeys_Descr, HK_DELETE );
msg = AddHotkeyName( _( "Delete Component" ), s_Schematic_Hokeys_Descr, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, delete_xpm );
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP,
msg, delete_xpm );
} }
if( libEntry && !libEntry->GetDocFileName().IsEmpty() ) if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), datasheet_xpm );
datasheet_xpm );
} }
...@@ -382,28 +339,20 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) ...@@ -382,28 +339,20 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
if( !GLabel->m_Flags ) if( !GLabel->m_Flags )
{ {
msg = AddHotkeyName( _( "Move Global Label" ), msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg, move_text_xpm ); msg = AddHotkeyName( _( "Copy Global Label" ), s_Schematic_Hokeys_Descr,
msg = AddHotkeyName( _( "Copy Global Label" ),
s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
msg, copy_button );
} }
msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr,
HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, rotate_glabel_xpm );
msg, rotate_glabel_xpm ); msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, edit_text_xpm );
HK_EDIT ); msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_text_xpm );
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
msg, delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
...@@ -412,8 +361,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) ...@@ -412,8 +361,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
_( "Change to Label" ), glabel2label_xpm ); _( "Change to Label" ), glabel2label_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_( "Change to Text" ), glabel2text_xpm ); _( "Change to Text" ), glabel2text_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm ); _( "Change Type" ), gl_change_xpm );
} }
...@@ -425,29 +373,19 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -425,29 +373,19 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
if( !HLabel->m_Flags ) if( !HLabel->m_Flags )
{ {
msg = AddHotkeyName( _( "Move Hierarchical Label" ), msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg, move_text_xpm ); msg = AddHotkeyName( _( "Copy Hierarchical Label" ), s_Schematic_Hokeys_Descr,
msg = AddHotkeyName( _( "Copy Hierarchical Label" ),
s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
msg, copy_button );
} }
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
HK_ROTATE ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, rotate_glabel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
msg, rotate_glabel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, edit_text_xpm );
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
HK_EDIT ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
msg, delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
...@@ -456,8 +394,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -456,8 +394,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
_( "Change to Text" ), glabel2text_xpm ); _( "Change to Text" ), glabel2text_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Global Label" ), label2glabel_xpm ); _( "Change to Global Label" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm ); _( "Change Type" ), gl_change_xpm );
} }
...@@ -471,26 +408,17 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -471,26 +408,17 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
{ {
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg, move_text_xpm ); msg = AddHotkeyName( _( "Copy Label" ), s_Schematic_Hokeys_Descr,
msg = AddHotkeyName( _( "Copy Label" ),
s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
msg, copy_button );
} }
msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
HK_ROTATE ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
msg, rotate_pos_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, edit_text_xpm );
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr, HK_DELETE );
HK_EDIT ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
msg, edit_text_xpm );
msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
msg, delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
...@@ -499,8 +427,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -499,8 +427,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
_( "Change to Text" ), label2text_xpm ); _( "Change to Text" ), label2text_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Global Label" ), label2glabel_xpm ); _( "Change to Global Label" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm ); _( "Change Type" ), gl_change_xpm );
} }
...@@ -512,29 +439,20 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -512,29 +439,20 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
if( !Text->m_Flags ) if( !Text->m_Flags )
{ {
msg = AddHotkeyName( _( "Move Text" ), msg = AddHotkeyName( _( "Move Text" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg, move_text_xpm ); msg = AddHotkeyName( _( "Copy Text" ), s_Schematic_Hokeys_Descr,
msg = AddHotkeyName( _( "Copy Text" ),
s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
msg, copy_button );
} }
msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr,
HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, msg, rotate_pos_xpm );
rotate_pos_xpm ); msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, edit_text_xpm );
HK_EDIT ); msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_text_xpm );
edit_text_xpm );
msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr,
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg,
delete_text_xpm );
/* add menu change type text (to label, glabel, text), /* add menu change type text (to label, glabel, text),
* but only if this is a single line text * but only if this is a single line text
...@@ -543,22 +461,17 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -543,22 +461,17 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{ {
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_( "Change to Label" ), label2text_xpm ); _( "Change to Label" ), label2text_xpm );
ADD_MENUITEM( menu_change_type, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, _( "Change to Hierarchical Label" ), label2glabel_xpm );
_( "Change to Hierarchical Label" ), ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
label2glabel_xpm );
ADD_MENUITEM( menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Glabel" ), label2glabel_xpm ); _( "Change to Glabel" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm ); _( "Change Type" ), gl_change_xpm );
} }
} }
void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, WinEDA_SchematicFrame* frame )
WinEDA_SchematicFrame* frame )
{ {
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
wxString msg; wxString msg;
...@@ -567,28 +480,22 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, ...@@ -567,28 +480,22 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction,
{ {
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
_( "Break Wire" ), break_line_xpm );
} }
msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE );
HK_DELETE ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg,
delete_xpm );
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), WIREITEM | BUSITEM ) )
WIREITEM | BUSITEM ) )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm );
_( "Delete Node" ), delete_node_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, delete_connection_xpm );
_( "Delete Connection" ), delete_connection_xpm );
} }
} }
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, WinEDA_SchematicFrame* frame )
WinEDA_SchematicFrame* frame )
{ {
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur; wxPoint pos = frame->GetScreen()->m_Curseur;
...@@ -600,41 +507,32 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, ...@@ -600,41 +507,32 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire,
return; return;
} }
msg = AddHotkeyName( _( "Drag Wire" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Drag Wire" ), s_Schematic_Hokeys_Descr, HK_DRAG );
HK_DRAG ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, msg, move_track_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, msg,
move_track_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete Wire" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Delete Wire" ), s_Schematic_Hokeys_Descr, HK_DELETE );
HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm );
delete_node_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, delete_connection_xpm );
_( "Delete Connection" ), delete_connection_xpm );
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
break_line_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), add_junction_xpm );
add_junction_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ), add_line_label_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ),
add_line_label_xpm );
// Add global label command only if the cursor is over one end of the wire. // Add global label command only if the cursor is over one end of the wire.
if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y)
|| ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) ) || ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), add_glabel_xpm );
_( "Add Global Label" ), add_glabel_xpm );
} }
void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, WinEDA_SchematicFrame* frame )
WinEDA_SchematicFrame* frame )
{ {
bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur; wxPoint pos = frame->GetScreen()->m_Curseur;
...@@ -645,105 +543,89 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, ...@@ -645,105 +543,89 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus,
return; return;
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus" ), delete_bus_xpm );
delete_bus_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ), break_bus_xpm );
break_bus_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), add_junction_xpm );
add_junction_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ), add_line_label_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ),
add_line_label_xpm );
// Add global label command only if the cursor is over one end of the bus. // Add global label command only if the cursor is over one end of the bus.
if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y)
|| ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) ) || ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), add_glabel_xpm );
_( "Add Global Label" ), add_glabel_xpm );
} }
void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
{ {
wxString msg; wxString msg;
if( !Sheet->m_Flags ) if( !Sheet->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm );
_( "Enter Sheet" ), enter_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Move Sheet" ), msg = AddHotkeyName( _( "Move Sheet" ), s_Schematic_Hokeys_Descr,
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_sheet_xpm );
msg, move_sheet_xpm );
msg = AddHotkeyName( _( "Drag Sheet" ), s_Schematic_Hokeys_Descr, HK_DRAG );
msg = AddHotkeyName( _( "Drag Sheet" ), s_Schematic_Hokeys_Descr, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_sheet_xpm );
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST,
msg, move_sheet_xpm );
} }
if( Sheet->m_Flags ) if( Sheet->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm );
apply_xpm );
} }
else else
{ {
msg = AddHotkeyName( _( "Edit Sheet" ), msg = AddHotkeyName( _( "Edit Sheet" ), s_Schematic_Hokeys_Descr, HK_EDIT );
s_Schematic_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, msg, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, msg, edit_sheet_xpm );
edit_sheet_xpm );
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 PinSheets" ),
import_hierarchical_label_xpm ); import_hierarchical_label_xpm );
if( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, if( Sheet->HasUndefinedLabels() ) // Sheet has pin labels, and can be cleaned
_( "Cleanup PinSheets" ), options_pinsheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup PinSheets" ),
options_pinsheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ), delete_sheet_xpm );
delete_sheet_xpm );
} }
} }
void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
{ {
wxString msg; wxString msg;
if( !PinSheet->m_Flags ){ if( !PinSheet->m_Flags )
msg = AddHotkeyName( _( "Move PinSheet" ), {
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); msg = AddHotkeyName( _( "Move PinSheet" ), s_Schematic_Hokeys_Descr,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, HK_MOVE_COMPONENT_OR_ITEM );
msg, move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, msg, move_xpm );
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm );
edit_xpm );
if( !PinSheet->m_Flags ) if( !PinSheet->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm );
delete_pinsheet_xpm );
} }
void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
{ {
wxString msg; wxString msg;
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm );
_( "Cancel Block" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, _( "Window Zoom" ), ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, _( "Window Zoom" ), zoom_selected_xpm );
zoom_selected_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
...@@ -752,20 +634,15 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) ...@@ -752,20 +634,15 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{ {
ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button ); ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), copyblock_xpm );
copyblock_xpm );
msg = AddHotkeyName( _( "Drag Block" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Drag Block" ), s_Schematic_Hokeys_Descr,
HK_MOVEBLOCK_TO_DRAGBLOCK ); HK_MOVEBLOCK_TO_DRAGBLOCK );
ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, msg, ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, msg, move_xpm );
move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), mirror_H_xpm );
delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK,
_( "Mirror Block ||" ), mirror_H_xpm );
#if 0 #if 0
#ifdef __WINDOWS__ #ifdef __WINDOWS__
ADD_MENUITEM( menu_other_block_commands, ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
_( "Copy to Clipboard" ), copy_button ); _( "Copy to Clipboard" ), copy_button );
#endif #endif
#endif #endif
...@@ -773,11 +650,8 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) ...@@ -773,11 +650,8 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
} }
void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, WinEDA_SchematicFrame* aFrame )
WinEDA_SchematicFrame* aFrame )
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), delete_xpm );
delete_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ), info_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER,
_( "Marker Error Info" ), info_xpm );
} }
...@@ -346,7 +346,6 @@ static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter, ...@@ -346,7 +346,6 @@ static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
{ {
SCH_SHEET_PIN* SheetLabelStruct;
EDA_Colors txtcolor = UNSPECIFIED_COLOR; EDA_Colors txtcolor = UNSPECIFIED_COLOR;
wxSize size; wxSize size;
wxString Text; wxString Text;
...@@ -392,20 +391,17 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct ) ...@@ -392,20 +391,17 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) ); plotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
plotter->text( wxPoint( Struct->m_Pos.x, plotter->text( wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ),
Struct->m_Pos.y + Struct->m_Size.y + 4 ),
txtcolor, Text, TEXT_ORIENT_HORIZ, size, txtcolor, Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false ); thickness, italic, false );
/* Draw texts : SheetLabel */
SheetLabelStruct = Struct->m_Label;
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) ); plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
while( SheetLabelStruct != NULL ) /* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& label, Struct->GetSheetPins() )
{ {
Plot_Hierarchical_PIN_Sheet( plotter, SheetLabelStruct ); label.Plot( plotter );
SheetLabelStruct = SheetLabelStruct->Next();
} }
} }
......
...@@ -184,7 +184,7 @@ int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag, ...@@ -184,7 +184,7 @@ int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, wxString& aMsgDiag,
int ii, fieldNdx, size; int ii, fieldNdx, size;
char Name1[256], Char1[256], Char2[256]; char Name1[256], Char1[256], Char2[256];
SCH_SHEET* SheetStruct; SCH_SHEET* SheetStruct;
SCH_SHEET_PIN* SheetLabelStruct, * OldSheetLabel = NULL; SCH_SHEET_PIN* SheetLabelStruct;
int Failed = FALSE; int Failed = FALSE;
char* ptcar; char* ptcar;
...@@ -305,28 +305,21 @@ error line %d, aborted\n" ), ...@@ -305,28 +305,21 @@ error line %d, aborted\n" ),
if( fieldNdx > 1 ) if( fieldNdx > 1 )
{ {
SheetLabelStruct = new SCH_SHEET_PIN( SheetStruct, wxPoint( 0, 0 ), int x, y;
CONV_FROM_UTF8( Name1 ) );
if( SheetStruct->m_Label == NULL )
OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct;
else
OldSheetLabel->SetNext( (EDA_BaseStruct*) SheetLabelStruct );
OldSheetLabel = SheetLabelStruct;
/* Read coordinates. */ /* Read coordinates. */
if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, &x, &y, &size ) != 5 )
&SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y,
&size ) != 5 )
{ {
aMsgDiag.Printf( wxT( "EESchema file Sheet Label Caract \ aMsgDiag.Printf( wxT( "EESchema file sheet label error at line %d, ignoring.\n" ),
error line %d, aborted\n" ),
*aLineNum ); *aLineNum );
aMsgDiag << CONV_FROM_UTF8( Line ); aMsgDiag << CONV_FROM_UTF8( Line );
DisplayError( frame, aMsgDiag ); DisplayError( frame, aMsgDiag );
continue; continue;
} }
SheetLabelStruct = new SCH_SHEET_PIN( SheetStruct, wxPoint( x, y ),
CONV_FROM_UTF8( Name1 ) );
if( size == 0 ) if( size == 0 )
size = DEFAULT_SIZE_TEXT; size = DEFAULT_SIZE_TEXT;
SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size;
...@@ -356,6 +349,8 @@ error line %d, aborted\n" ), ...@@ -356,6 +349,8 @@ error line %d, aborted\n" ),
if( Char2[0] == 'R' ) if( Char2[0] == 'R' )
SheetLabelStruct->m_Edge = 1; SheetLabelStruct->m_Edge = 1;
SheetStruct->AddLabel( SheetLabelStruct );
} }
} }
......
...@@ -374,16 +374,31 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -374,16 +374,31 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_IMPORT_GLABEL:
if ( screen->GetCurItem() if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
&& screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE ) GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*)screen->GetCurItem(), &dc ) );
GetScreen()->SetCurItem(
Import_PinSheet( (SCH_SHEET*)screen->GetCurItem(), &dc ) );
break; break;
case ID_POPUP_SCH_CLEANUP_SHEET: case ID_POPUP_SCH_CLEANUP_SHEET:
if ( screen->GetCurItem() if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
&& screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE ) {
( (SCH_SHEET*) screen->GetCurItem() )->CleanupSheet( this, true, true ); SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem();
if( !sheet->HasUndefinedLabels() )
{
DisplayInfoMessage( this,
_( "There are no undefined labels in this sheet to clean up." ) );
return;
}
if( !IsOK( this, _( "Do you wish to cleanup this sheet" ) ) )
return;
/* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
SaveCopyInUndoList( sheet, UR_CHANGED );
sheet->CleanupSheet();
OnModify();
DrawPanel->PostDirtyRect( sheet->GetBoundingBox() );
}
break; break;
case ID_POPUP_SCH_EDIT_PINSHEET: case ID_POPUP_SCH_EDIT_PINSHEET:
......
...@@ -144,7 +144,6 @@ structures and cannot be undone.\nOk to continue renaming?" ); ...@@ -144,7 +144,6 @@ structures and cannot be undone.\nOk to continue renaming?" );
static void MoveOrResizeSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase ) static void MoveOrResizeSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase )
{ {
wxPoint moveVector; wxPoint moveVector;
SCH_SHEET_PIN* sheetLabel;
BASE_SCREEN* screen = aPanel->GetScreen(); BASE_SCREEN* screen = aPanel->GetScreen();
SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem(); SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem();
...@@ -153,16 +152,9 @@ static void MoveOrResizeSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase ...@@ -153,16 +152,9 @@ static void MoveOrResizeSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase
if( sheet->m_Flags & IS_RESIZED ) if( sheet->m_Flags & IS_RESIZED )
{ {
sheet->m_Size.x = MAX( s_PreviousSheetWidth, screen->m_Curseur.x - sheet->m_Pos.x ); wxSize newSize( MAX( s_PreviousSheetWidth, screen->m_Curseur.x - sheet->m_Pos.x ),
sheet->m_Size.y = MAX( s_PreviousSheetHeight, screen->m_Curseur.y - sheet->m_Pos.y ); MAX( s_PreviousSheetHeight, screen->m_Curseur.y - sheet->m_Pos.y ) );
sheetLabel = sheet->m_Label; sheet->Resize( newSize );
while( sheetLabel )
{
if( sheetLabel->m_Edge )
sheetLabel->m_Pos.x = sheet->m_Pos.x + sheet->m_Size.x;
sheetLabel = sheetLabel->Next();
}
} }
else /* Move Sheet */ else /* Move Sheet */
{ {
...@@ -244,8 +236,6 @@ SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC ) ...@@ -244,8 +236,6 @@ SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC )
void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
{ {
SCH_SHEET_PIN* sheetLabel;
if( aSheet == NULL || aSheet->m_Flags & IS_NEW ) if( aSheet == NULL || aSheet->m_Flags & IS_NEW )
return; return;
...@@ -263,16 +253,13 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -263,16 +253,13 @@ void WinEDA_SchematicFrame::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;
sheetLabel = aSheet->m_Label;
while( sheetLabel ) BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, aSheet->GetSheetPins() )
{ {
s_PreviousSheetWidth = MAX( s_PreviousSheetWidth, s_PreviousSheetWidth = MAX( s_PreviousSheetWidth,
(int) ( ( sheetLabel->GetLength() + 1 ) * ( sheetLabel.GetLength() + 1 ) * sheetLabel.m_Size.x );
sheetLabel->m_Size.x ) );
s_PreviousSheetHeight = MAX( s_PreviousSheetHeight, s_PreviousSheetHeight = MAX( s_PreviousSheetHeight,
sheetLabel->m_Pos.y - aSheet->m_Pos.y ); sheetLabel.m_Pos.y - aSheet->m_Pos.y );
sheetLabel = sheetLabel->Next();
} }
DrawPanel->ManageCurseur = MoveOrResizeSheet; DrawPanel->ManageCurseur = MoveOrResizeSheet;
......
...@@ -17,9 +17,9 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); ...@@ -17,9 +17,9 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static int s_CurrentTypeLabel = NET_INPUT; static int s_CurrentTypeLabel = NET_INPUT;
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
static wxPoint s_InitialPosition; // remember here the initial value of the pin label when moving it static wxPoint s_InitialPosition; // remember the initial value of the pin label when moving it
/****************************************/ /****************************************/
...@@ -38,9 +38,8 @@ private: ...@@ -38,9 +38,8 @@ private:
WinEDA_GraphicTextCtrl* m_TextWin; WinEDA_GraphicTextCtrl* m_TextWin;
public: WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent, public: WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent,
SCH_SHEET_PIN* curr_pinsheet, SCH_SHEET_PIN* curr_pinsheet,
const wxPoint& framepos = const wxPoint& framepos = wxPoint( -1, -1 ) );
wxPoint( -1, -1 ) );
~WinEDA_PinSheetPropertiesFrame() { }; ~WinEDA_PinSheetPropertiesFrame() { };
private: private:
...@@ -51,8 +50,8 @@ private: ...@@ -51,8 +50,8 @@ private:
}; };
BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -121,8 +120,7 @@ void WinEDA_PinSheetPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED( ...@@ -121,8 +120,7 @@ void WinEDA_PinSheetPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED(
void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
{ {
m_CurrentPinSheet->m_Text = m_TextWin->GetText(); m_CurrentPinSheet->m_Text = m_TextWin->GetText();
m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize();
m_TextWin->GetTextSize();
m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection(); m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection();
EndModal( wxID_OK ); EndModal( wxID_OK );
...@@ -133,8 +131,7 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) ...@@ -133,8 +131,7 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
*/ */
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
SCH_SHEET_PIN* SheetLabel = SCH_SHEET_PIN* SheetLabel = (SCH_SHEET_PIN*) Panel->GetScreen()->GetCurItem();
(SCH_SHEET_PIN*) Panel->GetScreen()->GetCurItem();
if( SheetLabel == NULL ) if( SheetLabel == NULL )
return; return;
...@@ -168,31 +165,17 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -168,31 +165,17 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
wxASSERT( Sheet != NULL && Sheet->Type() == DRAW_SHEET_STRUCT_TYPE );
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
int flags = m_Flags; int flags = m_Flags;
m_Flags = 0; m_Flags = 0;
if( flags & IS_NEW ) if( flags & IS_NEW )
{ {
frame->SaveCopyInUndoList( Sheet, UR_CHANGED ); frame->SaveCopyInUndoList( Sheet, UR_CHANGED );
if( Sheet->m_Label == NULL ) Sheet->AddLabel( this );
Sheet->m_Label = this;
else
{
SCH_SHEET_PIN* pinsheet = Sheet->m_Label;
while( pinsheet )
{
if( pinsheet->Next() == NULL )
{
pinsheet->SetNext( this );
break;
}
pinsheet = pinsheet->Next();
}
}
} }
else // pin sheet was existing and only moved else // pin sheet was existing and only moved
{ {
wxPoint tmp = m_Pos; wxPoint tmp = m_Pos;
...@@ -206,7 +189,8 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -206,7 +189,8 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
m_Pos.x = Sheet->m_Pos.x; m_Pos.x = Sheet->m_Pos.x;
m_Edge = 0; m_Edge = 0;
if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + ( Sheet->m_Size.x / 2 ) ) )
{ {
m_Edge = 1; m_Edge = 1;
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
...@@ -219,7 +203,6 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -219,7 +203,6 @@ void SCH_SHEET_PIN::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL; frame->DrawPanel->ForceCloseManageCurseur = NULL;
} }
...@@ -241,8 +224,7 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel, ...@@ -241,8 +224,7 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel,
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
SCH_SHEET_PIN* SheetLabel = SCH_SHEET_PIN* SheetLabel = (SCH_SHEET_PIN*) panel->GetScreen()->GetCurItem();
(SCH_SHEET_PIN*) panel->GetScreen()->GetCurItem();
if( SheetLabel == NULL ) if( SheetLabel == NULL )
return; return;
...@@ -273,8 +255,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -273,8 +255,7 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, wxDC* DC )
wxDC* DC )
{ {
if( SheetLabel == NULL ) if( SheetLabel == NULL )
return wxID_CANCEL; return wxID_CANCEL;
...@@ -297,8 +278,7 @@ int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel, ...@@ -297,8 +278,7 @@ int WinEDA_SchematicFrame::Edit_PinSheet( SCH_SHEET_PIN* SheetLabel,
/* Add a new sheet pin to the sheet at the current cursor position. /* Add a new sheet pin to the sheet at the current cursor position.
*/ */
SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet, SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
wxDC* DC )
{ {
wxString Line, Text; wxString Line, Text;
SCH_SHEET_PIN* NewSheetLabel; SCH_SHEET_PIN* NewSheetLabel;
...@@ -330,41 +310,35 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet, ...@@ -330,41 +310,35 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Create_PinSheet( SCH_SHEET* Sheet,
/* Automatically create a sheet labels from global labels for each node in /* Automatically create a sheet labels from global labels for each node in
* the corresponding hierarchy. * the corresponding hierarchy.
*/ */
SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
wxDC* DC )
{ {
EDA_BaseStruct* DrawStruct; EDA_BaseStruct* DrawStruct;
SCH_SHEET_PIN* NewSheetLabel, * SheetLabel = NULL; SCH_SHEET_PIN* NewSheetLabel;
SCH_HIERLABEL* HLabel = NULL; SCH_HIERLABEL* HLabel = NULL;
if( !Sheet->m_AssociatedScreen ) if( !Sheet->m_AssociatedScreen )
return NULL; return NULL;
DrawStruct = Sheet->m_AssociatedScreen->EEDrawList; DrawStruct = Sheet->m_AssociatedScreen->EEDrawList;
HLabel = NULL; HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL ) if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
continue; continue;
HLabel = (SCH_HIERLABEL*) DrawStruct; HLabel = (SCH_HIERLABEL*) DrawStruct;
/* A global label has been found: check is there a corresponding /* A global label has been found: check if there a corresponding sheet label. */
* sheet label. */ if( !Sheet->HasLabel( HLabel->m_Text ) )
SheetLabel = Sheet->m_Label;
for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
{
if( SheetLabel->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
{
break;
}
}
if( SheetLabel == NULL )
break; break;
HLabel = NULL;
} }
if( (HLabel == NULL ) || SheetLabel ) if( HLabel == NULL )
{ {
DisplayInfoMessage( this, _( "No new hierarchical labels found" ), 10 ); DisplayInfoMessage( this, _( "No new hierarchical labels found" ) );
return NULL; return NULL;
} }
...@@ -392,8 +366,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet, ...@@ -392,8 +366,7 @@ SCH_SHEET_PIN* WinEDA_SchematicFrame::Import_PinSheet( SCH_SHEET* Sheet,
* This sheet label can not be put in a pile "undelete" because it would not * This sheet label can not be put in a pile "undelete" because it would not
* Possible to link it back it's 'SCH_SHEET' parent. * Possible to link it back it's 'SCH_SHEET' parent.
*/ */
void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw, void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelToDel )
SCH_SHEET_PIN* aSheetLabelToDel )
{ {
SCH_SHEET* parent = (SCH_SHEET*) aSheetLabelToDel->GetParent(); SCH_SHEET* parent = (SCH_SHEET*) aSheetLabelToDel->GetParent();
...@@ -406,23 +379,7 @@ void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw, ...@@ -406,23 +379,7 @@ void WinEDA_SchematicFrame::DeleteSheetLabel( bool aRedraw,
std::cout << "\n\n\n" << std::flush; std::cout << "\n\n\n" << std::flush;
#endif #endif
SCH_SHEET_PIN* prev = NULL; parent->RemoveLabel( aSheetLabelToDel );
SCH_SHEET_PIN* label = parent->m_Label;
for( ; label; prev = label, label = label->Next() )
{
if( label == aSheetLabelToDel )
{
if( prev )
prev->SetNext( label->Next() );
else
parent->m_Label = label->Next();
delete aSheetLabelToDel;
break;
}
}
if( aRedraw ) if( aRedraw )
DrawPanel->PostDirtyRect( parent->GetBoundingBox() ); DrawPanel->PostDirtyRect( parent->GetBoundingBox() );
......
...@@ -175,14 +175,14 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -175,14 +175,14 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
else else
line << wxT( "~ " ); line << wxT( "~ " );
line << 0 << wxT( " " ) << m_component->m_TextInside << wxT( " " ); line << 0 << wxT( " " ) << m_component->GetPinNameOffset() << wxT( " " );
if( m_component->m_DrawPinNum ) if( m_component->ShowPinNumbers() )
line << wxT( "Y " ); line << wxT( "Y " );
else else
line << wxT( "N " ); line << wxT( "N " );
if( m_component->m_DrawPinName ) if( m_component->ShowPinNames() )
line << wxT( "Y " ); line << wxT( "Y " );
else else
line << wxT( "N " ); line << wxT( "N " );
......
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