7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-04 22:35:30 +00:00

made m_CurrentItem private, beautification

This commit is contained in:
dickelbeck 2007-08-20 01:20:48 +00:00
parent 4ca51f7554
commit 6acce67a64
65 changed files with 19701 additions and 18147 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,22 @@ Please add newer entries at the top, list the date and your name with
email address.
2007-Aug-19 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ all
* Made BASE_SCREEN::m_CurrentItem private so we can force usage of the new
SetCurItem() function, and use it to put a breakpoint on the only place
that m_CurrentItem is changed, namely in the new SetCurItem() function.
( Added new function GetCurItem() as well to class BASE_SCREEN in
drawpanel_wxstruct.h.) Using a stack trace at the breakpoint we can tell
who called it. There were in excess of 450 edits to get this done so I
had to commit it asap so other folks could get on with edits without a
merge conflict.
* Started work on the COLLECTOR class which will assist in giving a choice
in PCBNEW when there is more than one click candidate at the same mouse
or cursor coordinates. COLLECTOR not committed yet.
* More beautification.
2007-Aug-14 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================

View File

@ -1,6 +1,6 @@
/******************************************************************/
/* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */
/******************************************************************/
/******************************************************************/
/* drawpanel.cpp - fonctions des classes du type WinEDA_DrawPanel */
/******************************************************************/
#ifdef __GNUG__
#pragma implementation
@ -11,487 +11,557 @@
/* defines locaux */
#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */
#define CURSOR_SIZE 12 /* taille de la croix du curseur PCB */
/*******************************************************/
/* Class BASE_SCREEN: classe de gestion d'un affichage */
/*******************************************************/
BASE_SCREEN::BASE_SCREEN(int idscreen): EDA_BaseStruct(SCREEN_STRUCT_TYPE)
/*******************************************************/
/* Class BASE_SCREEN: classe de gestion d'un affichage */
/*******************************************************/
BASE_SCREEN::BASE_SCREEN( int idscreen ) : EDA_BaseStruct( SCREEN_STRUCT_TYPE )
{
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();
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();
}
/******************************/
BASE_SCREEN::~BASE_SCREEN(void)
BASE_SCREEN::~BASE_SCREEN( void )
/******************************/
{
if ( m_ZoomList ) free(m_ZoomList);
if ( m_GridList ) free(m_GridList);
ClearUndoRedoList();
if( m_ZoomList )
free( m_ZoomList );
if( m_GridList )
free( m_GridList );
ClearUndoRedoList();
}
/*******************************/
void BASE_SCREEN::InitDatas(void)
void BASE_SCREEN::InitDatas( void )
/*******************************/
{
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;
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;
/* 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;
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;
}
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;
}
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;
// 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;
m_O_Curseur = m_Curseur;
m_CurrentItem = NULL;
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
/* 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
}
/******************************************************************/
wxPoint BASE_SCREEN::CursorRealPosition(const wxPoint & ScreenPos)
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
/******************************************************************/
{
wxPoint curpos;
wxPoint curpos;
curpos.x = ScreenPos.x * GetZoom();
curpos.y = ScreenPos.y * GetZoom();
curpos.x = ScreenPos.x* GetZoom();
curpos.x += m_DrawOrg.x;
curpos.y += m_DrawOrg.y;
curpos.y = ScreenPos.y* GetZoom();
return curpos;
curpos.x += m_DrawOrg.x;
curpos.y += m_DrawOrg.y;
return curpos;
}
/***************************************/
int BASE_SCREEN::GetInternalUnits(void)
int BASE_SCREEN::GetInternalUnits( void )
/***************************************/
{
switch (m_Type )
{
default:
case SCHEMATIC_FRAME :
return EESCHEMA_INTERNAL_UNIT;
break;
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;
}
case GERBER_FRAME:
case CVPCB_DISPLAY_FRAME:
case MODULE_EDITOR_FRAME:
case PCB_FRAME:
return PCB_INTERNAL_UNIT;
}
}
/*****************************************/
wxSize BASE_SCREEN::ReturnPageSize(void)
wxSize BASE_SCREEN::ReturnPageSize( void )
/*****************************************/
/* Retourne en unites internes la taille de la feuille de dessin
(la taille de la feuille est connue en 1/1000 ")
*/
* (la taille de la feuille est connue en 1/1000 ")
*/
{
wxSize PageSize;
switch (m_Type )
{
default:
case SCHEMATIC_FRAME :
PageSize = m_CurrentSheet->m_Size;
break;
wxSize PageSize;
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;
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;
}
/********************************************/
void BASE_SCREEN::SetZoomList(int * zoomlist)
void BASE_SCREEN::SetZoomList( int* zoomlist )
/********************************************/
/* init liste des zoom (NULL terminated)
*/
*/
{
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;
}
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;
}
}
/***********************************/
void BASE_SCREEN::SetFirstZoom(void)
void BASE_SCREEN::SetFirstZoom( void )
/***********************************/
/* ajuste le coeff de zoom a 1*/
{
m_Zoom = 1;
m_Zoom = 1;
}
/****************************/
int BASE_SCREEN::GetZoom(void)
int BASE_SCREEN::GetZoom( void )
/****************************/
/* retourne le coeff de zoom */
{
return m_Zoom;
return m_Zoom;
}
/***********************************/
void BASE_SCREEN::SetZoom(int coeff)
void BASE_SCREEN::SetZoom( int coeff )
/***********************************/
/* ajuste le coeff de zoom a coeff */
{
m_Zoom = coeff;
if ( m_Zoom < 1 ) m_Zoom = 1;
m_Zoom = coeff;
if( m_Zoom < 1 )
m_Zoom = 1;
}
/********************************/
void BASE_SCREEN::SetNextZoom(void)
void BASE_SCREEN::SetNextZoom( void )
/********************************/
/* Selectionne le prochain coeff de zoom
*/
*/
{
m_Zoom *= 2;
m_Zoom *= 2;
if ( m_ZoomList == NULL ) return;
if( m_ZoomList == NULL )
return;
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;
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;
}
/*************************************/
void BASE_SCREEN::SetPreviousZoom(void)
void BASE_SCREEN::SetPreviousZoom( void )
/*************************************/
/* Selectionne le precedent coeff de zoom
*/
*/
{
m_Zoom /= 2;
if ( m_Zoom < 1 ) m_Zoom = 1;
m_Zoom /= 2;
if( m_Zoom < 1 )
m_Zoom = 1;
}
/**********************************/
void BASE_SCREEN::SetLastZoom(void)
void BASE_SCREEN::SetLastZoom( void )
/**********************************/
/* ajuste le coeff de zoom au max
*/
*/
{
if ( m_ZoomList == NULL ) return;
int ii;
for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) m_Zoom = m_ZoomList[ii];
if( m_ZoomList == NULL )
return;
int ii;
for( ii = 0; m_ZoomList[ii] != 0; ii++ )
m_Zoom = m_ZoomList[ii];
}
/********************************************/
void BASE_SCREEN::SetGridList(wxSize * gridlist)
void BASE_SCREEN::SetGridList( wxSize* gridlist )
/********************************************/
/* init liste des zoom (NULL terminated)
*/
*/
{
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;
}
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;
}
}
/**********************************************/
void BASE_SCREEN::SetGrid( const wxSize & size )
void BASE_SCREEN::SetGrid( const wxSize& size )
/**********************************************/
{
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;
}
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;
}
}
/*********************************/
wxSize BASE_SCREEN::GetGrid(void)
wxSize BASE_SCREEN::GetGrid( void )
/*********************************/
{
wxSize grid = m_Grid;
double xx, scale;
if ( m_GridList == NULL ) return wxSize(1,1);
wxSize grid = m_Grid;
double xx, scale;
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;
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;
}
/*********************************/
void BASE_SCREEN::SetNextGrid(void)
void BASE_SCREEN::SetNextGrid( void )
/*********************************/
/* Selectionne la prochaine grille
*/
*/
{
int ii;
int ii;
if ( m_GridList == NULL ) return;
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];
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];
}
/*************************************/
void BASE_SCREEN::SetPreviousGrid(void)
void BASE_SCREEN::SetPreviousGrid( void )
/*************************************/
/* Selectionne le precedent coeff de grille
*/
*/
{
int ii;
int ii;
if ( m_GridList == NULL ) return;
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];
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];
}
/**********************************/
void BASE_SCREEN::SetFirstGrid(void)
void BASE_SCREEN::SetFirstGrid( void )
/**********************************/
/* ajuste le coeff de grille a 1
*/
*/
{
if ( m_GridList == NULL ) return;
if( m_GridList == NULL )
return;
int ii = 0;
while ( m_GridList[ii].x > 0 ) ii ++;
m_Grid = m_GridList[ii-1];
int ii = 0;
while( m_GridList[ii].x > 0 )
ii++;
m_Grid = m_GridList[ii - 1];
}
/**********************************/
void BASE_SCREEN::SetLastGrid( void )
/**********************************/
/**********************************/
void BASE_SCREEN::SetLastGrid(void)
/**********************************/
/* ajuste le coeff de grille au max
*/
*/
{
if ( m_GridList == NULL ) return;
m_Grid = m_GridList[0];
if( m_GridList == NULL )
return;
m_Grid = m_GridList[0];
}
/*****************************************/
void BASE_SCREEN::ClearUndoRedoList(void)
void BASE_SCREEN::ClearUndoRedoList( void )
/*****************************************/
/* free the undo and the redo lists
*/
*/
{
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;
}
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;
}
}
/***********************************************************/
void BASE_SCREEN::AddItemToUndoList(EDA_BaseStruct * newitem)
void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem )
/************************************************************/
/* Put newitem in head of undo list
Deletes olds items if > count max.
*/
* Deletes olds items if > count max.
*/
{
int ii;
EDA_BaseStruct * item, *nextitem;
if ( newitem == NULL ) return;
newitem->Pnext = m_UndoList;
m_UndoList = newitem;
int ii;
EDA_BaseStruct* item, * nextitem;
/* 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;
}
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;
}
}
/***********************************************************/
void BASE_SCREEN::AddItemToRedoList(EDA_BaseStruct * newitem)
void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem )
/***********************************************************/
{
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;
}
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;
}
}
/*****************************************************/
EDA_BaseStruct * BASE_SCREEN::GetItemFromUndoList(void)
EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList( void )
/*****************************************************/
{
EDA_BaseStruct * item = m_UndoList;
EDA_BaseStruct* item = m_UndoList;
if ( item ) m_UndoList = item->Pnext;
return item;
if( item )
m_UndoList = item->Pnext;
return item;
}
/******************************************************/
EDA_BaseStruct * BASE_SCREEN::GetItemFromRedoList(void)
EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList( void )
/******************************************************/
{
EDA_BaseStruct * item = m_RedoList;
if ( item ) m_RedoList = item->Pnext;
return item;
EDA_BaseStruct* item = m_RedoList;
if( item )
m_RedoList = item->Pnext;
return item;
}
EDA_BaseStruct* BASE_SCREEN::GetCurItem()
{
return m_CurrentItem;
}
void BASE_SCREEN::SetCurItem( EDA_BaseStruct* aCurItem )
{
m_CurrentItem = aCurItem;
}

View File

@ -1,9 +1,9 @@
/****************************************************/
/* Routines de gestion des commandes sur blocks */
/* (section commune eeschema/pcbnew... */
/****************************************************/
/****************************************************/
/* Routines de gestion des commandes sur blocks */
/* (section commune eeschema/pcbnew... */
/****************************************************/
/* Fichier common.cpp */
/* Fichier common.cpp */
#include "fctsys.h"
#include "gr_basic.h"
@ -12,274 +12,285 @@
#include "macros.h"
/*******************/
/* DrawBlockStruct */
/*******************/
/*******************/
/* DrawBlockStruct */
/*******************/
/****************************************************************************/
DrawBlockStruct::DrawBlockStruct(void):
EDA_BaseStruct(BLOCK_LOCATE_STRUCT_TYPE), EDA_Rect()
DrawBlockStruct::DrawBlockStruct( void ) :
EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE )
, EDA_Rect()
/****************************************************************************/
{
m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */
m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */
m_BlockDrawStruct = NULL; /* pointeur sur la structure */
m_Color = BROWN;
m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */
m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */
m_BlockDrawStruct = NULL; /* pointeur sur la structure */
m_Color = BROWN;
}
/****************************************/
DrawBlockStruct::~DrawBlockStruct(void)
DrawBlockStruct::~DrawBlockStruct( void )
/****************************************/
{
}
/***************************************************************/
void DrawBlockStruct::SetMessageBlock(WinEDA_DrawFrame * frame)
void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame )
/***************************************************************/
/*
Print block command message (Block move, Block copy ...) in status bar
*/
{
wxString msg;
switch(m_Command)
{
case BLOCK_IDLE:
break;
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
msg = _("Block Move");
break;
case BLOCK_DRAG: /* Drag */
msg = _("Block Drag");
break;
case BLOCK_COPY: /* Copy */
msg = _("Block Copy");
break;
case BLOCK_DELETE: /* Delete */
msg = _("Block Delete");
break;
case BLOCK_SAVE: /* Save */
msg = _("Block Save");
break;
case BLOCK_PASTE:
msg = _("Block Paste");
break;
case BLOCK_ZOOM: /* Window Zoom */
msg = _("Win Zoom");
break;
case BLOCK_ROTATE: /* Rotate 90 deg */
msg = _("Block Rotate");
break;
case BLOCK_INVERT: /* Flip */
msg = _("Block Invert");
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */
msg = _("Block Mirror");
break;
case BLOCK_ABORT:
break;
default:
msg = wxT("????");
break;
}
frame->DisplayToolMsg(msg);
}
/**************************************************************/
void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC)
/**************************************************************/
{
int w = GetWidth()/panel->GetZoom();
int h = GetHeight()/panel->GetZoom();
if ( w == 0 || h == 0 )
GRLine(&panel->m_ClipBox, DC, GetX(), GetY(),
GetRight(), GetBottom(), 0, m_Color);
else
GRRect(&panel->m_ClipBox, DC, GetX(), GetY(),
GetRight(), GetBottom(), 0, m_Color);
}
/*************************************************************************/
bool WinEDA_DrawFrame::HandleBlockBegin(wxDC * DC, int key,
const wxPoint & startpos)
/*************************************************************************/
/* First command block function:
Init the Block infos: command type, initial position, and other variables..
*/
{
DrawBlockStruct * Block = & GetScreen()->BlockLocate;
if ( (Block->m_Command != BLOCK_IDLE) ||
( Block->m_State != STATE_NO_BLOCK) )
return FALSE;
Block->m_Flags = 0;
Block->m_Command = (CmdBlockType) ReturnBlockCommand(key);
if ( Block->m_Command == 0 )
return FALSE;
switch(Block->m_Command)
{
case BLOCK_IDLE: break;
case BLOCK_MOVE: /* Move */
case BLOCK_DRAG: /* Drag */
case BLOCK_COPY: /* Copy */
case BLOCK_DELETE: /* Delete */
case BLOCK_SAVE: /* Save */
case BLOCK_ROTATE: /* Rotate 90 deg */
case BLOCK_INVERT: /* Flip */
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
InitBlockLocateDatas(DrawPanel,startpos);
break;
case BLOCK_PASTE:
InitBlockLocateDatas(DrawPanel,startpos);
Block->m_BlockLastCursorPosition.x = 0;
Block->m_BlockLastCursorPosition.y = 0;
InitBlockPasteInfos();
if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */
{
DisplayError(this, wxT("No Block to paste"), 20);
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL;
return TRUE;
}
if ( DrawPanel->ManageCurseur == NULL )
{
Block->m_BlockDrawStruct = NULL;
DisplayError(this,
wxT("WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL"));
return TRUE;
}
Block->m_State = STATE_BLOCK_MOVE;
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE);
break;
default:
{
wxString msg;
msg << wxT("WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command ") << Block->m_Command;
DisplayError( this, msg );
}
break;
}
Block->SetMessageBlock(this);
return TRUE;
}
/******************************************************************/
void AbortBlockCurrentCommand(WinEDA_DrawPanel * Panel, wxDC * DC)
/******************************************************************/
/*
Cancel Current block operation.
*/
{
BASE_SCREEN * screen = Panel->GetScreen();
if( Panel->ManageCurseur) /* Erase current drawing on screen */
{
Panel->ManageCurseur(Panel,DC, FALSE); /* Efface dessin fantome */
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
screen->m_CurrentItem = NULL;
/* Delete the picked wrapper if this is a picked list. */
if( (screen->BlockLocate.m_Command != BLOCK_PASTE) &&
screen->BlockLocate.m_BlockDrawStruct )
{
if(screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE)
{
DrawPickedStruct * PickedList;
PickedList = (DrawPickedStruct*)screen->BlockLocate.m_BlockDrawStruct;
PickedList->DeleteWrapperList();
}
screen->BlockLocate.m_BlockDrawStruct = NULL;
}
}
screen->BlockLocate.m_Flags = 0;
screen->BlockLocate.m_State = STATE_NO_BLOCK;
screen->BlockLocate.m_Command = BLOCK_ABORT;
Panel->m_Parent->HandleBlockEnd(DC);
screen->BlockLocate.m_Command = BLOCK_IDLE;
Panel->m_Parent->DisplayToolMsg(wxEmptyString);
}
/*************************************************************************/
void InitBlockLocateDatas( WinEDA_DrawPanel * Panel,const wxPoint & startpos )
/*************************************************************************/
/*
Init the initial values of a BlockLocate, before starting a block command
*/
{
BASE_SCREEN * screen = Panel->GetScreen();
screen->BlockLocate.m_State = STATE_BLOCK_INIT;
screen->BlockLocate.SetOrigin(startpos);
screen->BlockLocate.SetSize(wxSize(0,0));
screen->BlockLocate.Pnext = NULL;
screen->BlockLocate.m_BlockDrawStruct = NULL;
Panel->ManageCurseur = DrawAndSizingBlockOutlines;
Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
}
/********************************************************************************/
void DrawAndSizingBlockOutlines(WinEDA_DrawPanel * panel, wxDC * DC, bool erase )
/********************************************************************************/
/* Redraw the outlines of the block which shows the search area for block commands
The first point of the rectangle showing the area is initialised
by InitBlockLocateDatas().
The other point of the rectangle is the mouse cursor
* Print block command message (Block move, Block copy ...) in status bar
*/
{
DrawBlockStruct * PtBlock;
wxString msg;
PtBlock = &panel->GetScreen()->BlockLocate;
switch( m_Command )
{
case BLOCK_IDLE:
break;
PtBlock->m_MoveVector = wxPoint(0,0);
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
msg = _( "Block Move" );
break;
GRSetDrawMode(DC, g_XorMode);
case BLOCK_DRAG: /* Drag */
msg = _( "Block Drag" );
break;
/* Effacement ancien cadre */
if( erase ) PtBlock->Draw(panel, DC);
case BLOCK_COPY: /* Copy */
msg = _( "Block Copy" );
break;
PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur;
PtBlock->SetEnd(panel->GetScreen()->m_Curseur);
case BLOCK_DELETE: /* Delete */
msg = _( "Block Delete" );
break;
PtBlock->Draw(panel, DC);
case BLOCK_SAVE: /* Save */
msg = _( "Block Save" );
break;
if ( PtBlock->m_State == STATE_BLOCK_INIT )
{
if ( PtBlock->GetWidth() || PtBlock->GetHeight() )
/* 2ieme point existant: le rectangle n'est pas de surface nulle */
PtBlock->m_State = STATE_BLOCK_END;
}
case BLOCK_PASTE:
msg = _( "Block Paste" );
break;
case BLOCK_ZOOM: /* Window Zoom */
msg = _( "Win Zoom" );
break;
case BLOCK_ROTATE: /* Rotate 90 deg */
msg = _( "Block Rotate" );
break;
case BLOCK_INVERT: /* Flip */
msg = _( "Block Invert" );
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */
msg = _( "Block Mirror" );
break;
case BLOCK_ABORT:
break;
default:
msg = wxT( "????" );
break;
}
frame->DisplayToolMsg( msg );
}
/**************************************************************/
void DrawBlockStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC )
/**************************************************************/
{
int w = GetWidth() / panel->GetZoom();
int h = GetHeight() / panel->GetZoom();
if( w == 0 || h == 0 )
GRLine( &panel->m_ClipBox, DC, GetX(), GetY(),
GetRight(), GetBottom(), 0, m_Color );
else
GRRect( &panel->m_ClipBox, DC, GetX(), GetY(),
GetRight(), GetBottom(), 0, m_Color );
}
/*************************************************************************/
bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
const wxPoint& startpos )
/*************************************************************************/
/* First command block function:
* Init the Block infos: command type, initial position, and other variables..
*/
{
DrawBlockStruct* Block = & GetScreen()->BlockLocate;
if( (Block->m_Command != BLOCK_IDLE)
|| ( Block->m_State != STATE_NO_BLOCK) )
return FALSE;
Block->m_Flags = 0;
Block->m_Command = (CmdBlockType) ReturnBlockCommand( key );
if( Block->m_Command == 0 )
return FALSE;
switch( Block->m_Command )
{
case BLOCK_IDLE:
break;
case BLOCK_MOVE: /* Move */
case BLOCK_DRAG: /* Drag */
case BLOCK_COPY: /* Copy */
case BLOCK_DELETE: /* Delete */
case BLOCK_SAVE: /* Save */
case BLOCK_ROTATE: /* Rotate 90 deg */
case BLOCK_INVERT: /* Flip */
case BLOCK_ZOOM: /* Window Zoom */
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
InitBlockLocateDatas( DrawPanel, startpos );
break;
case BLOCK_PASTE:
InitBlockLocateDatas( DrawPanel, startpos );
Block->m_BlockLastCursorPosition.x = 0;
Block->m_BlockLastCursorPosition.y = 0;
InitBlockPasteInfos();
if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */
{
DisplayError( this, wxT( "No Block to paste" ), 20 );
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL;
return TRUE;
}
if( DrawPanel->ManageCurseur == NULL )
{
Block->m_BlockDrawStruct = NULL;
DisplayError( this,
wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) );
return TRUE;
}
Block->m_State = STATE_BLOCK_MOVE;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
break;
default:
{
wxString msg;
msg << wxT( "WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command " ) <<
Block->m_Command;
DisplayError( this, msg );
}
break;
}
Block->SetMessageBlock( this );
return TRUE;
}
/******************************************************************/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/*
* Cancel Current block operation.
*/
{
BASE_SCREEN* screen = Panel->GetScreen();
if( Panel->ManageCurseur ) /* Erase current drawing on screen */
{
Panel->ManageCurseur( Panel, DC, FALSE ); /* Efface dessin fantome */
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
screen->SetCurItem( NULL );
/* Delete the picked wrapper if this is a picked list. */
if( (screen->BlockLocate.m_Command != BLOCK_PASTE)
&& screen->BlockLocate.m_BlockDrawStruct )
{
if( screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList;
PickedList = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
PickedList->DeleteWrapperList();
}
screen->BlockLocate.m_BlockDrawStruct = NULL;
}
}
screen->BlockLocate.m_Flags = 0;
screen->BlockLocate.m_State = STATE_NO_BLOCK;
screen->BlockLocate.m_Command = BLOCK_ABORT;
Panel->m_Parent->HandleBlockEnd( DC );
screen->BlockLocate.m_Command = BLOCK_IDLE;
Panel->m_Parent->DisplayToolMsg( wxEmptyString );
}
/*************************************************************************/
void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos )
/*************************************************************************/
/*
* Init the initial values of a BlockLocate, before starting a block command
*/
{
BASE_SCREEN* screen = Panel->GetScreen();
screen->BlockLocate.m_State = STATE_BLOCK_INIT;
screen->BlockLocate.SetOrigin( startpos );
screen->BlockLocate.SetSize( wxSize( 0, 0 ) );
screen->BlockLocate.Pnext = NULL;
screen->BlockLocate.m_BlockDrawStruct = NULL;
Panel->ManageCurseur = DrawAndSizingBlockOutlines;
Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
}
/********************************************************************************/
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/********************************************************************************/
/* Redraw the outlines of the block which shows the search area for block commands
* The first point of the rectangle showing the area is initialised
* by InitBlockLocateDatas().
* The other point of the rectangle is the mouse cursor
*/
{
DrawBlockStruct* PtBlock;
PtBlock = &panel->GetScreen()->BlockLocate;
PtBlock->m_MoveVector = wxPoint( 0, 0 );
GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */
if( erase )
PtBlock->Draw( panel, DC );
PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur;
PtBlock->SetEnd( panel->GetScreen()->m_Curseur );
PtBlock->Draw( panel, DC );
if( PtBlock->m_State == STATE_BLOCK_INIT )
{
if( PtBlock->GetWidth() || PtBlock->GetHeight() )
/* 2ieme point existant: le rectangle n'est pas de surface nulle */
PtBlock->m_State = STATE_BLOCK_END;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,156 +17,164 @@
/* Routines Locales */
/* Variables locales */
static int s_LastShape = '\\';
static int s_LastShape = '\\';
static wxPoint ItemInitialPosition;
/**************************************************************/
static void ExitBusEntry( WinEDA_DrawPanel * Panel, wxDC * DC )
static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
/* Routine de sortie des menus de trace */
{
DrawBusEntryStruct *BusEntry =
(DrawBusEntryStruct *)Panel->GetScreen()->m_CurrentItem;
DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry) /* trace en cours */
{
RedrawOneStruct(Panel, DC, BusEntry, g_XorMode);
if( BusEntry->m_Flags & IS_NEW )
{
delete BusEntry;
Panel->GetScreen()->m_CurrentItem = NULL;
}
else
{
BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct(Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE);
BusEntry->m_Flags = 0;
}
}
if( BusEntry ) /* trace en cours */
{
RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW )
{
delete BusEntry;
Panel->GetScreen()->SetCurItem( NULL );
}
else
{
BusEntry->m_Pos = ItemInitialPosition;
RedrawOneStruct( Panel, DC, BusEntry, GR_DEFAULT_DRAWMODE );
BusEntry->m_Flags = 0;
}
}
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
}
/************************************************************************/
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Dessin du Segment "BusEntry" lors des deplacements du curseur
*/
*/
{
BASE_SCREEN * screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct *BusEntry = (DrawBusEntryStruct *) screen->m_CurrentItem;
if( BusEntry == NULL ) return;
BASE_SCREEN* screen = panel->m_Parent->GetScreen();
DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
/* effacement apres deplacement curseur */
if( erase )
RedrawOneStruct(panel, DC, BusEntry, g_XorMode);
if( BusEntry == NULL )
return;
/* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct(panel, DC, BusEntry, g_XorMode);
/* effacement apres deplacement curseur */
if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */
BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
}
/**********************************************************************************/
DrawBusEntryStruct * WinEDA_SchematicFrame::CreateBusEntry(wxDC * DC, int entry_type)
DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type )
/**********************************************************************************/
/* Create a new bus entry, and prepare moving function (for later place it)
*/
*/
{
DrawBusEntryStruct * BusEntry = new DrawBusEntryStruct(GetScreen()->m_Curseur,
s_LastShape , entry_type);
BusEntry->m_Flags = IS_NEW;
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
s_LastShape, entry_type );
DrawPanel->CursorOff(DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
DrawPanel->CursorOn(DC); // Display schematic cursor
BusEntry->m_Flags = IS_NEW;
GetScreen()->SetModify();
DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
DrawPanel->CursorOn( DC ); // Display schematic cursor
StartMoveBusEntry(BusEntry, DC);
return BusEntry;
GetScreen()->SetModify();
StartMoveBusEntry( BusEntry, DC );
return BusEntry;
}
/**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry(DrawBusEntryStruct * BusEntry,
wxDC * DC)
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC* DC )
/**************************************************************************/
{
if ( BusEntry == NULL ) return;
if( BusEntry == NULL )
return;
if ( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
}
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
}
BusEntry->m_Flags |= IS_MOVED;
BusEntry->m_Flags |= IS_MOVED;
ItemInitialPosition = BusEntry->m_Pos;
ItemInitialPosition = BusEntry->m_Pos;
DrawPanel->CursorOff(DC);
GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->m_CurrentItem = BusEntry;
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn(DC);
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = BusEntry->m_Pos;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetCurItem( BusEntry );
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitBusEntry;
DrawPanel->CursorOn( DC );
}
/************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape(wxDC * DC,
DrawBusEntryStruct *BusEntry, int entry_shape)
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry, int entry_shape )
/************************************************************/
/* set the shape of BusEntry (shape = / or \ )
*/
*/
{
if ( BusEntry == NULL ) return;
if( BusEntry == NULL )
return;
if ( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE )
{
DisplayError(this, wxT("SetBusEntryType: Bad StructType") );
return;
}
if( BusEntry->m_StructType != DRAW_BUSENTRY_STRUCT_TYPE )
{
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
return;
}
/* Put old item in undo list if it is not currently in edit */
if ( BusEntry->m_Flags == 0 ) SaveCopyInUndoList(BusEntry, IS_CHANGED);
/* Put old item in undo list if it is not currently in edit */
if( BusEntry->m_Flags == 0 )
SaveCopyInUndoList( BusEntry, IS_CHANGED );
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
switch( entry_shape )
{
case '\\' :
s_LastShape = '\\';
BusEntry->m_Size.y = 100;
break;
switch( entry_shape )
{
case '\\':
s_LastShape = '\\';
BusEntry->m_Size.y = 100;
break;
case '/' :
s_LastShape = '/';
BusEntry->m_Size.y = -100;
break;
}
case '/':
s_LastShape = '/';
BusEntry->m_Size.y = -100;
break;
}
TestDanglingEnds(GetScreen()->EEDrawList, NULL);
RedrawOneStruct(DrawPanel, DC, BusEntry, g_XorMode);
GetScreen()->SetModify();
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
GetScreen()->SetModify();
}
/************************************************************************/
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct *BusEntry)
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
/************************************************************************/
{
int entry_shape = '\\';
int entry_shape = '\\';
if ( BusEntry->m_Size.y < 0 ) entry_shape = '/';
return entry_shape;
if( BusEntry->m_Size.y < 0 )
entry_shape = '/';
return entry_shape;
}

