Begin schematic object rationalization and other minor improvements

This commit is contained in:
Wayne Stambaugh 2010-10-26 16:25:48 -04:00
parent 704e3c5133
commit 1e7d95d58e
43 changed files with 499 additions and 724 deletions

View File

@ -4,6 +4,22 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-oct-26 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
* Change screen list object array type from wxARRAY to std::vector.
* Move all SCH_SCREEN methods into file class_sch_screen.cpp.
* Move find dialog files to dialogs sub-directory.
* Remove hallucinatory save and restore methods I wrote from component
library draw objects.
* Merge external TstAlignSegment function to SCH_LINE::MergeOverlap method.
* Move save schematic method to files-io.cpp and remove empty file
save_schemas.cpp.
++include
* Remove unused internal link list next and back methods from base screen
object.
2010-oct-25 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema

View File

@ -231,7 +231,7 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings(wxCommandEvent& event)
/* Exports settings to other sheets if requested: */
SCH_SCREEN * screen;
/* Build the screen list */
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
/* Update the datas */
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{

View File

@ -15,7 +15,7 @@
#include "general.h"
#include "protos.h"
#include "../eeschema/dialog_schematic_find.h"
#include "../eeschema/dialogs/dialog_schematic_find.h"
/* Constructor and destructor for SCH_ITEM */

View File

@ -73,8 +73,8 @@ set(EESCHEMA_SRCS
dialog_print_using_printer.cpp
dialog_sch_sheet_props.cpp
dialog_sch_sheet_props_base.cpp
dialog_schematic_find.cpp
dialog_schematic_find_base.cpp
dialogs/dialog_schematic_find.cpp
dialogs/dialog_schematic_find_base.cpp
dialog_SVG_print.cpp
dialog_SVG_print_base.cpp
edit_component_in_lib.cpp
@ -123,7 +123,6 @@ set(EESCHEMA_SRCS
pinedit.cpp
plot.cpp
read_from_file_schematic_items_descriptions.cpp
save_schemas.cpp
schedit.cpp
schematic_undo_redo.cpp
schframe.cpp

View File

@ -36,7 +36,7 @@ static int ReplaceDuplicatedTimeStamps();
void WinEDA_SchematicFrame::UpdateSheetNumberAndDate()
{
wxString date = GenDate();
EDA_ScreenList s_list;
SCH_SCREENS s_list;
// Set the date
for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL;
@ -206,7 +206,7 @@ void WinEDA_SchematicFrame::DeleteAnnotation( bool aCurrentSheetOnly,
{
SCH_ITEM* strct;
SCH_SCREEN* screen;
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
screen = ScreenList.GetFirst();
@ -989,7 +989,7 @@ static bool SortItemByTimeStamp( const SCH_ITEM* item1, const SCH_ITEM* item2 )
int ReplaceDuplicatedTimeStamps()
{
/* Build the whole screen list */
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
/* Build the list of items with time stamps (components and sheets)
* note: if all items have a different time stamp, this ensure also

View File

@ -29,52 +29,6 @@ SCH_ITEM* s_OldWiresList;
wxPoint s_ConnexionStartPoint;
/* Extract the old wires, junctions and buses, an if CreateCopy replace them
* by a copy. Old ones must be put in undo list, and the new ones can be
* modified by clean up safely.
* If an abort command is made, old wires must be put in EEDrawList, and
* copies must be deleted. This is because previously stored undo commands
* can handle pointers on wires or bus, and we do not delete wires or bus,
* we must put they in undo list.
*
* Because cleanup delete and/or modify bus and wires, the more easy is to put
* all wires in undo list and use a new copy of wires for cleanup.
*/
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{
SCH_ITEM* item, * next_item, * new_item, * List = NULL;
for( item = EEDrawList; item != NULL; item = next_item )
{
next_item = item->Next();
switch( item->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
RemoveFromDrawList( item );
item->SetNext( List );
List = item;
if( CreateCopy )
{
if( item->Type() == DRAW_JUNCTION_STRUCT_TYPE )
new_item = ( (SCH_JUNCTION*) item )->GenCopy();
else
new_item = ( (SCH_LINE*) item )->GenCopy();
new_item->SetNext( EEDrawList );
EEDrawList = new_item;
}
break;
default:
break;
}
}
return List;
}
/* Replace the wires in screen->EEDrawList by s_OldWiresList wires.
*/
static void RestoreOldWires( SCH_SCREEN* screen )

View File

@ -14,7 +14,7 @@
#include "general.h"
#include "dlist.h"
#include "dialog_schematic_find.h"
#include "dialogs/dialog_schematic_find.h"
/**********************************************/

View File

@ -14,7 +14,7 @@
#include "macros.h"
#include "protos.h"
#include "class_library.h"
#include "dialog_schematic_find.h"
#include "dialogs/dialog_schematic_find.h"
#include "lib_rectangle.h"
#include "lib_pin.h"
#include "lib_text.h"

View File

@ -2,12 +2,15 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "kicad_string.h"
#include "eeschema_id.h"
#include "appl_wxstruct.h"
#include "class_drawpanel.h"
#include "program.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
@ -46,8 +49,7 @@ static int SchematicZoomList[] =
5, 7, 10, 15, 20, 30, 40, 60, 80, 120, 160, 230, 320, 480, 640, 800, 1280
};
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / \
sizeof( int ) )
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / sizeof( int ) )
#define MM_TO_SCH_UNITS 1000.0 / 25.4 //schematic internal unites are mils
@ -57,7 +59,7 @@ static int SchematicZoomList[] =
* because wires and pins are considered as connected when the are to the same coordinate
* we cannot mix coordinates in mils (internal units) and mm
* (that cannot exactly converted in mils in many cases
* in fact schematic must only use 50 and 25 mils to place labnels, wires and components
* in fact schematic must only use 50 and 25 mils to place labels, wires and components
* others values are useful only for graphic items (mainly in library editor)
* so use integer values in mils only.
*/
@ -70,8 +72,7 @@ static GRID_TYPE SchematicGridList[] = {
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
};
#define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / \
sizeof( GRID_TYPE ) )
#define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / sizeof( GRID_TYPE ) )
SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
@ -103,8 +104,6 @@ SCH_SCREEN::~SCH_SCREEN()
}
/* Routine to clear (free) EESchema drawing list of a screen.
*/
void SCH_SCREEN::FreeDrawList()
{
SCH_ITEM* DrawStruct;
@ -165,68 +164,265 @@ void SCH_SCREEN::AddToDrawList( SCH_ITEM* st )
}
/*********************************************************************/
/* Class EDA_ScreenList to handle the list of screens in a hierarchy */
/*********************************************************************/
EDA_ScreenList::EDA_ScreenList()
/* Extract the old wires, junctions and buses, an if CreateCopy replace them
* by a copy. Old ones must be put in undo list, and the new ones can be
* modified by clean up safely.
* If an abort command is made, old wires must be put in EEDrawList, and
* copies must be deleted. This is because previously stored undo commands
* can handle pointers on wires or bus, and we do not delete wires or bus,
* we must put they in undo list.
*
* Because cleanup delete and/or modify bus and wires, the more easy is to put
* all wires in undo list and use a new copy of wires for cleanup.
*/
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{
m_Index = 0;
SCH_ITEM* item, * next_item, * new_item, * List = NULL;
for( item = EEDrawList; item != NULL; item = next_item )
{
next_item = item->Next();
switch( item->Type() )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
RemoveFromDrawList( item );
item->SetNext( List );
List = item;
if( CreateCopy )
{
if( item->Type() == DRAW_JUNCTION_STRUCT_TYPE )
new_item = ( (SCH_JUNCTION*) item )->GenCopy();
else
new_item = ( (SCH_LINE*) item )->GenCopy();
new_item->SetNext( EEDrawList );
EEDrawList = new_item;
}
break;
default:
break;
}
}
return List;
}
/* Routine cleaning:
* - Includes segments or buses aligned in only 1 segment
* - Detects identical objects superimposed
*/
bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{
SCH_ITEM* DrawList, * TstDrawList;
bool Modify = FALSE;
DrawList = EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
TstDrawList = DrawList->Next();
while( TstDrawList )
{
if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
SCH_LINE* line = (SCH_LINE*) DrawList;
if( line->MergeOverlap( (SCH_LINE*) TstDrawList ) )
{
/* keep the bits set in .m_Flags, because the deleted
* segment can be flagged */
DrawList->m_Flags |= TstDrawList->m_Flags;
EraseStruct( TstDrawList, this );
SetRefreshReq();
TstDrawList = EEDrawList;
Modify = TRUE;
}
else
{
TstDrawList = TstDrawList->Next();
}
}
else
{
TstDrawList = TstDrawList->Next();
}
}
}
}
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->TestDanglingEnds( EEDrawList, DC );
return Modify;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_SCREEN::Save( FILE* aFile ) const
{
// Creates header
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0
|| fprintf( aFile, " date %s\n", CONV_TO_UTF8( DateAndTime() ) ) < 0 )
return FALSE;
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{
if( fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( lib.GetName() ) ) < 0 )
return FALSE;
}
if( fprintf( aFile, "EELAYER %2d %2d\n", g_LayerDescr.NumberOfLayers,
g_LayerDescr.CurrentLayer ) < 0
|| fprintf( aFile, "EELAYER END\n" ) < 0 )
return FALSE;
/* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for
* SheetNumber and Sheet Count in a complex hierarchy, but useful in
* simple hierarchy and flat hierarchy. Used also to search the root
* sheet ( ScreenNumber = 1 ) within the files
*/
if( fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( m_CurrentSheetDesc->m_Name ),
m_CurrentSheetDesc->m_Size.x, m_CurrentSheetDesc->m_Size.y ) < 0
|| fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ) < 0
|| fprintf( aFile, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) ) < 0
|| fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) ) < 0
|| fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) ) < 0
|| fprintf( aFile, "Comp \"%s\"\n", CONV_TO_UTF8( m_Company ) ) < 0
|| fprintf( aFile, "Comment1 \"%s\"\n", CONV_TO_UTF8( m_Commentaire1 ) ) < 0
|| fprintf( aFile, "Comment2 \"%s\"\n", CONV_TO_UTF8( m_Commentaire2 ) ) < 0
|| fprintf( aFile, "Comment3 \"%s\"\n", CONV_TO_UTF8( m_Commentaire3 ) ) < 0
|| fprintf( aFile, "Comment4 \"%s\"\n", CONV_TO_UTF8( m_Commentaire4 ) ) < 0
|| fprintf( aFile, "$EndDescr\n" ) < 0 )
return FALSE;
for( SCH_ITEM* item = EEDrawList; item; item = item->Next() )
{
if( !item->Save( aFile ) )
return FALSE;
}
if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 )
return FALSE;
return TRUE;
}
/** Function ClearUndoORRedoList
* free the undo or redo list from List element
* Wrappers are deleted.
* datas pointed by wrappers are deleted if not in use in schematic
* i.e. when they are copy of a schematic item or they are no more in use
* (DELETED)
* @param aList = the UNDO_REDO_CONTAINER to clear
* @param aItemCount = the count of items to remove. < 0 for all items
* items (commands stored in list) are removed from the beginning of the list.
* So this function can be called to remove old commands
*/
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
{
if( aItemCount == 0 )
return;
unsigned icnt = aList.m_CommandsList.size();
if( aItemCount > 0 )
icnt = aItemCount;
for( unsigned ii = 0; ii < icnt; ii++ )
{
if( aList.m_CommandsList.size() == 0 )
break;
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
curr_cmd->ClearListAndDeleteItems();
delete curr_cmd; // Delete command
}
}
/******************************************************************/
/* Class SCH_SCREENS to handle the list of screens in a hierarchy */
/******************************************************************/
SCH_SCREENS::SCH_SCREENS()
{
m_index = 0;
BuildScreenList( g_RootSheet );
}
SCH_SCREEN* EDA_ScreenList::GetFirst()
SCH_SCREENS::~SCH_SCREENS()
{
m_Index = 0;
if( m_List.GetCount() > 0 )
return m_List[0];
}
SCH_SCREEN* SCH_SCREENS::GetFirst()
{
m_index = 0;
if( m_screens.size() > 0 )
return m_screens[0];
return NULL;
}
SCH_SCREEN* EDA_ScreenList::GetNext()
SCH_SCREEN* SCH_SCREENS::GetNext()
{
if( m_Index < m_List.GetCount() )
m_Index++;
return GetScreen( m_Index );
if( m_index < m_screens.size() )
m_index++;
return GetScreen( m_index );
}
/* return the m_List[index] item
*/
SCH_SCREEN* EDA_ScreenList::GetScreen( unsigned int index )
SCH_SCREEN* SCH_SCREENS::GetScreen( unsigned int aIndex )
{
if( index < m_List.GetCount() )
return m_List[index];
if( aIndex < m_screens.size() )
return m_screens[ aIndex ];
return NULL;
}
void EDA_ScreenList::AddScreenToList( SCH_SCREEN* testscreen )
void SCH_SCREENS::AddScreenToList( SCH_SCREEN* aScreen )
{
if( testscreen == NULL )
if( aScreen == NULL )
return;
for( unsigned int i = 0; i< m_List.GetCount(); i++ )
for( unsigned int i = 0; i < m_screens.size(); i++ )
{
if( m_List[i] == testscreen )
if( m_screens[i] == aScreen )
return;
}
m_List.Add( testscreen );
m_screens.push_back( aScreen );
}
void EDA_ScreenList::BuildScreenList( EDA_BaseStruct* s )
void SCH_SCREENS::BuildScreenList( EDA_BaseStruct* aItem )
{
if( s && s->Type() == DRAW_SHEET_STRUCT_TYPE )
if( aItem && aItem->Type() == DRAW_SHEET_STRUCT_TYPE )
{
SCH_SHEET* ds = (SCH_SHEET*) s;
s = ds->m_AssociatedScreen;
SCH_SHEET* ds = (SCH_SHEET*) aItem;
aItem = ds->m_AssociatedScreen;
}
if( s && s->Type() == SCREEN_STRUCT_TYPE )
if( aItem && aItem->Type() == SCREEN_STRUCT_TYPE )
{
SCH_SCREEN* screen = (SCH_SCREEN*) s;
SCH_SCREEN* screen = (SCH_SCREEN*) aItem;
AddScreenToList( screen );
EDA_BaseStruct* strct = screen->EEDrawList;
while( strct )

View File

@ -295,8 +295,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
// XML output:
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
<< m_Pos << "/>\n";
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_Pos << "/>\n";
}
@ -517,8 +516,7 @@ EDA_Rect SCH_LINE::GetBoundingBox()
int ymax = MAX( m_Start.y, m_End.y ) + width;
// return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_Rect ret( wxPoint( xmin, ymin ),
wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
return ret;
}
@ -631,6 +629,70 @@ void SCH_LINE::Rotate( wxPoint rotationPoint )
}
bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
{
wxCHECK_MSG( aLine != NULL && aLine->Type() == DRAW_SEGMENT_STRUCT_TYPE, false,
wxT( "Cannot test line segment for overlap." ) );
if( this == aLine )
return false;
if( GetLayer() != aLine->GetLayer() )
return false;
// Search for a common end, and modify coordinates to ensure RefSegm->m_End
// == TstSegm->m_Start
if( m_Start == aLine->m_Start )
{
if( m_End == aLine->m_End )
return true;
EXCHG( m_Start, aLine->m_End );
}
else if( m_Start == aLine->m_End )
{
EXCHG( m_Start, m_End );
EXCHG( aLine->m_Start, aLine->m_End );
}
else if( m_End == aLine->m_End )
{
EXCHG( aLine->m_Start, aLine->m_End );
}
else if( m_End != aLine->m_Start )
// No common end point, segments cannot be merged.
return false;
/* Test alignment: */
if( m_Start.y == m_End.y ) // Horizontal segment
{
if( aLine->m_Start.y == aLine->m_End.y )
{
m_End = aLine->m_End;
return true;
}
}
else if( m_Start.x == m_End.x ) // Vertical segment
{
if( aLine->m_Start.x == aLine->m_End.x )
{
m_End = aLine->m_End;
return true;
}
}
else
{
if( atan2( (double) ( m_Start.x - m_End.x ), (double) ( m_Start.y - m_End.y ) )
== atan2( (double) ( aLine->m_Start.x - aLine->m_End.x ),
(double) ( aLine->m_Start.y - aLine->m_End.y ) ) )
{
m_End = aLine->m_End;
return true;
}
}
return false;
}
/***********************/
/* Class SCH_POLYLINE */
/***********************/
@ -686,15 +748,13 @@ bool SCH_POLYLINE::Save( FILE* aFile ) const
layer = "Wire";
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n",
width, layer, GetCornerCount() ) == EOF )
if( fprintf( aFile, "Poly %s %s %d\n", width, layer, GetCornerCount() ) == EOF )
{
return false;
}
for( unsigned ii = 0; ii < GetCornerCount(); ii++ )
{
if( fprintf( aFile, "\t%-4d %-4d\n",
m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF )
if( fprintf( aFile, "\t%-4d %-4d\n", m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF )
{
success = false;
break;

View File

@ -96,6 +96,18 @@ public:
virtual void Mirror_Y( int aYaxis_position );
virtual void Rotate( wxPoint rotationPoint );
/**
* Check line against \a aLine to see if it overlaps and merge if it does.
*
* This method will change the line to be equivalent of the line and \a aLine if the
* two lines overlap. This method is used to merge multple line segments into a single
* line.
*
* @param aLine - Line to compare.
* @retuen True if lines overlap and the line was merged with \a aLine.
*/
bool MergeOverlap( SCH_LINE* aLine );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );

View File

@ -3,7 +3,6 @@
/**************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "trigo.h"
#include "confirm.h"
@ -15,58 +14,6 @@
#include "netlist.h"
static int TstAlignSegment( SCH_LINE* RefSegm, SCH_LINE* TstSegm );
/* Routine cleaning:
* - Includes segments or buses aligned in only 1 segment
* - Detects identical objects superimposed
*/
bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{
SCH_ITEM* DrawList, * TstDrawList;
int flag;
bool Modify = FALSE;
DrawList = EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
TstDrawList = DrawList->Next();
while( TstDrawList )
{
if( TstDrawList->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
flag = TstAlignSegment( (SCH_LINE*) DrawList,
(SCH_LINE*) TstDrawList );
if( flag )
{
/* keep the bits set in .m_Flags, because the deleted
* segment can be flagged */
DrawList->m_Flags |= TstDrawList->m_Flags;
EraseStruct( TstDrawList, this );
SetRefreshReq();
TstDrawList = EEDrawList;
Modify = TRUE;
}
else
TstDrawList = TstDrawList->Next();
}
else
TstDrawList = TstDrawList->Next();
}
}
}
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->TestDanglingEnds( EEDrawList, DC );
return Modify;
}
/* Routine to start/end segment (BUS or wires) on junctions.
*/
void BreakSegmentOnJunction( SCH_SCREEN* Screen )
@ -155,68 +102,3 @@ void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint )
DrawList = NewSegment;
}
}
/* Search if the 2 segments RefSegm and TstSegm are on a line.
* Return 0 if no
* 1 if yes, and RefSegm is modified to be the equivalent segment
*/
static int TstAlignSegment( SCH_LINE* RefSegm, SCH_LINE* TstSegm )
{
if( RefSegm == TstSegm )
return 0;
if( RefSegm->GetLayer() != TstSegm->GetLayer() )
return 0;
// search for a common end, and modify coordinates to ensure RefSegm->m_End
// == TstSegm->m_Start
if( RefSegm->m_Start == TstSegm->m_Start )
{
if( RefSegm->m_End == TstSegm->m_End )
return 1;
EXCHG( RefSegm->m_Start, RefSegm->m_End );
}
else if( RefSegm->m_Start == TstSegm->m_End )
{
EXCHG( RefSegm->m_Start, RefSegm->m_End );
EXCHG( TstSegm->m_Start, TstSegm->m_End );
}
else if( RefSegm->m_End == TstSegm->m_End )
{
EXCHG( TstSegm->m_Start, TstSegm->m_End );
}
else if( RefSegm->m_End != TstSegm->m_Start )
// No common end point, segments cannot be merged.
return 0;
/* Test alignment: */
if( RefSegm->m_Start.y == RefSegm->m_End.y ) // Horizontal segment
{
if( TstSegm->m_Start.y == TstSegm->m_End.y )
{
RefSegm->m_End = TstSegm->m_End;
return 1;
}
}
else if( RefSegm->m_Start.x == RefSegm->m_End.x ) // Vertical segment
{
if( TstSegm->m_Start.x == TstSegm->m_End.x )
{
RefSegm->m_End = TstSegm->m_End;
return 1;
}
}
else
{
if( atan2( (double) ( RefSegm->m_Start.x - RefSegm->m_End.x ),
(double) ( RefSegm->m_Start.y - RefSegm->m_End.y ) ) ==
atan2( (double) ( TstSegm->m_Start.x - TstSegm->m_End.x ),
(double) ( TstSegm->m_Start.y - TstSegm->m_End.y ) ) )
{
RefSegm->m_End = TstSegm->m_End;
return 1;
}
}
return 0;
}

