2008-03-24 20:54:45 +00:00
|
|
|
/***************************************************************/
|
|
|
|
/* base_screen.cpp - fonctions des classes du type BASE_SCREEN */
|
|
|
|
/***************************************************************/
|
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 */
|
|
|
|
/*******************************************************/
|
2008-03-21 19:26:12 +00:00
|
|
|
BASE_SCREEN::BASE_SCREEN( int idscreen, KICAD_T aType ) :
|
2007-09-01 12:00:30 +00:00
|
|
|
EDA_BaseStruct( aType )
|
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-09-01 12:00:30 +00:00
|
|
|
BASE_SCREEN::~BASE_SCREEN()
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_ZoomList )
|
|
|
|
free( m_ZoomList );
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_GridList )
|
|
|
|
free( m_GridList );
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::InitDatas()
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************/
|
|
|
|
{
|
2008-03-24 20:54:45 +00:00
|
|
|
m_ScreenNumber = m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom = 32;
|
2008-03-24 20:54:45 +00:00
|
|
|
m_Grid = wxSize( 50, 50 ); /* Default grid size */
|
|
|
|
m_UserGrid = g_UserGrid; /* User Default grid size */
|
2007-08-20 01:20:48 +00:00
|
|
|
m_UserGridIsON = FALSE;
|
|
|
|
m_UserGridUnit = g_UserGrid_Unit;
|
|
|
|
m_Diviseur_Grille = 1;
|
|
|
|
m_Center = TRUE;
|
|
|
|
|
2008-03-24 20:54:45 +00:00
|
|
|
/* Init draw offset and default page size */
|
|
|
|
switch( m_Type )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case SCHEMATIC_FRAME:
|
|
|
|
m_Center = FALSE;
|
2008-02-12 21:12:46 +00:00
|
|
|
m_CurrentSheetDesc = &g_Sheet_A4;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case PCB_FRAME:
|
2008-02-12 21:12:46 +00:00
|
|
|
m_CurrentSheetDesc = &g_Sheet_A4;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_FRAME:
|
2008-02-12 21:12:46 +00:00
|
|
|
m_CurrentSheetDesc = &g_Sheet_GERBER;
|
2007-08-20 01:20:48 +00:00
|
|
|
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 :
|
2008-03-21 19:26:12 +00:00
|
|
|
m_DrawOrg.x -= m_DrawOrg.x % 256;
|
2007-08-20 01:20:48 +00:00
|
|
|
m_DrawOrg.y -= m_DrawOrg.y % 256;
|
|
|
|
|
|
|
|
m_O_Curseur = m_Curseur;
|
|
|
|
|
|
|
|
SetCurItem( NULL );
|
|
|
|
|
|
|
|
/* indicateurs divers */
|
2008-03-24 20:54:45 +00:00
|
|
|
m_FlagRefreshReq = 0; /* Redraw screen requste flag */
|
|
|
|
m_FlagModified = 0; // Set when any change is made on borad
|
|
|
|
m_FlagSave = 1; // Used in auto save: set when an auto save is made
|
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-12-05 20:54:11 +00:00
|
|
|
// D(printf("curpos=%d,%d GetZoom=%d, mDrawOrg=%d,%d\n", curpos.x, curpos.y, GetZoom(), m_DrawOrg.x, m_DrawOrg.y );)
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-10-09 12:29:02 +00:00
|
|
|
curpos.x = ScreenPos.x * GetZoom();
|
|
|
|
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-09-01 12:00:30 +00:00
|
|
|
int BASE_SCREEN::GetInternalUnits()
|
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-09-01 12:00:30 +00:00
|
|
|
wxSize BASE_SCREEN::ReturnPageSize()
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-24 20:54:45 +00:00
|
|
|
/* Return in internal units the page size
|
|
|
|
* Note: the page size is handled in 1/1000 ", not in internal units
|
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 PageSize;
|
|
|
|
|
|
|
|
switch( m_Type )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SCHEMATIC_FRAME:
|
2008-02-12 21:12:46 +00:00
|
|
|
PageSize = m_CurrentSheetDesc->m_Size;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GERBER_FRAME:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case PCB_FRAME:
|
2008-02-12 21:12:46 +00:00
|
|
|
PageSize.x = m_CurrentSheetDesc->m_Size.x * (PCB_INTERNAL_UNIT / 1000);
|
|
|
|
PageSize.y = m_CurrentSheetDesc->m_Size.y * (PCB_INTERNAL_UNIT / 1000);
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PageSize;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-21 19:26:12 +00:00
|
|
|
/**************************************************/
|
|
|
|
void BASE_SCREEN::SetZoomList( const int* zoomlist )
|
|
|
|
/**************************************************/
|
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
|
|
|
{
|
2008-03-21 19:26:12 +00:00
|
|
|
int nbitems;
|
|
|
|
const int* zoom;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-21 19:26:12 +00:00
|
|
|
// get list length
|
2007-08-20 01:20:48 +00:00
|
|
|
for( nbitems = 1, zoom = zoomlist; ; zoom++, nbitems++ )
|
|
|
|
{
|
|
|
|
if( *zoom == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-21 19:26:12 +00:00
|
|
|
// resize our list
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_ZoomList )
|
|
|
|
free( m_ZoomList );
|
|
|
|
|
2008-03-21 19:26:12 +00:00
|
|
|
m_ZoomList = (int*) MyZMalloc( nbitems * sizeof(int) );
|
|
|
|
|
|
|
|
int ii;
|
2007-08-20 01:20:48 +00:00
|
|
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetFirstZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Zoom = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-21 19:26:12 +00:00
|
|
|
/******************************/
|
|
|
|
int BASE_SCREEN::GetZoom() const
|
|
|
|
/******************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
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
|
|
|
/***********************************/
|
|
|
|
{
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetNextZoom()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetPreviousZoom()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetLastZoom()
|
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-09-01 12:00:30 +00:00
|
|
|
wxSize BASE_SCREEN::GetGrid()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetNextGrid()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetPreviousGrid()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetFirstGrid()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::SetLastGrid()
|
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-09-01 12:00:30 +00:00
|
|
|
void BASE_SCREEN::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
|
|
|
/* 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-09-01 12:00:30 +00:00
|
|
|
EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList()
|
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-09-01 12:00:30 +00:00
|
|
|
EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList()
|
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;
|
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-03-21 19:26:12 +00:00
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-09-20 21:06:49 +00:00
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
|
|
|
void BASE_SCREEN::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
EDA_BaseStruct* item = (EDA_BaseStruct*) EEDrawList; // @todo : use SCH_ITEM as type for item
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
// for now, make it look like XML, expand on this later.
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
|
|
|
">\n";
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
for( ; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
item->Show( nestLevel+1, os );
|
|
|
|
}
|
2008-03-21 19:26:12 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-24 07:14:01 +00:00
|
|
|
|