View File

@ -14,130 +14,135 @@
#include "protos.h"
/******************************************************************/
void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen)
void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
/******************************************************************/
{
switch( Struct->m_StructType )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
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:
Struct->m_Parent = Screen;
break;
switch( Struct->m_StructType )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
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:
Struct->m_Parent = Screen;
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
break;
}
default:
break;
}
}
/***************************************************************/
void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC)
void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/***************************************************************/
/* place the struct in EEDrawList.
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!
*/
* 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!
*/
{
if( m_Flags & IS_NEW)
{
Pnext = frame->m_CurrentScreen->EEDrawList;
frame->m_CurrentScreen->EEDrawList = this;
g_ItemToRepeat = this;
if ( frame->m_Ident == SCHEMATIC_FRAME )
((WinEDA_SchematicFrame *)frame)->SaveCopyInUndoList(this, IS_NEW);
}
if( m_Flags & IS_NEW )
{
Pnext = frame->m_CurrentScreen->EEDrawList;
frame->m_CurrentScreen->EEDrawList = this;
g_ItemToRepeat = this;
if( frame->m_Ident == SCHEMATIC_FRAME )
( (WinEDA_SchematicFrame*) frame )->SaveCopyInUndoList( this, IS_NEW );
}
m_Flags = 0;
frame->GetScreen()->SetModify();
frame->GetScreen()->m_CurrentItem = NULL;
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
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
}
if( DC )
{
frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->CursorOn( DC ); // Display schematic cursor
}
}
/***********************************************************************/
/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */
/***********************************************************************/
static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */
static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */
/* Constructeur de SCREEN */
SCH_SCREEN::SCH_SCREEN(int screentype): BASE_SCREEN(screentype)
SCH_SCREEN::SCH_SCREEN( int screentype ) : BASE_SCREEN( screentype )
{
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;
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;
}
/****************************/
SCH_SCREEN::~SCH_SCREEN(void)
SCH_SCREEN::~SCH_SCREEN( void )
/****************************/
{
ClearUndoRedoList();
FreeDrawList();
ClearUndoRedoList();
FreeDrawList();
}
/***********************************/
void SCH_SCREEN::FreeDrawList(void)
void SCH_SCREEN::FreeDrawList( void )
/***********************************/
/* Routine to clear (free) EESchema drawing list of a screen.
*/
*/
{
EDA_BaseStruct *DrawStruct;
EDA_BaseStruct* DrawStruct;
while (EEDrawList != NULL)
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
delete DrawStruct;
}
while( EEDrawList != NULL )
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
delete DrawStruct;
}
}
/**************************************************************/
void SCH_SCREEN::RemoveFromDrawList(EDA_BaseStruct *DrawStruct)
void SCH_SCREEN::RemoveFromDrawList( EDA_BaseStruct* DrawStruct )
/**************************************************************/
/* If found in EEDrawList, remove DrawStruct from EEDrawList.
DrawStruct is not deleted or modified
*/
* DrawStruct is not deleted or modified
*/
{
if (DrawStruct == EEDrawList)
EEDrawList = EEDrawList->Pnext;
else
{
EDA_BaseStruct * DrawList = EEDrawList;
while (DrawList->Pnext)
{
if (DrawList->Pnext == DrawStruct)
{
DrawList->Pnext = DrawList->Pnext->Pnext;
break;
}
DrawList = DrawList->Pnext;
}
}
if( DrawStruct == EEDrawList )
EEDrawList = EEDrawList->Pnext;
else
{
EDA_BaseStruct* DrawList = EEDrawList;
while( DrawList->Pnext )
{
if( DrawList->Pnext == DrawStruct )
{
DrawList->Pnext = DrawList->Pnext->Pnext;
break;
}
DrawList = DrawList->Pnext;
}
}
}
@ -145,156 +150,175 @@ void SCH_SCREEN::RemoveFromDrawList(EDA_BaseStruct *DrawStruct)
/* Class EDA_ScreenList to handle the list of screens in a hierarchy */
/*********************************************************************/
EDA_ScreenList::EDA_ScreenList(EDA_BaseStruct * DrawStruct)
EDA_ScreenList::EDA_ScreenList( EDA_BaseStruct* DrawStruct )
/* create the list of screens (i.e hierarchycal sheets) found in DrawStruct
if DrawStruct == NULL: start from root sheet and the root screen is included in list
*/
* if DrawStruct == NULL: start from root sheet and the root screen is included in list
*/
{
m_Count = 0;
m_List = NULL;
m_Index = 0;
/* Count the number of screens */
BuildScreenList(NULL, DrawStruct, & m_Count);
if( m_Count > NB_MAX_SHEET )
{
wxString msg;
msg.Printf(wxT("ReturnScreenList: Error: screen count > %d"), NB_MAX_SHEET);
DisplayError(NULL, msg);
}
m_Count = 0;
m_List = NULL;
m_Index = 0;
/* Count the number of screens */
BuildScreenList( NULL, DrawStruct, &m_Count );
if( m_Count > NB_MAX_SHEET )
{
wxString msg;
msg.Printf( wxT( "ReturnScreenList: Error: screen count > %d" ), NB_MAX_SHEET );
DisplayError( NULL, msg );
}
m_List = (SCH_SCREEN **) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) );
/* Fill the list */
BuildScreenList(m_List, DrawStruct, & m_Count);
m_List = (SCH_SCREEN**) MyZMalloc( sizeof(SCH_SCREEN *) * (m_Count + 2) );
/* Fill the list */
BuildScreenList( m_List, DrawStruct, &m_Count );
}
/*****************************************/
EDA_ScreenList::~EDA_ScreenList()
/*****************************************/
{
if ( m_List ) free( m_List );
m_List = NULL;
if( m_List )
free( m_List );
m_List = NULL;
}
/*****************************************/
SCH_SCREEN * EDA_ScreenList::GetFirst(void)
SCH_SCREEN* EDA_ScreenList::GetFirst( void )
/*****************************************/
{
m_Index = 0;
if ( m_List ) return * m_List;
else return NULL;
m_Index = 0;
if( m_List )
return *m_List;
else
return NULL;
}
/*****************************************/
SCH_SCREEN * EDA_ScreenList::GetNext(void)
SCH_SCREEN* EDA_ScreenList::GetNext( void )
/*****************************************/
{
if (m_Index < m_Count) m_Index ++;
if ( (m_Index < m_Count) && m_List )
{
return m_List[m_Index];
}
else return NULL;
if( m_Index < m_Count )
m_Index++;
if( (m_Index < m_Count) && m_List )
{
return m_List[m_Index];
}
else
return NULL;
}
/************************************************/
SCH_SCREEN * EDA_ScreenList::GetScreen(int index)
SCH_SCREEN* EDA_ScreenList::GetScreen( int index )
/************************************************/
/* return the m_List[index] item
*/
*/
{
SCH_SCREEN * screen = NULL;
if( (index >= 0) && index < m_Count )
screen = m_List[index];
SCH_SCREEN* screen = NULL;
return screen;
if( (index >= 0) && index < m_Count )
screen = m_List[index];
return screen;
}
/**************************************************/
void EDA_ScreenList::UpdateSheetNumberAndDate(void)
void EDA_ScreenList::UpdateSheetNumberAndDate( void )
/**************************************************/
/* Update the sheet number, the sheet count and the date for all sheets in list
*/
*/
{
int SheetNumber = 1;
SCH_SCREEN * screen;
wxString sheet_date = GenDate();
for ( screen = GetFirst(); screen != NULL; screen = GetNext() )
{
screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */
screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */
screen->m_Date = sheet_date; /* Update the sheet date */
}
int SheetNumber = 1;
SCH_SCREEN* screen;
wxString sheet_date = GenDate();
for( screen = GetFirst(); screen != NULL; screen = GetNext() )
{
screen->m_SheetNumber = SheetNumber++; /* Update the sheet number */
screen->m_NumberOfSheet = m_Count; /* Update the number of sheets */
screen->m_Date = sheet_date; /* Update the sheet date */
}
}
/************************************************************************/
SCH_SCREEN ** EDA_ScreenList::BuildScreenList(SCH_SCREEN ** ScreenList,
EDA_BaseStruct * DrawStruct, int * Count)
SCH_SCREEN** EDA_ScreenList::BuildScreenList( SCH_SCREEN** ScreenList,
EDA_BaseStruct* DrawStruct, int* Count )
/************************************************************************/
/* Count the Hierachical sheet number (ScreenList == NULL )
or fill the screen pointer buffer (ScreenList != NULL )
If DrawStruct = NULL, search starts from Root screen, and puts root screen in list
Recursive function !
*/
* or fill the screen pointer buffer (ScreenList != NULL )
* If DrawStruct = NULL, search starts from Root screen, and puts root screen in list
* Recursive function !
*/
{
bool HasSubhierarchy = FALSE;
EDA_BaseStruct * CurrStruct;
if( * Count > NB_MAX_SHEET )
{
return ScreenList;
}
bool HasSubhierarchy = FALSE;
EDA_BaseStruct* CurrStruct;
/* Read the current list and put Screen pointers in list */
if ( DrawStruct == NULL )
{
DrawStruct = ScreenSch->EEDrawList;
if ( ScreenList )
{
*ScreenList = ScreenSch;
ScreenList++;
}
else (*Count)++;
}
CurrStruct = DrawStruct;
while( CurrStruct )
{
if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE )
{
HasSubhierarchy = TRUE;
if ( ScreenList )
{
*ScreenList = (SCH_SCREEN*) CurrStruct;
ScreenList++;
}
else (*Count)++;
}
CurrStruct = CurrStruct->Pnext;
}
if ( ! HasSubhierarchy ) return ScreenList;
/* Read the Sub Hierarchies */
CurrStruct = DrawStruct;
while( CurrStruct )
{
if(CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE )
{
SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct;
/* Go to Subhierachy if needed
(warning: BuildScreenList must not called with a NULL parameter
for DrawStruct, because BuildScreenList restart from the root screen
when DrawStruct == NULL */
if ( Screen->EEDrawList )
ScreenList = BuildScreenList(ScreenList, Screen->EEDrawList,Count);
}
CurrStruct = CurrStruct->Pnext;
}
return ScreenList;
if( *Count > NB_MAX_SHEET )
{
return ScreenList;
}
/* Read the current list and put Screen pointers in list */
if( DrawStruct == NULL )
{
DrawStruct = ScreenSch->EEDrawList;
if( ScreenList )
{
*ScreenList = ScreenSch;
ScreenList++;
}
else
(*Count)++;
}
CurrStruct = DrawStruct;
while( CurrStruct )
{
if( CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE )
{
HasSubhierarchy = TRUE;
if( ScreenList )
{
*ScreenList = (SCH_SCREEN*) CurrStruct;
ScreenList++;
}
else
(*Count)++;
}
CurrStruct = CurrStruct->Pnext;
}
if( !HasSubhierarchy )
return ScreenList;
/* Read the Sub Hierarchies */
CurrStruct = DrawStruct;
while( CurrStruct )
{
if( CurrStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE )
{
SCH_SCREEN* Screen = (SCH_SCREEN*) CurrStruct;
/* Go to Subhierachy if needed
* (warning: BuildScreenList must not called with a NULL parameter
* for DrawStruct, because BuildScreenList restart from the root screen
* when DrawStruct == NULL */
if( Screen->EEDrawList )
ScreenList = BuildScreenList( ScreenList, Screen->EEDrawList, Count );
}
CurrStruct = CurrStruct->Pnext;
}
return ScreenList;
}

View File

@ -1,6 +1,6 @@
/********************************************/
/* Definitions for the EESchema program: */
/********************************************/
/********************************************/
/* Definitions for the EESchema program: */
/********************************************/
#ifndef CLASS_SCREEN_H
#define CLASS_SCREEN_H
@ -18,66 +18,66 @@
/* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/
typedef enum {
NET_INPUT,
NET_OUTPUT,
NET_BIDI,
NET_TRISTATE,
NET_UNSPECIFIED,
NET_TMAX /* Derniere valeur: fin de tableau */
NET_INPUT,
NET_OUTPUT,
NET_BIDI,
NET_TRISTATE,
NET_UNSPECIFIED,
NET_TMAX /* Derniere valeur: fin de tableau */
} TypeSheetLabel;
/* Messages correspondants aux types ou forme des labels */
#ifdef MAIN
const char * SheetLabelType[] =
{
"Input",
"Output",
"BiDi",
"3State",
"UnSpc",
"?????"
};
const char* SheetLabelType[] =
{
"Input",
"Output",
"BiDi",
"3State",
"UnSpc",
"?????"
};
#else
extern const char * SheetLabelType[];
extern const char* SheetLabelType[];
#endif
/* Description du graphisme des icones associes aux types des Global_Labels */
#ifdef MAIN
int TemplateIN_HN[] = {6, 0,0, -1,-1, -2,-1, -2,1, -1,1, 0,0};
int TemplateIN_HI[] = {6, 0,0, 1,1, 2,1, 2,-1, 1,-1, 0,0};
int TemplateIN_BOTTOM[] = {6, 0,0, 1,-1, 1,-2, -1,-2, -1,-1, 0,0};
int TemplateIN_UP[] = {6, 0,0, 1,1, 1,2, -1,2, -1,1, 0,0};
int TemplateOUT_HN[] = {6, -2,0, -1,1, 0,1, 0,-1, -1,-1, -2,0};
int TemplateOUT_HI[] = {6, 2,0, 1,-1, 0,-1, 0,1, 1,1, 2,0};
int TemplateOUT_BOTTOM[] = {6, 0,-2, 1,-1, 1,0, -1,0, -1,-1, 0,-2};
int TemplateOUT_UP[] = {6, 0,2, 1,1, 1,0, -1,0, -1,1, 0,2};
int TemplateUNSPC_HN[] = {5, 0,-1, -2,-1, -2,1, 0,1, 0,-1};
int TemplateUNSPC_HI[] = {5, 0,-1, 2,-1, 2,1, 0,1, 0,-1};
int TemplateUNSPC_BOTTOM[] = {5, 1,0, 1,-2, -1,-2, -1,0, 1,0};
int TemplateUNSPC_UP[] = {5, 1,0, 1,2, -1,2, -1,0, 1,0};
int TemplateBIDI_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0};
int TemplateBIDI_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0};
int TemplateBIDI_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0};
int TemplateBIDI_UP[] = {5, 0,0, -1, 1, 0, 2, 1, 1, 0,0};
int Template3STATE_HN[] = {5, 0,0, -1,-1, -2,0, -1,1, 0,0};
int Template3STATE_HI[] = {5, 0,0, 1,-1, 2,0, 1,1, 0,0};
int Template3STATE_BOTTOM[] = {5, 0,0, -1,-1, 0,-2, 1,-1, 0,0};
int Template3STATE_UP[] = {5, 0,0, -1,1, 0,2, 1,1, 0,0};
int * TemplateShape[5][4] =
{
{TemplateIN_HN,TemplateIN_UP,TemplateIN_HI,TemplateIN_BOTTOM},
{TemplateOUT_HN,TemplateOUT_UP,TemplateOUT_HI,TemplateOUT_BOTTOM},
{TemplateBIDI_HN,TemplateBIDI_UP,TemplateBIDI_HI,TemplateBIDI_BOTTOM},
{Template3STATE_HN,Template3STATE_UP,Template3STATE_HI,Template3STATE_BOTTOM},
{TemplateUNSPC_HN,TemplateUNSPC_UP,TemplateUNSPC_HI,TemplateUNSPC_BOTTOM}
};
int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
int* TemplateShape[5][4] =
{
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM },
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM },
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM },
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM }
};
#else
extern int * TemplateShape[5][4];
extern int* TemplateShape[5][4];
#endif
@ -85,69 +85,76 @@ extern int * TemplateShape[5][4];
class DrawSheetStruct;
class SCH_SCREEN: public BASE_SCREEN
class SCH_SCREEN : public BASE_SCREEN
{
public:
SCH_SCREEN(int idtype);
~SCH_SCREEN();
SCH_SCREEN( int idtype );
~SCH_SCREEN();
void FreeDrawList(void); // Free EESchema drawing list (does not delete the sub hierarchies)
void Place(WinEDA_DrawFrame * frame, wxDC * DC) {};
void RemoveFromDrawList(EDA_BaseStruct *DrawStruct);/* remove DrawStruct from EEDrawList. */
void ClearUndoORRedoList(EDA_BaseStruct *List);
bool SchematicCleanUp( wxDC * DC = NULL );
EDA_BaseStruct * ExtractWires(bool CreateCopy);
void FreeDrawList( void ); // Free EESchema drawing list (does not delete the sub hierarchies)
/* full undo redo management : */
virtual void ClearUndoRedoList(void);
virtual void AddItemToUndoList(EDA_BaseStruct * item);
virtual void AddItemToRedoList(EDA_BaseStruct * item);
void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
void RemoveFromDrawList( EDA_BaseStruct* DrawStruct );/* remove DrawStruct from EEDrawList. */
void ClearUndoORRedoList( EDA_BaseStruct* List );
bool SchematicCleanUp( wxDC* DC = NULL );
EDA_BaseStruct* ExtractWires( bool CreateCopy );
/* full undo redo management : */
virtual void ClearUndoRedoList( void );
virtual void AddItemToUndoList( EDA_BaseStruct* item );
virtual void AddItemToRedoList( EDA_BaseStruct* item );
};
class DrawSheetLabelStruct: public EDA_BaseStruct, public EDA_TextStruct
class DrawSheetLabelStruct : public EDA_BaseStruct
, public EDA_TextStruct
{
public:
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE si non connecté
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE si non connecté
public:
DrawSheetLabelStruct(DrawSheetStruct * parent,
const wxPoint & pos = wxPoint(0,0), const wxString & text = wxEmptyString);
~DrawSheetLabelStruct(void) {}
DrawSheetLabelStruct * GenCopy(void);
DrawSheetLabelStruct * Next(void)
{ return (DrawSheetLabelStruct *) Pnext;}
void Place(WinEDA_DrawFrame * frame, wxDC * DC);
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1);
DrawSheetLabelStruct( DrawSheetStruct* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~DrawSheetLabelStruct( void ) { }
DrawSheetLabelStruct* GenCopy( void );
DrawSheetLabelStruct* Next( void )
{ return (DrawSheetLabelStruct*) Pnext; }
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
};
class DrawSheetStruct: public SCH_SCREEN /* Gestion de la hierarchie */
class DrawSheetStruct : public SCH_SCREEN /* Gestion de la hierarchie */
{
public:
wxString m_SheetName;
int m_SheetNameSize;
wxString m_SheetName;
int m_SheetNameSize;
// wxString m_FileName; in SCH_SCREEN
int m_FileNameSize;
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
int m_Layer;
DrawSheetLabelStruct *m_Label; /* Points de connection */
int m_NbLabel; /* Nombre de points de connexion */
int m_FileNameSize;
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
int m_Layer;
DrawSheetLabelStruct* m_Label; /* Points de connection */
int m_NbLabel; /* Nombre de points de connexion */
public:
DrawSheetStruct(const wxPoint & pos = wxPoint(0,0) );
~DrawSheetStruct(void);
void Place(WinEDA_DrawFrame * frame, wxDC * DC);
DrawSheetStruct * GenCopy(void);
void Display_Infos(WinEDA_DrawFrame * frame);
void CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC);
virtual void Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode, int Color = -1);
void SwapData(DrawSheetStruct * copyitem);
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
~DrawSheetStruct( void );
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
DrawSheetStruct* GenCopy( void );
void Display_Infos( WinEDA_DrawFrame* frame );
void CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
void SwapData( DrawSheetStruct* copyitem );
};
@ -155,23 +162,22 @@ public:
class EDA_ScreenList
{
private:
int m_Count;
SCH_SCREEN ** m_List;
int m_Index;
int m_Count;
SCH_SCREEN** m_List;
int m_Index;
public:
EDA_ScreenList(EDA_BaseStruct * DrawStruct);
~EDA_ScreenList();
int GetCount(void) { return m_Count; }
SCH_SCREEN * GetFirst(void);
SCH_SCREEN * GetNext(void);
SCH_SCREEN * GetScreen(int index);
void UpdateSheetNumberAndDate(void);
EDA_ScreenList( EDA_BaseStruct* DrawStruct );
~EDA_ScreenList();
int GetCount( void ) { return m_Count; }
SCH_SCREEN* GetFirst( void );
SCH_SCREEN* GetNext( void );
SCH_SCREEN* GetScreen( int index );
void UpdateSheetNumberAndDate( void );
private:
SCH_SCREEN ** BuildScreenList(SCH_SCREEN ** ScreenList,
EDA_BaseStruct * DrawStruct, int * Count);
SCH_SCREEN** BuildScreenList( SCH_SCREEN** ScreenList,
EDA_BaseStruct* DrawStruct, int* Count );
};
#endif /* CLASS_SCREEN_H */

View File

@ -395,9 +395,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
if( hotkey )
{
if( m_CurrentScreen->m_CurrentItem
&& m_CurrentScreen->m_CurrentItem->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->m_CurrentItem );
if( m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() );
else
OnHotKey( DC, hotkey, NULL );
}

File diff suppressed because it is too large Load Diff

View File