View File

@ -438,8 +438,7 @@ void DeleteAllMarkers( int type )
SCH_SCREEN* screen;
SCH_ITEM * DrawStruct, * NextStruct;
SCH_MARKER* Marker;
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
for( screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )

View File

@ -185,7 +185,7 @@ static int MinimalReq[PIN_NMAX][PIN_NMAX] =
int TestDuplicateSheetNames(bool aCreateMarker)
{
int err_count = 0;
EDA_ScreenList ScreenList; // Created the list of screen
SCH_SCREENS ScreenList; // Created the list of screen
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;
@ -270,7 +270,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
g_EESchemaVar.NbWarningErc = 0;
/* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;

View File

@ -17,6 +17,86 @@
/*****************************************************************************
* Routine to save an EESchema file. *
* FileSave controls how the file is to be saved - under what name. *
* Returns TRUE if the file has been saved. *
*****************************************************************************/
bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave )
{
wxString msg;
wxFileName schematicFileName, backupFileName;
FILE* f;
if( screen == NULL )
screen = (SCH_SCREEN*) GetScreen();
/* If no name exists in the window yet - save as new. */
if( screen->m_FileName.IsEmpty() )
FileSave = FILE_SAVE_NEW;
switch( FileSave )
{
case FILE_SAVE_AS:
schematicFileName = screen->m_FileName;
backupFileName = schematicFileName;
/* Rename the old file to a '.bak' one: */
if( schematicFileName.FileExists() )
{
backupFileName.SetExt( wxT( "bak" ) );
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
DisplayError( this, wxT( "Warning: unable to rename old file" ) );
}
}
break;
case FILE_SAVE_NEW:
{
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
screen->m_FileName, SchematicFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
screen->m_FileName = dlg.GetPath();
schematicFileName = dlg.GetPath();
break;
}
default:
break;
}
if( ( f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
msg = _( "Failed to create file " ) + schematicFileName.GetFullPath();
DisplayError( this, msg );
return false;
}
if( FileSave == FILE_SAVE_NEW )
screen->m_FileName = schematicFileName.GetFullPath();
bool success = screen->Save( f );
if( !success )
DisplayError( this, _( "File write operation failed." ) );
else
screen->ClrModify();
fclose( f );
return success;
}
/* Commands to save project or the current page.
*/
void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
@ -55,8 +135,7 @@ bool WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsN
SCH_SCREEN* screen;
wxString FullFileName, msg;
bool LibCacheExist = false;
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
@ -232,7 +311,7 @@ void WinEDA_SchematicFrame::SaveProject()
{
SCH_SCREEN* screen;
wxFileName fn;
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
for( screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )

View File

@ -26,7 +26,7 @@
#include <boost/foreach.hpp>
#include "dialog_schematic_find.h"
#include "dialogs/dialog_schematic_find.h"
void WinEDA_SchematicFrame::OnFindDrcMarker( wxFindDialogEvent& event )

View File

@ -13,7 +13,7 @@
#include "libeditframe.h"
#include "class_libentry.h"
#include "dialog_schematic_find.h"
#include "dialogs/dialog_schematic_find.h"
/* How to add a new hotkey:

View File

@ -423,26 +423,6 @@ void LIB_ARC::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& a
}
void LIB_ARC::saveAttributes()
{
m_savedPos = m_Pos;
m_savedStartPos = m_ArcStart;
m_savedEndPos = m_ArcEnd;
m_savedAngle1 = m_t1;
m_savedAngle2 = m_t2;
}
void LIB_ARC::restoreAttributes()
{
m_Pos = m_savedPos;
m_ArcStart = m_savedStartPos;
m_ArcEnd = m_savedEndPos;
m_t1 = m_savedAngle1;
m_t2 = m_savedAngle2;
}
EDA_Rect LIB_ARC::GetBoundingBox()
{
int minX, minY, maxX, maxY, angleStart, angleEnd;
@ -535,14 +515,10 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
saveAttributes();
SetEraseLastDrawItem();
}
else
{
// Save the current arc positions in case the resize is aborted.
saveAttributes();
// The arc center point has to be rotated with while adjusting the
// start or end point, determine the side of this point and the distance
// from the start / end point
@ -600,9 +576,6 @@ void LIB_ARC::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_ARC is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
SetEraseLastDrawItem( false );
m_lastEditState = 0;
m_editState = 0;

View File

@ -28,10 +28,6 @@ class LIB_ARC : public LIB_DRAW_ITEM
wxPoint m_ArcEnd; /* Arc end position. */
wxPoint m_Pos; /* Radius center point. */
int m_Width; /* Line width */
wxPoint m_savedStartPos;
wxPoint m_savedEndPos;
int m_savedAngle1;
int m_savedAngle2;
double m_editCenterDistance;
SELECT_T m_editSelectPoint;
int m_editState;
@ -49,16 +45,6 @@ class LIB_ARC : public LIB_DRAW_ITEM
*/
void drawEditGraphics( EDA_Rect* aClipBox, wxDC* aDC, int aColor );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculates the center, radius, and angles at \a aPosition when the arc is being edited.
*

View File

@ -236,20 +236,6 @@ void LIB_CIRCLE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint
}
void LIB_CIRCLE::saveAttributes()
{
m_savedPos = m_Pos;
m_savedRadius = m_Radius;
}
void LIB_CIRCLE::restoreAttributes()
{
m_Pos = m_savedPos;
m_Radius = m_savedRadius;
}
EDA_Rect LIB_CIRCLE::GetBoundingBox()
{
EDA_Rect rect;
@ -296,12 +282,10 @@ void LIB_CIRCLE::BeginEdit( int aEditMode, const wxPoint aPosition )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
saveAttributes();
SetEraseLastDrawItem();
}
else if( aEditMode == IS_RESIZED )
{
saveAttributes();
SetEraseLastDrawItem();
}
@ -323,9 +307,6 @@ void LIB_CIRCLE::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_CIRCLE is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
SetEraseLastDrawItem( false );
m_Flags = 0;
}

