Commit f9af593e authored by Wayne Stambaugh's avatar Wayne Stambaugh

Minor EESchema improvements.

* Rename sch_item files to sch_junction.
* Make global variable g_ItemToRepeat a private member of SCH_EDIT_FRAME
  object.
* Encapsulate SCH_SCREEN reference count member.
parent 2dd12871
...@@ -61,7 +61,7 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) ...@@ -61,7 +61,7 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop! if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop!
screen->AddToDrawList( this ); screen->AddToDrawList( this );
g_ItemToRepeat = this; frame->SetRepeatItem( this );
frame->SaveCopyInUndoList( this, UR_NEW ); frame->SaveCopyInUndoList( this, UR_NEW );
} }
......
...@@ -119,7 +119,7 @@ set(EESCHEMA_SRCS ...@@ -119,7 +119,7 @@ set(EESCHEMA_SRCS
sch_bus_entry.cpp sch_bus_entry.cpp
sch_component.cpp sch_component.cpp
sch_field.cpp sch_field.cpp
sch_items.cpp sch_junction.cpp
sch_line.cpp sch_line.cpp
sch_marker.cpp sch_marker.cpp
sch_no_connect.cpp sch_no_connect.cpp
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "protos.h" #include "protos.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_text.h" #include "sch_text.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_polyline.h" #include "sch_polyline.h"
...@@ -183,7 +183,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -183,7 +183,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
GetScreen()->SetCurItem( newsegment ); GetScreen()->SetCurItem( newsegment );
DrawPanel->ManageCurseur = DrawSegment; DrawPanel->ManageCurseur = DrawSegment;
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
} }
else // A segment is in progress: terminates the current segment and add a new segment. else // A segment is in progress: terminates the current segment and add a new segment.
{ {
...@@ -331,8 +331,8 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -331,8 +331,8 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{ {
if( segment->m_Flags ) if( segment->m_Flags )
{ {
if( !g_ItemToRepeat ) if( !m_itemToRepeat )
g_ItemToRepeat = segment; m_itemToRepeat = segment;
} }
segment->m_Flags = 0; segment->m_Flags = 0;
...@@ -468,7 +468,7 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras ...@@ -468,7 +468,7 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras
*/ */
void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
{ {
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
if( ( GetScreen()->GetCurItem() == NULL ) if( ( GetScreen()->GetCurItem() == NULL )
|| ( ( GetScreen()->GetCurItem()->m_Flags & IS_NEW ) == 0 ) ) || ( ( GetScreen()->GetCurItem()->m_Flags & IS_NEW ) == 0 ) )
...@@ -502,7 +502,7 @@ SCH_JUNCTION* SCH_EDIT_FRAME::CreateNewJunctionStruct( wxDC* DC, ...@@ -502,7 +502,7 @@ SCH_JUNCTION* SCH_EDIT_FRAME::CreateNewJunctionStruct( wxDC* DC,
NewJunction = new SCH_JUNCTION( pos ); NewJunction = new SCH_JUNCTION( pos );
g_ItemToRepeat = NewJunction; m_itemToRepeat = NewJunction;
DrawPanel->CursorOff( DC ); // Erase schematic cursor DrawPanel->CursorOff( DC ); // Erase schematic cursor
NewJunction->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); NewJunction->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
...@@ -525,7 +525,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::CreateNewNoConnectStruct( wxDC* DC ) ...@@ -525,7 +525,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::CreateNewNoConnectStruct( wxDC* DC )
SCH_NO_CONNECT* NewNoConnect; SCH_NO_CONNECT* NewNoConnect;
NewNoConnect = new SCH_NO_CONNECT( GetScreen()->m_Curseur ); NewNoConnect = new SCH_NO_CONNECT( GetScreen()->m_Curseur );
g_ItemToRepeat = NewNoConnect; m_itemToRepeat = NewNoConnect;
DrawPanel->CursorOff( DC ); // Erase schematic cursor DrawPanel->CursorOff( DC ); // Erase schematic cursor
NewNoConnect->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); NewNoConnect->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
...@@ -555,7 +555,11 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -555,7 +555,11 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->Refresh(); Panel->Refresh();
} }
else else
g_ItemToRepeat = NULL; {
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
parent->SetRepeatItem( NULL );
}
/* Clear m_Flags which is used in edit functions: */ /* Clear m_Flags which is used in edit functions: */
SCH_ITEM* item = Screen->GetDrawItems(); SCH_ITEM* item = Screen->GetDrawItems();
...@@ -574,40 +578,40 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -574,40 +578,40 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
*/ */
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{ {
if( g_ItemToRepeat == NULL ) if( m_itemToRepeat == NULL )
return; return;
g_ItemToRepeat = g_ItemToRepeat->Clone(); m_itemToRepeat = m_itemToRepeat->Clone();
if( g_ItemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode
{ {
wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) g_ItemToRepeat )->m_Pos; wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos;
g_ItemToRepeat->m_Flags = IS_NEW; m_itemToRepeat->m_Flags = IS_NEW;
( (SCH_COMPONENT*) g_ItemToRepeat )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp();
g_ItemToRepeat->Move( pos ); m_itemToRepeat->Move( pos );
g_ItemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
StartMovePart( (SCH_COMPONENT*) g_ItemToRepeat, DC ); StartMovePart( (SCH_COMPONENT*) m_itemToRepeat, DC );
return; return;
} }
g_ItemToRepeat->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) ); m_itemToRepeat->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) );
if( g_ItemToRepeat->Type() == SCH_TEXT_T if( m_itemToRepeat->Type() == SCH_TEXT_T
|| g_ItemToRepeat->Type() == SCH_LABEL_T || m_itemToRepeat->Type() == SCH_LABEL_T
|| g_ItemToRepeat->Type() == SCH_HIERARCHICAL_LABEL_T || m_itemToRepeat->Type() == SCH_HIERARCHICAL_LABEL_T
|| g_ItemToRepeat->Type() == SCH_GLOBAL_LABEL_T ) || m_itemToRepeat->Type() == SCH_GLOBAL_LABEL_T )
{ {
( (SCH_TEXT*) g_ItemToRepeat )->IncrementLabel(); ( (SCH_TEXT*) m_itemToRepeat )->IncrementLabel();
} }
if( g_ItemToRepeat ) if( m_itemToRepeat )
{ {
g_ItemToRepeat->SetNext( GetScreen()->GetDrawItems() ); m_itemToRepeat->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( g_ItemToRepeat ); GetScreen()->SetDrawItems( m_itemToRepeat );
TestDanglingEnds( GetScreen()->GetDrawItems(), NULL ); TestDanglingEnds( GetScreen()->GetDrawItems(), NULL );
g_ItemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW ); SaveCopyInUndoList( m_itemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0; m_itemToRepeat->m_Flags = 0;
} }
} }
......
...@@ -42,7 +42,9 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -42,7 +42,9 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
} }
g_ItemToRepeat = NULL; SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
parent->SetRepeatItem( NULL );
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "protos.h" #include "protos.h"
#include "netlist.h" #include "netlist.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_sheet.h" #include "sch_sheet.h"
#include "sch_text.h" #include "sch_text.h"
...@@ -312,7 +312,7 @@ bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC ) ...@@ -312,7 +312,7 @@ bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC )
if( DelStruct ) if( DelStruct )
{ {
g_ItemToRepeat = NULL; frame->SetRepeatItem( NULL );
DeleteStruct( frame->DrawPanel, DC, DelStruct ); DeleteStruct( frame->DrawPanel, DC, DelStruct );
frame->TestDanglingEnds( frame->GetScreen()->GetDrawItems(), DC ); frame->TestDanglingEnds( frame->GetScreen()->GetDrawItems(), DC );
frame->OnModify( ); frame->OnModify( );
......
...@@ -36,7 +36,7 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -36,7 +36,7 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
if( TextStruct == NULL ) if( TextStruct == NULL )
return; return;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
if( (TextStruct->m_Flags & IS_NEW) == 0 ) if( (TextStruct->m_Flags & IS_NEW) == 0 )
{ {
...@@ -120,7 +120,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type ) ...@@ -120,7 +120,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type )
{ {
SCH_TEXT* NewText = NULL; SCH_TEXT* NewText = NULL;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
switch( type ) switch( type )
{ {
...@@ -215,8 +215,9 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -215,8 +215,9 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
BASE_SCREEN* screen = Panel->GetScreen(); BASE_SCREEN* screen = Panel->GetScreen();
SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem(); SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem();
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
g_ItemToRepeat = NULL; parent->SetRepeatItem( NULL );
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
...@@ -335,7 +336,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype ) ...@@ -335,7 +336,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in
// undo list // undo list
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
} }
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "class_library.h" #include "class_library.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_polyline.h" #include "sch_polyline.h"
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
// Global variables // Global variables
bool g_OptNetListUseNames; /* TRUE to use names rather than net bool g_OptNetListUseNames; /* TRUE to use names rather than net
* The numbers (PSPICE netlist only) */ * The numbers (PSPICE netlist only) */
SCH_ITEM* g_ItemToRepeat; /* Pointer to the last structure
* for duplicatation by the repeat command.
* (NULL if no struct exists) */
wxSize g_RepeatStep; wxSize g_RepeatStep;
int g_RepeatDeltaLabel; int g_RepeatDeltaLabel;
......
...@@ -132,9 +132,6 @@ public: ...@@ -132,9 +132,6 @@ public:
int Flags; int Flags;
}; };
extern SCH_ITEM* g_ItemToRepeat; /* Pointer to the last structure used
* by the repeat command. NULL if no
* item to repeat */
extern wxSize g_RepeatStep; extern wxSize g_RepeatStep;
extern int g_RepeatDeltaLabel; extern int g_RepeatDeltaLabel;
......
...@@ -76,7 +76,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, ...@@ -76,7 +76,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC,
bool AllowWildSeach = TRUE; bool AllowWildSeach = TRUE;
static wxString lastCommponentName; static wxString lastCommponentName;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
if( !libname.IsEmpty() ) if( !libname.IsEmpty() )
......
...@@ -256,7 +256,7 @@ void SCH_EDIT_FRAME::InstallPreviousSheet() ...@@ -256,7 +256,7 @@ void SCH_EDIT_FRAME::InstallPreviousSheet()
if( m_CurrentSheet->Last() == g_RootSheet ) if( m_CurrentSheet->Last() == g_RootSheet )
return; return;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
ClearMsgPanel(); ClearMsgPanel();
//make a copy for testing purposes. //make a copy for testing purposes.
...@@ -287,7 +287,7 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet ) ...@@ -287,7 +287,7 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet )
DisplayError( this, wxT( "InstallNextScreen() error" ) ); return; DisplayError( this, wxT( "InstallNextScreen() error" ) ); return;
} }
m_CurrentSheet->Push( Sheet ); m_CurrentSheet->Push( Sheet );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
ClearMsgPanel(); ClearMsgPanel();
UpdateScreenFromSheet( this ); UpdateScreenFromSheet( this );
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "protos.h" #include "protos.h"
#include "libeditframe.h" #include "libeditframe.h"
#include "class_libentry.h" #include "class_libentry.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_sheet.h" #include "sch_sheet.h"
...@@ -351,7 +351,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -351,7 +351,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break; break;
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( notBusy && g_ItemToRepeat && ( g_ItemToRepeat->m_Flags == 0 ) ) if( notBusy && m_itemToRepeat && ( m_itemToRepeat->m_Flags == 0 ) )
RepeatDrawItem( DC ); RepeatDrawItem( DC );
break; break;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "protos.h" #include "protos.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_component.h" #include "sch_component.h"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "class_library.h" #include "class_library.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
#include "lib_pin.h" #include "lib_pin.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_text.h" #include "sch_text.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_component.h" #include "sch_component.h"
...@@ -36,7 +36,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -36,7 +36,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( ( m_ID_current_state == 0 ) || ( DrawStruct && DrawStruct->m_Flags ) ) if( ( m_ID_current_state == 0 ) || ( DrawStruct && DrawStruct->m_Flags ) )
{ {
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
...@@ -106,8 +106,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -106,8 +106,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_NOCONN_BUTT: case ID_NOCONN_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{ {
g_ItemToRepeat = CreateNewNoConnectStruct( DC ); m_itemToRepeat = CreateNewNoConnectStruct( DC );
GetScreen()->SetCurItem( g_ItemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
...@@ -122,8 +122,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -122,8 +122,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
case ID_JUNCTION_BUTT: case ID_JUNCTION_BUTT:
if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) ) if( ( DrawStruct == NULL ) || ( DrawStruct->m_Flags == 0 ) )
{ {
g_ItemToRepeat = CreateNewJunctionStruct( DC, GetScreen()->m_Curseur, TRUE ); m_itemToRepeat = CreateNewJunctionStruct( DC, GetScreen()->m_Curseur, TRUE );
GetScreen()->SetCurItem( g_ItemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE; DrawPanel->m_AutoPAN_Request = TRUE;
} }
else else
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_text.h" #include "sch_text.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "sch_polyline.h" #include "sch_polyline.h"
#include "sch_sheet.h" #include "sch_sheet.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_items.h" #include "sch_junction.h"
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint ) void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint )
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "class_library.h" #include "class_library.h"
#include "lib_pin.h" #include "lib_pin.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_component.h" #include "sch_component.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "sch_items.h" #include "sch_junction.h"
/**********************/ /**********************/
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "protos.h" #include "protos.h"
#include "netlist.h" #include "netlist.h"
#include "class_library.h" #include "class_library.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_marker.h" #include "sch_marker.h"
...@@ -101,7 +101,7 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type ) ...@@ -101,7 +101,7 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
AddGrid( SchematicGridList[i] ); AddGrid( SchematicGridList[i] );
SetGrid( wxRealPoint( 50, 50 ) ); /* Default grid size. */ SetGrid( wxRealPoint( 50, 50 ) ); /* Default grid size. */
m_RefCount = 0; m_refCount = 0;
m_Center = false; /* Suitable for schematic only. For m_Center = false; /* Suitable for schematic only. For
* libedit and viewlib, must be set * libedit and viewlib, must be set
* to true */ * to true */
...@@ -116,6 +116,14 @@ SCH_SCREEN::~SCH_SCREEN() ...@@ -116,6 +116,14 @@ SCH_SCREEN::~SCH_SCREEN()
} }
void SCH_SCREEN::DecRefCount()
{
wxCHECK_RET( m_refCount != 0,
wxT( "Screen reference count already zero. Bad programmer!" ) );
m_refCount--;
}
void SCH_SCREEN::FreeDrawList() void SCH_SCREEN::FreeDrawList()
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
......
...@@ -59,7 +59,7 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : ...@@ -59,7 +59,7 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
m_labels[i].SetParent( this ); m_labels[i].SetParent( this );
if( m_AssociatedScreen ) if( m_AssociatedScreen )
m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->IncRefCount();
} }
...@@ -69,9 +69,9 @@ SCH_SHEET::~SCH_SHEET() ...@@ -69,9 +69,9 @@ SCH_SHEET::~SCH_SHEET()
// perhaps it should be deleted also. // perhaps it should be deleted also.
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
m_AssociatedScreen->m_RefCount--; m_AssociatedScreen->GetRefCount();
if( m_AssociatedScreen->m_RefCount == 0 ) if( m_AssociatedScreen->GetRefCount() == 0 )
delete m_AssociatedScreen; delete m_AssociatedScreen;
} }
} }
...@@ -692,14 +692,14 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame ) ...@@ -692,14 +692,14 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
if( screen ) if( screen )
{ {
m_AssociatedScreen = screen; m_AssociatedScreen = screen;
m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->IncRefCount();
//do not need to load the sub-sheets - this has already been done. //do not need to load the sub-sheets - this has already been done.
} }
else else
{ {
m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->IncRefCount();
success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
if( success ) if( success )
...@@ -790,9 +790,9 @@ current sheet data if possible)?" ), ...@@ -790,9 +790,9 @@ current sheet data if possible)?" ),
// Can be NULL if loading a file when creating a new sheet. // Can be NULL if loading a file when creating a new sheet.
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
m_AssociatedScreen->m_RefCount--; // be careful with these m_AssociatedScreen->DecRefCount(); // be careful with these
if( m_AssociatedScreen->m_RefCount == 0 ) if( m_AssociatedScreen->GetRefCount() == 0 )
SAFE_DELETE( m_AssociatedScreen ); SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // will be created later m_AssociatedScreen = NULL; // will be created later
...@@ -802,7 +802,7 @@ current sheet data if possible)?" ), ...@@ -802,7 +802,7 @@ current sheet data if possible)?" ),
// if an associated screen exists, shared between this sheet and others // if an associated screen exists, shared between this sheet and others
// sheets, what we do ? // sheets, what we do ?
if( m_AssociatedScreen && ( m_AssociatedScreen->m_RefCount > 1 ) ) if( m_AssociatedScreen && ( m_AssociatedScreen->GetRefCount() > 1 ) )
{ {
msg = _( "This sheet uses shared data in a complex hierarchy" ); msg = _( "This sheet uses shared data in a complex hierarchy" );
msg << wxT( "\n" ); msg << wxT( "\n" );
...@@ -817,8 +817,8 @@ otherwise delete current sheet data)" ); ...@@ -817,8 +817,8 @@ otherwise delete current sheet data)" );
aFrame->SaveEEFile( m_AssociatedScreen, FILE_SAVE_AS ); aFrame->SaveEEFile( m_AssociatedScreen, FILE_SAVE_AS );
m_AssociatedScreen->m_FileName = oldfilename; m_AssociatedScreen->m_FileName = oldfilename;
} }
m_AssociatedScreen->m_RefCount--; //be careful with these m_AssociatedScreen->DecRefCount(); //be careful with these
m_AssociatedScreen = NULL; //will be created later m_AssociatedScreen = NULL; //will be created later
} }
SetFileName( aFileName ); SetFileName( aFileName );
...@@ -827,9 +827,9 @@ otherwise delete current sheet data)" ); ...@@ -827,9 +827,9 @@ otherwise delete current sheet data)" );
// current sheet data // current sheet data
if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) ) if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) )
{ {
m_AssociatedScreen->m_RefCount--; m_AssociatedScreen->DecRefCount();
if( m_AssociatedScreen->m_RefCount == 0 ) if( m_AssociatedScreen->GetRefCount() == 0 )
SAFE_DELETE( m_AssociatedScreen ); SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // so that we reload.. m_AssociatedScreen = NULL; // so that we reload..
...@@ -840,14 +840,14 @@ otherwise delete current sheet data)" ); ...@@ -840,14 +840,14 @@ otherwise delete current sheet data)" );
else if( Screen_to_use ) else if( Screen_to_use )
{ {
m_AssociatedScreen = Screen_to_use; m_AssociatedScreen = Screen_to_use;
m_AssociatedScreen->m_RefCount++; m_AssociatedScreen->IncRefCount();
} }
//just make a new screen if needed. //just make a new screen if needed.
if( !m_AssociatedScreen ) if( !m_AssociatedScreen )
{ {
m_AssociatedScreen = new SCH_SCREEN(); m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->m_RefCount++; // be careful with these m_AssociatedScreen->IncRefCount(); // be careful with these
} }
m_AssociatedScreen->m_FileName = aFileName; m_AssociatedScreen->m_FileName = aFileName;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_component.h" #include "sch_component.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_sheet.h" #include "sch_sheet.h"
...@@ -161,14 +161,14 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -161,14 +161,14 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
case ID_HIERARCHY: case ID_HIERARCHY:
InstallHierarchyFrame( &dc, pos ); InstallHierarchyFrame( &dc, pos );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
break; break;
case wxID_CUT: case wxID_CUT:
if( screen->m_BlockLocate.m_Command != BLOCK_MOVE ) if( screen->m_BlockLocate.m_Command != BLOCK_MOVE )
break; break;
HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
SetSheetNumberAndCount(); SetSheetNumberAndCount();
break; break;
...@@ -316,7 +316,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -316,7 +316,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE ); DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
TestDanglingEnds( screen->GetDrawItems(), &dc ); TestDanglingEnds( screen->GetDrawItems(), &dc );
DrawPanel->Refresh(); DrawPanel->Refresh();
break; break;
...@@ -352,7 +352,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -352,7 +352,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DeleteStruct( DrawPanel, &dc, item ); DeleteStruct( DrawPanel, &dc, item );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
TestDanglingEnds( screen->GetDrawItems(), &dc ); TestDanglingEnds( screen->GetDrawItems(), &dc );
SetSheetNumberAndCount(); SetSheetNumberAndCount();
OnModify(); OnModify();
...@@ -757,7 +757,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -757,7 +757,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// End switch ( id ) (Command execution) // End switch ( id ) (Command execution)
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
SetToolbars(); SetToolbars();
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "protos.h" #include "protos.h"
#include "sch_bus_entry.h" #include "sch_bus_entry.h"
#include "sch_marker.h" #include "sch_marker.h"
#include "sch_items.h" #include "sch_junction.h"
#include "sch_line.h" #include "sch_line.h"
#include "sch_no_connect.h" #include "sch_no_connect.h"
#include "sch_component.h" #include "sch_component.h"
......
...@@ -181,7 +181,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, ...@@ -181,7 +181,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
SetIcon( wxICON( icon_eeschema ) ); SetIcon( wxICON( icon_eeschema ) );
#endif #endif
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
/* Get config */ /* Get config */
LoadSettings(); LoadSettings();
...@@ -329,7 +329,7 @@ void SCH_EDIT_FRAME::CreateScreens() ...@@ -329,7 +329,7 @@ void SCH_EDIT_FRAME::CreateScreens()
if( g_RootSheet->m_AssociatedScreen == NULL ) if( g_RootSheet->m_AssociatedScreen == NULL )
{ {
g_RootSheet->m_AssociatedScreen = new SCH_SCREEN(); g_RootSheet->m_AssociatedScreen = new SCH_SCREEN();
g_RootSheet->m_AssociatedScreen->m_RefCount++; g_RootSheet->m_AssociatedScreen->IncRefCount();
} }
g_RootSheet->m_AssociatedScreen->m_FileName = m_DefaultSchematicFileName; g_RootSheet->m_AssociatedScreen->m_FileName = m_DefaultSchematicFileName;
......
...@@ -213,7 +213,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC ) ...@@ -213,7 +213,7 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
/* Create hierarchy sheet. */ /* Create hierarchy sheet. */
SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
{ {
g_ItemToRepeat = NULL; m_itemToRepeat = NULL;
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur ); SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->m_Curseur );
......
...@@ -22,6 +22,9 @@ class SCH_SHEET_PIN; ...@@ -22,6 +22,9 @@ class SCH_SHEET_PIN;
class SCH_SCREEN : public BASE_SCREEN class SCH_SCREEN : public BASE_SCREEN
{ {
int m_refCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero.
/** /**
* Function addConnectedItemsToBlock * Function addConnectedItemsToBlock
* add items connected at \a aPosition to the block pick list. * add items connected at \a aPosition to the block pick list.
...@@ -35,9 +38,6 @@ class SCH_SCREEN : public BASE_SCREEN ...@@ -35,9 +38,6 @@ class SCH_SCREEN : public BASE_SCREEN
void addConnectedItemsToBlock( const wxPoint& aPosition ); void addConnectedItemsToBlock( const wxPoint& aPosition );
public: public:
int m_RefCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero.
SCH_SCREEN( KICAD_T aType = SCH_SCREEN_T ); SCH_SCREEN( KICAD_T aType = SCH_SCREEN_T );
~SCH_SCREEN(); ~SCH_SCREEN();
...@@ -46,6 +46,12 @@ public: ...@@ -46,6 +46,12 @@ public:
return wxT( "SCH_SCREEN" ); return wxT( "SCH_SCREEN" );
} }
void DecRefCount();
void IncRefCount() { m_refCount++; }
int GetRefCount() const { return m_refCount; }
/** /**
* Function GetDrawItems(). * Function GetDrawItems().
* *
......
...@@ -93,6 +93,8 @@ private: ...@@ -93,6 +93,8 @@ private:
wxArrayString m_findStringHistoryList; wxArrayString m_findStringHistoryList;
wxArrayString m_replaceStringHistoryList; wxArrayString m_replaceStringHistoryList;
BLOCK_SELECTOR m_blockItems; ///< List of selected items. BLOCK_SELECTOR m_blockItems; ///< List of selected items.
SCH_ITEM* m_itemToRepeat; ///< Last item to insert by the repeat command.
int m_repeatLabelDelta; ///< Repeat label number increment step.
public: public:
SCH_EDIT_FRAME( wxWindow* father, SCH_EDIT_FRAME( wxWindow* father,
...@@ -500,6 +502,8 @@ public: ...@@ -500,6 +502,8 @@ public:
void DeleteSheetLabel( bool aRedraw, void DeleteSheetLabel( bool aRedraw,
SCH_SHEET_PIN* aSheetLabelToDel ); SCH_SHEET_PIN* aSheetLabelToDel );
int GetLabelIncrement() const { return m_repeatLabelDelta; }
private: private:
// Component // Component
...@@ -653,6 +657,8 @@ public: ...@@ -653,6 +657,8 @@ public:
void RepeatDrawItem( wxDC* DC ); void RepeatDrawItem( wxDC* DC );
void SetRepeatItem( SCH_ITEM* aItem ) { m_itemToRepeat = aItem; }
void TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ); void TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC );
// ERC: // ERC:
......
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