@ -14,339 +14,351 @@
#include "protos.h"
/* Fonctions locales */
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void ExitMoveTexte(WinEDA_DrawPanel * panel, wxDC *DC);
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
/* Variables locales */
static wxPoint ItemInitialPosition;
static int OldOrient;
static wxSize OldSize;
static int s_DefaultShapeGLabel = (int) NET_INPUT;
static int s_DefaultOrientGLabel = 0;
static int OldOrient;
static wxSize OldSize;
static int s_DefaultShapeGLabel = (int) NET_INPUT;
static int s_DefaultOrientGLabel = 0;
/************************************/
/* class WinEDA_LabelPropertiesFrame */
/************************************/
/************************************/
/* class WinEDA_LabelPropertiesFrame */
/************************************/
#include "dialog_edit_label.cpp"
/****************************************************************************/
void WinEDA_LabelPropertiesFrame::TextPropertiesAccept(wxCommandEvent& event)
void WinEDA_LabelPropertiesFrame::TextPropertiesAccept( wxCommandEvent& event )
/****************************************************************************/
{
wxString text;
int value;
/* save old text in undo list if not already in edit */
if ( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList(m_CurrentText, IS_CHANGED);
wxString text;
int value;
text = m_TextLabel->GetValue();
if ( ! text.IsEmpty() ) m_CurrentText->m_Text = text;
else if ( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError(this, _("Empty Text!") );
/* save old text in undo list if not already in edit */
if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, IS_CHANGED );
m_CurrentText->m_Orient = m_TextOrient->GetSelection();
text = m_TextSize->GetValue();
value = ReturnValueFromString(g_UnitMetric, text, m_Parent->m_InternalUnits);
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if ( m_TextShape ) m_CurrentText->m_Shape = m_TextShape->GetSelection();
text = m_TextLabel->GetValue();
if( !text.IsEmpty() )
m_CurrentText->m_Text = text;
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) );
m_Parent->GetScreen()->SetModify();
m_CurrentText->m_Orient = m_TextOrient->GetSelection();
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection();
/* Make the text size as new default size if it is a new text */
if ( (m_CurrentText->m_Flags & IS_NEW) != 0 )
g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
m_Parent->GetScreen()->SetModify();
Close(TRUE);
/* Make the text size as new default size if it is a new text */
if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
Close( TRUE );
}
/********************************************************************************/
void WinEDA_SchematicFrame::StartMoveTexte(DrawTextStruct * TextStruct, wxDC *DC)
void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC )
/********************************************************************************/
{
if(TextStruct == NULL) return;
if( TextStruct == NULL )
return;
g_ItemToRepeat = NULL;
if ( (TextStruct->m_Flags & IS_NEW) == 0 )
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = TextStruct->GenCopy();
}
g_ItemToRepeat = NULL;
TextStruct->m_Flags |= IS_MOVED;
if( (TextStruct->m_Flags & IS_NEW) == 0 )
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = TextStruct->GenCopy();
}
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
OldOrient = TextStruct->m_Orient;
break;
TextStruct->m_Flags |= IS_MOVED;
default: break;
}
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
OldOrient = TextStruct->m_Orient;
break;
DrawPanel->CursorOff(DC);
m_CurrentScreen->m_Curseur = ItemInitialPosition;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify();
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
DrawPanel->CursorOn(DC);
default:
break;
}
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = ItemInitialPosition;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify();
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->CursorOn( DC );
}
/*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText(DrawTextStruct * TextStruct,
wxDC * DC)
void WinEDA_SchematicFrame::EditSchematicText( DrawTextStruct* TextStruct,
wxDC* DC )
/*************************************************************************/
/* Edit the properties of the text (Label, Gloab label, graphic text).. )
pointed by "TextStruct"
*/
* pointed by "TextStruct"
*/
{
if(TextStruct == NULL) return;
if( TextStruct == NULL )
return;
DrawPanel->CursorOff(DC);
RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode);
DrawPanel->CursorOff( DC );
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
WinEDA_LabelPropertiesFrame * frame = new WinEDA_LabelPropertiesFrame(this,
TextStruct, wxPoint(30,30));
frame->ShowModal(); frame->Destroy();
WinEDA_LabelPropertiesFrame* frame = new WinEDA_LabelPropertiesFrame( this,
TextStruct,
wxPoint( 30, 30 ) );
frame->ShowModal(); frame->Destroy();
RedrawOneStruct(DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE);
DrawPanel->CursorOn(DC);
RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC );
}
/***********************************************************************************/
void WinEDA_SchematicFrame::ChangeTextOrient(DrawTextStruct * TextStruct, wxDC * DC)
void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC* DC )
/***********************************************************************************/
{
if( TextStruct == NULL )
TextStruct = (DrawTextStruct *) PickStruct(GetScreen()->m_Curseur,
GetScreen()->EEDrawList, TEXTITEM|LABELITEM);
if( TextStruct == NULL ) return;
if( TextStruct == NULL )
TextStruct = (DrawTextStruct*) PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, TEXTITEM | LABELITEM );
if( TextStruct == NULL )
return;
/* save old text in undo list if is not already in edit */
if ( TextStruct->m_Flags == 0 )
SaveCopyInUndoList(TextStruct, IS_CHANGED);
/* save old text in undo list if is not already in edit */
if( TextStruct->m_Flags == 0 )
SaveCopyInUndoList( TextStruct, IS_CHANGED );
/* Effacement du texte en cours */
DrawPanel->CursorOff(DC);
RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode);
/* Effacement du texte en cours */
DrawPanel->CursorOff( DC );
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rotation du texte */
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
((DrawTextStruct*)TextStruct)->m_Orient++;
((DrawTextStruct*)TextStruct)->m_Orient &= 3;
break;
/* Rotation du texte */
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
( (DrawTextStruct*) TextStruct )->m_Orient++;
( (DrawTextStruct*) TextStruct )->m_Orient &= 3;
break;
default: break;
}
default:
break;
}
GetScreen()->SetModify();
GetScreen()->SetModify();
/* Reaffichage */
RedrawOneStruct(DrawPanel, DC, TextStruct, g_XorMode);
DrawPanel->CursorOn(DC);
/* Reaffichage */
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
DrawPanel->CursorOn( DC );
}
/*************************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewText(wxDC * DC, int type)
EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
/*************************************************************************/
/* Routine to create new text struct (GraphicText, label or Glabel).
*/
*/
{
DrawTextStruct * NewText = NULL;
DrawTextStruct* NewText = NULL;
g_ItemToRepeat = NULL;
g_ItemToRepeat = NULL;
switch( type )
{
case LAYER_NOTES:
NewText = new DrawTextStruct(m_CurrentScreen->m_Curseur);
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
break;
switch( type )
{
case LAYER_NOTES:
NewText = new DrawTextStruct( m_CurrentScreen->m_Curseur );
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
break;
case LAYER_LOCLABEL:
{
NewText = new DrawLabelStruct(m_CurrentScreen->m_Curseur);
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
}
break;
case LAYER_LOCLABEL:
{
NewText = new DrawLabelStruct( m_CurrentScreen->m_Curseur );
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
}
break;
case LAYER_GLOBLABEL:
NewText = new DrawGlobalLabelStruct(m_CurrentScreen->m_Curseur);
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
((DrawGlobalLabelStruct*)NewText)->m_Shape = s_DefaultShapeGLabel;
((DrawGlobalLabelStruct*)NewText)->m_Orient = s_DefaultOrientGLabel;
break;
case LAYER_GLOBLABEL:
NewText = new DrawGlobalLabelStruct( m_CurrentScreen->m_Curseur );
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
( (DrawGlobalLabelStruct*) NewText )->m_Shape = s_DefaultShapeGLabel;
( (DrawGlobalLabelStruct*) NewText )->m_Orient = s_DefaultOrientGLabel;
break;
default:
DisplayError(this, wxT("Editexte: Internal error") );
break;
}
default:
DisplayError( this, wxT( "Editexte: Internal error" ) );
break;
}
NewText->m_Flags = IS_NEW | IS_MOVED;
NewText->m_Flags = IS_NEW | IS_MOVED;
RedrawOneStruct(DrawPanel, DC, NewText, g_XorMode);
EditSchematicText(NewText, DC);
RedrawOneStruct( DrawPanel, DC, NewText, g_XorMode );
EditSchematicText( NewText, DC );
if ( NewText->m_Text.IsEmpty() )
{
delete NewText;
return NULL;
}
if( NewText->m_Text.IsEmpty() )
{
delete NewText;
return NULL;
}
if ( type == LAYER_GLOBLABEL )
{
s_DefaultShapeGLabel = ((DrawGlobalLabelStruct*)NewText)->m_Shape;
s_DefaultOrientGLabel = ((DrawGlobalLabelStruct*)NewText)->m_Orient;
}
if( type == LAYER_GLOBLABEL )
{
s_DefaultShapeGLabel = ( (DrawGlobalLabelStruct*) NewText )->m_Shape;
s_DefaultOrientGLabel = ( (DrawGlobalLabelStruct*) NewText )->m_Orient;
}
RedrawOneStruct(DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE);
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE );
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
m_CurrentScreen->m_CurrentItem = NewText;
m_CurrentScreen->SetCurItem( NewText );
return NewText;
return NewText;
}
/****************************************/
/* Dessin du Texte en deplacement */
/****************************************/
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
/****************************************/
/* Dessin du Texte en deplacement */
/****************************************/
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
EDA_BaseStruct * TextStruct = panel->GetScreen()->m_CurrentItem;
EDA_BaseStruct* TextStruct = panel->GetScreen()->GetCurItem();
/* effacement ancienne position */
if( erase )
RedrawOneStruct(panel, DC, TextStruct, g_XorMode);
/* effacement ancienne position */
if( erase )
RedrawOneStruct( panel, DC, TextStruct, g_XorMode );
/* Redessin du texte */
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
((DrawTextStruct*)TextStruct)->m_Pos = panel->GetScreen()->m_Curseur;
break;
/* Redessin du texte */
switch( TextStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
( (DrawTextStruct*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur;
break;
default: break;
}
default:
break;
}
RedrawOneStruct(panel, DC, TextStruct, g_XorMode);
RedrawOneStruct( panel, DC, TextStruct, g_XorMode );
}
/*************************************************************/
static void ExitMoveTexte(WinEDA_DrawPanel * Panel, wxDC *DC)
static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/* Routine de sortie des menus de Texte */
{
SCH_SCREEN * screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen;
EDA_BaseStruct * Struct = screen->m_CurrentItem;
SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen;
EDA_BaseStruct* Struct = screen->GetCurItem();
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
g_ItemToRepeat = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
if( Struct == NULL) /* Pas de trace en cours */
{
return;
}
if( Struct == NULL ) /* Pas de trace en cours */
{
return;
}
/* ici : trace en cours */
/* ici : trace en cours */
/* Effacement du trace en cours et suppression eventuelle de la structure */
RedrawOneStruct(Panel, DC, Struct, g_XorMode);
/* Effacement du trace en cours et suppression eventuelle de la structure */
RedrawOneStruct( Panel, DC, Struct, g_XorMode );
if( Struct->m_Flags & IS_NEW ) /* Suppression du nouveau texte en cours de placement */
{
delete Struct;
screen->m_CurrentItem = NULL;
}
if( Struct->m_Flags & IS_NEW ) /* Suppression du nouveau texte en cours de placement */
{
delete Struct;
screen->SetCurItem( NULL );
}
else /* Remise a jour des anciens parametres du texte */
{
switch( Struct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
{
DrawTextStruct* Text = (DrawTextStruct*) Struct;
Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize;
Text->m_Orient = OldOrient;
}
break;
else /* Remise a jour des anciens parametres du texte */
{
switch( Struct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
{
DrawTextStruct * Text = (DrawTextStruct *) Struct;
Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize;
Text->m_Orient = OldOrient;
}
break;
default:
break;
}
default: break;
}
RedrawOneStruct(Panel, DC, Struct, GR_DEFAULT_DRAWMODE);
Struct->m_Flags = 0;
}
RedrawOneStruct( Panel, DC, Struct, GR_DEFAULT_DRAWMODE );
Struct->m_Flags = 0;
}
}
/*****************************************************************************/
void WinEDA_SchematicFrame::ConvertTextType(DrawTextStruct * Text,
wxDC * DC, int newtype)
void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text,
wxDC* DC, int newtype )
/*****************************************************************************/
/* Routine to change a text type to an other one (GraphicText, label or Glabel).
*/
*/
{
if ( Text == NULL ) return;
if( Text == NULL )
return;
/* save Text in undo list if not already in edit, or moving ... */
if ( Text->m_Flags == 0 )
SaveCopyInUndoList(Text, IS_CHANGED);
/* save Text in undo list if not already in edit, or moving ... */
if( Text->m_Flags == 0 )
SaveCopyInUndoList( Text, IS_CHANGED );
DrawPanel->CursorOff(DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel, DC, Text, g_XorMode); // erase drawing
switch( newtype )
{
case DRAW_LABEL_STRUCT_TYPE:
Text->m_StructType = DRAW_LABEL_STRUCT_TYPE;
Text->m_Layer = LAYER_LOCLABEL;
break;
DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, Text, g_XorMode );
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
Text->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE;
Text->m_Layer = LAYER_GLOBLABEL;
break;
// erase drawing
switch( newtype )
{
case DRAW_LABEL_STRUCT_TYPE:
Text->m_StructType = DRAW_LABEL_STRUCT_TYPE;
Text->m_Layer = LAYER_LOCLABEL;
break;
case DRAW_TEXT_STRUCT_TYPE:
Text->m_StructType = DRAW_TEXT_STRUCT_TYPE;
Text->m_Layer = LAYER_NOTES;
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
Text->m_StructType = DRAW_GLOBAL_LABEL_STRUCT_TYPE;
Text->m_Layer = LAYER_GLOBLABEL;
break;
default:
DisplayError(this, wxT("ConvertTextType: Internal error") );
break;
}
case DRAW_TEXT_STRUCT_TYPE:
Text->m_StructType = DRAW_TEXT_STRUCT_TYPE;
Text->m_Layer = LAYER_NOTES;
break;
RedrawOneStruct(DrawPanel, DC, Text, GR_DEFAULT_DRAWMODE);
DrawPanel->CursorOn(DC); // redraw schematic cursor
default:
DisplayError( this, wxT( "ConvertTextType: Internal error" ) );
break;
}
RedrawOneStruct( DrawPanel, DC, Text, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); // redraw schematic cursor
}

File diff suppressed because it is too large Load Diff

View File

@ -15,104 +15,107 @@
/************************************************************/
void SetStructFather(EDA_BaseStruct * Struct, BASE_SCREEN * Screen)
void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
/************************************************************/
{
switch( Struct->m_StructType )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
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:
Struct->m_Parent = Screen;
break;
switch( Struct->m_StructType )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
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:
Struct->m_Parent = Screen;
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
break;
}
default:
break;
}
}
/*************************************************************/
void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC)
void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/*************************************************************/
{
if( m_Flags & IS_NEW)
{
Pnext = frame->m_CurrentScreen->EEDrawList;
frame->m_CurrentScreen->EEDrawList = this;
g_ItemToRepeat = this;
}
if( m_Flags & IS_NEW )
{
Pnext = frame->m_CurrentScreen->EEDrawList;
frame->m_CurrentScreen->EEDrawList = this;
g_ItemToRepeat = this;
}
m_Flags = 0;
SetFlagModify(frame->GetScreen());
frame->GetScreen()->m_CurrentItem = NULL;
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
m_Flags = 0;
SetFlagModify( frame->GetScreen() );
frame->GetScreen()->SetCurItem( NULL );
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->DrawPanel->CursorOff(DC); // Erase schematic cursor
RedrawOneStruct(frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE);
frame->DrawPanel->CursorOn(DC); // Display schematic cursor
frame->DrawPanel->CursorOff( DC ); // Erase schematic cursor
RedrawOneStruct( frame->DrawPanel, DC, this, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->CursorOn( DC ); // Display schematic cursor
}
/**************************************************/
/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */
/***************************************************/
static int table_zoom[] = {1,2,4,8,16,32,64,128, 0}; /* Valeurs standards du zoom */
/**************************************************/
/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */
/***************************************************/
static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */
/* Constructeur de SCREEN */
SCH_SCREEN::SCH_SCREEN(EDA_BaseStruct * parent, WinEDA_DrawFrame * frame_source, int idtype):
BASE_SCREEN(parent, frame_source, idtype)
SCH_SCREEN::SCH_SCREEN( EDA_BaseStruct* parent, WinEDA_DrawFrame* frame_source, int idtype ) :
BASE_SCREEN( parent, frame_source, idtype )
{
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;
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;
}
/****************************/
SCH_SCREEN::~SCH_SCREEN(void)
SCH_SCREEN::~SCH_SCREEN( void )
/****************************/
{
ClearUndoRedoList();
FreeDrawList();
ClearUndoRedoList();
FreeDrawList();
}
/*************************************/
SCH_SCREEN * SCH_SCREEN::GenCopy(void)
SCH_SCREEN* SCH_SCREEN::GenCopy( void )
/*************************************/
{
// TODO
return NULL;
return NULL;
}
/***********************************/
void SCH_SCREEN::FreeDrawList(void)
void SCH_SCREEN::FreeDrawList( void )
/***********************************/
/* Routine to clear EESchema drawing list of a screen.
*/
*/
{
EDA_BaseStruct *DrawStruct;
EDA_BaseStruct* DrawStruct;
while (EEDrawList != NULL)
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
delete DrawStruct;
}
while( EEDrawList != NULL )
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
delete DrawStruct;
}
}

View File

@ -14,518 +14,544 @@
/* Routines Locales */
static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC);
static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer );
static void Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitTrace( WinEDA_DrawFrame* frame, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
/*************************************************************/
void WinEDA_SchematicFrame::BeginSegment(wxDC * DC, int type)
void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
/*************************************************************/
/* Routine de Trace de segments ( WIRES, BUS ) pour lesquels chaque segment
est une structure.
*/
* est une structure.
*/
{
DrawSegmentStruct * oldsegment, * newsegment;
wxPoint pos = GetScreen()->m_Curseur;
DrawSegmentStruct* oldsegment, * newsegment;
wxPoint pos = GetScreen()->m_Curseur;
if ( GetScreen()->m_CurrentItem &&
(GetScreen()->m_CurrentItem->m_Flags == 0) )
GetScreen()->m_CurrentItem = NULL;
if( GetScreen()->GetCurItem()
&& (GetScreen()->GetCurItem()->m_Flags == 0) )
GetScreen()->SetCurItem( NULL );
if ( GetScreen()->m_CurrentItem )
{
switch (GetScreen()->m_CurrentItem->m_StructType )
{
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
break;
if( GetScreen()->GetCurItem() )
{
switch( GetScreen()->GetCurItem()->m_StructType )
{
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
break;
default:
return;
}
}
default:
return;
}
}
oldsegment = newsegment =
(DrawSegmentStruct *) GetScreen()->m_CurrentItem;
oldsegment = newsegment =
(DrawSegmentStruct*) GetScreen()->GetCurItem();
if (!newsegment) /* 1er point : creation de la 1ere structure */
{
if( !newsegment ) /* 1er point : creation de la 1ere structure */
{
switch( type )
{
default:
newsegment = new DrawSegmentStruct( pos, LAYER_NOTES );
break;
switch(type)
{
default:
newsegment = new DrawSegmentStruct(pos, LAYER_NOTES);
break;
case LAYER_WIRE:
newsegment = new DrawSegmentStruct(pos, LAYER_WIRE);
if ( LocatePinEnd(GetScreen()->EEDrawList, pos) )
newsegment->m_StartIsDangling = FALSE;
break;
case LAYER_BUS:
newsegment = new DrawSegmentStruct(pos, LAYER_BUS);
break;
}
case LAYER_WIRE:
newsegment = new DrawSegmentStruct( pos, LAYER_WIRE );
if( LocatePinEnd( GetScreen()->EEDrawList, pos ) )
newsegment->m_StartIsDangling = FALSE;
break;
newsegment->m_Flags = IS_NEW;
GetScreen()->m_CurrentItem = newsegment;
GetScreen()->ManageCurseur = Segment_in_Ghost;
GetScreen()->ForceCloseManageCurseur = ExitTrace;
g_ItemToRepeat = NULL;
}
case LAYER_BUS:
newsegment = new DrawSegmentStruct( pos, LAYER_BUS );
break;
}
else /* Trace en cours: Placement d'un point supplementaire */
{
if( (oldsegment->m_Start.x == oldsegment->m_End.x) &&
(oldsegment->m_Start.y == oldsegment->m_End.y) ) /* Structure inutile */
return;
GetScreen()->ManageCurseur(DrawPanel, DC, FALSE);
oldsegment->m_EndIsDangling = FALSE;
newsegment->m_Flags = IS_NEW;
GetScreen()->SetCurItem( newsegment );
GetScreen()->ManageCurseur = Segment_in_Ghost;
GetScreen()->ForceCloseManageCurseur = ExitTrace;
g_ItemToRepeat = NULL;
}
else /* Trace en cours: Placement d'un point supplementaire */
{
if( (oldsegment->m_Start.x == oldsegment->m_End.x)
&& (oldsegment->m_Start.y == oldsegment->m_End.y) ) /* Structure inutile */
return;
GetScreen()->ManageCurseur( DrawPanel, DC, FALSE );
oldsegment->m_EndIsDangling = FALSE;
/* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/
if ( IsTerminalPoint(GetScreen(), oldsegment->m_End, oldsegment->m_Layer) )
{
EndSegment(DC); return;
}
/* Creation du segment suivant ou fin de tracé si point sur pin, jonction ...*/
if( IsTerminalPoint( GetScreen(), oldsegment->m_End, oldsegment->m_Layer ) )
{
EndSegment( DC ); return;
}
/* Placement en liste generale */
oldsegment->Pnext = GetScreen()->EEDrawList;
g_ItemToRepeat = GetScreen()->EEDrawList = oldsegment;
GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel,DC, oldsegment, GR_DEFAULT_DRAWMODE);
GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor
/* Placement en liste generale */
oldsegment->Pnext = GetScreen()->EEDrawList;
g_ItemToRepeat = GetScreen()->EEDrawList = oldsegment;
GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, oldsegment, GR_DEFAULT_DRAWMODE );
GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor
/* Creation du segment suivant */
newsegment = oldsegment->GenCopy();
newsegment->m_Start = oldsegment->m_End;
newsegment->m_End = pos;
oldsegment->m_Flags = 0;
newsegment->m_Flags = IS_NEW;
GetScreen()->m_CurrentItem = newsegment;
GetScreen()->ManageCurseur(DrawPanel, DC, FALSE);
newsegment->m_StartIsDangling = FALSE;
newsegment->m_EndIsDangling = TRUE;
}
/* Creation du segment suivant */
newsegment = oldsegment->GenCopy();
newsegment->m_Start = oldsegment->m_End;
newsegment->m_End = pos;
oldsegment->m_Flags = 0;
newsegment->m_Flags = IS_NEW;
GetScreen()->SetCurItem( newsegment );
GetScreen()->ManageCurseur( DrawPanel, DC, FALSE );
newsegment->m_StartIsDangling = FALSE;
newsegment->m_EndIsDangling = TRUE;
}
}
/*************************************************************/
/* Routine de fin de trace d'une struct segment (Wire, Bus */
/*************************************************************/
void WinEDA_SchematicFrame::EndSegment(wxDC *DC)
void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
{
DrawSegmentStruct * segment = (DrawSegmentStruct *)GetScreen()->m_CurrentItem;
DrawSegmentStruct* segment = (DrawSegmentStruct*) GetScreen()->GetCurItem();
if ( GetScreen()->ManageCurseur == NULL ) return;
if ( segment == NULL ) return;
if ( (segment->m_Flags & IS_NEW) == 0) return;
if( GetScreen()->ManageCurseur == NULL )
return;
if( segment == NULL )
return;
if( (segment->m_Flags & IS_NEW) == 0 )
return;
if( (segment->m_Start.x == segment->m_End.x) &&
(segment->m_Start.y == segment->m_End.y) ) /* Structure inutile */
{
EraseStruct(segment, (SCH_SCREEN*)GetScreen());
segment = NULL;
}
if( (segment->m_Start.x == segment->m_End.x)
&& (segment->m_Start.y == segment->m_End.y) )/* Structure inutile */
{
EraseStruct( segment, (SCH_SCREEN*) GetScreen() );
segment = NULL;
}
else
{
/* Placement en liste generale */
GetScreen()->ManageCurseur( DrawPanel, DC, FALSE );
segment->Pnext = GetScreen()->EEDrawList;
g_ItemToRepeat = GetScreen()->EEDrawList = segment;
segment->m_Flags = 0;
}
else
{ /* Placement en liste generale */
GetScreen()->ManageCurseur(DrawPanel, DC, FALSE);
segment->Pnext = GetScreen()->EEDrawList;
g_ItemToRepeat = GetScreen()->EEDrawList = segment;
segment->m_Flags = 0;
}
/* Fin de trace */
GetScreen()->ManageCurseur = NULL;
GetScreen()->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
/* Fin de trace */
GetScreen()->ManageCurseur = NULL;
GetScreen()->ForceCloseManageCurseur = NULL;
GetScreen()->m_CurrentItem = NULL;
TestDanglingEnds(GetScreen()->EEDrawList, DC);
SetFlagModify(GetScreen());
if( segment )
{
GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel,DC, segment, GR_DEFAULT_DRAWMODE);
GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor
}
TestDanglingEnds( GetScreen()->EEDrawList, DC );
SetFlagModify( GetScreen() );
if( segment )
{
GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, segment, GR_DEFAULT_DRAWMODE );
GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor
}
}
/****************************************************************************/
static void Segment_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/****************************************************************************/
/* Dessin du Segment Fantome lors des deplacements du curseur
*/
*/
{
DrawSegmentStruct * segment =
(DrawSegmentStruct *) panel->m_Parent->GetScreen()->m_CurrentItem;
wxPoint endpos;
int color;
DrawSegmentStruct* segment =
(DrawSegmentStruct*) panel->m_Parent->GetScreen()->GetCurItem();
wxPoint endpos;
int color;
if ( segment == NULL ) return;
if( segment == NULL )
return;
color = ReturnLayerColor(segment->m_Layer) ^ HIGHT_LIGHT_FLAG;
color = ReturnLayerColor( segment->m_Layer ) ^ HIGHT_LIGHT_FLAG;
endpos = panel->m_Parent->GetScreen()->m_Curseur;
endpos = panel->m_Parent->GetScreen()->m_Curseur;
if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
{
if (ABS(endpos.x - segment->m_Start.x) < ABS(endpos.y - segment->m_Start.y))
endpos.x = segment->m_Start.x;
else
endpos.y = segment->m_Start.y;
}
if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
{
if( ABS( endpos.x - segment->m_Start.x ) < ABS( endpos.y - segment->m_Start.y ) )
endpos.x = segment->m_Start.x;
else
endpos.y = segment->m_Start.y;
}
if( erase ) // Redraw if segment lengtht != 0
{
if ( (segment->m_Start.x != segment->m_End.x) ||
(segment->m_Start.y != segment->m_End.y) )
RedrawOneStruct(panel,DC, segment, XOR_MODE, color);
}
segment->m_End = endpos;
// Redraw if segment lengtht != 0
if( erase ) // Redraw if segment lengtht != 0
{
if( (segment->m_Start.x != segment->m_End.x)
|| (segment->m_Start.y != segment->m_End.y) )
RedrawOneStruct( panel, DC, segment, XOR_MODE, color );
}
segment->m_End = endpos;
if ( (segment->m_Start.x != segment->m_End.x) ||
(segment->m_Start.y != segment->m_End.y) )
RedrawOneStruct(panel,DC, segment, XOR_MODE,color);
// Redraw if segment lengtht != 0
if( (segment->m_Start.x != segment->m_End.x)
|| (segment->m_Start.y != segment->m_End.y) )
RedrawOneStruct( panel, DC, segment, XOR_MODE, color );
}
/*****************************************************************************/
static void Polyline_in_Ghost(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*****************************************************************************/
/* Dessin du du Polyline Fantome lors des deplacements du curseur
*/
*/
{
DrawPolylineStruct * NewPoly =
(DrawPolylineStruct *)panel->m_Parent->GetScreen()->m_CurrentItem;
int color;
wxPoint endpos;
DrawPolylineStruct* NewPoly =
(DrawPolylineStruct*) panel->m_Parent->GetScreen()->GetCurItem();
int color;
wxPoint endpos;
endpos = panel->m_Parent->GetScreen()->m_Curseur;
color = ReturnLayerColor(NewPoly->m_Layer);
endpos = panel->m_Parent->GetScreen()->m_Curseur;
color = ReturnLayerColor( NewPoly->m_Layer );
GRSetDrawMode(DC, XOR_MODE);
GRSetDrawMode( DC, XOR_MODE );
if( g_HVLines )
{
/* Coerce the line to vertical or horizontal one: */
if (ABS(endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2]) <
ABS(endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1]))
endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2];
else
endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1];
}
if( g_HVLines )
{
/* Coerce the line to vertical or horizontal one: */
if( ABS( endpos.x - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] ) <
ABS( endpos.y - NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] ) )
endpos.x = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2];
else
endpos.y = NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1];
}
NewPoly->m_NumOfPoints++;
if( erase )
RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color);
NewPoly->m_NumOfPoints++;
if( erase )
RedrawOneStruct( panel, DC, NewPoly, XOR_MODE, color );
NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x;
NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y;
RedrawOneStruct(panel,DC, NewPoly, XOR_MODE, color);
NewPoly->m_NumOfPoints--;
NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 2] = endpos.x;
NewPoly->m_Points[NewPoly->m_NumOfPoints * 2 - 1] = endpos.y;
RedrawOneStruct( panel, DC, NewPoly, XOR_MODE, color );
NewPoly->m_NumOfPoints--;
}
/**********************************************************/
void WinEDA_SchematicFrame::DeleteCurrentSegment(wxDC * DC)
void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
/**********************************************************/
/*
Routine effacant le dernier trait trace, ou l'element pointe par la souris
*/
* Routine effacant le dernier trait trace, ou l'element pointe par la souris
*/
{
g_ItemToRepeat = NULL;
g_ItemToRepeat = NULL;
if( (GetScreen()->GetCurItem() == NULL)
|| ( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 ) )
{
return;
}
if( (GetScreen()->m_CurrentItem == NULL) ||
((GetScreen()->m_CurrentItem->m_Flags & IS_NEW) == 0) )
{
return;
}
/* Trace en cours: annulation */
if( GetScreen()->GetCurItem()->m_StructType == DRAW_POLYLINE_STRUCT_TYPE )
{
Polyline_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
}
else
{
Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
}
/* Trace en cours: annulation */
if (GetScreen()->m_CurrentItem->m_StructType == DRAW_POLYLINE_STRUCT_TYPE)
{
Polyline_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */
}
else
{
Segment_in_Ghost(DrawPanel, DC, FALSE); /* Effacement du trace en cours */
}
EraseStruct(GetScreen()->m_CurrentItem, GetScreen());
GetScreen()->ManageCurseur = NULL;
GetScreen()->m_CurrentItem = NULL;
EraseStruct( GetScreen()->GetCurItem(), GetScreen() );
GetScreen()->ManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
}
/***************************************************************************/
EDA_BaseStruct * WinEDA_SchematicFrame::CreateNewJunctionStruct(wxDC * DC)
EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( wxDC* DC )
/***************************************************************************/
/* Routine to create new connection struct.
*/
*/
{
DrawJunctionStruct *NewConnect;
DrawJunctionStruct* NewConnect;
NewConnect = new DrawJunctionStruct(GetScreen()->m_Curseur);
NewConnect = new DrawJunctionStruct( GetScreen()->m_Curseur );
g_ItemToRepeat = NewConnect;
g_ItemToRepeat = NewConnect;
GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel,DC, NewConnect, GR_DEFAULT_DRAWMODE);
GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor
GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, NewConnect, GR_DEFAULT_DRAWMODE );
GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor
NewConnect->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = NewConnect;
SetFlagModify(GetScreen());
return(NewConnect);
NewConnect->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = NewConnect;
SetFlagModify( GetScreen() );
return NewConnect;
}
/*************************************************************************/
EDA_BaseStruct *WinEDA_SchematicFrame::CreateNewNoConnectStruct(wxDC * DC)
EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
/*************************************************************************/
/*Routine to create new NoConnect struct. ( Symbole de Non Connexion)
*/
*/
{
DrawNoConnectStruct *NewNoConnect;
DrawNoConnectStruct* NewNoConnect;
NewNoConnect = new DrawNoConnectStruct(GetScreen()->m_Curseur);
g_ItemToRepeat = NewNoConnect;
NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur );
g_ItemToRepeat = NewNoConnect;
GetScreen()->CursorOff(DrawPanel, DC); // Erase schematic cursor
RedrawOneStruct(DrawPanel,DC, NewNoConnect, GR_DEFAULT_DRAWMODE);
GetScreen()->CursorOn(DrawPanel, DC); // Display schematic cursor
GetScreen()->CursorOff( DrawPanel, DC ); // Erase schematic cursor
RedrawOneStruct( DrawPanel, DC, NewNoConnect, GR_DEFAULT_DRAWMODE );
GetScreen()->CursorOn( DrawPanel, DC ); // Display schematic cursor
NewNoConnect->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = NewNoConnect;
SetFlagModify(GetScreen());
return(NewNoConnect);
NewNoConnect->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = NewNoConnect;
SetFlagModify( GetScreen() );
return NewNoConnect;
}
/**********************************************************/
static void ExitTrace(WinEDA_DrawFrame * frame, wxDC * DC)
static void ExitTrace( WinEDA_DrawFrame* frame, wxDC* DC )
/**********************************************************/
/* Routine de sortie des menus de trace */
{
BASE_SCREEN * Screen = frame->GetScreen();
BASE_SCREEN* Screen = frame->GetScreen();
if( Screen->m_CurrentItem) /* trace en cours */
{
Screen->ManageCurseur(frame->DrawPanel, DC, FALSE);
Screen->ManageCurseur = NULL;
Screen->ForceCloseManageCurseur = NULL;
EraseStruct(Screen->m_CurrentItem,(SCH_SCREEN*) Screen);
Screen->m_CurrentItem = NULL;
return;
}
else g_ItemToRepeat = NULL; // Fin de commande generale
if( Screen->GetCurItem() ) /* trace en cours */
{
Screen->ManageCurseur( frame->DrawPanel, DC, FALSE );
Screen->ManageCurseur = NULL;
Screen->ForceCloseManageCurseur = NULL;
EraseStruct( Screen->GetCurItem(), (SCH_SCREEN*) Screen );
Screen->SetCurItem( NULL );
return;
}
else
g_ItemToRepeat = NULL; // Fin de commande generale
}
/***************************************************/
void WinEDA_SchematicFrame::RepeatDrawItem(wxDC *DC)
void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
/***************************************************/
/* Routine de recopie du dernier element dessine
Les elements duplicables sont
fils, bus, traits, textes, labels
Les labels termines par un nombre seront incrementes
*/
* Les elements duplicables sont
* fils, bus, traits, textes, labels
* Les labels termines par un nombre seront incrementes
*/
{
char Line[256];
int ox = 0, oy = 0;
char Line[256];
int ox = 0, oy = 0;
if( g_ItemToRepeat == NULL ) return;
if( g_ItemToRepeat == NULL )
return;
switch( g_ItemToRepeat->m_StructType )
{
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawJunctionStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
switch( g_ItemToRepeat->m_StructType )
{
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawNoConnectStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
case DRAW_NOCONNECT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
case DRAW_TEXT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawTextStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy(Line,STRUCT->GetText());
IncrementLabelMember(Line);
STRUCT->m_Text = Line;
break;
case DRAW_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawLabelStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy(Line,STRUCT->GetText());
IncrementLabelMember(Line);
STRUCT->m_Text = Line;
break;
case DRAW_TEXT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawTextStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy( Line, STRUCT->GetText() );
IncrementLabelMember( Line );
STRUCT->m_Text = Line;
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawGlobalLabelStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy(Line,STRUCT->GetText());
IncrementLabelMember(Line);
STRUCT->m_Text = Line;
break;
case DRAW_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawLabelStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy( Line, STRUCT->GetText() );
IncrementLabelMember( Line );
STRUCT->m_Text = Line;
break;
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawSegmentStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Start.x += g_RepeatStep.x; ox = STRUCT->m_Start.x;
STRUCT->m_Start.y += g_RepeatStep.y; oy = STRUCT->m_Start.y;
STRUCT->m_End.x += g_RepeatStep.x;
STRUCT->m_End.y += g_RepeatStep.y;
break;
case DRAW_RACCORD_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ((DrawRaccordStruct*) g_ItemToRepeat)
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy( Line, STRUCT->GetText() );
IncrementLabelMember( Line );
STRUCT->m_Text = Line;
break;
default:
g_ItemToRepeat = NULL;
DisplayError(this, "Repeat Type Error", 10);
break;
}
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawSegmentStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Start.x += g_RepeatStep.x; ox = STRUCT->m_Start.x;
STRUCT->m_Start.y += g_RepeatStep.y; oy = STRUCT->m_Start.y;
STRUCT->m_End.x += g_RepeatStep.x;
STRUCT->m_End.y += g_RepeatStep.y;
break;
if ( g_ItemToRepeat )
{
g_ItemToRepeat->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = g_ItemToRepeat;
TestDanglingEnds(GetScreen()->EEDrawList, NULL);
RedrawOneStruct(DrawPanel,DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE);
// GetScreen()->Curseur.x = ox; GetScreen()->Curseur.x = oy;
case DRAW_RACCORD_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawRaccordStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
break;
default:
g_ItemToRepeat = NULL;
DisplayError( this, "Repeat Type Error", 10 );
break;
}
if( g_ItemToRepeat )
{
g_ItemToRepeat->Pnext = GetScreen()->EEDrawList;
GetScreen()->EEDrawList = g_ItemToRepeat;
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE );
// GetScreen()->Curseur.x = ox; GetScreen()->Curseur.x = oy;
// GRMouseWarp(DrawPanel, DrawPanel->CursorScreenPosition() );
}
}
}
/******************************************/
void IncrementLabelMember(char * Line)
void IncrementLabelMember( char* Line )
/******************************************/
/* Routine incrementant les labels, c'est a dire pour les textes finissant
par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre
*/
* par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre
*/
{
char * strnum;
int ii;
char* strnum;
int ii;
strnum = Line + strlen(Line) - 1;
if( !isdigit(*strnum) ) return;
strnum = Line + strlen( Line ) - 1;
if( !isdigit( *strnum ) )
return;
while( (strnum >= Line) && isdigit(*strnum) ) strnum--;
strnum++; /* pointe le debut de la chaine des digits */
ii = atoi(strnum) + g_RepeatDeltaLabel;
sprintf(strnum, "%d", ii);
while( (strnum >= Line) && isdigit( *strnum ) )
strnum--;
strnum++; /* pointe le debut de la chaine des digits */
ii = atoi( strnum ) + g_RepeatDeltaLabel;
sprintf( strnum, "%d", ii );
}
/***************************************************************************/
static bool IsTerminalPoint(SCH_SCREEN * screen, const wxPoint & pos, int layer)
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
/***************************************************************************/
/* Returne TRUE si pos est un point possible pour terminer automatiquement un
segment, c'est a dire pour
- type WIRE, si il y a
- une jonction
- ou une pin
- ou une extrémité unique de fil
- type BUS, si il y a
- ou une extrémité unique de BUS
*/
* segment, c'est a dire pour
* - type WIRE, si il y a
* - une jonction
* - ou une pin
* - ou une extrémité unique de fil
*
* - type BUS, si il y a
* - ou une extrémité unique de BUS
*/
{
EDA_BaseStruct * item;
LibDrawPin * pin;
DrawLibItemStruct * LibItem = NULL;
DrawSheetLabelStruct * pinsheet;
wxPoint itempos;
EDA_BaseStruct* item;
LibDrawPin* pin;
DrawLibItemStruct* LibItem = NULL;
DrawSheetLabelStruct* pinsheet;
wxPoint itempos;
switch ( layer )
{
case LAYER_BUS:
item = PickStruct(screen, BUSITEM);
if ( item ) return TRUE;
pinsheet = LocateAnyPinSheet(pos, screen->EEDrawList );
if ( pinsheet && IsBusLabel(pinsheet->GetText()) )
{
itempos = pinsheet->m_Pos;
if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE;
}
break;
switch( layer )
{
case LAYER_BUS:
item = PickStruct( screen, BUSITEM );
if( item )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
if( pinsheet && IsBusLabel( pinsheet->GetText() ) )
{
itempos = pinsheet->m_Pos;
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
return TRUE;
}
break;
case LAYER_NOTES:
item = PickStruct(screen, DRAWITEM);
if ( item )
return TRUE;
break;
case LAYER_NOTES:
item = PickStruct( screen, DRAWITEM );
if( item )
return TRUE;
break;
case LAYER_WIRE:
item = PickStruct(screen, RACCORDITEM |JUNCTIONITEM);
if ( item ) return TRUE;
case LAYER_WIRE:
item = PickStruct( screen, RACCORDITEM | JUNCTIONITEM );
if( item )
return TRUE;
pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem );
if ( pin && LibItem )
{
// calcul de la position exacte du point de connexion de la pin,
// selon orientation du composant:
itempos = LibItem->GetScreenCoord(pin->m_Pos);
itempos.x += LibItem->m_Pos.x;
itempos.y += LibItem->m_Pos.y;
if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE;
}
pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem );
if( pin && LibItem )
{
// calcul de la position exacte du point de connexion de la pin,
// selon orientation du composant:
itempos = LibItem->GetScreenCoord( pin->m_Pos );
itempos.x += LibItem->m_Pos.x;
itempos.y += LibItem->m_Pos.y;
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
return TRUE;
}
item = PickStruct(screen, WIREITEM);
if ( item ) return TRUE;
item = PickStruct( screen, WIREITEM );
if( item )
return TRUE;
item = PickStruct(screen, LABELITEM);
if ( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE) &&
( ((DrawGlobalLabelStruct*)item)->m_Pos.x == pos.x) &&
( ((DrawGlobalLabelStruct*)item)->m_Pos.y == pos.y) )
return TRUE;
item = PickStruct( screen, LABELITEM );
if( item && (item->m_StructType != DRAW_TEXT_STRUCT_TYPE)
&& ( ( (DrawGlobalLabelStruct*) item )->m_Pos.x == pos.x )
&& ( ( (DrawGlobalLabelStruct*) item )->m_Pos.y == pos.y ) )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
if ( pinsheet && ! IsBusLabel(pinsheet->GetText()) )
{
itempos = pinsheet->m_Pos;
if ( (itempos.x == pos.x) && (itempos.y == pos.y) ) return TRUE;
}
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
if( pinsheet && !IsBusLabel( pinsheet->GetText() ) )
{
itempos = pinsheet->m_Pos;
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
return TRUE;
}
break;
break;
default:
break;
}
default:
break;
}
return FALSE;
return FALSE;
}