View File

@ -15,24 +15,12 @@ class LIB_CIRCLE : public LIB_DRAW_ITEM
wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments).
int m_Width; // Line width.
int m_savedRadius; // Temporary storage of radius before editing begins.
/**
* Draws the arc.
*/
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculate the new circle at \a aPosition when editing.
*

View File

@ -79,19 +79,6 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct
*/
virtual void calcEdit( const wxPoint& aPosition ) {}
/**
* Save the current item attributes while editing.
*
* This method is used to save the drawing attributes of the item during editing.
* These values are restored when an edit is canceled by calling EndEdit().
*/
virtual void saveAttributes() {}
/**
* Restore the saved attributes when an existing item edit is cancelled.
*/
virtual void restoreAttributes() {}
bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing
///< artifacts.
@ -119,7 +106,6 @@ protected:
wxString m_typeName; ///< Name of object displayed in the message panel.
wxPoint m_savedPos; ///< Temporary position when editing an existing item.
wxPoint m_initialPos; ///< Temporary position when moving an existing item.
wxPoint m_initialCursorPos; ///< Initial cursor position at the beginning of a move.

View File

@ -343,22 +343,6 @@ void LIB_FIELD::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint&
}
void LIB_FIELD::saveAttributes()
{
m_savedPos = m_Pos;
m_savedText = m_Text;
m_savedOrientation = m_Orient;
}
void LIB_FIELD::restoreAttributes()
{
m_Pos = m_savedPos;
m_Text = m_savedText;
m_Orient = m_savedOrientation;
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
@ -661,7 +645,6 @@ void LIB_FIELD::BeginEdit( int aEditMode, const wxPoint aPosition )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
saveAttributes();
SetEraseLastDrawItem();
}
else
@ -687,9 +670,6 @@ void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Bad call to EndEdit(). Text is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
m_Flags = 0;
m_rotate = false;
m_updateText = false;

