2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/******************************************************************/
|
2008-12-04 04:28:11 +00:00
|
|
|
void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Struct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_COMPONENT:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
2008-11-24 06:53:43 +00:00
|
|
|
Struct->SetParent( Screen );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* place the struct in EEDrawList.
|
2007-08-20 01:20:48 +00:00
|
|
|
* if it is a new item, it it also put in undo list
|
|
|
|
* for an "old" item, saving it in undo list must be done before editiing, and not here!
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Flags & IS_NEW )
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
SCH_SCREEN* screen = frame->GetScreen();
|
2008-02-26 19:19:54 +00:00
|
|
|
if( !screen->CheckIfOnDrawList( this ) ) //don't want a loop!
|
|
|
|
screen->AddToDrawList( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToRepeat = this;
|
|
|
|
if( frame->m_Ident == SCHEMATIC_FRAME )
|
2008-04-17 16:25:29 +00:00
|
|
|
frame->SaveCopyInUndoList( this, IS_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Flags = 0;
|
|
|
|
frame->GetScreen()->SetModify();
|
|
|
|
frame->GetScreen()->SetCurItem( NULL );
|
|
|
|
frame->DrawPanel->ManageCurseur = NULL;
|
|
|
|
frame->DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE );
|
|
|
|
frame->DrawPanel->CursorOn( DC ); // Display schematic cursor
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */
|
|
|
|
/***********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Constructeur de SCREEN */
|
2008-02-26 19:19:54 +00:00
|
|
|
SCH_SCREEN::SCH_SCREEN( int screentype, KICAD_T aType ) :
|
2007-09-01 12:00:30 +00:00
|
|
|
BASE_SCREEN( screentype, aType )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EEDrawList = NULL; /* Schematic items list */
|
|
|
|
m_Zoom = 32;
|
|
|
|
m_Grid = wxSize( 50, 50 ); /* pas de la grille */
|
|
|
|
SetZoomList( table_zoom );
|
|
|
|
SetGridList( g_GridList );
|
|
|
|
m_UndoRedoCountMax = 10;
|
2008-02-26 19:19:54 +00:00
|
|
|
m_RefCount = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
SCH_SCREEN::~SCH_SCREEN()
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
ClearUndoRedoList();
|
|
|
|
FreeDrawList();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
void SCH_SCREEN::FreeDrawList()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine to clear (free) EESchema drawing list of a screen.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
while( EEDrawList != NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = EEDrawList;
|
2008-04-14 19:22:48 +00:00
|
|
|
EEDrawList = EEDrawList->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
SAFE_DELETE( DrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
EEDrawList = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2008-04-14 19:22:48 +00:00
|
|
|
void SCH_SCREEN::RemoveFromDrawList( SCH_ITEM * DrawStruct )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* If found in EEDrawList, remove DrawStruct from EEDrawList.
|
2007-08-20 01:20:48 +00:00
|
|
|
* DrawStruct is not deleted or modified
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawStruct == EEDrawList )
|
2008-04-14 19:22:48 +00:00
|
|
|
EEDrawList = EEDrawList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
EDA_BaseStruct* DrawList = EEDrawList;
|
2008-04-14 19:22:48 +00:00
|
|
|
while( DrawList && DrawList->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( DrawList->Next() == DrawStruct )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawList->SetNext( DrawList->Next()->Next() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawList = DrawList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/**************************************************************/
|
2008-04-14 19:22:48 +00:00
|
|
|
bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* st )
|
2008-02-12 21:12:46 +00:00
|
|
|
/**************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM * DrawList = EEDrawList;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
while( DrawList )
|
|
|
|
{
|
|
|
|
if( DrawList == st )
|
|
|
|
return true;
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawList = DrawList->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/**************************************************************/
|
2008-04-14 19:22:48 +00:00
|
|
|
void SCH_SCREEN::AddToDrawList( SCH_ITEM* st )
|
2008-02-12 21:12:46 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{ //simple function to add to the head of the drawlist.
|
2008-11-24 06:53:43 +00:00
|
|
|
st->SetNext( EEDrawList );
|
2008-02-26 19:19:54 +00:00
|
|
|
EEDrawList = st;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* Class EDA_ScreenList to handle the list of screens in a hierarchy */
|
|
|
|
/*********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-12 18:39:20 +00:00
|
|
|
/********************************/
|
|
|
|
EDA_ScreenList::EDA_ScreenList()
|
|
|
|
/********************************/
|
|
|
|
{
|
|
|
|
m_Index = 0;
|
|
|
|
BuildScreenList( g_RootSheet );
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
SCH_SCREEN* EDA_ScreenList::GetFirst()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Index = 0;
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_List.GetCount() > 0 )
|
|
|
|
return m_List[0];
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
SCH_SCREEN* EDA_ScreenList::GetNext()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_Index < m_List.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Index++;
|
2008-02-26 19:19:54 +00:00
|
|
|
return GetScreen( m_Index );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
SCH_SCREEN* EDA_ScreenList::GetScreen( unsigned int index )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* return the m_List[index] item
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( index < m_List.GetCount() )
|
|
|
|
return m_List[index];
|
|
|
|
return NULL;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/************************************************/
|
|
|
|
void EDA_ScreenList::AddScreenToList( SCH_SCREEN* testscreen )
|
|
|
|
/************************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( testscreen == NULL )
|
|
|
|
return;
|
|
|
|
for( unsigned int i = 0; i< m_List.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( m_List[i] == testscreen )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_List.Add( testscreen );
|
2008-02-12 21:12:46 +00:00
|
|
|
#ifdef DEBUG
|
2008-02-26 19:19:54 +00:00
|
|
|
printf( "EDA_ScreenList::AddScreenToList adding %s\n",
|
|
|
|
(const char*) testscreen->m_FileName.mb_str(
|
|
|
|
) );
|
2008-02-12 21:12:46 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/************************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
void EDA_ScreenList::BuildScreenList( EDA_BaseStruct* s )
|
2008-02-12 21:12:46 +00:00
|
|
|
/************************************************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( s && s->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
DrawSheetStruct* ds = (DrawSheetStruct*) s;
|
|
|
|
s = ds->m_AssociatedScreen;
|
|
|
|
}
|
|
|
|
if( s && s->Type() == SCREEN_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) s;
|
|
|
|
AddScreenToList( screen );
|
|
|
|
EDA_BaseStruct* strct = screen->EEDrawList;
|
|
|
|
while( strct )
|
|
|
|
{
|
|
|
|
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
BuildScreenList( strct );
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
strct = strct->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* Class EDA_SheetList to handle the list of Sheets in a hierarchy */
|
|
|
|
/*********************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/*****************************************/
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath* EDA_SheetList::GetFirst()
|
2008-02-12 21:12:46 +00:00
|
|
|
/*****************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
m_index = 0;
|
|
|
|
if( m_count > 0 )
|
|
|
|
return &( m_List[0] );
|
|
|
|
return NULL;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/*****************************************/
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath* EDA_SheetList::GetNext()
|
2008-02-12 21:12:46 +00:00
|
|
|
/*****************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_index < m_count )
|
|
|
|
m_index++;
|
|
|
|
return GetSheet( m_index );
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/************************************************/
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawSheetPath* EDA_SheetList::GetSheet( int index )
|
2008-02-12 21:12:46 +00:00
|
|
|
/************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/* return the m_List[index] item
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( index < m_count )
|
|
|
|
return &(m_List[index]);
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************************/
|
2008-02-26 19:19:54 +00:00
|
|
|
void EDA_SheetList::BuildSheetList( DrawSheetStruct* sheet )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************************/
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_List == NULL )
|
|
|
|
{
|
|
|
|
int count = sheet->CountSheets();
|
|
|
|
m_count = count;
|
|
|
|
m_index = 0;
|
|
|
|
if( m_List )
|
|
|
|
free( m_List );m_List = NULL;
|
2008-02-28 19:27:25 +00:00
|
|
|
count *= sizeof(DrawSheetPath);
|
|
|
|
m_List = (DrawSheetPath*) MyZMalloc( count );
|
2008-02-26 19:19:54 +00:00
|
|
|
memset( (void*) m_List, 0, count );
|
|
|
|
m_currList.Clear();
|
|
|
|
}
|
|
|
|
m_currList.Push( sheet );
|
|
|
|
m_List[m_index] = m_currList;
|
|
|
|
m_index++;
|
|
|
|
if( sheet->m_AssociatedScreen != NULL )
|
|
|
|
{
|
|
|
|
EDA_BaseStruct* strct = m_currList.LastDrawList();
|
|
|
|
while( strct )
|
|
|
|
{
|
|
|
|
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
DrawSheetStruct* sht = (DrawSheetStruct*) strct;
|
|
|
|
BuildSheetList( sht );
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
strct = strct->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
m_currList.Pop();
|
|
|
|
}
|
|
|
|
|