View File

@ -1,6 +1,6 @@
/****************************************/
/* Module to load/save EESchema files. */
/****************************************/
/****************************************/
/* Module to load/save EESchema files. */
/****************************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -15,184 +15,193 @@
#include "id.h"
static void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList);
static void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList );
/* Variables locales */
/************************************************************************************/
int WinEDA_SchematicFrame::LoadOneEEProject(const wxString & FileName, bool IsNew)
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
/************************************************************************************/
/*
Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs
which are not already loaded)
*/
* Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
{
SCH_SCREEN *screen;
wxString FullFileName, msg;
bool LibCacheExist = FALSE;
EDA_ScreenList ScreenList(NULL);
for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
if(screen->IsModify())
break;
}
if ( screen )
{
if( ! IsOK(this, _("Clear Schematic Hierarchy (modified!)?")) ) return FALSE;
if ( ScreenSch->m_FileName != g_DefaultSchematicFileName )
SetLastProject(ScreenSch->m_FileName);
}
SCH_SCREEN* screen;
wxString FullFileName, msg;
bool LibCacheExist = FALSE;
EDA_ScreenList ScreenList( NULL );
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
if( screen->IsModify() )
break;
}
if( screen )
{
if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) )
return FALSE;
if( ScreenSch->m_FileName != g_DefaultSchematicFileName )
SetLastProject( ScreenSch->m_FileName );
}
screen = ScreenSch ;
screen = ScreenSch;
FullFileName = FileName;
if( (FullFileName.IsEmpty() ) && !IsNew )
{
wxString mask = wxT("*") + g_SchExtBuffer;
FullFileName = EDA_FileSelector( _("Schematic files:"),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SchExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if ( FullFileName.IsEmpty() ) return ( FALSE );
}
FullFileName = FileName;
if( ( FullFileName.IsEmpty() ) && !IsNew )
{
wxString mask = wxT( "*" ) + g_SchExtBuffer;
FullFileName = EDA_FileSelector( _( "Schematic files:" ),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SchExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( FullFileName.IsEmpty() )
return FALSE;
}
if( ClearProjectDrawList(screen, TRUE) == FALSE ) return(1);
if( ClearProjectDrawList( screen, TRUE ) == FALSE )
return 1;
ActiveScreen = m_CurrentScreen = screen = ScreenSch;
ScreenSch->ClearUndoRedoList();
screen->m_CurrentItem = NULL;
wxSetWorkingDirectory(wxPathOnly(FullFileName) );
m_CurrentScreen->m_FileName = FullFileName;
Affiche_Message(wxEmptyString);
MsgPanel->EraseMsgBox();
ActiveScreen = m_CurrentScreen = screen = ScreenSch;
ScreenSch->ClearUndoRedoList();
screen->SetCurItem( NULL );
wxSetWorkingDirectory( wxPathOnly( FullFileName ) );
m_CurrentScreen->m_FileName = FullFileName;
Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox();
memset( &g_EESchemaVar,0, sizeof(g_EESchemaVar) );
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
m_CurrentScreen->ClrModify();
m_CurrentScreen->Pnext = NULL;
m_CurrentScreen->ClrModify();
m_CurrentScreen->Pnext = NULL;
if( IsNew )
{
screen->m_CurrentSheet = &g_Sheet_A4;
screen->SetZoom(32);
screen->m_SheetNumber = screen->m_NumberOfSheet = 1;
screen->m_Title = wxT("noname.sch");
m_CurrentScreen->m_FileName = screen->m_Title;
screen->m_Company.Empty();
screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty();
screen->m_Commentaire3.Empty();
screen->m_Commentaire4.Empty();
Read_Config(wxEmptyString, TRUE);
Zoom_Automatique(TRUE);
ReDrawPanel();
return (1);
}
// Rechargement de la configuration:
msg = _("Ready\nWorking dir: \n") + wxGetCwd();
PrintMsg(msg);
if( IsNew )
{
screen->m_CurrentSheet = &g_Sheet_A4;
screen->SetZoom( 32 );
screen->m_SheetNumber = screen->m_NumberOfSheet = 1;
screen->m_Title = wxT( "noname.sch" );
m_CurrentScreen->m_FileName = screen->m_Title;
screen->m_Company.Empty();
screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty();
screen->m_Commentaire3.Empty();
screen->m_Commentaire4.Empty();
Read_Config( wxEmptyString, TRUE );
Zoom_Automatique( TRUE );
ReDrawPanel();
return 1;
}
Read_Config(wxEmptyString, FALSE);
// Rechargement de la configuration:
msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd();
PrintMsg( msg );
// Delete old caches.
LibraryStruct *nextlib, *lib = g_LibraryList;
for (; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if ( lib->m_IsLibCache )
FreeCmpLibrary(this, lib->m_Name);
}
Read_Config( wxEmptyString, FALSE );
if( IsNew )
{
ReDrawPanel();
return (1);
}
// Delete old caches.
LibraryStruct* nextlib, * lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if( lib->m_IsLibCache )
FreeCmpLibrary( this, lib->m_Name );
}
// Loading the project library cache
wxString FullLibName;
wxString shortfilename;
wxSplitPath(ScreenSch->m_FileName, NULL, &shortfilename, NULL);
FullLibName << wxT(".") << STRING_DIR_SEP << shortfilename << wxT(".cache") << g_LibExtBuffer;
if ( wxFileExists(FullLibName) )
{
wxString libname;
libname = FullLibName;
ChangeFileNameExt(libname,wxEmptyString);
msg = wxT("Load ") + FullLibName;
LibraryStruct *LibCache = LoadLibraryName(this, FullLibName, libname);
if ( LibCache )
{
LibCache->m_IsLibCache = TRUE;
msg += wxT(" OK");
}
else msg += wxT(" ->Error");
PrintMsg( msg );
LibCacheExist = TRUE;
}
if( IsNew )
{
ReDrawPanel();
return 1;
}
if ( ! wxFileExists(ScreenSch->m_FileName) && !LibCacheExist) // Nouveau projet prpbablement
{
msg.Printf( _("File %s not found (new project ?)"),
ScreenSch->m_FileName.GetData() );
DisplayInfo(this, msg, 20);
return (-1);
}
if( LoadOneEEFile(ScreenSch, ScreenSch->m_FileName) == FALSE) return (0);
// Loading the project library cache
wxString FullLibName;
wxString shortfilename;
wxSplitPath( ScreenSch->m_FileName, NULL, &shortfilename, NULL );
FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) <<
g_LibExtBuffer;
if( wxFileExists( FullLibName ) )
{
wxString libname;
libname = FullLibName;
ChangeFileNameExt( libname, wxEmptyString );
msg = wxT( "Load " ) + FullLibName;
LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname );
if( LibCache )
{
LibCache->m_IsLibCache = TRUE;
msg += wxT( " OK" );
}
else
msg += wxT( " ->Error" );
PrintMsg( msg );
LibCacheExist = TRUE;
}
/* load all subhierarchies fond in current list and new loaded list */
LoadSubHierarchy(this, ScreenSch->EEDrawList);
if( !wxFileExists( ScreenSch->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement
{
msg.Printf( _( "File %s not found (new project ?)" ),
ScreenSch->m_FileName.GetData() );
DisplayInfo( this, msg, 20 );
return -1;
}
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = ScreenSch;
Zoom_Automatique(FALSE);
if( LoadOneEEFile( ScreenSch, ScreenSch->m_FileName ) == FALSE )
return 0;
return (1);
/* load all subhierarchies fond in current list and new loaded list */
LoadSubHierarchy( this, ScreenSch->EEDrawList );
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = ScreenSch;
Zoom_Automatique( FALSE );
return 1;
}
/*******************************************************************************/
void LoadSubHierarchy(WinEDA_SchematicFrame * frame, EDA_BaseStruct *DrawList)
void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList )
/*******************************************************************************/
/* load subhierarcy when sheets are found in DrawList
recursive function.
*/
* recursive function.
*/
{
EDA_BaseStruct * EEDrawList = DrawList;
while(EEDrawList)
{
if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE)
{
#undef STRUCT
#define STRUCT ((DrawSheetStruct*)EEDrawList)
int timestamp = STRUCT->m_TimeStamp;
if(timestamp == 0 )
{
timestamp = GetTimeStamp();
STRUCT->m_TimeStamp = timestamp;
}
if( ! STRUCT->m_FileName.IsEmpty() )
{
if( frame->LoadOneEEFile(STRUCT, STRUCT->m_FileName) == TRUE )
{
LoadSubHierarchy(frame, STRUCT->EEDrawList);
}
}
else DisplayError(frame, _("No FileName in SubSheet"));
}
EEDrawList = EEDrawList->Pnext;
}
EDA_BaseStruct* EEDrawList = DrawList;
while( EEDrawList )
{
if( EEDrawList->m_StructType == DRAW_SHEET_STRUCT_TYPE )
{
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) EEDrawList )
int timestamp = STRUCT->m_TimeStamp;
if( timestamp == 0 )
{
timestamp = GetTimeStamp();
STRUCT->m_TimeStamp = timestamp;
}
if( !STRUCT->m_FileName.IsEmpty() )
{
if( frame->LoadOneEEFile( STRUCT, STRUCT->m_FileName ) == TRUE )
{
LoadSubHierarchy( frame, STRUCT->EEDrawList );
}
}
else
DisplayError( frame, _( "No FileName in SubSheet" ) );
}
EEDrawList = EEDrawList->Pnext;
}
}

View File