View File

@ -19,7 +19,6 @@
class LIB_FIELD : public LIB_DRAW_ITEM, public EDA_TextStruct
{
wxString m_savedText; ///< Temporary storage for the string when edition.
int m_savedOrientation; ///< Temporary storage for orientation when editing.
bool m_rotate; ///< Flag to indicate a rotation occurred while editing.
bool m_updateText; ///< Flag to indicate text change occurred while editing.
@ -29,16 +28,6 @@ class LIB_FIELD : public LIB_DRAW_ITEM, public EDA_TextStruct
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculate the new circle at \a aPosition when editing.
*

View File

@ -308,18 +308,6 @@ void LIB_POLYLINE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoi
}
void LIB_POLYLINE::saveAttributes()
{
m_savedPolyPoints = m_PolyPoints;
}
void LIB_POLYLINE::restoreAttributes()
{
m_PolyPoints = m_savedPolyPoints;
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
@ -433,8 +421,6 @@ void LIB_POLYLINE::BeginEdit( int aEditMode, const wxPoint aPosition )
}
else if( aEditMode == IS_RESIZED )
{
saveAttributes();
// Drag one edge point of the polyline
// Find the nearest edge point to be dragged
wxPoint startPoint = m_PolyPoints[0];
@ -472,7 +458,6 @@ void LIB_POLYLINE::BeginEdit( int aEditMode, const wxPoint aPosition )
{
m_initialCursorPos = aPosition;
m_initialPos = m_PolyPoints[0];
saveAttributes();
SetEraseLastDrawItem();
}
@ -500,9 +485,6 @@ void LIB_POLYLINE::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_POLYLINE is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
m_Flags = 0;
SetEraseLastDrawItem( false );
}

