2007-08-20 01:20:48 +00:00
|
|
|
/******************************************************************/
|
|
|
|
/* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */
|
|
|
|
/******************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* defines locaux */
|
2007-08-20 01:20:48 +00:00
|
|
|
#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* Class BASE_SCREEN: classe de gestion d'un affichage */
|
|
|
|
/*******************************************************/
|
|
|
|
BASE_SCREEN::BASE_SCREEN( int idscreen ) : EDA_BaseStruct( SCREEN_STRUCT_TYPE )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EEDrawList = NULL; /* Schematic items list */
|
|
|
|
m_Type = idscreen;
|
|
|
|
m_ZoomList = NULL;
|
|
|
|
m_GridList = NULL;
|
|
|
|
m_UndoList = NULL;
|
|
|
|
m_RedoList = NULL;
|
|
|
|
m_UndoRedoCountMax = 1;
|
|
|
|
m_FirstRedraw = TRUE;
|
|
|
|
InitDatas();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN::~BASE_SCREEN( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_ZoomList )
|
|
|
|
free( m_ZoomList );
|
|
|
|
if( m_GridList )
|
|
|
|
free( m_GridList );
|
|
|
|
ClearUndoRedoList();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::InitDatas( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */
|
|
|
|
m_Zoom = 32;
|
|
|
|
m_Grid = wxSize( 50, 50 ); /* pas de la grille */
|
|
|
|
m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */
|
|
|
|
m_UserGridIsON = FALSE;
|
|
|
|
m_UserGridUnit = g_UserGrid_Unit;
|
|
|
|
m_Diviseur_Grille = 1;
|
|
|
|
m_Center = TRUE;
|
|
|
|
|
|
|
|
/* offsets pour tracer le circuit sur l'ecran */
|
|
|
|
switch( m_Type ) // Init taille sheet par defaut
|
|
|
|
{
|
|
|
|
case SCHEMATIC_FRAME:
|
|
|
|
m_Center = FALSE;
|
|
|
|
m_CurrentSheet = &g_Sheet_A4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case PCB_FRAME:
|
|
|
|
m_CurrentSheet = &g_Sheet_A4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_FRAME:
|
|
|
|
m_CurrentSheet = &g_Sheet_GERBER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_Center )
|
|
|
|
{
|
|
|
|
m_Curseur.x = m_Curseur.y = 0;
|
|
|
|
m_DrawOrg.x = -ReturnPageSize().x / 2;
|
|
|
|
m_DrawOrg.y = -ReturnPageSize().y / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_DrawOrg.x = m_DrawOrg.y = 0;
|
|
|
|
m_Curseur.x = ReturnPageSize().x / 2;
|
|
|
|
m_Curseur.y = ReturnPageSize().y / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DrawOrg est rendu multiple du zoom min :
|
|
|
|
m_DrawOrg.x -= m_DrawOrg.x % 256;
|
|
|
|
m_DrawOrg.y -= m_DrawOrg.y % 256;
|
|
|
|
|
|
|
|
m_O_Curseur = m_Curseur;
|
|
|
|
|
|
|
|
SetCurItem( NULL );
|
|
|
|
|
|
|
|
/* indicateurs divers */
|
|
|
|
m_FlagRefreshReq = 0; /* indique que l'ecran doit redessine */
|
|
|
|
m_FlagModified = 0; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
|
|
|
|
m_FlagSave = 1; // indique sauvegarde auto faite
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
/******************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
|
2007-05-28 18:09:49 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint curpos;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
curpos.x = ScreenPos.x* GetZoom();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
curpos.y = ScreenPos.y* GetZoom();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
curpos.x += m_DrawOrg.x;
|
|
|
|
curpos.y += m_DrawOrg.y;
|
|
|
|
|
|
|
|
return curpos;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
int BASE_SCREEN::GetInternalUnits( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SCHEMATIC_FRAME:
|
|
|
|
return EESCHEMA_INTERNAL_UNIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_FRAME:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case PCB_FRAME:
|
|
|
|
return PCB_INTERNAL_UNIT;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
wxSize BASE_SCREEN::ReturnPageSize( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Retourne en unites internes la taille de la feuille de dessin
|
2007-08-20 01:20:48 +00:00
|
|
|
* (la taille de la feuille est connue en 1/1000 ")
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxSize PageSize;
|
|
|
|
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SCHEMATIC_FRAME:
|
|
|
|
PageSize = m_CurrentSheet->m_Size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_FRAME:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case PCB_FRAME:
|
|
|
|
PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT / 1000);
|
|
|
|
PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT / 1000);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PageSize;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetZoomList( int* zoomlist )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* init liste des zoom (NULL terminated)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii, nbitems, * zoom;
|
|
|
|
|
|
|
|
// Decompte des items
|
|
|
|
for( nbitems = 1, zoom = zoomlist; ; zoom++, nbitems++ )
|
|
|
|
{
|
|
|
|
if( *zoom == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init liste
|
|
|
|
if( m_ZoomList )
|
|
|
|
free( m_ZoomList );
|
|
|
|
m_ZoomList = (int*) MyZMalloc( nbitems * sizeof( int) );
|
|
|
|
|
|
|
|
for( ii = 0, zoom = zoomlist; ii < nbitems; zoom++, ii++ )
|
|
|
|
{
|
|
|
|
m_ZoomList[ii] = *zoom;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetFirstZoom( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************/
|
|
|
|
/* ajuste le coeff de zoom a 1*/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
int BASE_SCREEN::GetZoom( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************/
|
|
|
|
/* retourne le coeff de zoom */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
return m_Zoom;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetZoom( int coeff )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************/
|
|
|
|
/* ajuste le coeff de zoom a coeff */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom = coeff;
|
|
|
|
if( m_Zoom < 1 )
|
|
|
|
m_Zoom = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetNextZoom( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Selectionne le prochain coeff de zoom
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom *= 2;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_ZoomList == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii, zoom_max = 512;
|
|
|
|
for( ii = 0; m_ZoomList[ii] != 0; ii++ )
|
|
|
|
zoom_max = m_ZoomList[ii];
|
|
|
|
|
|
|
|
if( m_Zoom > zoom_max )
|
|
|
|
m_Zoom = zoom_max;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetPreviousZoom( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Selectionne le precedent coeff de zoom
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom /= 2;
|
|
|
|
if( m_Zoom < 1 )
|
|
|
|
m_Zoom = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetLastZoom( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* ajuste le coeff de zoom au max
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_ZoomList == NULL )
|
|
|
|
return;
|
|
|
|
int ii;
|
|
|
|
for( ii = 0; m_ZoomList[ii] != 0; ii++ )
|
|
|
|
m_Zoom = m_ZoomList[ii];
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetGridList( wxSize* gridlist )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* init liste des zoom (NULL terminated)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii, nbitems;
|
|
|
|
wxSize* grid;
|
|
|
|
|
|
|
|
// Decompte des items
|
|
|
|
for( nbitems = 0, grid = gridlist; ; grid++, nbitems++ )
|
|
|
|
{
|
|
|
|
if( (grid->x <= 0) || (grid->y <= 0) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init liste
|
|
|
|
if( m_GridList )
|
|
|
|
free( m_GridList );
|
|
|
|
m_GridList = (wxSize*) MyZMalloc( nbitems * sizeof(wxSize) );
|
|
|
|
|
|
|
|
for( ii = 0, grid = gridlist; ii < nbitems; grid++, ii++ )
|
|
|
|
{
|
|
|
|
m_GridList[ii] = *grid;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetGrid( const wxSize& size )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_GridList == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( (size.x <= 0) || (size.y <= 0) )
|
|
|
|
{
|
|
|
|
m_UserGrid = g_UserGrid;
|
|
|
|
m_UserGridIsON = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Grid = size;
|
|
|
|
m_UserGridIsON = FALSE;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
wxSize BASE_SCREEN::GetGrid( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxSize grid = m_Grid;
|
|
|
|
double xx, scale;
|
|
|
|
|
|
|
|
if( m_GridList == NULL )
|
|
|
|
return wxSize( 1, 1 );
|
|
|
|
|
|
|
|
if( m_UserGridIsON || m_Grid.x < 0 || m_Grid.y < 0 )
|
|
|
|
{
|
|
|
|
if( m_UserGridUnit == INCHES )
|
|
|
|
scale = 10000;
|
|
|
|
else
|
|
|
|
scale = 10000 / 25.4;
|
|
|
|
xx = m_UserGrid.x * scale;
|
|
|
|
grid.x = (int) (xx + 0.5);
|
|
|
|
xx = m_UserGrid.y * scale;
|
|
|
|
grid.y = (int) (xx + 0.5);
|
|
|
|
}
|
|
|
|
return grid;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetNextGrid( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Selectionne la prochaine grille
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
|
|
|
|
if( m_GridList == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( m_GridList[ii].x <= 0 )
|
|
|
|
break;
|
|
|
|
if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (m_GridList[ii].x > 0) && (ii > 0) )
|
|
|
|
m_Grid = m_GridList[ii - 1];
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetPreviousGrid( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Selectionne le precedent coeff de grille
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
|
|
|
|
if( m_GridList == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( m_GridList[ii].x <= 0 )
|
|
|
|
break;
|
|
|
|
if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (m_GridList[ii].x > 0) && (m_GridList[ii + 1].x > 0) )
|
|
|
|
m_Grid = m_GridList[ii + 1];
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetFirstGrid( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* ajuste le coeff de grille a 1
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_GridList == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii = 0;
|
|
|
|
while( m_GridList[ii].x > 0 )
|
|
|
|
ii++;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Grid = m_GridList[ii - 1];
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::SetLastGrid( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* ajuste le coeff de grille au max
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_GridList == NULL )
|
|
|
|
return;
|
|
|
|
m_Grid = m_GridList[0];
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::ClearUndoRedoList( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* free the undo and the redo lists
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* nextitem;
|
|
|
|
|
|
|
|
while( m_UndoList )
|
|
|
|
{
|
|
|
|
nextitem = m_UndoList->Pnext;
|
|
|
|
delete m_UndoList;
|
|
|
|
m_UndoList = nextitem;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( m_RedoList )
|
|
|
|
{
|
|
|
|
nextitem = m_RedoList->Pnext;
|
|
|
|
delete m_RedoList;
|
|
|
|
m_RedoList = nextitem;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Put newitem in head of undo list
|
2007-08-20 01:20:48 +00:00
|
|
|
* Deletes olds items if > count max.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
EDA_BaseStruct* item, * nextitem;
|
|
|
|
|
|
|
|
if( newitem == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
newitem->Pnext = m_UndoList;
|
|
|
|
m_UndoList = newitem;
|
|
|
|
|
|
|
|
/* Free first items, if count max reached */
|
|
|
|
for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ )
|
|
|
|
{
|
|
|
|
if( item->Pnext == NULL )
|
|
|
|
return;
|
|
|
|
item = item->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
nextitem = item->Pnext;
|
|
|
|
item->Pnext = NULL; // Set end of chain
|
|
|
|
|
|
|
|
// Delete the extra items
|
|
|
|
for( item = nextitem; item != NULL; item = nextitem )
|
|
|
|
{
|
|
|
|
nextitem = item->Pnext;
|
|
|
|
delete item;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
EDA_BaseStruct* item, * nextitem;
|
|
|
|
|
|
|
|
if( newitem == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
newitem->Pnext = m_RedoList;
|
|
|
|
m_RedoList = newitem;
|
|
|
|
/* Free first items, if count max reached */
|
|
|
|
for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ )
|
|
|
|
{
|
|
|
|
if( item->Pnext == NULL )
|
|
|
|
break;
|
|
|
|
item = item->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
nextitem = item->Pnext;
|
|
|
|
item->Pnext = NULL; // Set end of chain
|
|
|
|
|
|
|
|
// Delete the extra items
|
|
|
|
for( item = nextitem; item != NULL; item = nextitem )
|
|
|
|
{
|
|
|
|
nextitem = item->Pnext;
|
|
|
|
delete item;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* item = m_UndoList;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( item )
|
|
|
|
m_UndoList = item->Pnext;
|
|
|
|
return item;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList( void )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* item = m_RedoList;
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
m_RedoList = item->Pnext;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BASE_SCREEN::SetCurItem( EDA_BaseStruct* aCurItem )
|
|
|
|
{
|
|
|
|
m_CurrentItem = aCurItem;
|
|
|
|
}
|