@ -15,453 +15,481 @@
/* Routines Locales */
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC );
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC );
/* Variables locales */
static int OldTransMat[2][2];
static int OldTransMat[2][2];
static wxPoint OldPos;
/*******************************************************/
wxString SelectFromLibBrowser(WinEDA_DrawFrame *parent)
wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
/*******************************************************/
{
wxString name;
WinEDA_ViewlibFrame * Viewer;
wxSemaphore semaphore(0,1);
Viewer = parent->m_Parent->ViewlibFrame;
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
if ( Viewer ) Viewer->Destroy();
Viewer = parent->m_Parent->ViewlibFrame = new
WinEDA_ViewlibFrame(parent->m_Parent->SchematicFrame,
parent->m_Parent, NULL, & semaphore );
Viewer->AdjustScrollBars();
wxString name;
WinEDA_ViewlibFrame* Viewer;
wxSemaphore semaphore( 0, 1 );
// Show the library viewer frame until it is closed
while ( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
{
wxYield();
wxMilliSleep(50);
}
name = g_CurrentViewComponentName;
return name;
Viewer = parent->m_Parent->ViewlibFrame;
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
if( Viewer )
Viewer->Destroy();
Viewer = parent->m_Parent->ViewlibFrame = new
WinEDA_ViewlibFrame(
parent->m_Parent->SchematicFrame,
parent->m_Parent,
NULL,
&semaphore );
Viewer->AdjustScrollBars();
// Show the library viewer frame until it is closed
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
{
wxYield();
wxMilliSleep( 50 );
}
name = g_CurrentViewComponentName;
return name;
}
/**************************************************************************/
EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
const wxString& libname,
wxArrayString& HistoryList,
bool UseLibBrowser )
/**************************************************************************/
/**************************************************************************/
EDA_SchComponentStruct * WinEDA_SchematicFrame::Load_Component(wxDC * DC,
const wxString & libname, wxArrayString & HistoryList,
bool UseLibBrowser)
/**************************************************************************/
/* load from a library and place a component
if libname != "", search in lib "libname"
else search in all loaded libs
*/
* if libname != "", search in lib "libname"
* else search in all loaded libs
*/
{
int ii, CmpCount = 0;
LibDrawField * Field;
EDA_LibComponentStruct *Entry = NULL;
EDA_SchComponentStruct * DrawLibItem = NULL;
LibraryStruct *Library = NULL;
wxString Name, keys, msg;
bool AllowWildSeach = TRUE;
g_ItemToRepeat = NULL;
DrawPanel->m_IgnoreMouseEvents = TRUE;
if ( ! libname.IsEmpty() )
{
Library = g_LibraryList;
while (Library)
{
if( Library->m_Name == libname )
{
CmpCount = Library->m_NumOfParts;
break;
}
Library = Library->m_Pnext;
}
}
else
{
LibraryStruct * lib = g_LibraryList;
while (lib)
{
CmpCount += lib->m_NumOfParts;
lib = lib->m_Pnext;
}
}
int ii, CmpCount = 0;
LibDrawField* Field;
EDA_LibComponentStruct* Entry = NULL;
EDA_SchComponentStruct* DrawLibItem = NULL;
LibraryStruct* Library = NULL;
wxString Name, keys, msg;
bool AllowWildSeach = TRUE;
/* Ask for a component name or key words */
msg.Printf (_("component selection (%d items loaded):"), CmpCount);
Name = GetComponentName(this, HistoryList, msg,
UseLibBrowser ? SelectFromLibBrowser : NULL);
Name.MakeUpper();
if( Name.IsEmpty() )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */
}
if( Name.GetChar(0) == '=' )
{
AllowWildSeach = FALSE;
keys = Name.AfterFirst('=');
if( DataBaseGetName(this, keys, Name) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
g_ItemToRepeat = NULL;
DrawPanel->m_IgnoreMouseEvents = TRUE;
else if( Name == wxT("*") )
{
AllowWildSeach = FALSE;
if( GetNameOfPartToLoad(this, Library, Name) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
if( !libname.IsEmpty() )
{
Library = g_LibraryList;
while( Library )
{
if( Library->m_Name == libname )
{
CmpCount = Library->m_NumOfParts;
break;
}
Library = Library->m_Pnext;
}
}
else
{
LibraryStruct* lib = g_LibraryList;
while( lib )
{
CmpCount += lib->m_NumOfParts;
lib = lib->m_Pnext;
}
}
else if( Name.Contains( wxT("?")) || Name.Contains( wxT("*")) )
{
AllowWildSeach = FALSE;
if( DataBaseGetName(this, keys, Name) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
/* Ask for a component name or key words */
msg.Printf( _( "component selection (%d items loaded):" ), CmpCount );
Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT);
if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */
{
AllowWildSeach = FALSE;
wxString wildname = wxChar('*') + Name + wxChar('*');
Name = wildname;
if( DataBaseGetName(this, keys, Name) )
Entry = FindLibPart(Name.GetData(), libname, FIND_ROOT);
if( Entry == NULL)
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
Name = GetComponentName( this, HistoryList, msg,
UseLibBrowser ? SelectFromLibBrowser : NULL );
Name.MakeUpper();
if( Name.IsEmpty() )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL; /* annulation de commande */
}
if( Name.GetChar( 0 ) == '=' )
{
AllowWildSeach = FALSE;
keys = Name.AfterFirst( '=' );
if( DataBaseGetName( this, keys, Name ) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
else if( Name == wxT( "*" ) )
{
AllowWildSeach = FALSE;
if( GetNameOfPartToLoad( this, Library, Name ) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
else if( Name.Contains( wxT( "?" ) ) || Name.Contains( wxT( "*" ) ) )
{
AllowWildSeach = FALSE;
if( DataBaseGetName( this, keys, Name ) == 0 )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT );
if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */
{
AllowWildSeach = FALSE;
wxString wildname = wxChar( '*' ) + Name + wxChar( '*' );
Name = wildname;
if( DataBaseGetName( this, keys, Name ) )
Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT );
if( Entry == NULL )
{
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
return NULL;
}
}
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
if( Entry == NULL)
{
msg = _("Failed to find part ") + Name + _(" in library");
DisplayError(this, msg, 10);
return NULL;
}
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->MouseToCursorSchema();
if( Entry == NULL )
{
msg = _( "Failed to find part " ) + Name + _( " in library" );
DisplayError( this, msg, 10 );
return NULL;
}
AddHistoryComponentName(HistoryList, Name);
AddHistoryComponentName( HistoryList, Name );
DrawPanel->ManageCurseur = ShowWhileMoving ;
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
DrawLibItem = new EDA_SchComponentStruct(m_CurrentScreen->m_Curseur);
DrawLibItem->m_Multi = 1; /* Selection de l'unite 1 dans le boitier */
DrawLibItem->m_Convert = 1;
DrawLibItem->m_ChipName = Name;
DrawLibItem->m_TimeStamp = GetTimeStamp();
DrawLibItem->m_Flags = IS_NEW | IS_MOVED;
DrawLibItem = new EDA_SchComponentStruct( m_CurrentScreen->m_Curseur );
DrawLibItem->m_Multi = 1;/* Selection de l'unite 1 dans le boitier */
DrawLibItem->m_Convert = 1;
DrawLibItem->m_ChipName = Name;
DrawLibItem->m_TimeStamp = GetTimeStamp();
DrawLibItem->m_Flags = IS_NEW | IS_MOVED;
/* Init champ Valeur */
DrawLibItem->m_Field[VALUE].m_Pos.x =
Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[VALUE].m_Pos.y =
Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient;
DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName;
DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs;
DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify;
DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify;
/* Init champ Valeur */
DrawLibItem->m_Field[VALUE].m_Pos.x =
Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[VALUE].m_Pos.y =
Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient;
DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName;
DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs;
DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify;
DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify;
msg = Entry->m_Prefix.m_Text;
if ( msg.IsEmpty() ) msg = wxT("U");
msg += wxT("?");
msg = Entry->m_Prefix.m_Text;
if( msg.IsEmpty() )
msg = wxT( "U" );
msg += wxT( "?" );
/* Init champ Reference */
DrawLibItem->m_Field[REFERENCE].m_Pos.x =
Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[REFERENCE].m_Pos.y =
Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->m_Field[REFERENCE].m_Text = msg;
DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs;
DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify;
DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify;
/* Init champ Reference */
DrawLibItem->m_Field[REFERENCE].m_Pos.x =
Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x;
DrawLibItem->m_Field[REFERENCE].m_Pos.y =
Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y;
DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->m_Field[REFERENCE].m_Text = msg;
DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs;
DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify;
DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify;
/* Init des autres champs si predefinis dans la librairie */
for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*)Field->Pnext )
{
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) continue;
ii = Field->m_FieldId;
if( ii < 2 ) continue;
if( ii >= NUMBER_OF_FIELDS ) continue;
DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x;
DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y;
DrawLibItem->m_Field[ii].m_Size = Field->m_Size;
DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs;
DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient;
DrawLibItem->m_Field[ii].m_Text = Field->m_Text;
DrawLibItem->m_Field[ii].m_Name = Field->m_Name;
DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify;
DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify;
}
/* Init des autres champs si predefinis dans la librairie */
for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
{
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue;
ii = Field->m_FieldId;
if( ii < 2 )
continue;
if( ii >= NUMBER_OF_FIELDS )
continue;
DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x;
DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y;
DrawLibItem->m_Field[ii].m_Size = Field->m_Size;
DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs;
DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient;
DrawLibItem->m_Field[ii].m_Text = Field->m_Text;
DrawLibItem->m_Field[ii].m_Name = Field->m_Name;
DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify;
DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify;
}
/* Trace du composant */
DrawStructsInGhost(DrawPanel, DC, DrawLibItem, 0, 0 );
MsgPanel->EraseMsgBox();
DrawLibItem->Display_Infos(this);
/* Trace du composant */
DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 );
MsgPanel->EraseMsgBox();
DrawLibItem->Display_Infos( this );
return DrawLibItem;
return DrawLibItem;
}
/**************************************************************************/
/*** Routine de deplacement du composant. ***/
/*** Appele par GeneralControle grace a ActiveScreen->ManageCurseur. ***/
/**************************************************************************/
static void ShowWhileMoving(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
wxPoint move_vector;
wxPoint move_vector;
EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * )
panel->m_Parent->m_CurrentScreen->m_CurrentItem;
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*)
panel->m_Parent->m_CurrentScreen->GetCurItem();
/* Effacement du composant */
if( erase )
DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 );
/* Effacement du composant */
if( erase )
DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 );
move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x;
move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y;
MoveOneStruct(DrawLibItem, move_vector);
move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x;
move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y;
MoveOneStruct( DrawLibItem, move_vector );
DrawStructsInGhost(panel, DC, DrawLibItem, 0, 0 );
DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 );
}
/**************************************************************************/
void WinEDA_SchematicFrame::CmpRotationMiroir(
EDA_SchComponentStruct * DrawComponent, wxDC * DC, int type_rotate )
EDA_SchComponentStruct* DrawComponent, wxDC* DC, int type_rotate )
/**************************************************************************/
/* Routine permettant les rotations et les miroirs d'un composant
Si DC = NULL : pas de redessin
*/
* Si DC = NULL : pas de redessin
*/
{
if ( DrawComponent == NULL ) return;
if( DrawComponent == NULL )
return;
/* Efface le trace precedent */
if ( DC )
{
DrawPanel->CursorOff(DC);
if ( DrawComponent->m_Flags )
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode);
}
/* Efface le trace precedent */
if( DC )
{
DrawPanel->CursorOff( DC );
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
}
DrawComponent->SetRotationMiroir(type_rotate);
DrawComponent->SetRotationMiroir( type_rotate );
/* Redessine le composant dans la nouvelle position */
if ( DC )
{
if( DrawComponent->m_Flags )
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE);
DrawPanel->CursorOn(DC);
}
/* Redessine le composant dans la nouvelle position */
if( DC )
{
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC );
}
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
GetScreen()->SetModify();
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
GetScreen()->SetModify();
}
/************************************************************/
static void ExitPlaceCmp(WinEDA_DrawPanel * Panel, wxDC * DC )
static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************/
/* Routine de sortie de la fonction de placement de composant
*/
*/
{
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*)
Panel->m_Parent->m_CurrentScreen->GetCurItem();
EDA_SchComponentStruct * DrawLibItem = (EDA_SchComponentStruct * )
Panel->m_Parent->m_CurrentScreen->m_CurrentItem;
if( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
{
DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 );
delete DrawLibItem;
}
else if( DrawLibItem ) /* Deplacement ancien composant en cours */
{
wxPoint move_vector;
DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 );
if ( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
{
DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 );
delete DrawLibItem;
}
move_vector.x = OldPos.x - DrawLibItem->m_Pos.x;
move_vector.y = OldPos.y - DrawLibItem->m_Pos.y;
else if ( DrawLibItem ) /* Deplacement ancien composant en cours */
{
wxPoint move_vector;
DrawStructsInGhost(Panel, DC, DrawLibItem, 0, 0 );
MoveOneStruct( DrawLibItem, move_vector );
move_vector.x = OldPos.x - DrawLibItem->m_Pos.x;
move_vector.y = OldPos.y - DrawLibItem->m_Pos.y;
memcpy( DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) );
DrawLibItem->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
}
MoveOneStruct(DrawLibItem, move_vector);
memcpy(DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) );
DrawLibItem->Draw(Panel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE);
}
DrawLibItem->m_Flags = 0;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->m_Parent->m_CurrentScreen->m_CurrentItem = NULL;
DrawLibItem->m_Flags = 0;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->m_Parent->m_CurrentScreen->SetCurItem( NULL );
}
/************************************************************************/
void WinEDA_SchematicFrame::SelPartUnit(EDA_SchComponentStruct *DrawComponent,
int unit, wxDC * DC)
void WinEDA_SchematicFrame::SelPartUnit( EDA_SchComponentStruct* DrawComponent,
int unit, wxDC* DC )
/************************************************************************/
/* Selection de l'unite dans les boitiers a multiples Parts */
{
int m_UnitCount;
EDA_LibComponentStruct * LibEntry;
int m_UnitCount;
EDA_LibComponentStruct* LibEntry;
if (DrawComponent == NULL) return;
if( DrawComponent == NULL )
return;
LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT);
if( LibEntry == NULL ) return;
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( LibEntry == NULL )
return;
m_UnitCount = LibEntry->m_UnitCount;
m_UnitCount = LibEntry->m_UnitCount;
if( m_UnitCount <= 1 ) return;
if( m_UnitCount <= 1 )
return;
if( DrawComponent->m_Multi == unit ) return;
if ( unit < 1 ) unit = 1;
if ( unit > m_UnitCount ) unit = m_UnitCount;
if( DrawComponent->m_Multi == unit )
return;
if( unit < 1 )
unit = 1;
if( unit > m_UnitCount )
unit = m_UnitCount;
/* Efface le trace precedent */
if ( DrawComponent->m_Flags )
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode);
/* Efface le trace precedent */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
/* Mise a jour du numero d'unite */
DrawComponent->m_Multi = unit;
/* Mise a jour du numero d'unite */
DrawComponent->m_Multi = unit;
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags )
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE);
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
GetScreen()->SetModify();
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
GetScreen()->SetModify();
}
/************************************************************************/
void WinEDA_SchematicFrame::ConvertPart(EDA_SchComponentStruct *DrawComponent,
wxDC * DC)
void WinEDA_SchematicFrame::ConvertPart( EDA_SchComponentStruct* DrawComponent,
wxDC* DC )
/************************************************************************/
{
int ii;
EDA_LibComponentStruct *LibEntry;
int ii;
EDA_LibComponentStruct* LibEntry;
if (DrawComponent == NULL) return;
if( DrawComponent == NULL )
return;
LibEntry = FindLibPart(DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT);
if( LibEntry == NULL ) return;
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( LibEntry == NULL )
return;
if( (ii = LookForConvertPart(LibEntry) ) < 2 )
{
DisplayError(this, wxT("No Convert found"), 10); return;
}
if( ( ii = LookForConvertPart( LibEntry ) ) < 2 )
{
DisplayError( this, wxT( "No Convert found" ), 10 ); return;
}
/* Efface le trace precedent */
if ( DrawComponent->m_Flags )
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), g_XorMode);
/* Efface le trace precedent */
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
DrawComponent->m_Convert++;
if( DrawComponent->m_Convert > ii ) DrawComponent->m_Convert = 1;
DrawComponent->m_Convert++;
if( DrawComponent->m_Convert > ii )
DrawComponent->m_Convert = 1;
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags & IS_MOVED)
DrawStructsInGhost(DrawPanel, DC, DrawComponent, 0, 0 );
else DrawComponent->Draw(DrawPanel, DC, wxPoint(0,0), GR_DEFAULT_DRAWMODE);
/* Redessine le composant dans la nouvelle position */
if( DrawComponent->m_Flags & IS_MOVED )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
GetScreen()->SetModify();
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
GetScreen()->SetModify();
}
/**********************************************************/
int LookForConvertPart( EDA_LibComponentStruct * LibEntry )
int LookForConvertPart( EDA_LibComponentStruct* LibEntry )
/**********************************************************/
/* Retourne la plus grande valeur trouvee dans la liste des elements
"drawings" du composant LibEntry, pour le membre .Convert
Si il n'y a pas de representation type "convert", la valeur
retournee est 0 ou 1
Si il y a une representation type "convert",
la valeur retournee est > 1 (typiquement 2)
* "drawings" du composant LibEntry, pour le membre .Convert
* Si il n'y a pas de representation type "convert", la valeur
* retournee est 0 ou 1
* Si il y a une representation type "convert",
* la valeur retournee est > 1 (typiquement 2)
*/
{
int ii;
LibEDA_BaseStruct *DrawLibEntry;
int ii;
LibEDA_BaseStruct* DrawLibEntry;
DrawLibEntry = LibEntry->m_Drawings;
ii = 0;
while( DrawLibEntry)
{
if (ii < DrawLibEntry->m_Convert ) ii = DrawLibEntry->m_Convert;
DrawLibEntry = DrawLibEntry->Next();
}
DrawLibEntry = LibEntry->m_Drawings;
ii = 0;
while( DrawLibEntry )
{
if( ii < DrawLibEntry->m_Convert )
ii = DrawLibEntry->m_Convert;
DrawLibEntry = DrawLibEntry->Next();
}
return (ii);
return ii;
}
/***********************************************************************************/
void WinEDA_SchematicFrame::StartMovePart(EDA_SchComponentStruct * Component,
wxDC * DC)
void WinEDA_SchematicFrame::StartMovePart( EDA_SchComponentStruct* Component,
wxDC* DC )
/***********************************************************************************/
{
if( Component == NULL) return;
if( Component->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE)
return;
if( Component == NULL )
return;
if( Component->m_StructType != DRAW_LIB_ITEM_STRUCT_TYPE )
return;
if ( Component->m_Flags == 0 )
{
if ( g_ItemToUndoCopy ) delete g_ItemToUndoCopy;
g_ItemToUndoCopy = Component->GenCopy();
}
if( Component->m_Flags == 0 )
{
if( g_ItemToUndoCopy )
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = Component->GenCopy();
}
DrawPanel->CursorOff(DC);
m_CurrentScreen->m_Curseur = Component->m_Pos;
DrawPanel->MouseToCursorSchema();
DrawPanel->ManageCurseur = ShowWhileMoving ;
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
m_CurrentScreen->m_CurrentItem = Component;
OldPos = Component->m_Pos;
memcpy(OldTransMat, Component->m_Transform, sizeof(OldTransMat) );
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = Component->m_Pos;
DrawPanel->MouseToCursorSchema();
RedrawOneStruct(DrawPanel, DC, Component, g_XorMode);
Component->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur(DrawPanel, DC,FALSE);
DrawPanel->m_AutoPAN_Request = TRUE;
DrawPanel->CursorOn(DC);
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
m_CurrentScreen->SetCurItem( Component );
OldPos = Component->m_Pos;
memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) );
RedrawOneStruct( DrawPanel, DC, Component, g_XorMode );
Component->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->m_AutoPAN_Request = TRUE;
DrawPanel->CursorOn( DC );
}

View File