View File

@ -15,7 +15,6 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
int m_ModifyIndex; // Index of the polyline point to modify
std::vector<wxPoint> m_savedPolyPoints;
/**
* Draw the polyline.
@ -23,16 +22,6 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculate the polyline attributes relative to \a aPosition while editing.
*

View File

@ -215,20 +215,6 @@ void LIB_RECTANGLE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC,
}
void LIB_RECTANGLE::saveAttributes()
{
m_savedPos = m_Pos;
m_savedEndPos = m_End;
}
void LIB_RECTANGLE::restoreAttributes()
{
m_Pos = m_savedPos;
m_End = m_savedEndPos;
}
void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* aFrame )
{
wxString msg;
@ -339,14 +325,12 @@ void LIB_RECTANGLE::BeginEdit( int aEditMode, const wxPoint aPosition )
m_isHeightLocked = abs( m_End.y - aPosition.y ) >= MINIMUM_SELECTION_DISTANCE;
}
saveAttributes();
SetEraseLastDrawItem();
}
else if( aEditMode == IS_MOVED )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
saveAttributes();
SetEraseLastDrawItem();
}
@ -368,9 +352,6 @@ void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Bad call to EndEdit(). LIB_RECTANGLE is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
m_Flags = 0;
m_isHeightLocked = false;
m_isWidthLocked = false;

View File

@ -18,24 +18,12 @@ class LIB_RECTANGLE : public LIB_DRAW_ITEM
bool m_isHeightLocked; // Flag: Keep height locked
bool m_isStartPointSelected; // Flag: is the upper left edge selected?
wxPoint m_savedEndPos; // Temporary storage of current end position before editing.
/**
* Draw the rectangle.
*/
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculate the rectangle attributes relative to \a aPosition while editing.
*

View File

@ -360,22 +360,6 @@ void LIB_TEXT::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint&
}
void LIB_TEXT::saveAttributes()
{
m_savedPos = m_Pos;
m_savedText = m_Text;
m_savedOrientation = m_Orient;
}
void LIB_TEXT::restoreAttributes()
{
m_Pos = m_savedPos;
m_Text = m_savedText;
m_Orient = m_savedOrientation;
}
void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
{
wxString msg;
@ -453,7 +437,6 @@ void LIB_TEXT::BeginEdit( int aEditMode, const wxPoint aPosition )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
saveAttributes();
SetEraseLastDrawItem();
}
else
@ -479,9 +462,6 @@ void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Bad call to EndEdit(). Text is not being edited." ) );
if( aAbort && !IsNew() )
restoreAttributes();
m_Flags = 0;
m_rotate = false;
m_updateText = false;

View File

@ -15,7 +15,6 @@
class LIB_TEXT : public LIB_DRAW_ITEM, public EDA_TextStruct
{
wxString m_savedText; ///< Temporary storage for the string when edition.
int m_savedOrientation; ///< Temporary storage for orientation when editing.
bool m_rotate; ///< Flag to indicate a rotation occurred while editing.
bool m_updateText; ///< Flag to indicate text change occurred while editing.
@ -25,16 +24,6 @@ class LIB_TEXT : public LIB_DRAW_ITEM, public EDA_TextStruct
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
/**
* See LIB_DRAW_ITEM::saveAttributes().
*/
void saveAttributes();
/**
* See LIB_DRAW_ITEM::restoreAttributes().
*/
void restoreAttributes();
/**
* Calculate the text attributes ralative to \a aPosition while editing.
*

View File

@ -23,8 +23,7 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
wxString msg;
LIB_COMPONENT* Entry;
CMP_LIBRARY* libCache;
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, ArchFullFileName );
libCache->SetCache();

View File

@ -538,7 +538,7 @@ bool WinEDA_SchematicFrame::CreateNetlist( int aFormat, const wxString& aFullFil
}
/* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList;
SCH_SCREENS ScreenList;
for( SCH_SCREEN* screen = ScreenList.GetFirst();
screen != NULL;
screen = ScreenList.GetNext() )

View File

@ -83,14 +83,12 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
DIALOG_LIB_EDIT_PIN dlg( this );
wxString units = GetUnitsLabel( g_UserUnit );
dlg.SetOrientationList( LIB_PIN::GetOrientationNames(),
LIB_PIN::GetOrientationSymbols() );
dlg.SetOrientationList( LIB_PIN::GetOrientationNames(), LIB_PIN::GetOrientationSymbols() );
dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->m_Orient ) );
dlg.SetStyleList( LIB_PIN::GetStyleNames(),
LIB_PIN::GetStyleSymbols());
dlg.SetStyleList( LIB_PIN::GetStyleNames(), LIB_PIN::GetStyleSymbols() );
dlg.SetStyle( LIB_PIN::GetStyleCodeIndex( pin->m_PinShape ) );
dlg.SetElectricalTypeList( LIB_PIN::GetElectricalTypeNames(),
LIB_PIN::GetElectricalTypeSymbols());
LIB_PIN::GetElectricalTypeSymbols() );
dlg.SetElectricalType( pin->m_PinType );
dlg.SetName( pin->m_PinName );
dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit,
@ -102,8 +100,7 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
pin->m_PinNumSize,
m_InternalUnits ) );
dlg.SetNumberTextSizeUnits( units );
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen,
m_InternalUnits ) );
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen, m_InternalUnits ) );
dlg.SetLengthUnits( units );
dlg.SetAddToAllParts( pin->GetUnit() == 0 );
dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 );
@ -137,8 +134,7 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
dlg.GetNumberTextSize(),
m_InternalUnits );
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(),
m_InternalUnits );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_InternalUnits );
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
LastPinType = dlg.GetElectricalType();
LastPinCommonConvert = dlg.GetAddToAllBodyStyles();
@ -271,8 +267,7 @@ another pin. Continue?" ) );
}
/* Put linked pins in new position, and clear flags */
for( Pin = m_component->GetNextPin(); Pin != NULL;
Pin = m_component->GetNextPin( Pin ) )
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{
if( Pin->m_Flags == 0 )
continue;
@ -437,8 +432,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
if( g_EditPinByPinIsOn == false )
pin->m_Flags |= IS_LINKED;
pin->m_Pos.x = GetScreen()->m_Curseur.x;
pin->m_Pos.y = -GetScreen()->m_Curseur.y;
pin->m_Pos = GetScreen()->GetCursorDrawPosition();
pin->m_PinLen = LastPinLength;
pin->m_Orient = LastPinOrient;
pin->m_PinType = LastPinType;
@ -471,7 +465,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
if (pin->m_Flags & IS_CANCELLED)
{
DeletePin(NULL, m_component, pin);
DeletePin( NULL, m_component, pin );
m_drawItem = NULL;
}
else

View File

@ -1,159 +0,0 @@
/**********************************************/
/* eesave.cpp Module to Save EESchema files */
/**********************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "macros.h"
#include "program.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/*****************************************************************************
* Routine to save an EESchema file. *
* FileSave controls how the file is to be saved - under what name. *
* Returns TRUE if the file has been saved. *
*****************************************************************************/
bool WinEDA_SchematicFrame::SaveEEFile( SCH_SCREEN* screen, int FileSave )
{
wxString msg, tmp;
wxFileName schematicFileName, backupFileName;
FILE* f;
wxString dirbuf;
if( screen == NULL )
screen = (SCH_SCREEN*) GetScreen();
/* If no name exists in the window yet - save as new. */
if( screen->m_FileName.IsEmpty() )
FileSave = FILE_SAVE_NEW;
switch( FileSave )
{
case FILE_SAVE_AS:
schematicFileName = screen->m_FileName;
backupFileName = schematicFileName;
/* Rename the old file to a '.bak' one: */
if( schematicFileName.FileExists() )
{
backupFileName.SetExt( wxT( "bak" ) );
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( schematicFileName.GetFullPath(),
backupFileName.GetFullPath() ) )
{
DisplayError( this,
wxT( "Warning: unable to rename old file" ), 10 );
}
}
break;
case FILE_SAVE_NEW:
{
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
screen->m_FileName, SchematicFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
screen->m_FileName = dlg.GetPath();
schematicFileName = dlg.GetPath();
break;
}
default:
break;
}
if( ( f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
msg = _( "Failed to create file " ) + schematicFileName.GetFullPath();
DisplayError( this, msg );
return false;
}
if( FileSave == FILE_SAVE_NEW )
screen->m_FileName = schematicFileName.GetFullPath();
bool success = screen->Save( f );
if( !success )
DisplayError( this, _( "File write operation failed." ) );
else
screen->ClrModify();
fclose( f );
return success;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_SCREEN::Save( FILE* aFile ) const
{
// Creates header
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0
|| fprintf( aFile, " date %s\n", CONV_TO_UTF8( DateAndTime() ) ) < 0 )
return FALSE;
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{
if( fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( lib.GetName() ) ) < 0 )
return FALSE;
}
if( fprintf( aFile, "EELAYER %2d %2d\n", g_LayerDescr.NumberOfLayers,
g_LayerDescr.CurrentLayer ) < 0
|| fprintf( aFile, "EELAYER END\n" ) < 0 )
return FALSE;
/* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for
* SheetNumber and Sheet Count in a complex hierarchy, but useful in
* simple hierarchy and flat hierarchy. Used also to search the root
* sheet ( ScreenNumber = 1 ) within the files
*/
if( fprintf( aFile, "$Descr %s %d %d\n", CONV_TO_UTF8( m_CurrentSheetDesc->m_Name ),
m_CurrentSheetDesc->m_Size.x, m_CurrentSheetDesc->m_Size.y ) < 0
|| fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ) < 0
|| fprintf( aFile, "Title \"%s\"\n", CONV_TO_UTF8( m_Title ) ) < 0
|| fprintf( aFile, "Date \"%s\"\n", CONV_TO_UTF8( m_Date ) ) < 0
|| fprintf( aFile, "Rev \"%s\"\n", CONV_TO_UTF8( m_Revision ) ) < 0
|| fprintf( aFile, "Comp \"%s\"\n", CONV_TO_UTF8( m_Company ) ) < 0
|| fprintf( aFile, "Comment1 \"%s\"\n", CONV_TO_UTF8( m_Commentaire1 ) ) < 0
|| fprintf( aFile, "Comment2 \"%s\"\n", CONV_TO_UTF8( m_Commentaire2 ) ) < 0
|| fprintf( aFile, "Comment3 \"%s\"\n", CONV_TO_UTF8( m_Commentaire3 ) ) < 0
|| fprintf( aFile, "Comment4 \"%s\"\n", CONV_TO_UTF8( m_Commentaire4 ) ) < 0
|| fprintf( aFile, "$EndDescr\n" ) < 0 )
return FALSE;
for( SCH_ITEM* item = EEDrawList; item; item = item->Next() )
{
if( !item->Save( aFile ) )
return FALSE;
}
if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 )
return FALSE;
return TRUE;
}