@ -1,6 +1,6 @@
/***************/
/* hotkeys.cpp */
/***************/
/***************/
/* hotkeys.cpp */
/***************/
#include "fctsys.h"
@ -16,431 +16,474 @@
#include "protos.h"
enum hotkey_id_commnand {
HK_NOT_FOUND = 0,
HK_RESET_LOCAL_COORD,
HK_HELP,
HK_ZOOM_IN,
HK_ZOOM_OUT,
HK_ZOOM_REDRAW,
HK_ZOOM_CENTER,
HK_NEXT_SEARCH,
HK_DELETE,
HK_REPEAT_LAST,
HK_MOVEBLOCK_TO_DRAGBLOCK,
HK_ROTATE_COMPONENT,
HK_MIRROR_X_COMPONENT,
HK_MIRROR_Y_COMPONENT,
HK_ORIENT_NORMAL_COMPONENT,
HK_MOVE_COMPONENT,
HK_ADD_NEW_COMPONENT,
HK_BEGIN_WIRE
HK_NOT_FOUND = 0,
HK_RESET_LOCAL_COORD,
HK_HELP,
HK_ZOOM_IN,
HK_ZOOM_OUT,
HK_ZOOM_REDRAW,
HK_ZOOM_CENTER,
HK_NEXT_SEARCH,
HK_DELETE,
HK_REPEAT_LAST,
HK_MOVEBLOCK_TO_DRAGBLOCK,
HK_ROTATE_COMPONENT,
HK_MIRROR_X_COMPONENT,
HK_MIRROR_Y_COMPONENT,
HK_ORIENT_NORMAL_COMPONENT,
HK_MOVE_COMPONENT,
HK_ADD_NEW_COMPONENT,
HK_BEGIN_WIRE
};
/* Class to handle hotkey commnands. hotkeys have a default value
This class allows (for the future..) the real key code changed by user(from a key code list file, TODO)
*/
* This class allows (for the future..) the real key code changed by user(from a key code list file, TODO)
*/
class Ki_HotkeyInfo
{
public:
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message.
hotkey_id_commnand m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message.
hotkey_id_commnand m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
public:
Ki_HotkeyInfo(const wxChar * infomsg, hotkey_id_commnand idcommand, int keycode);
Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand idcommand, int keycode );
};
Ki_HotkeyInfo::Ki_HotkeyInfo(const wxChar * infomsg, hotkey_id_commnand idcommand, int keycode)
Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand idcommand, int keycode )
{
m_KeyCode = keycode; // Key code (ascii value for ascii keys or wxWidgets code for function key
m_InfoMsg = infomsg; // info message.
m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
m_KeyCode = keycode; // Key code (ascii value for ascii keys or wxWidgets code for function key
m_InfoMsg = infomsg; // info message.
m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
}
/* local variables */
/* Hotkey list: */
static Ki_HotkeyInfo HkBeginWire(wxT("begin Wire"), HK_BEGIN_WIRE, 'W');
static Ki_HotkeyInfo HkAddComponent(wxT("Add Component"), HK_ADD_NEW_COMPONENT, 'A');
static Ki_HotkeyInfo HkMirrorYComponent(wxT("Mirror Y Component"), HK_MIRROR_Y_COMPONENT, 'Y');
static Ki_HotkeyInfo HkMirrorXComponent(wxT("Mirror X Component"), HK_MIRROR_X_COMPONENT, 'X');
static Ki_HotkeyInfo HkOrientNormalComponent(wxT("Orient Normal Component"), HK_ORIENT_NORMAL_COMPONENT, 'N');
static Ki_HotkeyInfo HkRotateComponent(wxT("Rotate Component"), HK_ROTATE_COMPONENT, 'R');
static Ki_HotkeyInfo HkMoveComponent(wxT("Move Component"), HK_MOVE_COMPONENT, 'M');
static Ki_HotkeyInfo HkMove2Drag(wxT("Switch move block to drag block"), HK_MOVEBLOCK_TO_DRAGBLOCK, '\t');
static Ki_HotkeyInfo HkInsert(wxT("Repeat Last Item"), HK_REPEAT_LAST, WXK_INSERT);
static Ki_HotkeyInfo HkDelete(wxT("Delete Item"), HK_DELETE, WXK_DELETE);
static Ki_HotkeyInfo HkResetLocalCoord(wxT("Reset local coord."), HK_RESET_LOCAL_COORD, ' ');
static Ki_HotkeyInfo HkNextSearch(wxT("Next Search"), HK_NEXT_SEARCH, WXK_F5);
static Ki_HotkeyInfo HkZoomCenter(wxT("Zoom Center"), HK_ZOOM_CENTER, WXK_F4);
static Ki_HotkeyInfo HkZoomRedraw(wxT("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3);
static Ki_HotkeyInfo HkZoomOut(wxT("Zoom Out"), HK_ZOOM_OUT, WXK_F2);
static Ki_HotkeyInfo HkZoomIn(wxT("Zoom In"), HK_ZOOM_IN, WXK_F1);
static Ki_HotkeyInfo HkHelp(wxT("Help: this message"), HK_HELP, '?');
static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' );
static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' );
static Ki_HotkeyInfo HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_COMPONENT,
'Y' );
static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT,
'X' );
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo HkRotateComponent( wxT( "Rotate Component" ), HK_ROTATE_COMPONENT, 'R' );
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component" ), HK_MOVE_COMPONENT, 'M' );
static Ki_HotkeyInfo HkMove2Drag( wxT( "Switch move block to drag block" ),
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
static Ki_HotkeyInfo HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
static Ki_HotkeyInfo HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' );
static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH, WXK_F5 );
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
// List of hotkey descriptors for schematic
static Ki_HotkeyInfo *s_Schematic_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkNextSearch, &HkResetLocalCoord,
&HkDelete, &HkInsert, &HkMove2Drag,
&HkMoveComponent, &HkAddComponent,
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, & HkOrientNormalComponent,
&HkBeginWire,
NULL
static Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkNextSearch, &HkResetLocalCoord,
&HkDelete, &HkInsert, &HkMove2Drag,
&HkMoveComponent, &HkAddComponent,
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent,
&HkBeginWire,
NULL
};
// Library editor:
static Ki_HotkeyInfo HkInsertPin(wxT("Repeat Pin"), HK_REPEAT_LAST, WXK_INSERT);
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
// List of hotkey descriptors for libray editor
static Ki_HotkeyInfo *s_LibEdit_Hotkey_List[] =
static Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
{
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
&HkInsertPin,
NULL
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
&HkInsertPin,
NULL
};
/****************************************************/
static wxString ReturnKeyNameFromKeyCode(int keycode)
static wxString ReturnKeyNameFromKeyCode( int keycode )
/****************************************************/
/*
* return the key name from the key code
* Only some wxWidgets key values are handled for function key
* @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name wxString
*/
* return the key name from the key code
* Only some wxWidgets key values are handled for function key
* @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name wxString
*/
{
wxString keyname, modifier, fullkeyname;
if ( keycode & GR_KB_CTRL) modifier << wxT("Ctrl ");
if ( keycode & GR_KB_ALT) modifier << wxT("Alt ");
if ( keycode & GR_KB_SHIFT) modifier << wxT("Shift ");
keycode &= ~(GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT);
wxString keyname, modifier, fullkeyname;
switch ( keycode )
{
default:
keyname.Printf(wxT("%c"), keycode);
break;
case WXK_F1:
case WXK_F2:
case WXK_F3:
case WXK_F4:
case WXK_F5:
case WXK_F6:
case WXK_F7:
case WXK_F8:
case WXK_F9:
case WXK_F10:
case WXK_F11:
case WXK_F12:
keyname.Printf(wxT("F%d"), keycode - WXK_F1 + 1);
break;
case ' ':
keyname = wxT("space");
break;
if( keycode & GR_KB_CTRL )
modifier << wxT( "Ctrl " );
if( keycode & GR_KB_ALT )
modifier << wxT( "Alt " );
if( keycode & GR_KB_SHIFT )
modifier << wxT( "Shift " );
keycode &= ~(GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT);
case '\t':
keyname = wxT("Tab");
break;
switch( keycode )
{
default:
keyname.Printf( wxT( "%c" ), keycode );
break;
case WXK_DELETE:
keyname = wxT("Delete");
break;
case WXK_F1:
case WXK_F2:
case WXK_F3:
case WXK_F4:
case WXK_F5:
case WXK_F6:
case WXK_F7:
case WXK_F8:
case WXK_F9:
case WXK_F10:
case WXK_F11:
case WXK_F12:
keyname.Printf( wxT( "F%d" ), keycode - WXK_F1 + 1 );
break;
case WXK_INSERT:
keyname = wxT("Insert");
break;
}
fullkeyname = modifier + keyname;
return keyname;
case ' ':
keyname = wxT( "space" );
break;
case '\t':
keyname = wxT( "Tab" );
break;
case WXK_DELETE:
keyname = wxT( "Delete" );
break;
case WXK_INSERT:
keyname = wxT( "Insert" );
break;
}
fullkeyname = modifier + keyname;
return keyname;
}
/****************************************************************************/
static void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List)
static void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo** List )
/*****************************************************************************/
/*
* Displays the current hotkey list
* @param frame = current open frame
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @return none
*/
* Displays the current hotkey list
* @param frame = current open frame
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @return none
*/
{
wxString keyname;
wxString msg = _("Current hotkey list:\n\n");
for ( ; * List != NULL; List++ )
{
Ki_HotkeyInfo * hk_decr = * List;
if ( hk_decr->m_InfoMsg.IsEmpty() ) break;
msg += _("key ");
keyname = ReturnKeyNameFromKeyCode(hk_decr->m_KeyCode);
msg += keyname + wxT(": ") + hk_decr->m_InfoMsg + wxT("\n");
}
DisplayInfo(frame, msg);
wxString keyname;
wxString msg = _( "Current hotkey list:\n\n" );
for( ; *List != NULL; List++ )
{
Ki_HotkeyInfo* hk_decr = *List;
if( hk_decr->m_InfoMsg.IsEmpty() )
break;
msg += _( "key " );
keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
msg += keyname + wxT( ": " ) + hk_decr->m_InfoMsg + wxT( "\n" );
}
DisplayInfo( frame, msg );
}
/******************************************************************/
static int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List)
static int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List )
/******************************************************************/
/*
* Return an id identifier fron a key code for OnHotKey() function
* @param key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @return the corresponding function identifier from the Ki_HotkeyInfo List
*/
* Return an id identifier fron a key code for OnHotKey() function
* @param key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands
* @return the corresponding function identifier from the Ki_HotkeyInfo List
*/
{
for ( ; * List != NULL; List++ )
{
Ki_HotkeyInfo * hk_decr = * List;
if ( hk_decr->m_KeyCode == key ) return hk_decr->m_Idcommand;
}
return HK_NOT_FOUND;
for( ; *List != NULL; List++ )
{
Ki_HotkeyInfo* hk_decr = *List;
if( hk_decr->m_KeyCode == key )
return hk_decr->m_Idcommand;
}
return HK_NOT_FOUND;
}
/***********************************************************/
void WinEDA_SchematicFrame::OnHotKey(wxDC * DC, int hotkey,
EDA_BaseStruct * DrawStruct)
void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct )
/***********************************************************/
/* Hot keys. Some commands are relatives to the item under the mouse cursor
Commands are case insensitive
Zoom commands are not managed here
*/
* Commands are case insensitive
* Zoom commands are not managed here
*/
{
bool PopupOn = m_CurrentScreen->m_CurrentItem &&
m_CurrentScreen->m_CurrentItem->m_Flags;
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
if ( hotkey == 0 ) return;
bool PopupOn = m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->GetCurItem()->m_Flags;
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
if( hotkey == 0 )
return;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a';
// Search commnd from key :
switch ( GetCommandCodeFromHotkey(hotkey, s_Schematic_Hotkey_List) )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_Schematic_Hotkey_List);
break;
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp(BLOCK_DRAG, DC);
break;
// Search commnd from key :
switch( GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List ) )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_DELETE:
if ( PopupOn ) break;
RefreshToolBar = LocateAndDeleteItem(this, DC);
m_CurrentScreen->SetModify();
m_CurrentScreen->m_CurrentItem = NULL;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_Schematic_Hotkey_List );
break;
case HK_REPEAT_LAST:
if ( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) )
{
RepeatDrawItem(DC);
}
else wxBell();
break;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
case HK_NEXT_SEARCH :
if ( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker(1);
else FindSchematicItem(wxEmptyString, 2);
break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp( BLOCK_DRAG, DC );
break;
case HK_ADD_NEW_COMPONENT: // Add component
if ( DrawStruct && DrawStruct->m_Flags ) break;
// switch to m_ID_current_state = ID_COMPONENT_BUTT;
if ( m_ID_current_state != ID_COMPONENT_BUTT ) SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _("Add Component"));
OnLeftClick(DC, MousePos);
break;
case HK_DELETE:
if( PopupOn )
break;
RefreshToolBar = LocateAndDeleteItem( this, DC );
m_CurrentScreen->SetModify();
m_CurrentScreen->SetCurItem( NULL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
break;
case HK_BEGIN_WIRE: // Add wire
if ( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible
{
if ( DrawStruct->m_Flags ) // Item selected and edition in progress
{
if (DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE )
{
EDA_DrawLineStruct * segment = (EDA_DrawLineStruct *)DrawStruct;
if ( segment->m_Layer != LAYER_WIRE ) break;
}
else break;
}
}
// switch to m_ID_current_state = ID_WIRE_BUTT;
if ( m_ID_current_state != ID_WIRE_BUTT ) SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _("Add Wire"));
OnLeftClick(DC, MousePos);
case HK_REPEAT_LAST:
if( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) )
{
RepeatDrawItem( DC );
}
else
wxBell();
break;
case HK_NEXT_SEARCH:
if( g_LastSearchIsMarker )
WinEDA_SchematicFrame::FindMarker( 1 );
else
FindSchematicItem( wxEmptyString, 2 );
break;
case HK_ADD_NEW_COMPONENT: // Add component
if( DrawStruct && DrawStruct->m_Flags )
break;
case HK_ROTATE_COMPONENT: // Component Rotation
if ( DrawStruct == NULL )
{
DrawStruct = PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, LIBITEM|TEXTITEM|LABELITEM );
if ( DrawStruct == NULL ) break;
if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct == NULL ) break;
}
switch (DrawStruct->m_StructType)
{
case DRAW_LIB_ITEM_STRUCT_TYPE:
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE );
break;
// switch to m_ID_current_state = ID_COMPONENT_BUTT;
if( m_ID_current_state != ID_COMPONENT_BUTT )
SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _( "Add Component" ) );
OnLeftClick( DC, MousePos );
break;
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC);
break;
}
break;
case HK_BEGIN_WIRE: // Add wire
if( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible
{
if( DrawStruct->m_Flags ) // Item selected and edition in progress
{
if( DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE )
{
EDA_DrawLineStruct* segment = (EDA_DrawLineStruct*) DrawStruct;
if( segment->m_Layer != LAYER_WIRE )
break;
}
else
break;
}
}
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_Y );
}
break;
// switch to m_ID_current_state = ID_WIRE_BUTT;
if( m_ID_current_state != ID_WIRE_BUTT )
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
OnLeftClick( DC, MousePos );
break;
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_X );
}
break;
case HK_ROTATE_COMPONENT: // Component Rotation
if( DrawStruct == NULL )
{
DrawStruct = PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, LIBITEM | TEXTITEM | LABELITEM );
if( DrawStruct == NULL )
break;
if( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL )
break;
}
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_NORMAL );
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
switch( DrawStruct->m_StructType )
{
case DRAW_LIB_ITEM_STRUCT_TYPE:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
case HK_MOVE_COMPONENT: // Start move Component
if ( PopupOn ) break;
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct && (DrawStruct->m_Flags ==0) )
{
m_CurrentScreen->m_CurrentItem = DrawStruct;
Process_Move_Item(m_CurrentScreen->m_CurrentItem, DC);
}
break;
}
if ( RefreshToolBar ) SetToolbars();
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE );
break;
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
ChangeTextOrient( (DrawTextStruct*) DrawStruct, DC );
break;
}
break;
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_Y );
}
break;
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_X );
}
break;
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_NORMAL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case HK_MOVE_COMPONENT: // Start move Component
if( PopupOn )
break;
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct && (DrawStruct->m_Flags ==0) )
{
m_CurrentScreen->SetCurItem( DrawStruct );
Process_Move_Item( m_CurrentScreen->GetCurItem(), DC );
}
break;
}
if( RefreshToolBar )
SetToolbars();
}
/***********************************************************/
void WinEDA_LibeditFrame::OnHotKey(wxDC * DC, int hotkey,
EDA_BaseStruct * DrawStruct)
void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct )
/***********************************************************/
/* Hot keys for the component editot. Some commands are relatives to the item under the mouse cursor
Commands are case insensitive
Zoom commands are not managed here
*/
* Commands are case insensitive
* Zoom commands are not managed here
*/
{
bool PopupOn = m_CurrentScreen->m_CurrentItem &&
m_CurrentScreen->m_CurrentItem->m_Flags;
bool PopupOn = m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->GetCurItem()->m_Flags;
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
if ( hotkey == 0 ) return;
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
if( hotkey == 0 )
return;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a';
switch ( GetCommandCodeFromHotkey(hotkey, s_LibEdit_Hotkey_List) )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_LibEdit_Hotkey_List);
break;
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
case HK_REPEAT_LAST:
if ( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) &&
(LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
{
RepeatPinItem(DC, (LibDrawPin*) LibItemToRepeat);
}
else wxBell();
break;
}
switch( GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List ) )
{
default:
case HK_NOT_FOUND:
return;
break;
if ( RefreshToolBar ) SetToolbars();
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_LibEdit_Hotkey_List );
break;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
case HK_REPEAT_LAST:
if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0)
&& (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
{
RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat );
}
else
wxBell();
break;
}
if( RefreshToolBar )
SetToolbars();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/******************************************************/
/* schedit.cpp: fonctions generales de la schematique */
/******************************************************/
/******************************************************/
/* schedit.cpp: fonctions generales de la schematique */
/******************************************************/
#include "fctsys.h"
@ -19,332 +19,336 @@ static wxArrayString s_CmpNameList;
static wxArrayString s_PowerNameList;
/**********************************************************************************/
void WinEDA_SchematicFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos)
void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/**********************************************************************************/
/* Traite les commandes declenchée par le bouton gauche de la souris,
quand un outil est deja selectionné
*/
* quand un outil est deja selectionné
*/
{
EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem;
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
if ( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = FALSE;
g_ItemToRepeat = NULL;
if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = FALSE;
g_ItemToRepeat = NULL;
if ( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours
{
switch (DrawStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
DrawStruct->Place( this, DC);
m_CurrentScreen->m_CurrentItem = NULL;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
return;
if( DrawStruct && DrawStruct->m_Flags ) // Commande "POPUP" en cours
{
switch( DrawStruct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
DrawStruct->Place( this, DC );
m_CurrentScreen->SetCurItem( NULL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
return;
case SCREEN_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
DisplayError(this,
wxT("OnLeftClick err: unexpected type for Place"));
DrawStruct->m_Flags = 0;
break;
case SCREEN_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
DisplayError( this,
wxT( "OnLeftClick err: unexpected type for Place" ) );
DrawStruct->m_Flags = 0;
break;
case DRAW_SEGMENT_STRUCT_TYPE: // Segment peut-etre en cours de trace
break;
case DRAW_SEGMENT_STRUCT_TYPE: // Segment peut-etre en cours de trace
break;
default:
DisplayError(this,
wxT("WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0"));
DrawStruct->m_Flags = 0;
break;
}
}
else
{
DrawStruct = SchematicGeneralLocateAndDisplay();
}
}
default:
DisplayError( this,
wxT( "WinEDA_SchematicFrame::OnLeftClick err: m_Flags != 0" ) );
DrawStruct->m_Flags = 0;
break;
}
}
else
{
DrawStruct = SchematicGeneralLocateAndDisplay();
}
}
switch ( m_ID_current_state )
{
case 0:
break;
switch( m_ID_current_state )
{
case 0:
break;
case ID_NO_SELECT_BUTT:
break;
case ID_NO_SELECT_BUTT:
break;
case ID_HIERARCHY_PUSH_POP_BUTT:
if ( DrawStruct && DrawStruct->m_Flags ) break;
DrawStruct = SchematicGeneralLocateAndDisplay();
if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) )
{
InstallNextScreen((DrawSheetStruct *) DrawStruct);
}
else InstallPreviousScreen();
break;
case ID_HIERARCHY_PUSH_POP_BUTT:
if( DrawStruct && DrawStruct->m_Flags )
break;
DrawStruct = SchematicGeneralLocateAndDisplay();
if( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) )
{
InstallNextScreen( (DrawSheetStruct*) DrawStruct );
}
else
InstallPreviousScreen();
break;
case ID_NOCONN_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem =
g_ItemToRepeat = CreateNewNoConnectStruct(DC);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place(this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
}
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
break;
case ID_NOCONN_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
g_ItemToRepeat = CreateNewNoConnectStruct( DC );
m_CurrentScreen->SetCurItem( g_ItemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
break;
case ID_JUNCTION_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem = g_ItemToRepeat
= CreateNewJunctionStruct(DC, m_CurrentScreen->m_Curseur, TRUE);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place(this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
}
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
break;
case ID_JUNCTION_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
g_ItemToRepeat = CreateNewJunctionStruct( DC, m_CurrentScreen->m_Curseur, TRUE );
m_CurrentScreen->SetCurItem( g_ItemToRepeat );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
break;
case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem = DrawStruct =
CreateBusEntry(DC,
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place(this, DC);
m_CurrentScreen->m_CurrentItem = NULL;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct =
CreateBusEntry( DC,
(m_ID_current_state == ID_WIRETOBUS_ENTRY_BUTT) ?
WIRE_TO_BUS : BUS_TO_BUS );
m_CurrentScreen->SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
m_CurrentScreen->SetCurItem( NULL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
LocateAndDeleteItem(this, DC);
m_CurrentScreen->SetModify();
m_CurrentScreen->m_CurrentItem = NULL;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
LocateAndDeleteItem( this, DC );
m_CurrentScreen->SetModify();
m_CurrentScreen->SetCurItem( NULL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
break;
case ID_WIRE_BUTT:
BeginSegment(DC, LAYER_WIRE);
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_WIRE_BUTT:
BeginSegment( DC, LAYER_WIRE );
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_BUS_BUTT:
BeginSegment(DC, LAYER_BUS);
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_BUS_BUTT:
BeginSegment( DC, LAYER_BUS );
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_LINE_COMMENT_BUTT:
BeginSegment(DC, LAYER_NOTES);
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_LINE_COMMENT_BUTT:
BeginSegment( DC, LAYER_NOTES );
DrawPanel->m_AutoPAN_Request = TRUE;
break;
case ID_TEXT_COMMENT_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem =
CreateNewText(DC, LAYER_NOTES);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place(this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_TEXT_COMMENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_NOTES ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_LABEL_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem =
CreateNewText(DC, LAYER_LOCLABEL);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
case ID_LABEL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_LOCLABEL ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case ID_GLABEL_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem =
CreateNewText(DC, LAYER_GLOBLABEL);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place(this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
case ID_GLABEL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( CreateNewText( DC, LAYER_GLOBLABEL ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case ID_SHEET_SYMBOL_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem = CreateSheet(DC);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
case ID_SHEET_SYMBOL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( CreateSheet( DC ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case ID_IMPORT_GLABEL_BUTT:
case ID_SHEET_LABEL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
DrawStruct = SchematicGeneralLocateAndDisplay();
case ID_IMPORT_GLABEL_BUTT:
case ID_SHEET_LABEL_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
DrawStruct = SchematicGeneralLocateAndDisplay();
if ( DrawStruct == NULL) break;
if( DrawStruct == NULL )
break;
if( (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) &&
(DrawStruct->m_Flags == 0) )
{
if ( m_ID_current_state == ID_IMPORT_GLABEL_BUTT )
m_CurrentScreen->m_CurrentItem =
Import_PinSheet( (DrawSheetStruct *) DrawStruct, DC);
else
m_CurrentScreen->m_CurrentItem =
Create_PinSheet( (DrawSheetStruct *) DrawStruct, DC);
}
else if( (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE) &&
(DrawStruct->m_Flags != 0) )
{
DrawStruct->Place(this, DC);
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
if( (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE)
&& (DrawStruct->m_Flags == 0) )
{
if( m_ID_current_state == ID_IMPORT_GLABEL_BUTT )
m_CurrentScreen->SetCurItem(
Import_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) );
else
m_CurrentScreen->SetCurItem(
Create_PinSheet( (DrawSheetStruct*) DrawStruct, DC ) );
}
else if( (DrawStruct->m_StructType == DRAW_SHEETLABEL_STRUCT_TYPE)
&& (DrawStruct->m_Flags != 0) )
{
DrawStruct->Place( this, DC );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case ID_COMPONENT_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem = Load_Component(DC, wxEmptyString,
s_CmpNameList, TRUE);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
case ID_COMPONENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem( Load_Component( DC, wxEmptyString,
s_CmpNameList, TRUE ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case ID_PLACE_POWER_BUTT:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->m_CurrentItem =
Load_Component(DC, wxT("power"),s_PowerNameList, FALSE);
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC);
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
case ID_PLACE_POWER_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
m_CurrentScreen->SetCurItem(
Load_Component( DC, wxT( "power" ), s_PowerNameList, FALSE ) );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
{
DrawStruct->Place( this, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
default :
{
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString);
wxString msg( wxT("WinEDA_SchematicFrame::OnLeftClick error state "));
msg << m_ID_current_state;
DisplayError(this, msg);
break;
}
}
default:
{
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
wxString msg( wxT( "WinEDA_SchematicFrame::OnLeftClick error state " ) );
msg << m_ID_current_state;
DisplayError( this, msg );
break;
}
}
}
/***************************************************************************/
void WinEDA_SchematicFrame::OnLeftDClick(wxDC * DC, const wxPoint& MousePos)
void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/***************************************************************************/
/* Appelé sur un double click:
pour un élément editable (textes, composant):
appel de l'editeur correspondant.
pour une connexion en cours:
termine la connexion
*/
* pour un élément editable (textes, composant):
* appel de l'editeur correspondant.
* pour une connexion en cours:
* termine la connexion
*/
{
EDA_BaseStruct * DrawStruct = m_CurrentScreen->m_CurrentItem;
wxPoint pos = GetPosition();
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
wxPoint pos = GetPosition();
switch ( m_ID_current_state )
{
case 0:
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay();
}
switch( m_ID_current_state )
{
case 0:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay();
}
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) )
break;
if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) )
break;
// Element localisé
switch ( DrawStruct->m_StructType )
{
case DRAW_SHEET_STRUCT_TYPE:
InstallNextScreen((DrawSheetStruct *) DrawStruct);
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
InstallCmpeditFrame(this, pos, (EDA_SchComponentStruct *) DrawStruct);
DrawPanel->MouseToCursorSchema();
break;
// Element localisé
switch( DrawStruct->m_StructType )
{
case DRAW_SHEET_STRUCT_TYPE:
InstallNextScreen( (DrawSheetStruct*) DrawStruct );
break;
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
EditSchematicText( (DrawTextStruct*)DrawStruct, DC);
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
InstallCmpeditFrame( this, pos, (EDA_SchComponentStruct*) DrawStruct );
DrawPanel->MouseToCursorSchema();
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
EditCmpFieldText( (PartTextStruct *)DrawStruct, DC);
DrawPanel->MouseToCursorSchema();
break;
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
EditSchematicText( (DrawTextStruct*) DrawStruct, DC );
break;
default:
break;
}
break; // end case 0
case DRAW_PART_TEXT_STRUCT_TYPE:
EditCmpFieldText( (PartTextStruct*) DrawStruct, DC );
DrawPanel->MouseToCursorSchema();
break;
case ID_BUS_BUTT:
case ID_WIRE_BUTT:
case ID_LINE_COMMENT_BUTT:
if ( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
EndSegment(DC);
break;
}
default:
break;
}
break; // end case 0
case ID_BUS_BUTT:
case ID_WIRE_BUTT:
case ID_LINE_COMMENT_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
EndSegment( DC );
break;
}
}

View File

@ -1,7 +1,7 @@
/******************************************************************/
/* onrightclick.cpp - creation du menu popup appele par le bouton */
/* droit de la souris */
/******************************************************************/
/******************************************************************/
/* onrightclick.cpp - creation du menu popup appele par le bouton */
/* droit de la souris */
/******************************************************************/
#ifdef __GNUG__
#pragma implementation
@ -44,514 +44,555 @@
#include "Edit_Comp_Value.xpm"
/* functions to add commands and submenus depending on the item */
static void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame);
static void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire,
WinEDA_SchematicFrame * frame);
static void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus,
WinEDA_SchematicFrame * frame);
static void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet);
static void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet);
static void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text );
static void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label );
static void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel );
static void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component );
static void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field );
static void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction,
WinEDA_SchematicFrame * frame);
static void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame );
static void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire,
WinEDA_SchematicFrame* frame );
static void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus,
WinEDA_SchematicFrame* frame );
static void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet );
static void AddMenusForPinSheet( wxMenu* PopMenu, DrawSheetLabelStruct* PinSheet );
static void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text );
static void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label );
static void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel );
static void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component );
static void AddMenusForComponentField( wxMenu* PopMenu, PartTextStruct* Field );
static void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction,
WinEDA_SchematicFrame* frame );
/***********************************************************************/
void WinEDA_SchematicFrame::ToolOnRightClick(wxCommandEvent& event)
void WinEDA_SchematicFrame::ToolOnRightClick( wxCommandEvent& event )
/***********************************************************************/
{
int id = event.GetId();
int id = event.GetId();
switch ( id )
{
default:
DisplayError(this, wxT("ToolOnRightClick() error"));
break;
}
switch( id )
{
default:
DisplayError( this, wxT( "ToolOnRightClick() error" ) );
break;
}
}
/*****************************************************************/
void WinEDA_SchematicFrame::OnRightClick(const wxPoint& MousePos,
wxMenu * PopMenu)
void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu )
/*****************************************************************/
/* Prepare le menu PullUp affiché par un click sur le bouton droit
de la souris.
Ce menu est ensuite complété par la liste des commandes de ZOOM
*/
* de la souris.
* Ce menu est ensuite complété par la liste des commandes de ZOOM
*/
{
EDA_BaseStruct *DrawStruct = m_CurrentScreen->m_CurrentItem;
bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE);
EDA_BaseStruct* DrawStruct = m_CurrentScreen->GetCurItem();
bool BlockActive = (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE);
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
// Simple localisation des elements si possible
if ( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay(FALSE);
if ( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) )
{
DrawSheetLabelStruct * slabel;
slabel = LocateSheetLabel( (DrawSheetStruct *)DrawStruct,
m_CurrentScreen->m_Curseur);
if ( slabel ) DrawStruct = slabel;
}
}
// Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay( FALSE );
if( DrawStruct && (DrawStruct->m_StructType == DRAW_SHEET_STRUCT_TYPE) )
{
DrawSheetLabelStruct* slabel;
slabel = LocateSheetLabel( (DrawSheetStruct*) DrawStruct,
m_CurrentScreen->m_Curseur );
if( slabel )
DrawStruct = slabel;
}
}
// If Command in progress: put the menu "cancel" and "end tool"
if ( m_ID_current_state )
{
if ( DrawStruct && DrawStruct->m_Flags )
{
ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm);
}
else
{
ADD_MENUITEM(PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _("End Tool"), cancel_tool_xpm);
}
PopMenu->AppendSeparator();
}
// If Command in progress: put the menu "cancel" and "end tool"
if( m_ID_current_state )
{
if( DrawStruct && DrawStruct->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
}
else
{
ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ), cancel_tool_xpm );
}
PopMenu->AppendSeparator();
}
else
{
if( (DrawStruct && DrawStruct->m_Flags) || BlockActive )
{
if( BlockActive )
AddMenusForBlock( PopMenu, this );
else
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator();
}
}
else
{
if ( (DrawStruct && DrawStruct->m_Flags) || BlockActive )
{
if ( BlockActive ) AddMenusForBlock( PopMenu, this);
else ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel"), cancel_xpm);
PopMenu->AppendSeparator();
}
}
if( BlockActive )
return;
if( DrawStruct == NULL )
{
if( m_CurrentScreen != ScreenSch )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), leave_sheet_xpm );
PopMenu->AppendSeparator();
}
return;
}
if ( BlockActive ) return;
if ( DrawStruct == NULL )
{
if ( m_CurrentScreen != ScreenSch )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _("Leave Sheet") , leave_sheet_xpm);
PopMenu->AppendSeparator();
}
return;
}
m_CurrentScreen->SetCurItem( DrawStruct );
m_CurrentScreen->m_CurrentItem = DrawStruct;
int flags = DrawStruct->m_Flags;
bool is_new = (flags & IS_NEW) ? TRUE : FALSE;
switch( DrawStruct->m_StructType )
{
case DRAW_NOCONNECT_STRUCT_TYPE:
int flags = DrawStruct->m_Flags;
bool is_new = (flags & IS_NEW) ? TRUE : FALSE;
switch ( DrawStruct->m_StructType )
{
case DRAW_NOCONNECT_STRUCT_TYPE:
// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move noconnect");
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete noconn"), delete_xpm);
break;
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete noconn" ), delete_xpm );
break;
case DRAW_JUNCTION_STRUCT_TYPE:
AddMenusForJunction(PopMenu, (DrawJunctionStruct *)DrawStruct, this);
break;
case DRAW_JUNCTION_STRUCT_TYPE:
AddMenusForJunction( PopMenu, (DrawJunctionStruct*) DrawStruct, this );
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
if( !flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
_("Move bus entry"), move_xpm);
if( GetBusEntryShape((DrawBusEntryStruct *)DrawStruct) == '\\')
PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_SLASH, _("set bus entry /"));
else PopMenu->Append(ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _("set bus entry \\"));
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE,
_("delete bus entry"), delete_bus_xpm);
break;
case DRAW_BUSENTRY_STRUCT_TYPE:
if( !flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
_( "Move bus entry" ), move_xpm );
if( GetBusEntryShape( (DrawBusEntryStruct*) DrawStruct ) == '\\' )
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH, _( "set bus entry /" ) );
else
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _( "set bus entry \\" ) );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "delete bus entry" ), delete_bus_xpm );
break;
case DRAW_MARKER_STRUCT_TYPE:
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete Marker"), delete_xpm);
break;
case DRAW_MARKER_STRUCT_TYPE:
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete Marker" ), delete_xpm );
break;
case DRAW_TEXT_STRUCT_TYPE:
AddMenusForText( PopMenu, (DrawTextStruct *) DrawStruct);
break;
case DRAW_TEXT_STRUCT_TYPE:
AddMenusForText( PopMenu, (DrawTextStruct*) DrawStruct );
break;
case DRAW_LABEL_STRUCT_TYPE:
AddMenusForLabel( PopMenu, (DrawLabelStruct *) DrawStruct);
break;
case DRAW_LABEL_STRUCT_TYPE:
AddMenusForLabel( PopMenu, (DrawLabelStruct*) DrawStruct );
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
AddMenusForGLabel(PopMenu, (DrawGlobalLabelStruct *) DrawStruct );
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
AddMenusForGLabel( PopMenu, (DrawGlobalLabelStruct*) DrawStruct );
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
{
AddMenusForComponentField(PopMenu, (PartTextStruct *) DrawStruct );
if ( flags) break;
// Many fields are inside a component. If this is the case, add the component menu
EDA_SchComponentStruct * Component = LocateSmallestComponent( GetScreen() );
if ( Component )
{
PopMenu->AppendSeparator();
AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct );
}
}
break;
case DRAW_PART_TEXT_STRUCT_TYPE:
{
AddMenusForComponentField( PopMenu, (PartTextStruct*) DrawStruct );
if( flags )
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
AddMenusForComponent(PopMenu, (EDA_SchComponentStruct *) DrawStruct );
break;
// Many fields are inside a component. If this is the case, add the component menu
EDA_SchComponentStruct* Component = LocateSmallestComponent( GetScreen() );
if( Component )
{
PopMenu->AppendSeparator();
AddMenusForComponent( PopMenu, (EDA_SchComponentStruct*) DrawStruct );
}
}
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
AddMenusForComponent( PopMenu, (EDA_SchComponentStruct*) DrawStruct );
break;
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move");
switch ( ((EDA_DrawLineStruct*)DrawStruct)->m_Layer)
{
case LAYER_WIRE:
AddMenusForWire(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this);
break;
switch( ( (EDA_DrawLineStruct*) DrawStruct )->m_Layer )
{
case LAYER_WIRE:
AddMenusForWire( PopMenu, (EDA_DrawLineStruct*) DrawStruct, this );
break;
case LAYER_BUS:
AddMenusForBus(PopMenu, (EDA_DrawLineStruct*)DrawStruct, this);
break;
case LAYER_BUS:
AddMenusForBus( PopMenu, (EDA_DrawLineStruct*) DrawStruct, this );
break;
default:
if ( is_new )
ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End drawing"), apply_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE,
_("Delete drawing"), delete_xpm);
break;
}
break;
default:
if( is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End drawing" ), apply_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete drawing" ), delete_xpm );
break;
}
case DRAW_SHEET_STRUCT_TYPE:
AddMenusForHierchicalSheet(PopMenu, (DrawSheetStruct *) DrawStruct);
break;
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
AddMenusForPinSheet(PopMenu, (DrawSheetLabelStruct *) DrawStruct);
break;
case DRAW_SHEET_STRUCT_TYPE:
AddMenusForHierchicalSheet( PopMenu, (DrawSheetStruct*) DrawStruct );
break;
default:
wxString msg;
msg.Printf(
wxT("WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d"),
DrawStruct->m_StructType);
DisplayError(this, msg );
break;
}
case DRAW_SHEETLABEL_STRUCT_TYPE:
AddMenusForPinSheet( PopMenu, (DrawSheetLabelStruct*) DrawStruct );
break;
PopMenu->AppendSeparator();
default:
wxString msg;
msg.Printf(
wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ),
DrawStruct->m_StructType );
DisplayError( this, msg );
break;
}
PopMenu->AppendSeparator();
}
/*************************************************************************/
void AddMenusForComponentField(wxMenu * PopMenu, PartTextStruct * Field )
void AddMenusForComponentField( wxMenu* PopMenu, PartTextStruct* Field )
/*************************************************************************/
/* Add menu commands for a component field (like value, reference)
*/
*/
{
if( ! Field->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Field"), move_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _("Rotate Field"), rotate_field_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_FIELD, _("Edit Field"), edit_text_xpm);
if( !Field->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Field" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _( "Rotate Field" ), rotate_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD, _( "Edit Field" ), edit_text_xpm );
}
/**************************************************************************/
void AddMenusForComponent(wxMenu * PopMenu, EDA_SchComponentStruct * Component )
void AddMenusForComponent( wxMenu* PopMenu, EDA_SchComponentStruct* Component )
/**************************************************************************/
/* Add menu commands for a component
*/
*/
{
EDA_LibComponentStruct * LibEntry;
LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT);
EDA_LibComponentStruct* LibEntry;
if( ! Component->m_Flags )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
_("Move Component (M)"), move_xpm);
}
// add menu orient et sous menu:
wxMenu *orientmenu = new wxMenu;
ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
_("Rotate + (R)"), rotate_pos_xpm);
ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _("Rotate -"), rotate_neg_xpm);
ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_X_CMP, _("Mirror -- (X)"), mirror_V_xpm);
ADD_MENUITEM(orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, _("Mirror || (Y)"), mirror_H_xpm);
ADD_MENUITEM(orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, _("Normal (N)"), normal_xpm);
ADD_MENUITEM_WITH_SUBMENU(PopMenu, orientmenu,
ID_POPUP_SCH_GENERIC_ORIENT_CMP, _("Orient Component"), orient_xpm);
LibEntry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
wxMenu *editmenu = new wxMenu;
ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_CMP, _("Edit"), edit_component_xpm);
if ( LibEntry && LibEntry->m_Options != ENTRY_POWER )
{
ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, _("Value"), edit_comp_value_xpm);
ADD_MENUITEM(editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _("Reference"), edit_comp_ref_xpm);
}
if( LibEntry && (LookForConvertPart(LibEntry) >= 2) )
editmenu->Append(ID_POPUP_SCH_EDIT_CONVERT_CMP, _("Convert"));
if( LibEntry && (LibEntry->m_UnitCount >= 2) )
{
wxMenu *sel_unit_menu = new wxMenu; int ii;
for( ii = 0; ii < LibEntry->m_UnitCount; ii++ )
{
wxString num_unit; num_unit.Printf( _("Unit %d %c"), ii+1, "?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii+1]);
sel_unit_menu->Append(ID_POPUP_SCH_SELECT_UNIT1 + ii,
num_unit);
}
editmenu->Append(ID_POPUP_SCH_SELECT_UNIT_CMP, _("Unit"), sel_unit_menu);
}
if( !Component->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
_( "Move Component (M)" ), move_xpm );
}
ADD_MENUITEM_WITH_SUBMENU(PopMenu, editmenu,
ID_POPUP_SCH_GENERIC_EDIT_CMP, _("Edit Component"), edit_component_xpm);
// add menu orient et sous menu:
wxMenu* orientmenu = new wxMenu;
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
_( "Rotate + (R)" ), rotate_pos_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, _( "Mirror -- (X)" ), mirror_V_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, _( "Mirror || (Y)" ), mirror_H_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, _( "Normal (N)" ), normal_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu,
ID_POPUP_SCH_GENERIC_ORIENT_CMP, _(
"Orient Component" ), orient_xpm );
if( ! Component->m_Flags )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _("Copy Component"), import_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CMP, _("Delete Component"), delete_xpm);
}
LibEntry = FindLibPart(Component->m_ChipName.GetData(), wxEmptyString, FIND_ALIAS);
if ( LibEntry && ! LibEntry->m_DocFile.IsEmpty() )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _("Doc"), datasheet_xpm);
wxMenu* editmenu = new wxMenu;
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, _( "Edit" ), edit_component_xpm );
if( LibEntry && LibEntry->m_Options != ENTRY_POWER )
{
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, _( "Value" ), edit_comp_value_xpm );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), edit_comp_ref_xpm );
}
if( LibEntry && (LookForConvertPart( LibEntry ) >= 2) )
editmenu->Append( ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ) );
if( LibEntry && (LibEntry->m_UnitCount >= 2) )
{
wxMenu* sel_unit_menu = new wxMenu; int ii;
for( ii = 0; ii < LibEntry->m_UnitCount; ii++ )
{
wxString num_unit; num_unit.Printf( _(
"Unit %d %c" ), ii + 1,
"?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii + 1] );
sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii,
num_unit );
}
editmenu->Append( ID_POPUP_SCH_SELECT_UNIT_CMP, _( "Unit" ), sel_unit_menu );
}
ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu,
ID_POPUP_SCH_GENERIC_EDIT_CMP, _(
"Edit Component" ), edit_component_xpm );
if( !Component->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _( "Copy Component" ), import_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP, _( "Delete Component" ), delete_xpm );
}
LibEntry = FindLibPart( Component->m_ChipName.GetData(), wxEmptyString, FIND_ALIAS );
if( LibEntry && !LibEntry->m_DocFile.IsEmpty() )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), datasheet_xpm );
}
/*******************************************************************/
void AddMenusForGLabel( wxMenu* PopMenu, DrawGlobalLabelStruct* GLabel )
/*******************************************************************/
/*******************************************************************/
void AddMenusForGLabel(wxMenu * PopMenu, DrawGlobalLabelStruct * GLabel )
/*******************************************************************/
/* Add menu commands for a Global Label
*/
*/
{
wxMenu * menu_change_type = new wxMenu;
if( ! GLabel->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Glabel"), move_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate GLabel (R)"), rotate_glabel_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit GLabel"), edit_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Glabel"), delete_text_xpm);
wxMenu* menu_change_type = new wxMenu;
// add menu change type text (to label, glabel, text):
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_("Change to Label"), glabel2label_xpm);
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_("Change to Text"), glabel2text_xpm);
ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm);
if( !GLabel->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Glabel" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate GLabel (R)" ), rotate_glabel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit GLabel" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Glabel" ), delete_text_xpm );
// add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_( "Change to Label" ), glabel2label_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_( "Change to Text" ), glabel2text_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
/*****************************************************************/
void AddMenusForLabel(wxMenu * PopMenu, DrawLabelStruct * Label )
void AddMenusForLabel( wxMenu* PopMenu, DrawLabelStruct* Label )
/*****************************************************************/
/* Add menu commands for a Label
*/
*/
{
wxMenu * menu_change_type = new wxMenu;
if( ! Label->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Label"), move_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Label (R)"), rotate_pos_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Label"), edit_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Label"), delete_text_xpm);
wxMenu* menu_change_type = new wxMenu;
// add menu change type text (to label, glabel, text):
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_("Change to Glabel"), label2glabel_xpm);
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_("Change to Text"), label2text_xpm);
ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm);
if( !Label->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Label" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Label (R)" ), rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Label" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Label" ), delete_text_xpm );
// add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Glabel" ), label2glabel_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_( "Change to Text" ), label2text_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
/*****************************************************************/
void AddMenusForText(wxMenu * PopMenu, DrawTextStruct * Text )
void AddMenusForText( wxMenu* PopMenu, DrawTextStruct* Text )
/*****************************************************************/
/* Add menu commands for a Text (a comment)
*/
*/
{
wxMenu * menu_change_type = new wxMenu;
if( ! Text->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Text"), move_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _("Rotate Text (R)"), rotate_pos_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_TEXT, _("Edit Text"), edit_text_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Text"), delete_text_xpm);
wxMenu* menu_change_type = new wxMenu;
// add menu change type text (to label, glabel, text):
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_("Change to Label"), label2text_xpm);
ADD_MENUITEM(menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_("Change to Glabel"), label2glabel_xpm);
ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _("Change Type"), gl_change_xpm);
if( !Text->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Text" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Text (R)" ), rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Text" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ), delete_text_xpm );
// add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_( "Change to Label" ), label2text_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Glabel" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm );
}
/*****************************************************************/
void AddMenusForJunction(wxMenu * PopMenu, DrawJunctionStruct * Junction,
WinEDA_SchematicFrame * frame)
void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction,
WinEDA_SchematicFrame* frame )
/*****************************************************************/
/* Add menu commands for a junction
*/
*/
{
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
if ( ! is_new )
{
if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm);
}
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("delete junction"), delete_xpm);
if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM|BUSITEM) )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm);
}
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
if( !is_new )
{
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
}
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "delete junction" ), delete_xpm );
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM | BUSITEM ) )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete node" ), delete_node_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _(
"Delete connection" ), delete_connection_xpm );
}
}
/*****************************************************************/
void AddMenusForWire(wxMenu * PopMenu, EDA_DrawLineStruct * Wire,
WinEDA_SchematicFrame * frame)
void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire,
WinEDA_SchematicFrame* frame )
/*****************************************************************/
/* Add menu commands for a wire
*/
*/
{
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur;
if ( is_new )
ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Wire"), apply_xpm);
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur;
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Wire"), delete_xpm);
if ( is_new ) return;
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_NODE, _("Delete node"), delete_node_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _("Delete connection"), delete_connection_xpm);
if( is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Wire" ), apply_xpm );
if ( PickStruct(frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM|BUSITEM|EXCLUDE_WIRE_BUS_ENDPOINTS) )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE, _("Break Wire"), break_line_xpm);
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Wire" ), delete_xpm );
PopMenu->AppendSeparator();
if( is_new )
return;
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm);
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete node" ), delete_node_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _(
"Delete connection" ), delete_connection_xpm );
// Place Global label command only if the cursor is over one end of the Wire:
if ( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) ||
( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm);
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen()->EEDrawList,
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add junction" ), add_junction_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add label" ), add_line_label_xpm );
// Place Global label command only if the cursor is over one end of the Wire:
if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y)
|| ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add global label" ), add_glabel_xpm );
}
/*****************************************************************/
void AddMenusForBus(wxMenu * PopMenu, EDA_DrawLineStruct * Bus,
WinEDA_SchematicFrame * frame)
void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus,
WinEDA_SchematicFrame* frame )
/*****************************************************************/
/* Add menu commands for a Bus
*/
*/
{
bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur;
bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur;
if ( is_new ) ADD_MENUITEM(PopMenu, ID_POPUP_END_LINE, _("End Bus"), apply_xpm);
if( is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Bus" ), apply_xpm );
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE,
_("Delete Bus"), delete_bus_xpm);
if ( ! is_new )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_BREAK_WIRE,
_("Break Bus"), break_bus_xpm);
PopMenu->AppendSeparator();
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _("Add junction") , add_junction_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_LABEL, _("Add label") , add_line_label_xpm);
// Place Global label command only if the cursor is over one end of the Bus:
if ( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) ||
( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ADD_GLABEL, _("Add global label") , add_glabel_xpm);
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Bus" ), delete_bus_xpm );
if( !is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE,
_( "Break Bus" ), break_bus_xpm );
PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add junction" ), add_junction_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add label" ), add_line_label_xpm );
// Place Global label command only if the cursor is over one end of the Bus:
if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y)
|| ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add global label" ), add_glabel_xpm );
}
/************************************************************************/
void AddMenusForHierchicalSheet(wxMenu * PopMenu, DrawSheetStruct * Sheet)
void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet )
/************************************************************************/
/* Add menu commands for a Sheet
*/
*/
{
if( ! Sheet->m_Flags )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_ENTER_SHEET, _("Enter Sheet"), enter_sheet_xpm);
PopMenu->AppendSeparator();
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _("Move Sheet"), move_sheet_xpm);
}
if ( Sheet->m_Flags )
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_END_SHEET, _("Place Sheet"), apply_xpm);
}
else
{
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_SHEET, _("Edit Sheet"), edit_sheet_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _("Resize Sheet"), resize_sheet_xpm);
if ( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_CLEANUP_SHEET,
_("Cleanup PinSheets"), options_pinsheet_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete Sheet"), delete_sheet_xpm);
}
if( !Sheet->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm );
PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Sheet" ), move_sheet_xpm );
}
if( Sheet->m_Flags )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm );
}
else
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, _( "Edit Sheet" ), edit_sheet_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ), resize_sheet_xpm );
if( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET,
_( "Cleanup PinSheets" ), options_pinsheet_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ), delete_sheet_xpm );
}
}
/************************************************************************/
void AddMenusForPinSheet(wxMenu * PopMenu, DrawSheetLabelStruct * PinSheet)
void AddMenusForPinSheet( wxMenu* PopMenu, DrawSheetLabelStruct* PinSheet )
/************************************************************************/
/* Add menu commands for a Pin Sheet (or Sheet label)
*/
*/
{
if( ! PinSheet->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _("Move PinSheet"), move_xpm);
if( !PinSheet->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _( "Move PinSheet" ), move_xpm );
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _("Edit PinSheet"), edit_xpm);
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm );
if( ! PinSheet->m_Flags )
ADD_MENUITEM(PopMenu, ID_POPUP_SCH_DELETE, _("Delete PinSheet"), delete_pinsheet_xpm);
if( !PinSheet->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm );
}
/**********************************************************************/
void AddMenusForBlock(wxMenu * PopMenu, WinEDA_SchematicFrame * frame)
void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
/**********************************************************************/
/* Add menu commands for block
*/
*/
{
ADD_MENUITEM(PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _("Cancel Block"), cancel_xpm);
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm );
PopMenu->AppendSeparator();
PopMenu->AppendSeparator();
if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK,
_("Win. Zoom (Midd butt drag mouse)"), zoom_selected_xpm);
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK,
_( "Win. Zoom (Midd butt drag mouse)" ), zoom_selected_xpm );
ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
if ( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
{
wxMenu * menu_other_block_commands = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU(PopMenu, menu_other_block_commands,
-1, _("Other block commands"), right_xpm);
ADD_MENUITEM(menu_other_block_commands, wxID_COPY, _("Save Block"), copy_button);
ADD_MENUITEM(menu_other_block_commands, ID_POPUP_COPY_BLOCK,
_("Copy Block (shift + drag mouse)"), copyblock_xpm);
ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DRAG_BLOCK, _("Drag Block (ctrl + drag mouse)"), move_xpm );
ADD_MENUITEM(menu_other_block_commands, ID_POPUP_DELETE_BLOCK,
_("Del. Block (shift+ctrl + drag mouse)"), delete_xpm );
ADD_MENUITEM(menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _("Mirror Block ||"), mirror_H_xpm);
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
{
wxMenu* menu_other_block_commands = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_other_block_commands,
-1, _( "Other block commands" ), right_xpm );
ADD_MENUITEM( menu_other_block_commands, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_COPY_BLOCK,
_( "Copy Block (shift + drag mouse)" ), copyblock_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DRAG_BLOCK,
_( "Drag Block (ctrl + drag mouse)" ), move_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DELETE_BLOCK,
_( "Del. Block (shift+ctrl + drag mouse)" ), delete_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _(
"Mirror Block ||" ), mirror_H_xpm );
#if 0
#ifdef __WINDOWS__
ADD_MENUITEM(menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
_("Copy to Clipboard"), copy_button);
ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
_( "Copy to Clipboard" ), copy_button );
#endif
#endif
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sheet.cpp
// Purpose:
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// RCS-ID:
// Copyright: License GNU
// Licence:
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
#pragma implementation "sheet.h"
#endif
@ -39,12 +40,12 @@
#include "protos.h"
/* Routines Locales */
static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC);
static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales */
static int s_SheetMindx, s_SheetMindy;
static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */
static int s_SheetMindx, s_SheetMindy;
static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */
#include "sheet.h"
@ -65,9 +66,9 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog )
////@begin WinEDA_SheetPropertiesFrame event table entries
EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick )
EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick )
////@end WinEDA_SheetPropertiesFrame event table entries
@ -77,123 +78,158 @@ END_EVENT_TABLE()
* WinEDA_SheetPropertiesFrame constructors
*/
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( )
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame()
{
}
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent,
DrawSheetStruct * currentsheet,
wxWindowID id, const wxString& caption,
const wxPoint & pos, const wxSize& size, long style )
DrawSheetStruct* currentsheet,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
m_Parent = parent;
m_CurrentSheet = currentsheet;
Create(parent, id, caption, pos, size, style);
m_Parent = parent;
m_CurrentSheet = currentsheet;
Create( parent, id, caption, pos, size, style );
AddUnitSymbol(*m_SheetNameTextSize);
PutValueInLocalUnits(*m_SheetNameSize,m_CurrentSheet->m_SheetNameSize,
m_Parent->m_InternalUnits);
AddUnitSymbol( *m_SheetNameTextSize );
PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize,
m_Parent->m_InternalUnits );
AddUnitSymbol(*m_FileNameTextSize);
PutValueInLocalUnits(*m_FileNameSize, m_CurrentSheet->m_FileNameSize,
m_Parent->m_InternalUnits);
AddUnitSymbol( *m_FileNameTextSize );
PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize,
m_Parent->m_InternalUnits );
}
/*!
* WinEDA_SheetPropertiesFrame creator
*/
bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint & pos, const wxSize& size, long style )
bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption,
const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_SheetPropertiesFrame member initialisation
m_FileNameWin = NULL;
m_SheetNameWin = NULL;
m_FileNameTextSize = NULL;
m_FileNameSize = NULL;
m_FileNameWin = NULL;
m_SheetNameWin = NULL;
m_FileNameTextSize = NULL;
m_FileNameSize = NULL;
m_SheetNameTextSize = NULL;
m_SheetNameSize = NULL;
m_SheetNameSize = NULL;
////@end WinEDA_SheetPropertiesFrame member initialisation
////@begin WinEDA_SheetPropertiesFrame creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
////@end WinEDA_SheetPropertiesFrame creation
return true;
}
/*!
* Control creation for WinEDA_SheetPropertiesFrame
*/
void WinEDA_SheetPropertiesFrame::CreateControls()
{
SetFont(*g_DialogFont);
{
SetFont( *g_DialogFont );
////@begin WinEDA_SheetPropertiesFrame content construction
// Generated by DialogBlocks, 27/02/2006 14:12:10 (unregistered)
WinEDA_SheetPropertiesFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
itemDialog1->SetSizer( itemBoxSizer2 );
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Filename:" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(300, -1), wxTE_PROCESS_ENTER );
itemBoxSizer4->Add(m_FileNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition,
wxSize( 300, -1 ), wxTE_PROCESS_ENTER );
itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Sheetname:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Sheetname:" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText7,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(300, -1), 0 );
itemBoxSizer4->Add(m_SheetNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition,
wxSize( 300, -1 ), 0 );
itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer3->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(m_FileNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameTextSize,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(m_FileNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(m_SheetNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameTextSize,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(m_SheetNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
itemBoxSizer2->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton16->SetForegroundColour(wxColour(0, 0, 255));
itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _(
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) );
itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton17->SetForegroundColour(wxColour(196, 0, 0));
itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _(
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) );
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
// Set validators
m_FileNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_FileName) );
m_SheetNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_SheetName) );
m_FileNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_FileName ) );
m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_SheetName ) );
////@end WinEDA_SheetPropertiesFrame content construction
}
/*!
* Should we show tooltips?
*/
@ -203,6 +239,7 @@ bool WinEDA_SheetPropertiesFrame::ShowToolTips()
return true;
}
/*!
* Get bitmap resources
*/
@ -211,11 +248,13 @@ wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_SheetPropertiesFrame bitmap retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullBitmap;
////@end WinEDA_SheetPropertiesFrame bitmap retrieval
}
/*!
* Get icon resources
*/
@ -224,340 +263,351 @@ wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_SheetPropertiesFrame icon retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullIcon;
////@end WinEDA_SheetPropertiesFrame icon retrieval
}
/*****************************************************************************/
void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept(wxCommandEvent& event)
void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
/*****************************************************************************/
{
wxString FileName, msg;
FileName = m_FileNameWin->GetValue();
FileName.Trim(FALSE); FileName.Trim(TRUE);
if ( FileName.IsEmpty() )
{
DisplayError(this, _("No Filename! Aborted") );
EndModal (FALSE);
return;
}
wxString FileName, msg;
ChangeFileNameExt( FileName,g_SchExtBuffer );
if ( m_CurrentSheet->m_FileName != FileName )
{
m_CurrentSheet->m_FileName = FileName;
if ( wxFileExists(FileName) ) /* do we reload the data from the existing file */
{
msg.Printf( _("A file named %s exists, load it ?"), FileName.GetData());
if( IsOK (this,msg) )
{
m_Parent->LoadOneSheet(m_CurrentSheet, FileName);
}
}
}
FileName = m_FileNameWin->GetValue();
FileName.Trim( FALSE ); FileName.Trim( TRUE );
msg = m_FileNameSize->GetValue();
m_CurrentSheet->m_FileNameSize =
ReturnValueFromString(g_UnitMetric,
msg, m_Parent->m_InternalUnits);
if( FileName.IsEmpty() )
{
DisplayError( this, _( "No Filename! Aborted" ) );
EndModal( FALSE );
return;
}
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
msg = m_SheetNameSize->GetValue();
m_CurrentSheet->m_SheetNameSize =
ReturnValueFromString(g_UnitMetric,
msg, m_Parent->m_InternalUnits);
ChangeFileNameExt( FileName, g_SchExtBuffer );
if( (m_CurrentSheet->m_SheetName.IsEmpty() ) )
m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName;
if( m_CurrentSheet->m_FileName != FileName )
{
m_CurrentSheet->m_FileName = FileName;
if( wxFileExists( FileName ) ) /* do we reload the data from the existing file */
{
msg.Printf( _( "A file named %s exists, load it ?" ), FileName.GetData() );
if( IsOK( this, msg ) )
{
m_Parent->LoadOneSheet( m_CurrentSheet, FileName );
}
}
}
msg = m_FileNameSize->GetValue();
m_CurrentSheet->m_FileNameSize =
ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits );
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
msg = m_SheetNameSize->GetValue();
m_CurrentSheet->m_SheetNameSize =
ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits );
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName;
EndModal(TRUE);
EndModal( TRUE );
}
/*************************************************************************/
bool WinEDA_SchematicFrame::EditSheet(DrawSheetStruct * Sheet, wxDC * DC)
bool WinEDA_SchematicFrame::EditSheet( DrawSheetStruct* Sheet, wxDC* DC )
/*************************************************************************/
/* Routine to edit the SheetName and the FileName for the sheet "Sheet" */
{
WinEDA_SheetPropertiesFrame * frame;
bool edit = TRUE;
WinEDA_SheetPropertiesFrame* frame;
bool edit = TRUE;
if ( Sheet == NULL ) return FALSE;
if( Sheet == NULL )
return FALSE;
/* Get the new texts */
RedrawOneStruct(DrawPanel, DC, Sheet, g_XorMode);
/* Get the new texts */
RedrawOneStruct( DrawPanel, DC, Sheet, g_XorMode );
DrawPanel->m_IgnoreMouseEvents = TRUE;
frame = new WinEDA_SheetPropertiesFrame(this, Sheet);
edit = frame->ShowModal(); frame->Destroy();
frame = new WinEDA_SheetPropertiesFrame( this, Sheet );
edit = frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
RedrawOneStruct(DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE);
return edit;
RedrawOneStruct( DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
return edit;
}
#define SHEET_MIN_WIDTH 500
#define SHEET_MIN_HEIGHT 150
/****************************************************************/
DrawSheetStruct * WinEDA_SchematicFrame::CreateSheet(wxDC * DC)
DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC )
/****************************************************************/
/* Routine de Creation d'une feuille de hierarchie (Sheet) */
{
g_ItemToRepeat = NULL;
g_ItemToRepeat = NULL;
DrawSheetStruct * Sheet = new DrawSheetStruct(m_CurrentScreen->m_Curseur);
DrawSheetStruct* Sheet = new DrawSheetStruct( m_CurrentScreen->m_Curseur );
Sheet->m_Flags = IS_NEW | IS_RESIZED;
Sheet->m_TimeStamp = GetTimeStamp();
Sheet->m_Parent = m_CurrentScreen;
s_SheetMindx = SHEET_MIN_WIDTH;
s_SheetMindy = SHEET_MIN_HEIGHT;
Sheet->m_Flags = IS_NEW | IS_RESIZED;
Sheet->m_TimeStamp = GetTimeStamp();
Sheet->m_Parent = m_CurrentScreen;
s_SheetMindx = SHEET_MIN_WIDTH;
s_SheetMindy = SHEET_MIN_HEIGHT;
m_CurrentScreen->m_CurrentItem = Sheet;
m_CurrentScreen->SetCurItem( Sheet );
DrawPanel->ManageCurseur = DeplaceSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur = DeplaceSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE);
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
return Sheet;
return Sheet;
}
/*******************************************************************************/
void WinEDA_SchematicFrame::ReSizeSheet(DrawSheetStruct * Sheet, wxDC * DC)
void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC )
/*******************************************************************************/
{
DrawSheetLabelStruct* sheetlabel;
DrawSheetLabelStruct* sheetlabel;
if ( Sheet == NULL ) return;
if( Sheet->m_Flags & IS_NEW) return;
if( Sheet == NULL )
return;
if( Sheet->m_Flags & IS_NEW )
return;
if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE)
{
DisplayError(this, wxT("WinEDA_SchematicFrame::ReSizeSheet: Bad SructType"));
return;
}
if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE )
{
DisplayError( this, wxT( "WinEDA_SchematicFrame::ReSizeSheet: Bad SructType" ) );
return;
}
GetScreen()->SetModify();
Sheet->m_Flags |= IS_RESIZED;
GetScreen()->SetModify();
Sheet->m_Flags |= IS_RESIZED;
/* sauvegarde des anciennes valeurs */
s_OldPos.x = Sheet->m_Size.x;
s_OldPos.y = Sheet->m_Size.y;
/* sauvegarde des anciennes valeurs */
s_OldPos.x = Sheet->m_Size.x;
s_OldPos.y = Sheet->m_Size.y;
/* Recalcul des dims min de la sheet */
s_SheetMindx = SHEET_MIN_WIDTH;
s_SheetMindy = SHEET_MIN_HEIGHT;
sheetlabel = Sheet->m_Label;
while(sheetlabel)
{
s_SheetMindx = MAX(s_SheetMindx,
(int)((sheetlabel->GetLength()+1) * sheetlabel->m_Size.x) );
s_SheetMindy = MAX(s_SheetMindy,sheetlabel->m_Pos.y - Sheet->m_Pos.y);
sheetlabel = (DrawSheetLabelStruct *) sheetlabel->Pnext;
}
DrawPanel->ManageCurseur = DeplaceSheet ;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
/* Recalcul des dims min de la sheet */
s_SheetMindx = SHEET_MIN_WIDTH;
s_SheetMindy = SHEET_MIN_HEIGHT;
sheetlabel = Sheet->m_Label;
while( sheetlabel )
{
s_SheetMindx = MAX( s_SheetMindx,
(int) ( (sheetlabel->GetLength() + 1) * sheetlabel->m_Size.x ) );
s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y );
sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext;
}
DrawPanel->ManageCurseur = DeplaceSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
/*********************************************************************************/
void WinEDA_SchematicFrame::StartMoveSheet(DrawSheetStruct* Sheet, wxDC * DC)
void WinEDA_SchematicFrame::StartMoveSheet( DrawSheetStruct* Sheet, wxDC* DC )
/*********************************************************************************/
{
if ( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) )
return;
if( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) )
return;
DrawPanel->CursorOff(DC);
m_CurrentScreen->m_Curseur = Sheet->m_Pos;
DrawPanel->MouseToCursorSchema();
s_OldPos = Sheet->m_Pos;
Sheet->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur = DeplaceSheet ;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
DrawPanel->CursorOn(DC);
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = Sheet->m_Pos;
DrawPanel->MouseToCursorSchema();
s_OldPos = Sheet->m_Pos;
Sheet->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur = DeplaceSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->CursorOn( DC );
}
/********************************************************/
/*** Routine de deplacement Sheet, lie au curseur. */
/* Appele par GeneralControle grace a ManageCurseur. */
/********************************************************/
static void DeplaceSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
wxPoint move_vector;
DrawSheetLabelStruct * SheetLabel;
BASE_SCREEN * screen = panel->m_Parent->m_CurrentScreen;
wxPoint move_vector;
DrawSheetLabelStruct* SheetLabel;
BASE_SCREEN* screen = panel->m_Parent->m_CurrentScreen;
DrawSheetStruct * Sheet = (DrawSheetStruct *)
screen->m_CurrentItem;
DrawSheetStruct* Sheet = (DrawSheetStruct*)
screen->GetCurItem();
/* Effacement du composant: tj apres depl curseur */
if( erase )
RedrawOneStruct(panel, DC, Sheet, g_XorMode);
/* Effacement du composant: tj apres depl curseur */
if( erase )
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
if( Sheet->m_Flags & IS_RESIZED)
{
Sheet->m_Size.x = MAX(s_SheetMindx,
screen->m_Curseur.x - Sheet->m_Pos.x);
Sheet->m_Size.y = MAX(s_SheetMindy,
screen->m_Curseur.y - Sheet->m_Pos.y);
SheetLabel = Sheet->m_Label;
while(SheetLabel)
{
if( SheetLabel->m_Edge)
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
SheetLabel = (DrawSheetLabelStruct *) SheetLabel->Pnext;
}
}
else /* Move Sheet */
{
move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x;
move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y;
MoveOneStruct(Sheet, move_vector);
}
if( Sheet->m_Flags & IS_RESIZED )
{
Sheet->m_Size.x = MAX( s_SheetMindx,
screen->m_Curseur.x - Sheet->m_Pos.x );
Sheet->m_Size.y = MAX( s_SheetMindy,
screen->m_Curseur.y - Sheet->m_Pos.y );
SheetLabel = Sheet->m_Label;
while( SheetLabel )
{
if( SheetLabel->m_Edge )
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext;
}
}
else /* Move Sheet */
{
move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x;
move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y;
MoveOneStruct( Sheet, move_vector );
}
RedrawOneStruct(panel, DC, Sheet, g_XorMode);
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
}
/****************************************************************/
void DrawSheetStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC)
void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/****************************************************************/
{
/* Placement en liste des structures si nouveau composant:*/
if(m_Flags & IS_NEW)
{
if ( ! ((WinEDA_SchematicFrame*)frame)->EditSheet(this, DC) )
{
frame->m_CurrentScreen->m_CurrentItem = NULL;
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
RedrawOneStruct(frame->DrawPanel, DC, this, g_XorMode);
delete this;
return;
}
/* Placement en liste des structures si nouveau composant:*/
if( m_Flags & IS_NEW )
{
if( !( (WinEDA_SchematicFrame*) frame )->EditSheet( this, DC ) )
{
frame->m_CurrentScreen->SetCurItem( NULL );
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
RedrawOneStruct( frame->DrawPanel, DC, this, g_XorMode );
delete this;
return;
}
if ( wxFileExists(m_FileName) )
{
((WinEDA_SchematicFrame*)frame)->LoadOneSheet(
this, m_FileName);
}
}
if( wxFileExists( m_FileName ) )
{
( (WinEDA_SchematicFrame*) frame )->LoadOneSheet(
this, m_FileName );
}
}
EDA_BaseStruct::Place(frame, DC);
EDA_BaseStruct::Place( frame, DC );
}
/****************************************/
/* Routine de sortie du Menu de Sheet */
/****************************************/
static void ExitSheet(WinEDA_DrawPanel * Panel, wxDC * DC)
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
{
SCH_SCREEN *Screen = (SCH_SCREEN *) Panel->m_Parent->m_CurrentScreen;
DrawSheetStruct * Sheet = (DrawSheetStruct *) Screen->m_CurrentItem;
if ( Sheet == NULL) return;
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen;
DrawSheetStruct* Sheet = (DrawSheetStruct*) Screen->GetCurItem();
/* Deplacement composant en cours */
if ( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
{
RedrawOneStruct(Panel, DC, Sheet, g_XorMode);
delete Sheet;
}
else if ( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */
{
RedrawOneStruct(Panel, DC, Sheet, g_XorMode);
Sheet->m_Size.x = s_OldPos.x;
Sheet->m_Size.y = s_OldPos.y;
RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE);
Sheet->m_Flags = 0;
}
if( Sheet == NULL )
return;
else if ( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */
{
wxPoint curspos = Screen->m_Curseur;
Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos;
DeplaceSheet(Panel, DC, TRUE);
RedrawOneStruct(Panel, DC, Sheet, GR_DEFAULT_DRAWMODE);
Sheet->m_Flags = 0;
Screen->m_Curseur = curspos;
}
/* Deplacement composant en cours */
if( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
{
RedrawOneStruct( Panel, DC, Sheet, g_XorMode );
delete Sheet;
}
else if( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */
{
RedrawOneStruct( Panel, DC, Sheet, g_XorMode );
Sheet->m_Size.x = s_OldPos.x;
Sheet->m_Size.y = s_OldPos.y;
RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE );
Sheet->m_Flags = 0;
}
else if( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */
{
wxPoint curspos = Screen->m_Curseur;
Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos;
DeplaceSheet( Panel, DC, TRUE );
RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE );
Sheet->m_Flags = 0;
Screen->m_Curseur = curspos;
}
else
Sheet->m_Flags = 0;
else Sheet->m_Flags = 0;
Screen->m_CurrentItem = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur =NULL;
Screen->SetCurItem( NULL );
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
}
/********************************************************************/
void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC )
/********************************************************************/
/********************************************************************/
void DrawSheetStruct::CleanupSheet(WinEDA_SchematicFrame * frame, wxDC *DC)
/********************************************************************/
/* Delete pinsheets which are not corresponding to a Global label
if DC != NULL, redraw Sheet
*/
* if DC != NULL, redraw Sheet
*/
{
DrawSheetLabelStruct* Pinsheet, * NextPinsheet;
if( ! IsOK(frame, _("Ok to cleanup this sheet") ) ) return;
Pinsheet = m_Label;
while(Pinsheet)
{
/* Search Glabel corresponding to this Pinsheet */
DrawSheetLabelStruct* Pinsheet, * NextPinsheet;
EDA_BaseStruct *DrawStruct = EEDrawList;
DrawGlobalLabelStruct * GLabel = NULL;
for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE )
continue;
GLabel = (DrawGlobalLabelStruct *) DrawStruct;
if( Pinsheet->m_Text.CmpNoCase(GLabel->m_Text) == 0 )
break; // Found!
GLabel = NULL;
}
if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) )
return;
NextPinsheet = (DrawSheetLabelStruct *) Pinsheet->Pnext;
if ( GLabel == NULL ) // Glabel not found: delete pinsheet
{
frame->GetScreen()->SetModify();
frame->DeleteSheetLabel(DC, Pinsheet);
}
Pinsheet = NextPinsheet;
}
Pinsheet = m_Label;
while( Pinsheet )
{
/* Search Glabel corresponding to this Pinsheet */
EDA_BaseStruct* DrawStruct = EEDrawList;
DrawGlobalLabelStruct* GLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE )
continue;
GLabel = (DrawGlobalLabelStruct*) DrawStruct;
if( Pinsheet->m_Text.CmpNoCase( GLabel->m_Text ) == 0 )
break; // Found!
GLabel = NULL;
}
NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext;
if( GLabel == NULL ) // Glabel not found: delete pinsheet
{
frame->GetScreen()->SetModify();
frame->DeleteSheetLabel( DC, Pinsheet );
}
Pinsheet = NextPinsheet;
}
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event )
{
EndModal(0);
EndModal( 0 );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
{
SheetPropertiesAccept(event);
EndModal(1);
SheetPropertiesAccept( event );
EndModal( 1 );
}

View File

@ -1,6 +1,6 @@
/****************************************************************/
/* sheetlab.cpp module pour creation /editin des Sheet labels */
/****************************************************************/
/****************************************************************/
/* sheetlab.cpp module pour creation /editin des Sheet labels */
/****************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -13,433 +13,456 @@
#include "protos.h"
/* Routines Locales */
static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC );
static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Variables locales */
static int CurrentTypeLabel = NET_INPUT;
static wxSize NetSheetTextSize(DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT);
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
/****************************************/
/* class WinEDA_PinSheetPropertiesFrame */
/****************************************/
/****************************************/
/* class WinEDA_PinSheetPropertiesFrame */
/****************************************/
#define NBSHAPES 5
static wxString shape_list[NBSHAPES] =
{
wxT("Input"), wxT("Output"), wxT("Bidi"), wxT("TriState"), wxT("Passive")
wxT( "Input" ), wxT( "Output" ), wxT( "Bidi" ), wxT( "TriState" ), wxT( "Passive" )
};
enum id_Textdit
{
ID_ACCEPT_PINSHEET_PROPERTIES = 1970,
ID_CANCEL_PINSHEET_PROPERTIES
enum id_Textdit {
ID_ACCEPT_PINSHEET_PROPERTIES = 1970,
ID_CANCEL_PINSHEET_PROPERTIES
};
/*****************************************************/
class WinEDA_PinSheetPropertiesFrame: public wxDialog
class WinEDA_PinSheetPropertiesFrame : public wxDialog
/*****************************************************/
{
private:
WinEDA_SchematicFrame * m_Parent;
DrawSheetLabelStruct * m_CurrentPinSheet;
wxRadioBox * m_PinSheetType;
wxRadioBox * m_PinSheetShape;
WinEDA_GraphicTextCtrl * m_TextWin;
WinEDA_SchematicFrame* m_Parent;
DrawSheetLabelStruct* m_CurrentPinSheet;
wxRadioBox* m_PinSheetType;
wxRadioBox* m_PinSheetShape;
WinEDA_GraphicTextCtrl* m_TextWin;
public:
// Constructor and destructor
WinEDA_PinSheetPropertiesFrame(WinEDA_SchematicFrame *parent,
DrawSheetLabelStruct * curr_pinsheet,
const wxPoint & framepos = wxPoint(-1,-1) );
~WinEDA_PinSheetPropertiesFrame(void){};
// Constructor and destructor
WinEDA_PinSheetPropertiesFrame( WinEDA_SchematicFrame* parent,
DrawSheetLabelStruct* curr_pinsheet,
const wxPoint& framepos = wxPoint( -1, -1 ) );
~WinEDA_PinSheetPropertiesFrame( void ) { };
private:
void PinSheetPropertiesAccept(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void PinSheetPropertiesAccept( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(WinEDA_PinSheetPropertiesFrame, wxDialog)
EVT_BUTTON(ID_ACCEPT_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept)
EVT_BUTTON(ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit)
BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog )
EVT_BUTTON( ID_ACCEPT_PINSHEET_PROPERTIES,
WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept )
EVT_BUTTON( ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit )
END_EVENT_TABLE()
/**********************************************************************************/
WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame(
WinEDA_SchematicFrame *parent,
DrawSheetLabelStruct * curr_pinsheet,
const wxPoint & framepos):
wxDialog(parent, -1, _("PinSheet Properties:"), framepos, wxSize(340, 220),
DIALOG_STYLE)
WinEDA_SchematicFrame* parent,
DrawSheetLabelStruct* curr_pinsheet,
const wxPoint& framepos ) :
wxDialog( parent, -1, _( "PinSheet Properties:" ), framepos, wxSize( 340, 220 ),
DIALOG_STYLE )
/**********************************************************************************/
{
wxPoint pos;
wxString number;
wxButton * Button;
wxPoint pos;
wxString number;
wxButton* Button;
m_Parent = parent;
Centre();
m_Parent = parent;
Centre();
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(MainBoxSizer);
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_CurrentPinSheet = curr_pinsheet;
m_CurrentPinSheet = curr_pinsheet;
/* Creation des boutons de commande */
Button = new wxButton(this, ID_ACCEPT_PINSHEET_PROPERTIES,
_("Ok"));
Button->SetForegroundColour(*wxRED);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
/* Creation des boutons de commande */
Button = new wxButton( this, ID_ACCEPT_PINSHEET_PROPERTIES,
_( "Ok" ) );
Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_CANCEL_PINSHEET_PROPERTIES,
_("Cancel"));
Button->SetForegroundColour(*wxBLUE);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button = new wxButton( this, ID_CANCEL_PINSHEET_PROPERTIES,
_( "Cancel" ) );
Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
m_TextWin = new WinEDA_GraphicTextCtrl(this, _("Text:"),
m_CurrentPinSheet->m_Text, m_CurrentPinSheet->m_Size.x,
g_UnitMetric , LeftBoxSizer, 200);
m_TextWin = new WinEDA_GraphicTextCtrl( this, _( "Text:" ),
m_CurrentPinSheet->m_Text, m_CurrentPinSheet->m_Size.x,
g_UnitMetric, LeftBoxSizer, 200 );
// Selection de la forme :
m_PinSheetShape = new wxRadioBox(this, -1, _("PinSheet Shape:"),
wxDefaultPosition, wxSize(-1,-1),
NBSHAPES, shape_list, 1);
m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape );
LeftBoxSizer->Add(m_PinSheetShape, 0, wxGROW|wxALL, 5);
// Selection de la forme :
m_PinSheetShape = new wxRadioBox( this, -1, _( "PinSheet Shape:" ),
wxDefaultPosition, wxSize( -1, -1 ),
NBSHAPES, shape_list, 1 );
m_PinSheetShape->SetSelection( m_CurrentPinSheet->m_Shape );
LeftBoxSizer->Add( m_PinSheetShape, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
}
/************************************************************************/
void WinEDA_PinSheetPropertiesFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void WinEDA_PinSheetPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/************************************************************************/
{
// true is to force the frame to close
Close(true);
Close( true );
}
/***********************************************************************************/
void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept(wxCommandEvent& event)
void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept( wxCommandEvent& event )
/***********************************************************************************/
{
m_CurrentPinSheet->m_Text = m_TextWin->GetText();
m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize();
m_CurrentPinSheet->m_Text = m_TextWin->GetText();
m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize();
m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection();
Close(TRUE);
m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection();
Close( TRUE );
}
/*****************************************************************/
static void ExitPinSheet(WinEDA_DrawPanel * Panel, wxDC * DC)
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
/*****************************************************************/
/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET
*/
/* Routine de sortie du Menu d'Edition Des NETS (Labels) SHEET
*/
{
DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *)
Panel->GetScreen()->m_CurrentItem;
DrawSheetLabelStruct* SheetLabel = (DrawSheetLabelStruct*)
Panel->GetScreen()->GetCurItem();
if ( SheetLabel == NULL ) return;
if( SheetLabel == NULL )
return;
if ( SheetLabel->m_Flags & IS_NEW )
{ /* Nouveau Placement en cours, on l'efface */
RedrawOneStruct(Panel, DC, SheetLabel, g_XorMode);
delete SheetLabel;
}
else
{
RedrawOneStruct(Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE);
SheetLabel->m_Flags = 0;
}
if( SheetLabel->m_Flags & IS_NEW )
{ /* Nouveau Placement en cours, on l'efface */
RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode );
delete SheetLabel;
}
else
{
RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
SheetLabel->m_Flags = 0;
}
Panel->GetScreen()->m_CurrentItem = NULL;
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->GetScreen()->SetCurItem( NULL );
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
}
/* Cette routine place un nouveau NetSheet ou place un ancien en cours
de deplacement
Si le NetSheet est nouveau, il est pointe par NewSheetLabel
*/
void DrawSheetLabelStruct::Place( WinEDA_DrawFrame * frame, wxDC * DC)
* de deplacement
* Si le NetSheet est nouveau, il est pointe par NewSheetLabel
*/
void DrawSheetLabelStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
{
DrawSheetStruct * Sheet = (DrawSheetStruct *) m_Parent;
DrawSheetStruct* Sheet = (DrawSheetStruct*) m_Parent;
if( m_Flags & IS_NEW ) /* ajout a la liste des structures */
{
if(Sheet->m_Label == NULL ) Sheet->m_Label = this;
else
{
DrawSheetLabelStruct * pinsheet = Sheet->m_Label;
while(pinsheet)
{
if( pinsheet->Pnext == NULL )
{
pinsheet->Pnext = this;
break;
}
pinsheet = (DrawSheetLabelStruct*)pinsheet->Pnext;
}
}
}
if( m_Flags & IS_NEW ) /* ajout a la liste des structures */
{
if( Sheet->m_Label == NULL )
Sheet->m_Label = this;
else
{
DrawSheetLabelStruct* pinsheet = Sheet->m_Label;
while( pinsheet )
{
if( pinsheet->Pnext == NULL )
{
pinsheet->Pnext = this;
break;
}
pinsheet = (DrawSheetLabelStruct*) pinsheet->Pnext;
}
}
}
m_Flags = 0;
m_Pos.x = Sheet->m_Pos.x;
m_Edge = 0;
if( frame->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) )
{
m_Edge = 1;
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
m_Flags = 0;
m_Pos.x = Sheet->m_Pos.x;
m_Edge = 0;
if( frame->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
{
m_Edge = 1;
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
m_Pos.y = frame->GetScreen()->m_Curseur.y;
if( m_Pos.y < Sheet->m_Pos.y ) m_Pos.y = Sheet->m_Pos.y;
if( m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) )
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
m_Pos.y = frame->GetScreen()->m_Curseur.y;
if( m_Pos.y < Sheet->m_Pos.y )
m_Pos.y = Sheet->m_Pos.y;
if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
RedrawOneStruct(frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE);
RedrawOneStruct( frame->DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
}
/*******************************************************************************/
void WinEDA_SchematicFrame::StartMove_PinSheet(DrawSheetLabelStruct * SheetLabel,
wxDC * DC)
void WinEDA_SchematicFrame::StartMove_PinSheet( DrawSheetLabelStruct* SheetLabel,
wxDC* DC )
/*******************************************************************************/
/* Initialise un deplacement de NetSheet */
{
NetSheetTextSize = SheetLabel->m_Size;
CurrentTypeLabel = SheetLabel->m_Shape;
SheetLabel->m_Flags |= IS_MOVED;
NetSheetTextSize = SheetLabel->m_Size;
CurrentTypeLabel = SheetLabel->m_Shape;
SheetLabel->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
/**********************************************************************/
/* Routine de deplacement du NetSheet actif selon la position souris */
/**********************************************************************/
static void Move_PinSheet(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
DrawSheetLabelStruct * SheetLabel = (DrawSheetLabelStruct *)
panel->m_Parent->GetScreen()->m_CurrentItem;
DrawSheetLabelStruct* SheetLabel = (DrawSheetLabelStruct*)
panel->m_Parent->GetScreen()->GetCurItem();
if ( SheetLabel == NULL ) return;
if( SheetLabel == NULL )
return;
DrawSheetStruct * Sheet = (DrawSheetStruct *) SheetLabel->m_Parent;
DrawSheetStruct* Sheet = (DrawSheetStruct*) SheetLabel->m_Parent;
if ( Sheet == NULL ) return;
if( erase )
RedrawOneStruct(panel, DC, SheetLabel, g_XorMode);
if( Sheet == NULL )
return;
if( erase )
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
SheetLabel->m_Edge = 0;
SheetLabel->m_Pos.x = Sheet->m_Pos.x;
if( panel->m_Parent->GetScreen()->m_Curseur.x > (Sheet->m_Pos.x + (Sheet->m_Size.x/2)) )
{
SheetLabel->m_Edge = 1;
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
SheetLabel->m_Edge = 0;
SheetLabel->m_Pos.x = Sheet->m_Pos.x;
if( panel->m_Parent->GetScreen()->m_Curseur.x > ( Sheet->m_Pos.x + (Sheet->m_Size.x / 2) ) )
{
SheetLabel->m_Edge = 1;
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
}
SheetLabel->m_Pos.y = panel->m_Parent->GetScreen()->m_Curseur.y;
if( SheetLabel->m_Pos.y < Sheet->m_Pos.y )
SheetLabel->m_Pos.y = Sheet->m_Pos.y;
if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y+Sheet->m_Size.y) )
SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
SheetLabel->m_Pos.y = panel->m_Parent->GetScreen()->m_Curseur.y;
if( SheetLabel->m_Pos.y < Sheet->m_Pos.y )
SheetLabel->m_Pos.y = Sheet->m_Pos.y;
if( SheetLabel->m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
SheetLabel->m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
RedrawOneStruct(panel, DC, SheetLabel, g_XorMode);
RedrawOneStruct( panel, DC, SheetLabel, g_XorMode );
}
/***************************************************************************/
void WinEDA_SchematicFrame::Edit_PinSheet(DrawSheetLabelStruct * SheetLabel,
wxDC * DC)
void WinEDA_SchematicFrame::Edit_PinSheet( DrawSheetLabelStruct* SheetLabel,
wxDC* DC )
/***************************************************************************/
/* Modification du texte d'un net sheet */
{
if( SheetLabel == NULL) return;
if( SheetLabel == NULL )
return;
RedrawOneStruct(DrawPanel, DC, SheetLabel, g_XorMode);
RedrawOneStruct( DrawPanel, DC, SheetLabel, g_XorMode );
WinEDA_PinSheetPropertiesFrame * frame =
new WinEDA_PinSheetPropertiesFrame(this, SheetLabel);
WinEDA_PinSheetPropertiesFrame* frame =
new WinEDA_PinSheetPropertiesFrame( this, SheetLabel );
frame->ShowModal(); frame->Destroy();
frame->ShowModal(); frame->Destroy();
RedrawOneStruct(DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE);
RedrawOneStruct( DrawPanel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
}
/***************************************************************/
DrawSheetLabelStruct * WinEDA_SchematicFrame::Create_PinSheet(
DrawSheetStruct * Sheet, wxDC * DC)
DrawSheetLabelStruct* WinEDA_SchematicFrame::Create_PinSheet(
DrawSheetStruct* Sheet, wxDC* DC )
/**************************************************************/
/* Addition d'un nouveau PinSheet sur la feuille selectionnee, a l'endroit
pointe par la souris
*/
* pointe par la souris
*/
{
wxString Line, Text;
DrawSheetLabelStruct * NewSheetLabel;
wxString Line, Text;
DrawSheetLabelStruct* NewSheetLabel;
switch(CurrentTypeLabel)
{
default: CurrentTypeLabel = NET_INPUT;
case NET_INPUT: Text = wxT("Pin Input: ");
break;
switch( CurrentTypeLabel )
{
default:
CurrentTypeLabel = NET_INPUT;
case NET_OUTPUT: Text = wxT("Pin Output: ");
break;
case NET_INPUT:
Text = wxT( "Pin Input: " );
break;
case NET_BIDI: Text = wxT("Pin BiDi: ");
break;
case NET_OUTPUT:
Text = wxT( "Pin Output: " );
break;
case NET_TRISTATE: Text = wxT("Pin TriStat: ");
break;
case NET_BIDI:
Text = wxT( "Pin BiDi: " );
break;
case NET_UNSPECIFIED: Text = wxT("Pin Unspec.: ");
break;
case NET_TRISTATE:
Text = wxT( "Pin TriStat: " );
break;
}
case NET_UNSPECIFIED:
Text = wxT( "Pin Unspec.: " );
break;
}
Get_Message(Text,Line, this);
if( Line.IsEmpty() ) return NULL;
Get_Message( Text, Line, this );
if( Line.IsEmpty() )
return NULL;
GetScreen()->SetModify();
GetScreen()->SetModify();
/* Creation en memoire */
NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), Line);
NewSheetLabel->m_Flags = IS_NEW;
NewSheetLabel->m_Size = NetSheetTextSize;
NewSheetLabel->m_Shape = CurrentTypeLabel;
/* Creation en memoire */
NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), Line );
NewSheetLabel->m_Flags = IS_NEW;
NewSheetLabel->m_Size = NetSheetTextSize;
NewSheetLabel->m_Shape = CurrentTypeLabel;
GetScreen()->m_CurrentItem = NewSheetLabel;
GetScreen()->SetCurItem( NewSheetLabel );
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
DrawPanel->ManageCurseur(DrawPanel, DC, TRUE);
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
return NewSheetLabel;
return NewSheetLabel;
}
/*****************************************************************************/
DrawSheetLabelStruct *
WinEDA_SchematicFrame::Import_PinSheet(DrawSheetStruct * Sheet, wxDC * DC)
DrawSheetLabelStruct* WinEDA_SchematicFrame::Import_PinSheet( DrawSheetStruct* Sheet, wxDC* DC )
/*****************************************************************************/
/* Permet de creer automatiquement les Sheet Labels a partir des Labels Globaux
de la feuille de sous hierarchie correspondante
*/
* de la feuille de sous hierarchie correspondante
*/
{
EDA_BaseStruct *DrawStruct;
DrawSheetLabelStruct * NewSheetLabel, * SheetLabel = NULL;
DrawGlobalLabelStruct * GLabel = NULL;
EDA_BaseStruct* DrawStruct;
DrawSheetLabelStruct* NewSheetLabel, * SheetLabel = NULL;
DrawGlobalLabelStruct* GLabel = NULL;
DrawStruct = Sheet->EEDrawList;
GLabel = NULL;
for (; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE )
continue;
GLabel = (DrawGlobalLabelStruct *) DrawStruct;
DrawStruct = Sheet->EEDrawList;
GLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE )
continue;
GLabel = (DrawGlobalLabelStruct*) DrawStruct;
/* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */
SheetLabel = Sheet->m_Label;
for( ;SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext )
{
if( SheetLabel->m_Text.CmpNoCase(GLabel->m_Text) == 0 )
{
break;
}
}
/* Ici si SheetLabel == NULL le G-Label n'a pas de SheetLabel corresp */
if( SheetLabel == NULL ) break;
}
/* Ici un G-Label a ete trouve: y a t-il un SheetLabel correspondant */
SheetLabel = Sheet->m_Label;
for( ; SheetLabel != NULL; SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext )
{
if( SheetLabel->m_Text.CmpNoCase( GLabel->m_Text ) == 0 )
{
break;
}
}
if( (GLabel == NULL ) || SheetLabel )
{
DisplayError(this, _("No New Global Label found"), 10);
return NULL;
}
/* Ici si SheetLabel == NULL le G-Label n'a pas de SheetLabel corresp */
if( SheetLabel == NULL )
break;
}
/* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */
if( (GLabel == NULL ) || SheetLabel )
{
DisplayError( this, _( "No New Global Label found" ), 10 );
return NULL;
}
GetScreen()->SetModify();
/* Creation en memoire */
NewSheetLabel = new DrawSheetLabelStruct(Sheet, wxPoint(0,0), GLabel->m_Text);
NewSheetLabel->m_Flags = IS_NEW;
NewSheetLabel->m_Size = NetSheetTextSize;
CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape;
/* Ici G-Label n'a pas de SheetLabel corresp, on va le creer */
GetScreen()->m_CurrentItem = NewSheetLabel;
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
Move_PinSheet(DrawPanel, DC, FALSE);
GetScreen()->SetModify();
/* Creation en memoire */
NewSheetLabel = new DrawSheetLabelStruct( Sheet, wxPoint( 0, 0 ), GLabel->m_Text );
NewSheetLabel->m_Flags = IS_NEW;
NewSheetLabel->m_Size = NetSheetTextSize;
CurrentTypeLabel = NewSheetLabel->m_Shape = GLabel->m_Shape;
return NewSheetLabel;
GetScreen()->SetCurItem( NewSheetLabel );
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
Move_PinSheet( DrawPanel, DC, FALSE );
return NewSheetLabel;
}
/**************************************************************/
void WinEDA_SchematicFrame::DeleteSheetLabel(wxDC * DC,
DrawSheetLabelStruct * SheetLabelToDel)
void WinEDA_SchematicFrame::DeleteSheetLabel( wxDC* DC,
DrawSheetLabelStruct* SheetLabelToDel )
/**************************************************************/
/*
Routine de suppression de 1 Structure type (DrawSheetLabelStruct.
Cette Structure ne peut etre mise en pile "undelete" car il ne serait pas
possible de la ratacher a la 'DrawSheetStruct' d'origine
si DC != NULL, effacement a l'ecran du dessin
*/
* Routine de suppression de 1 Structure type (DrawSheetLabelStruct.
* Cette Structure ne peut etre mise en pile "undelete" car il ne serait pas
* possible de la ratacher a la 'DrawSheetStruct' d'origine
* si DC != NULL, effacement a l'ecran du dessin
*/
{
EDA_BaseStruct * DrawStruct;
DrawSheetLabelStruct* SheetLabel, *NextLabel;
EDA_BaseStruct* DrawStruct;
DrawSheetLabelStruct* SheetLabel, * NextLabel;
if ( DC ) RedrawOneStruct(DrawPanel, DC, SheetLabelToDel, g_XorMode);
if( DC )
RedrawOneStruct( DrawPanel, DC, SheetLabelToDel, g_XorMode );
/* Recherche de la DrawSheetStruct d'origine */
DrawStruct = SheetLabelToDel->m_Parent;
/* Recherche de la DrawSheetStruct d'origine */
DrawStruct = SheetLabelToDel->m_Parent;
if (DrawStruct) // Modification du chainage
{
if (DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE)
{
DisplayError(this, wxT("DeleteSheetLabel error: m_Parent != DRAW_SHEET_STRUCT_TYPE"));
return;
}
if( DrawStruct ) // Modification du chainage
{
if( DrawStruct->m_StructType != DRAW_SHEET_STRUCT_TYPE )
{
DisplayError( this,
wxT( "DeleteSheetLabel error: m_Parent != DRAW_SHEET_STRUCT_TYPE" ) );
return;
}
/* suppression chainage */
SheetLabel = ((DrawSheetStruct *) DrawStruct)->m_Label;
if( SheetLabel == SheetLabelToDel )
((DrawSheetStruct *) DrawStruct)->m_Label =
(DrawSheetLabelStruct *)SheetLabel->Pnext;
/* suppression chainage */
SheetLabel = ( (DrawSheetStruct*) DrawStruct )->m_Label;
if( SheetLabel == SheetLabelToDel )
( (DrawSheetStruct*) DrawStruct )->m_Label =
(DrawSheetLabelStruct*) SheetLabel->Pnext;
else while( SheetLabel )/* Examen de la liste dependante et suppression chainage */
{
NextLabel = (DrawSheetLabelStruct *)SheetLabel->Pnext;
if( NextLabel == SheetLabelToDel )
{
SheetLabel->Pnext = NextLabel->Pnext;
break;;
}
SheetLabel = NextLabel;
}
}
else
while( SheetLabel ) /* Examen de la liste dependante et suppression chainage */
{
NextLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext;
if( NextLabel == SheetLabelToDel )
{
SheetLabel->Pnext = NextLabel->Pnext;
break;;
}
SheetLabel = NextLabel;
}
delete SheetLabelToDel;
}
delete SheetLabelToDel;
}

Some files were not shown because too many files have changed in this diff Show More