View File

@ -499,36 +499,3 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList( wxCommandEvent& event )
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
DrawPanel->Refresh();
}
/** Function ClearUndoORRedoList
* free the undo or redo list from List element
* Wrappers are deleted.
* datas pointed by wrappers are deleted if not in use in schematic
* i.e. when they are copy of a schematic item or they are no more in use
* (DELETED)
* @param aList = the UNDO_REDO_CONTAINER to clear
* @param aItemCount = the count of items to remove. < 0 for all items
* items (commands stored in list) are removed from the beginning of the list.
* So this function can be called to remove old commands
*/
void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList,
int aItemCount )
{
if( aItemCount == 0 )
return;
unsigned icnt = aList.m_CommandsList.size();
if( aItemCount > 0 )
icnt = aItemCount;
for( unsigned ii = 0; ii < icnt; ii++ )
{
if( aList.m_CommandsList.size() == 0 )
break;
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
curr_cmd->ClearListAndDeleteItems();
delete curr_cmd; // Delete command
}
}

View File

@ -30,12 +30,11 @@
#include "viewlib_frame.h"
#include "hotkeys.h"
#include "dialog_schematic_find.h"
#include "dialogs/dialog_schematic_find.h"
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
WinEDA_DrawFrame::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, WinEDA_DrawFrame::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
@ -64,12 +63,9 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_MENU( ID_POPUP_SCH_COPY_ITEM, WinEDA_SchematicFrame::OnCopySchematicItemRequest )
EVT_MENU( ID_CONFIG_REQ,
WinEDA_SchematicFrame::InstallConfigFrame )
EVT_MENU( ID_CONFIG_SAVE,
WinEDA_SchematicFrame::Process_Config )
EVT_MENU( ID_CONFIG_READ,
WinEDA_SchematicFrame::Process_Config )
EVT_MENU( ID_CONFIG_REQ, WinEDA_SchematicFrame::InstallConfigFrame )
EVT_MENU( ID_CONFIG_SAVE, WinEDA_SchematicFrame::Process_Config )
EVT_MENU( ID_CONFIG_READ, WinEDA_SchematicFrame::Process_Config )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START,
ID_PREFERENCES_HOTKEY_END,
WinEDA_SchematicFrame::Process_Config )
@ -93,10 +89,8 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_UNDO,
WinEDA_SchematicFrame::GetSchematicFromUndoList )
EVT_TOOL( wxID_REDO,
WinEDA_SchematicFrame::GetSchematicFromRedoList )
EVT_TOOL( wxID_UNDO, WinEDA_SchematicFrame::GetSchematicFromUndoList )
EVT_TOOL( wxID_REDO, WinEDA_SchematicFrame::GetSchematicFromRedoList )
EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
EVT_TOOL( wxID_PRINT, WinEDA_SchematicFrame::OnPrint )
EVT_TOOL( ID_GET_ERC, WinEDA_SchematicFrame::OnErc )
@ -104,15 +98,13 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_TOOL( ID_GET_TOOLS, WinEDA_SchematicFrame::OnCreateBillOfMaterials )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_SchematicFrame::OnFindItems )
EVT_TOOL( ID_BACKANNO_ITEMS, WinEDA_SchematicFrame::OnLoadStuffFile )
EVT_TOOL( ID_COMPONENT_BUTT,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_COMPONENT_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
// Tools and buttons for vertical toolbar.
EVT_TOOL( ID_NO_SELECT_BUTT,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
@ -131,18 +123,12 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
EVT_UPDATE_UI( wxID_CUT, WinEDA_SchematicFrame::OnUpdateBlockSelected )
EVT_UPDATE_UI( wxID_COPY, WinEDA_SchematicFrame::OnUpdateBlockSelected )
EVT_UPDATE_UI( wxID_PASTE, WinEDA_SchematicFrame::OnUpdatePaste )
EVT_UPDATE_UI( wxID_UNDO,
WinEDA_SchematicFrame::OnUpdateSchematicUndo )
EVT_UPDATE_UI( wxID_REDO,
WinEDA_SchematicFrame::OnUpdateSchematicRedo )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID,
WinEDA_SchematicFrame::OnUpdateGrid )
EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR,
WinEDA_SchematicFrame::OnUpdateSelectCursor )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS,
WinEDA_SchematicFrame::OnUpdateHiddenPins )
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
WinEDA_SchematicFrame::OnUpdateBusOrientation )
EVT_UPDATE_UI( wxID_UNDO, WinEDA_SchematicFrame::OnUpdateSchematicUndo )
EVT_UPDATE_UI( wxID_REDO, WinEDA_SchematicFrame::OnUpdateSchematicRedo )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, WinEDA_SchematicFrame::OnUpdateGrid )
EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, WinEDA_SchematicFrame::OnUpdateSelectCursor )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, WinEDA_SchematicFrame::OnUpdateHiddenPins )
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, WinEDA_SchematicFrame::OnUpdateBusOrientation )
EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM,
ID_TB_OPTIONS_SELECT_UNIT_INCH,
WinEDA_SchematicFrame::OnUpdateUnits )
@ -235,20 +221,17 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
if( m_VToolBar )
m_auimgr.AddPane( m_VToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
m_auimgr.AddPane( m_VToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
if( m_OptionsToolBar )
m_auimgr.AddPane( m_OptionsToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
if( DrawPanel )
m_auimgr.AddPane( DrawPanel,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.AddPane( DrawPanel, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
if( MsgPanel )
m_auimgr.AddPane( MsgPanel,
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.AddPane( MsgPanel, wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update();
}
@ -283,7 +266,7 @@ SCH_SHEET_PATH* WinEDA_SchematicFrame::GetSheet()
void WinEDA_SchematicFrame::SetSheetNumberAndCount()
{
SCH_SCREEN* screen = GetScreen();
EDA_ScreenList s_list;
SCH_SCREENS s_list;
/* Set the sheet count, and the sheet number (1 for root sheet)
*/
@ -296,8 +279,7 @@ void WinEDA_SchematicFrame::SetSheetNumberAndCount()
// and count them from root to the current sheet path:
SCH_SHEET_PATH* sheet;
for( sheet = SheetList.GetFirst(); sheet != NULL;
sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
wxString sheetpath = sheet->Path();
if( sheetpath == current_sheetpath ) // Current sheet path found
@ -365,8 +347,7 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL;
sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
break;
@ -428,8 +409,7 @@ int WinEDA_SchematicFrame::BestZoom()
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
size = DrawPanel->GetClientSize();
zoom = MAX( (double) dx / (double) size.x,
(double) dy / (double) size.y );
zoom = MAX( (double) dx / (double) size.x, (double) dy / (double) size.y );
GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2;
@ -486,10 +466,10 @@ wxString WinEDA_SchematicFrame::GetUniqueFilenameForCurrentSheet()
*/
void WinEDA_SchematicFrame::OnModify( )
{
GetScreen()->SetModify( );
GetScreen()->SetModify();
wxString date = GenDate();
EDA_ScreenList s_list;
SCH_SCREENS s_list;
// Set the date for each sheet
// There are 2 possibilities:
@ -508,8 +488,7 @@ void WinEDA_SchematicFrame::OnModify( )
void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event )
{
bool enable = ( GetScreen()
&& GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE );
bool enable = ( GetScreen() && GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE );
event.Enable( enable );
m_HToolBar->EnableTool( wxID_CUT, enable );
@ -545,8 +524,7 @@ void WinEDA_SchematicFrame::OnUpdateBusOrientation( wxUpdateUIEvent& event )
_( "Draw horizontal and vertical wires and buses only" );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, g_HVLines );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
tool_tip );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
}
@ -774,6 +752,7 @@ void WinEDA_SchematicFrame::OnExit( wxCommandEvent& event )
void WinEDA_SchematicFrame::SetLanguage( wxCommandEvent& event )
{
WinEDA_BasicFrame::SetLanguage( event );
if( m_LibeditFrame )
m_LibeditFrame->WinEDA_BasicFrame::SetLanguage( event );
}

View File

@ -143,10 +143,6 @@ public:
BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
~BASE_SCREEN();
BASE_SCREEN* Next() const { return (BASE_SCREEN*) Pnext; }
BASE_SCREEN* Back() const { return (BASE_SCREEN*) Pback; }
/**
* Function setCurItem
* sets the currently selected object, m_CurrentItem.

View File

@ -9,6 +9,7 @@
#include "base_struct.h"
#include "class_base_screen.h"
/* Max number of sheets in a hierarchy project: */
#define NB_MAX_SHEET 500
@ -44,11 +45,21 @@ public:
return wxT( "SCH_SCREEN" );
}
void FreeDrawList(); // Free EESchema drawing list (does not delete the sub hierarchies)
/**
* Free all the items from the schematic associated with the screen.
*
* This does not delete any sub hierarchies.
*/
void FreeDrawList();
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ) { };
void RemoveFromDrawList( SCH_ITEM* DrawStruct ); /* remove DrawStruct from EEDrawList. */
/**
* Remove \a aItem from the schematic associated with this screen.
*
* @param aItem - Item to be removed from schematic.
*/
void RemoveFromDrawList( SCH_ITEM* DrawStruct );
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* DrawStruct );
@ -62,7 +73,7 @@ public:
/** Function ClearUndoORRedoList
* free the undo or redo list from List element
* Wrappers are deleted.
* datas pointed by wrappers are deleted if not in use in schematic
* data pointed by wrappers are deleted if not in use in schematic
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
* @param aList = the UNDO_REDO_CONTAINER to clear
* @param aItemCount = the count of items to remove. < 0 for all items
@ -73,7 +84,8 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to \a aFile in "*.sch" format.
*
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
@ -86,25 +98,23 @@ public:
/********************************************************/
// screens are unique, and correspond to .sch files.
WX_DEFINE_ARRAY( SCH_SCREEN *, ScreenGrowArray );
class EDA_ScreenList
class SCH_SCREENS
{
private:
ScreenGrowArray m_List;
unsigned int m_Index;
std::vector< SCH_SCREEN* > m_screens;
unsigned int m_index;
public:
EDA_ScreenList();
~EDA_ScreenList() { }
int GetCount() { return m_List.GetCount(); }
SCH_SCREENS();
~SCH_SCREENS();
int GetCount() const { return m_screens.size(); }
SCH_SCREEN* GetFirst();
SCH_SCREEN* GetNext();
SCH_SCREEN* GetScreen( unsigned int index );
SCH_SCREEN* GetScreen( unsigned int aIndex );
private:
void AddScreenToList( SCH_SCREEN* testscreen );
void BuildScreenList( EDA_BaseStruct* sheet );
void AddScreenToList( SCH_SCREEN* aScreen );
void BuildScreenList( EDA_BaseStruct* aItem );
};
#endif /* CLASS_SCREEN_H */